Skip to content

Commit c749909

Browse files
committed
fix: bunch of fixes. Changed default values
1 parent e1c524f commit c749909

13 files changed

+35
-30
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"cpy-cli": "^3.0.0",
4343
"husky": "^4.0.7",
4444
"lerna": "^3.20.2",
45-
"nativescript-canvas": "2.1.16",
45+
"nativescript-canvas": "2.1.17",
4646
"nativescript-gesturehandler": "^0.1.4",
4747
"nativescript-tween": "0.0.5",
4848
"npm-watch": "^0.6.0",

plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"homepage": "https://github.com/Akylas/nativescript-chart",
2626
"readmeFilename": "README.md",
2727
"dependencies": {
28-
"nativescript-canvas": "^2.1.16",
28+
"nativescript-canvas": "^2.1.17",
2929
"nativescript-gesturehandler": "^0.1.4",
3030
"nativescript-tween": "^0.0.5",
3131
"number-format.js": "^2.0.9"

src/charting/charts/BarLineChartBase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export abstract class BarLineChartBase<U extends Entry, D extends IBarLineScatte
143143
this.mGridBackgroundPaint = new Paint();
144144
this.mGridBackgroundPaint.setStyle(Style.FILL);
145145
// this.mGridBackgroundPaint.setColor(Color.WHITE);
146-
this.mGridBackgroundPaint.setColor(new Color(255, 240, 240, 240)); // light
146+
this.mGridBackgroundPaint.setColor('#F0F0F0'); // light
147147
// grey
148148

149149
this.mBorderPaint = new Paint();

src/charting/charts/Chart.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
176176
// Utils.init(this._context);
177177
this.mMaxHighlightDistance = Utils.convertDpToPixel(500);
178178

179-
this.mDescription = new Description();
179+
// this.mDescription = new Description();
180180
this.mLegend = new Legend();
181181

182182
this.mLegendRenderer = new LegendRenderer(this.mViewPortHandler, this.mLegend);
@@ -188,7 +188,7 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
188188

189189
this.mInfoPaint = new Paint();
190190
this.mInfoPaint.setAntiAlias(true);
191-
this.mInfoPaint.setColor(new Color(255, 247, 189, 51)); // orange
191+
this.mInfoPaint.setColor('#F7BD33'); // orange
192192
this.mInfoPaint.setTextAlign(Align.CENTER);
193193
this.mInfoPaint.setTextSize(12);
194194

src/charting/components/LimitLine.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class LimitLine extends ComponentBase {
2424
private mLineWidth = 2;
2525

2626
/** the color of the limit line */
27-
private mLineColor = 'new Color(237, 91, 91)';
27+
private mLineColor = '#ED5B5B';
2828

2929
/** the style of the label text */
3030
private mTextStyle = Style.FILL_AND_STROKE;

src/charting/components/YAxis.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class YAxis extends AxisBase {
6363
/**
6464
* Color of the zero line
6565
*/
66-
protected mZeroLineColor = new Color('gray');
66+
protected mZeroLineColor = 'gray';
6767

6868
/**
6969
* Width of the zero line in pixels

src/charting/data/BarDataSet.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export class BarDataSet extends BarLineScatterCandleBubbleDataSet<BarEntry> impl
1313
/**
1414
* the color used for drawing the bar shadows
1515
*/
16-
private mBarShadowColor = new Color(255, 215, 215, 215);
16+
private mBarShadowColor = '#D7D7D7';
1717

1818
private mBarBorderWidth = 0.0;
1919

20-
private mBarBorderColor = new Color('black');
20+
private mBarBorderColor = 'black';
2121

2222
/**
2323
* the alpha value used to draw the highlight indicator bar
@@ -37,7 +37,7 @@ export class BarDataSet extends BarLineScatterCandleBubbleDataSet<BarEntry> impl
3737
constructor(yVals, label) {
3838
super(yVals, label);
3939

40-
this.mHighLightColor = new Color(255, 0, 0, 0);
40+
this.mHighLightColor = 'black';
4141

4242
this.calcStackSize(yVals);
4343
this.calcEntryCountIncludingStacks(yVals);

src/charting/data/BarLineScatterCandleBubbleDataSet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export abstract class BarLineScatterCandleBubbleDataSet<T extends Entry> extends
1212
/**
1313
* default highlight color
1414
*/
15-
mHighLightColor = new Color(255, 255, 187, 115);
15+
mHighLightColor: string | Color = '#FFBB73';
1616

1717
// constructor(yVals, label) {
1818
// super(yVals, label);

src/charting/data/BaseDataSet.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export abstract class BaseDataSet<T extends Entry> implements IDataSet<T> {
8989
/**
9090
* if true, y-values are drawn on the chart
9191
*/
92-
protected mDrawValues = true;
92+
protected mDrawValues = false;
9393

9494
/**
9595
* if true, y-icons are drawn on the chart
@@ -127,8 +127,8 @@ export abstract class BaseDataSet<T extends Entry> implements IDataSet<T> {
127127
}
128128

129129
// default color
130-
this.mColors.push(new Color(255, 140, 234, 255));
131-
this.mValueColors.push(new Color('black'));
130+
this.mColors.push('#8CEAFF');
131+
this.mValueColors.push('black');
132132
this.mLabel = label;
133133
}
134134

@@ -184,7 +184,7 @@ export abstract class BaseDataSet<T extends Entry> implements IDataSet<T> {
184184
*
185185
* @param color
186186
*/
187-
public addColor(color) {
187+
public addColor(color: string | Color) {
188188
if (this.mColors == null) this.mColors = [];
189189
this.mColors.push(color);
190190
}
@@ -214,12 +214,13 @@ export abstract class BaseDataSet<T extends Entry> implements IDataSet<T> {
214214
* @param color
215215
* @param alpha from 0-255
216216
*/
217-
public setColor(color: Color, alpha?: number) {
217+
public setColor(color: string | Color, alpha?: number) {
218218
this.resetColors();
219219
if (alpha === undefined) {
220220
this.mColors.push(color);
221221
} else {
222-
this.mColors.push(new Color(color.r, color.g, color.b, alpha));
222+
const actColor = color instanceof Color ? color: new Color(color)
223+
this.mColors.push(new Color(actColor.r, actColor.g, actColor.b, alpha));
223224
}
224225
}
225226

src/charting/data/LineRadarDataSet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export abstract class LineRadarDataSet<T extends Entry> extends LineScatterCandl
1313
/**
1414
* the color that is used for filling the line surface
1515
*/
16-
private mFillColor = new Color(255, 140, 234, 255); // rgb(140,234,255)
16+
private mFillColor: string | Color = '#8CEAFF'; // rgb(140,234,255)
1717

1818
/**
1919
* the drawable to be used for filling the line surface
@@ -45,7 +45,7 @@ export abstract class LineRadarDataSet<T extends Entry> extends LineScatterCandl
4545
*
4646
* @param color
4747
*/
48-
public setFillColor(color) {
48+
public setFillColor(color: string | Color) {
4949
this.mFillColor = color;
5050
this.mFillDrawable = null;
5151
}

src/charting/renderer/DataRenderer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ export abstract class DataRenderer extends Renderer {
5050
this.mDrawPaint.setDither(true);
5151
this.mValuePaint = new Paint();
5252
this.mValuePaint.setAntiAlias(true);
53-
this.mValuePaint.setColor(new Color(255, 63, 63, 63));
53+
this.mValuePaint.setColor('#3F3F3F');
5454
this.mValuePaint.setTextAlign(Align.CENTER);
5555
this.mValuePaint.setTextSize(9);
5656

5757
this.mHighlightPaint = new Paint();
5858
this.mHighlightPaint.setAntiAlias(true);
5959
this.mHighlightPaint.setStyle(Style.STROKE);
6060
this.mHighlightPaint.setStrokeWidth(2);
61-
this.mHighlightPaint.setColor(new Color(255, 255, 187, 115));
61+
this.mHighlightPaint.setColor('#FFBB73');
6262
}
6363

6464
protected isDrawingValuesAllowed(chart: ChartInterface) {

src/charting/renderer/LineRadarRenderer.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ export abstract class LineRadarRenderer extends LineScatterCandleRadarRenderer {
5555
* @param fillColor
5656
* @param fillAlpha
5757
*/
58-
protected drawFilledPath(c: Canvas, filledPath: Path, fillColor: Color, fillAlpha: number) {
59-
const color = new Color(fillAlpha, fillColor.r, fillColor.g, fillColor.b);
58+
protected drawFilledPath(c: Canvas, filledPath: Path, fillColor: Color | string, fillAlpha: number = 1) {
59+
let color = fillColor;
60+
if (fillAlpha < 1) {
61+
fillColor = fillColor instanceof Color ? fillColor : new Color(fillColor);
62+
color = new Color(fillAlpha, fillColor.r, fillColor.g, fillColor.b);
63+
}
6064
// let color = (fillAlpha << 24) | (fillColor & 0xffffff);
6165

6266
if (this.clipPathSupported()) {

src/charting/utils/ColorTemplate.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ export class ColorTemplate {
2323
* THE COLOR THEMES ARE PREDEFINED (predefined color integer arrays), FEEL
2424
* FREE TO CREATE YOUR OWN WITH AS MANY DIFFERENT COLORS AS YOU WANT
2525
*/
26-
public static LIBERTY_COLORS = [new Color(255, 207, 248, 246), new Color(255, 148, 212, 212), new Color(255, 136, 180, 187), new Color(255, 118, 174, 175), new Color(255, 42, 109, 130)];
27-
public static JOYFUL_COLORS = [new Color(255, 217, 80, 138), new Color(255, 254, 149, 7), new Color(255, 254, 247, 120), new Color(255, 106, 167, 134), new Color(255, 53, 194, 209)];
28-
public static PASTEL_COLORS = [new Color(255, 64, 89, 128), new Color(255, 149, 165, 124), new Color(255, 217, 184, 162), new Color(255, 191, 134, 134), new Color(255, 179, 48, 80)];
29-
public static COLORFUL_COLORS = [new Color(255, 193, 37, 82), new Color(255, 255, 102, 0), new Color(255, 245, 199, 0), new Color(255, 106, 150, 31), new Color(255, 179, 100, 53)];
30-
public static VORDIPLOM_COLORS = [new Color(255, 192, 255, 140), new Color(255, 255, 247, 140), new Color(255, 255, 208, 140), new Color(255, 140, 234, 255), new Color(255, 255, 140, 157)];
31-
public static MATERIAL_COLORS = [new Color('#2ecc71'), new Color('#f1c40f'), new Color('#e74c3c'), new Color('#3498db')];
26+
public static LIBERTY_COLORS = ['rgb(207, 248, 246)', 'rgb(148, 212, 212)', 'rgb(136, 180, 187)', 'rgb(118, 174, 175)', 'rgb(42, 109, 130)'];
27+
public static JOYFUL_COLORS = ['rgb(217, 80, 138)', 'rgb(254, 149, 7)', 'rgb(254, 247, 120)', 'rgb(106, 167, 134)', 'rgb(53, 194, 209)'];
28+
public static PASTEL_COLORS = ['rgb(64, 89, 128)', 'rgb(149, 165, 124)', 'rgb(217, 184, 162)', 'rgb(191, 134, 134)', 'rgb(179, 48, 80)'];
29+
public static COLORFUL_COLORS = ['rgb(193, 37, 82)', 'rgb(255, 102, 0)', 'rgb(245, 199, 0)', 'rgb(106, 150, 31)', 'rgb(179, 100, 53)'];
30+
public static VORDIPLOM_COLORS = ['rgb(192, 255, 140)', 'rgb(255, 247, 140)', 'rgb(255, 208, 140)', 'rgb(140, 234, 255)', 'rgb(255, 140, 157)'];
31+
public static MATERIAL_COLORS = ['#2ecc71', '#f1c40f', '#e74c3c', '#3498db'];
3232

3333
/**
3434
* Returns the Android ICS holo blue light color.
3535
*
3636
* @return
3737
*/
3838
public static getHoloBlue() {
39-
return new Color(255, 51, 181, 229);
39+
return 'rgb(51, 181, 229)';
4040
}
4141

4242
/**

0 commit comments

Comments
 (0)