@nativescript-community/ui-chart 1.2.36 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/animation/ChartAnimator.d.ts +47 -4
- package/animation/ChartAnimator.js +49 -11
- package/animation/ChartAnimator.js.map +1 -1
- package/animation/Tween.d.ts +1 -1
- package/animation/Tween.js +4 -2
- package/animation/Tween.js.map +1 -1
- package/buffer/AbstractBuffer.d.ts +28 -3
- package/buffer/AbstractBuffer.js +22 -3
- package/buffer/AbstractBuffer.js.map +1 -1
- package/buffer/BarBuffer.d.ts +8 -12
- package/buffer/BarBuffer.js +33 -36
- package/buffer/BarBuffer.js.map +1 -1
- package/buffer/HorizontalBarBuffer.js +13 -10
- package/buffer/HorizontalBarBuffer.js.map +1 -1
- package/charts/BarChart.d.ts +70 -15
- package/charts/BarChart.js +92 -63
- package/charts/BarChart.js.map +1 -1
- package/charts/BarLineChartBase.d.ts +494 -73
- package/charts/BarLineChartBase.js +788 -407
- package/charts/BarLineChartBase.js.map +1 -1
- package/charts/BubbleChart.d.ts +11 -5
- package/charts/BubbleChart.js +10 -8
- package/charts/BubbleChart.js.map +1 -1
- package/charts/CandleStickChart.d.ts +8 -5
- package/charts/CandleStickChart.js +9 -10
- package/charts/CandleStickChart.js.map +1 -1
- package/charts/Chart.d.ts +420 -91
- package/charts/Chart.js +590 -290
- package/charts/Chart.js.map +1 -1
- package/charts/CombinedChart.d.ts +59 -29
- package/charts/CombinedChart.js +74 -67
- package/charts/CombinedChart.js.map +1 -1
- package/charts/HorizontalBarChart.d.ts +37 -7
- package/charts/HorizontalBarChart.js +97 -59
- package/charts/HorizontalBarChart.js.map +1 -1
- package/charts/LineChart.d.ts +3 -5
- package/charts/LineChart.js +6 -10
- package/charts/LineChart.js.map +1 -1
- package/charts/PieChart.d.ts +218 -64
- package/charts/PieChart.js +278 -168
- package/charts/PieChart.js.map +1 -1
- package/charts/PieRadarChartBase.d.ts +107 -18
- package/charts/PieRadarChartBase.js +156 -73
- package/charts/PieRadarChartBase.js.map +1 -1
- package/charts/RadarChart.d.ts +75 -35
- package/charts/RadarChart.js +114 -103
- package/charts/RadarChart.js.map +1 -1
- package/charts/ScatterChart.d.ts +10 -5
- package/charts/ScatterChart.js +11 -10
- package/charts/ScatterChart.js.map +1 -1
- package/components/AxisBase.d.ts +271 -101
- package/components/AxisBase.js +264 -254
- package/components/AxisBase.js.map +1 -1
- package/components/ComponentBase.d.ts +54 -19
- package/components/ComponentBase.js +60 -48
- package/components/ComponentBase.js.map +1 -1
- package/components/Description.d.ts +18 -9
- package/components/Description.js +12 -26
- package/components/Description.js.map +1 -1
- package/components/IMarker.d.ts +30 -1
- package/components/IMarker.js.map +1 -1
- package/components/Legend.d.ts +155 -58
- package/components/Legend.js +208 -172
- package/components/Legend.js.map +1 -1
- package/components/LegendEntry.d.ts +38 -0
- package/components/LegendEntry.js +34 -0
- package/components/LegendEntry.js.map +1 -1
- package/components/LimitLine.d.ts +40 -22
- package/components/LimitLine.js +44 -56
- package/components/LimitLine.js.map +1 -1
- package/components/MarkerImage.d.ts +1 -0
- package/components/MarkerImage.js +97 -0
- package/components/MarkerImage.js.map +1 -0
- package/components/XAxis.d.ts +41 -10
- package/components/XAxis.js +42 -24
- package/components/XAxis.js.map +1 -1
- package/components/YAxis.d.ts +114 -37
- package/components/YAxis.js +138 -106
- package/components/YAxis.js.map +1 -1
- package/data/BarData.d.ts +32 -4
- package/data/BarData.js +92 -24
- package/data/BarData.js.map +1 -1
- package/data/BarDataSet.d.ts +35 -18
- package/data/BarDataSet.js +42 -47
- package/data/BarDataSet.js.map +1 -1
- package/data/BarEntry.d.ts +3 -0
- package/data/BarEntry.js.map +1 -1
- package/data/BarLineScatterCandleBubbleData.d.ts +5 -0
- package/data/BarLineScatterCandleBubbleData.js +5 -0
- package/data/BarLineScatterCandleBubbleData.js.map +1 -1
- package/data/BarLineScatterCandleBubbleDataSet.d.ts +11 -3
- package/data/BarLineScatterCandleBubbleDataSet.js +11 -7
- package/data/BarLineScatterCandleBubbleDataSet.js.map +1 -1
- package/data/BaseDataSet.d.ts +129 -71
- package/data/BaseDataSet.js +146 -169
- package/data/BaseDataSet.js.map +1 -1
- package/data/BaseEntry.d.ts +3 -0
- package/data/BaseEntry.js.map +1 -1
- package/data/BubbleData.d.ts +7 -1
- package/data/BubbleData.js +8 -2
- package/data/BubbleData.js.map +1 -1
- package/data/BubbleDataSet.d.ts +7 -7
- package/data/BubbleDataSet.js +8 -15
- package/data/BubbleDataSet.js.map +1 -1
- package/data/BubbleEntry.d.ts +1 -0
- package/data/BubbleEntry.js.map +1 -1
- package/data/CandleData.js.map +1 -1
- package/data/CandleDataSet.d.ts +64 -30
- package/data/CandleDataSet.js +67 -74
- package/data/CandleDataSet.js.map +1 -1
- package/data/CandleEntry.d.ts +4 -0
- package/data/CandleEntry.js.map +1 -1
- package/data/ChartData.d.ts +275 -20
- package/data/ChartData.js +400 -95
- package/data/ChartData.js.map +1 -1
- package/data/CombinedData.d.ts +39 -12
- package/data/CombinedData.js +87 -71
- package/data/CombinedData.js.map +1 -1
- package/data/DataSet.d.ts +59 -8
- package/data/DataSet.js +114 -26
- package/data/DataSet.js.map +1 -1
- package/data/Entry.js.map +1 -1
- package/data/LineData.d.ts +5 -0
- package/data/LineData.js +5 -0
- package/data/LineData.js.map +1 -1
- package/data/LineDataSet.d.ts +84 -49
- package/data/LineDataSet.js +94 -135
- package/data/LineDataSet.js.map +1 -1
- package/data/LineRadarDataSet.d.ts +27 -17
- package/data/LineRadarDataSet.js +22 -35
- package/data/LineRadarDataSet.js.map +1 -1
- package/data/LineScatterCandleRadarDataSet.d.ts +30 -15
- package/data/LineScatterCandleRadarDataSet.js +36 -39
- package/data/LineScatterCandleRadarDataSet.js.map +1 -1
- package/data/PieData.d.ts +26 -0
- package/data/PieData.js +28 -2
- package/data/PieData.js.map +1 -1
- package/data/PieDataSet.d.ts +40 -36
- package/data/PieDataSet.js +36 -88
- package/data/PieDataSet.js.map +1 -1
- package/data/PieEntry.d.ts +3 -0
- package/data/PieEntry.js.map +1 -1
- package/data/RadarData.d.ts +10 -4
- package/data/RadarData.js +5 -6
- package/data/RadarData.js.map +1 -1
- package/data/RadarDataSet.d.ts +7 -21
- package/data/RadarDataSet.js +10 -49
- package/data/RadarDataSet.js.map +1 -1
- package/data/RadarEntry.js.map +1 -1
- package/data/ScatterData.d.ts +4 -1
- package/data/ScatterData.js +5 -2
- package/data/ScatterData.js.map +1 -1
- package/data/ScatterDataSet.d.ts +24 -14
- package/data/ScatterDataSet.js +26 -31
- package/data/ScatterDataSet.js.map +1 -1
- package/formatter/DefaultAxisValueFormatter.d.ts +17 -3
- package/formatter/DefaultAxisValueFormatter.js +12 -5
- package/formatter/DefaultAxisValueFormatter.js.map +1 -1
- package/formatter/DefaultFillFormatter.js +7 -7
- package/formatter/DefaultFillFormatter.js.map +1 -1
- package/formatter/DefaultValueFormatter.js.map +1 -1
- package/formatter/IAxisValueFormatter.d.ts +20 -2
- package/formatter/IAxisValueFormatter.js.map +1 -1
- package/formatter/IFillFormatter.d.ts +25 -0
- package/formatter/IFillFormatter.js.map +1 -1
- package/formatter/IValueFormatter.d.ts +21 -0
- package/formatter/IValueFormatter.js.map +1 -1
- package/formatter/ValueFormatter.d.ts +60 -0
- package/formatter/ValueFormatter.js +60 -0
- package/formatter/ValueFormatter.js.map +1 -1
- package/highlight/BarHighlighter.d.ts +22 -2
- package/highlight/BarHighlighter.js +43 -17
- package/highlight/BarHighlighter.js.map +1 -1
- package/highlight/ChartHighlighter.d.ts +87 -5
- package/highlight/ChartHighlighter.js +129 -25
- package/highlight/ChartHighlighter.js.map +1 -1
- package/highlight/CombinedHighlighter.d.ts +6 -0
- package/highlight/CombinedHighlighter.js +31 -16
- package/highlight/CombinedHighlighter.js.map +1 -1
- package/highlight/Highlight.d.ts +54 -1
- package/highlight/Highlight.js +5 -0
- package/highlight/Highlight.js.map +1 -1
- package/highlight/HorizontalBarHighlighter.d.ts +1 -1
- package/highlight/HorizontalBarHighlighter.js +14 -13
- package/highlight/HorizontalBarHighlighter.js.map +1 -1
- package/highlight/IHighlighter.d.ts +11 -1
- package/highlight/IHighlighter.js.map +1 -1
- package/highlight/PieHighlighter.js +2 -2
- package/highlight/PieHighlighter.js.map +1 -1
- package/highlight/PieRadarHighlighter.d.ts +12 -1
- package/highlight/PieRadarHighlighter.js +12 -4
- package/highlight/PieRadarHighlighter.js.map +1 -1
- package/highlight/RadarHighlighter.d.ts +12 -0
- package/highlight/RadarHighlighter.js +24 -10
- package/highlight/RadarHighlighter.js.map +1 -1
- package/index.d.ts +11 -0
- package/index.js +15 -0
- package/index.js.map +1 -0
- package/interfaces/dataprovider/BarDataProvider.d.ts +4 -4
- package/interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider.d.ts +8 -3
- package/interfaces/dataprovider/BubbleDataProvider.d.ts +1 -1
- package/interfaces/dataprovider/CandleDataProvider.d.ts +1 -1
- package/interfaces/dataprovider/ChartInterface.d.ts +17 -22
- package/interfaces/dataprovider/CombinedDataProvider.d.ts +1 -1
- package/interfaces/dataprovider/LineDataProvider.d.ts +1 -1
- package/interfaces/dataprovider/ScatterDataProvider.d.ts +1 -1
- package/interfaces/datasets/IBarDataSet.d.ts +8 -22
- package/interfaces/datasets/IBarLineScatterCandleBubbleDataSet.d.ts +1 -3
- package/interfaces/datasets/IBubbleDataSet.d.ts +3 -9
- package/interfaces/datasets/ICandleDataSet.d.ts +44 -41
- package/interfaces/datasets/IDataSet.d.ts +35 -151
- package/interfaces/datasets/ILineDataSet.d.ts +15 -54
- package/interfaces/datasets/ILineRadarDataSet.d.ts +7 -28
- package/interfaces/datasets/ILineScatterCandleRadarDataSet.d.ts +5 -4
- package/interfaces/datasets/IPieDataSet.d.ts +22 -40
- package/interfaces/datasets/IRadarDataSet.d.ts +7 -13
- package/interfaces/datasets/IScatterDataSet.d.ts +17 -16
- package/jobs/AnimatedMoveViewJob.d.ts +3 -0
- package/jobs/AnimatedMoveViewJob.js +12 -8
- package/jobs/AnimatedMoveViewJob.js.map +1 -1
- package/jobs/AnimatedViewPortJob.d.ts +7 -8
- package/jobs/AnimatedViewPortJob.js +16 -23
- package/jobs/AnimatedViewPortJob.js.map +1 -1
- package/jobs/AnimatedZoomJob.d.ts +8 -5
- package/jobs/AnimatedZoomJob.js +30 -26
- package/jobs/AnimatedZoomJob.js.map +1 -1
- package/jobs/MoveViewJob.d.ts +3 -0
- package/jobs/MoveViewJob.js +10 -7
- package/jobs/MoveViewJob.js.map +1 -1
- package/jobs/ViewPortJob.d.ts +3 -5
- package/jobs/ViewPortJob.js +5 -11
- package/jobs/ViewPortJob.js.map +1 -1
- package/jobs/ZoomJob.js +14 -14
- package/jobs/ZoomJob.js.map +1 -1
- package/listener/BarLineChartTouchListener.d.ts +82 -1
- package/listener/BarLineChartTouchListener.js +169 -67
- package/listener/BarLineChartTouchListener.js.map +1 -1
- package/listener/ChartTouchListener.d.ts +39 -5
- package/listener/ChartTouchListener.js +38 -11
- package/listener/ChartTouchListener.js.map +1 -1
- package/listener/PieRadarChartTouchListener.d.ts +56 -1
- package/listener/PieRadarChartTouchListener.js +201 -17
- package/listener/PieRadarChartTouchListener.js.map +1 -1
- package/model/GradientColor.js.map +1 -1
- package/package.json +23 -15
- package/renderer/AxisRenderer.d.ts +66 -7
- package/renderer/AxisRenderer.js +69 -21
- package/renderer/AxisRenderer.js.map +1 -1
- package/renderer/BarChartRenderer.d.ts +11 -0
- package/renderer/BarChartRenderer.js +99 -71
- package/renderer/BarChartRenderer.js.map +1 -1
- package/renderer/BarLineScatterCandleBubbleRenderer.d.ts +37 -0
- package/renderer/BarLineScatterCandleBubbleRenderer.js +36 -8
- package/renderer/BarLineScatterCandleBubbleRenderer.js.map +1 -1
- package/renderer/BubbleChartRenderer.d.ts +6 -2
- package/renderer/BubbleChartRenderer.js +51 -40
- package/renderer/BubbleChartRenderer.js.map +1 -1
- package/renderer/CandleStickChartRenderer.d.ts +1 -1
- package/renderer/CandleStickChartRenderer.js +64 -50
- package/renderer/CandleStickChartRenderer.js.map +1 -1
- package/renderer/CombinedChartRenderer.d.ts +20 -1
- package/renderer/CombinedChartRenderer.js +72 -42
- package/renderer/CombinedChartRenderer.js.map +1 -1
- package/renderer/DataRenderer.d.ts +78 -4
- package/renderer/DataRenderer.js +65 -6
- package/renderer/DataRenderer.js.map +1 -1
- package/renderer/HorizontalBarChartRenderer.d.ts +5 -2
- package/renderer/HorizontalBarChartRenderer.js +87 -66
- package/renderer/HorizontalBarChartRenderer.js.map +1 -1
- package/renderer/LegendRenderer.d.ts +32 -0
- package/renderer/LegendRenderer.js +98 -59
- package/renderer/LegendRenderer.js.map +1 -1
- package/renderer/LineChartRenderer.d.ts +38 -1
- package/renderer/LineChartRenderer.js +198 -113
- package/renderer/LineChartRenderer.js.map +1 -1
- package/renderer/LineRadarRenderer.d.ts +19 -0
- package/renderer/LineRadarRenderer.js +25 -1
- package/renderer/LineRadarRenderer.js.map +1 -1
- package/renderer/LineScatterCandleRadarRenderer.d.ts +11 -0
- package/renderer/LineScatterCandleRadarRenderer.js +26 -9
- package/renderer/LineScatterCandleRadarRenderer.js.map +1 -1
- package/renderer/PieChartRenderer.d.ts +45 -1
- package/renderer/PieChartRenderer.js +195 -122
- package/renderer/PieChartRenderer.js.map +1 -1
- package/renderer/RadarChartRenderer.d.ts +10 -0
- package/renderer/RadarChartRenderer.js +119 -77
- package/renderer/RadarChartRenderer.js.map +1 -1
- package/renderer/Renderer.d.ts +8 -0
- package/renderer/Renderer.js +5 -0
- package/renderer/Renderer.js.map +1 -1
- package/renderer/ScatterChartRenderer.d.ts +5 -5
- package/renderer/ScatterChartRenderer.js +51 -37
- package/renderer/ScatterChartRenderer.js.map +1 -1
- package/renderer/XAxisRenderer.d.ts +29 -4
- package/renderer/XAxisRenderer.js +128 -95
- package/renderer/XAxisRenderer.js.map +1 -1
- package/renderer/XAxisRendererHorizontalBarChart.d.ts +11 -0
- package/renderer/XAxisRendererHorizontalBarChart.js +75 -57
- package/renderer/XAxisRendererHorizontalBarChart.js.map +1 -1
- package/renderer/XAxisRendererRadarChart.d.ts +5 -0
- package/renderer/XAxisRendererRadarChart.js +26 -13
- package/renderer/XAxisRendererRadarChart.js.map +1 -1
- package/renderer/YAxisRenderer.d.ts +42 -5
- package/renderer/YAxisRenderer.js +126 -69
- package/renderer/YAxisRenderer.js.map +1 -1
- package/renderer/YAxisRendererHorizontalBarChart.d.ts +22 -1
- package/renderer/YAxisRendererHorizontalBarChart.js +80 -58
- package/renderer/YAxisRendererHorizontalBarChart.js.map +1 -1
- package/renderer/YAxisRendererRadarChart.js +62 -32
- package/renderer/YAxisRendererRadarChart.js.map +1 -1
- package/renderer/scatter/ChevronDownShapeRenderer.d.ts +4 -0
- package/renderer/scatter/ChevronDownShapeRenderer.js +5 -1
- package/renderer/scatter/ChevronDownShapeRenderer.js.map +1 -1
- package/renderer/scatter/ChevronUpShapeRenderer.d.ts +4 -0
- package/renderer/scatter/ChevronUpShapeRenderer.js +5 -1
- package/renderer/scatter/ChevronUpShapeRenderer.js.map +1 -1
- package/renderer/scatter/CircleShapeRenderer.d.ts +4 -0
- package/renderer/scatter/CircleShapeRenderer.js +8 -5
- package/renderer/scatter/CircleShapeRenderer.js.map +1 -1
- package/renderer/scatter/CrossShapeRenderer.d.ts +4 -0
- package/renderer/scatter/CrossShapeRenderer.js +5 -1
- package/renderer/scatter/CrossShapeRenderer.js.map +1 -1
- package/renderer/scatter/IShapeRenderer.d.ts +14 -0
- package/renderer/scatter/IShapeRenderer.js.map +1 -1
- package/renderer/scatter/SquareShapeRenderer.d.ts +4 -0
- package/renderer/scatter/SquareShapeRenderer.js +8 -5
- package/renderer/scatter/SquareShapeRenderer.js.map +1 -1
- package/renderer/scatter/TriangleShapeRenderer.d.ts +4 -0
- package/renderer/scatter/TriangleShapeRenderer.js +9 -5
- package/renderer/scatter/TriangleShapeRenderer.js.map +1 -1
- package/renderer/scatter/XShapeRenderer.d.ts +4 -0
- package/renderer/scatter/XShapeRenderer.js +5 -1
- package/renderer/scatter/XShapeRenderer.js.map +1 -1
- package/utils/ColorTemplate.d.ts +21 -1
- package/utils/ColorTemplate.js +21 -3
- package/utils/ColorTemplate.js.map +1 -1
- package/utils/HorizontalViewPortHandler.d.ts +3 -0
- package/utils/HorizontalViewPortHandler.js +3 -0
- package/utils/HorizontalViewPortHandler.js.map +1 -1
- package/utils/MPSize.d.ts +7 -0
- package/utils/ObjectPool.d.ts +56 -0
- package/utils/ObjectPool.js +66 -8
- package/utils/ObjectPool.js.map +1 -1
- package/utils/Transformer.d.ts +118 -0
- package/utils/Transformer.js +141 -7
- package/utils/Transformer.js.map +1 -1
- package/utils/TransformerHorizontalBarChart.d.ts +10 -0
- package/utils/TransformerHorizontalBarChart.js +18 -2
- package/utils/TransformerHorizontalBarChart.js.map +1 -1
- package/utils/Utils.d.ts +139 -17
- package/utils/Utils.js +185 -60
- package/utils/Utils.js.map +1 -1
- package/utils/ViewPortHandler.d.ts +234 -19
- package/utils/ViewPortHandler.js +306 -63
- package/utils/ViewPortHandler.js.map +1 -1
- package/utils/colors/colorful.js.map +1 -1
- package/utils/colors/joyful.js.map +1 -1
- package/utils/colors/liberty.js.map +1 -1
- package/utils/colors/material.js.map +1 -1
- package/utils/colors/pastel.js.map +1 -1
- package/utils/colors/vordiplom.js.map +1 -1
- package/charts/index.d.ts +0 -11
- package/charts/index.js +0 -15
- package/charts/index.js.map +0 -1
package/data/ChartData.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { AxisDependency } from '../components/YAxis';
|
|
2
2
|
export class ChartData {
|
|
3
|
+
/**
|
|
4
|
+
* Default constructor.
|
|
5
|
+
*/
|
|
6
|
+
// public ChartData() {
|
|
7
|
+
// this.mDataSets = [];
|
|
8
|
+
// }
|
|
9
|
+
/**
|
|
10
|
+
* Constructor taking single or multiple DataSet objects.
|
|
11
|
+
*
|
|
12
|
+
* @param dataSets
|
|
13
|
+
*/
|
|
3
14
|
constructor(dataSets) {
|
|
15
|
+
/**
|
|
16
|
+
* maximum y-value in the value array across all axes
|
|
17
|
+
*/
|
|
4
18
|
this.mYMax = -Infinity;
|
|
19
|
+
/**
|
|
20
|
+
* the minimum y-value in the value array across all axes
|
|
21
|
+
*/
|
|
5
22
|
this.mYMin = Infinity;
|
|
23
|
+
/**
|
|
24
|
+
* maximum x-value in the value array
|
|
25
|
+
*/
|
|
6
26
|
this.mXMax = -Infinity;
|
|
27
|
+
/**
|
|
28
|
+
* minimum x-value in the value array
|
|
29
|
+
*/
|
|
7
30
|
this.mXMin = Infinity;
|
|
8
31
|
this.mLeftAxisMax = -Infinity;
|
|
9
32
|
this.mLeftAxisMin = Infinity;
|
|
@@ -12,25 +35,63 @@ export class ChartData {
|
|
|
12
35
|
this.mDataSets = dataSets || [];
|
|
13
36
|
this.notifyDataChanged();
|
|
14
37
|
}
|
|
38
|
+
// /**
|
|
39
|
+
// * Created because Arrays.asList(...) does not support modification.
|
|
40
|
+
// *
|
|
41
|
+
// * @param array
|
|
42
|
+
// * @return
|
|
43
|
+
// */
|
|
44
|
+
// private List<T> arrayToList(T[] array) {
|
|
45
|
+
// List<T> list = new ArrayList<>();
|
|
46
|
+
// for (T set : array) {
|
|
47
|
+
// list.add(set);
|
|
48
|
+
// }
|
|
49
|
+
// return list;
|
|
50
|
+
// }
|
|
51
|
+
// /**
|
|
52
|
+
// * constructor for chart data
|
|
53
|
+
// *
|
|
54
|
+
// * @param sets the dataset array
|
|
55
|
+
// */
|
|
56
|
+
// public ChartData(List<T> sets) {
|
|
57
|
+
// this.mDataSets = sets;
|
|
58
|
+
// notifyDataChanged();
|
|
59
|
+
// }
|
|
60
|
+
/**
|
|
61
|
+
* Call this method to let the ChartData know that the underlying data has
|
|
62
|
+
* changed. Calling this performs all necessary recalculations needed when
|
|
63
|
+
* the contained data has changed.
|
|
64
|
+
*/
|
|
15
65
|
notifyDataChanged() {
|
|
16
66
|
this.calcMinMax();
|
|
17
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Calc minimum and maximum y-values over all DataSets.
|
|
70
|
+
* Tell DataSets to recalculate their min and max y-values, this is only needed for autoScaleMinMax.
|
|
71
|
+
*
|
|
72
|
+
* @param fromX the x-value to start the calculation from
|
|
73
|
+
* @param toX the x-value to which the calculation should be performed
|
|
74
|
+
*/
|
|
18
75
|
calcMinMaxYRange(fromX, toX) {
|
|
19
76
|
for (const set of this.mDataSets) {
|
|
20
77
|
set.calcMinMaxYRange(fromX, toX);
|
|
21
78
|
}
|
|
79
|
+
// apply the new data
|
|
22
80
|
this.calcMinMax();
|
|
23
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Calc minimum and maximum values (both x and y) over all DataSets.
|
|
84
|
+
*/
|
|
24
85
|
calcMinMax() {
|
|
25
|
-
if (this.mDataSets
|
|
86
|
+
if (!this.mDataSets)
|
|
26
87
|
return;
|
|
27
88
|
this.mYMax = -Infinity;
|
|
28
89
|
this.mYMin = Infinity;
|
|
29
90
|
this.mXMax = -Infinity;
|
|
30
91
|
this.mXMin = Infinity;
|
|
31
|
-
const visibleDatasets = this.
|
|
92
|
+
const visibleDatasets = this.visibleDataSets;
|
|
32
93
|
for (const set of visibleDatasets) {
|
|
33
|
-
if (set.
|
|
94
|
+
if (set.visible) {
|
|
34
95
|
this.calcMinMaxForDataSet(set);
|
|
35
96
|
}
|
|
36
97
|
}
|
|
@@ -38,38 +99,50 @@ export class ChartData {
|
|
|
38
99
|
this.mLeftAxisMin = Infinity;
|
|
39
100
|
this.mRightAxisMax = -Infinity;
|
|
40
101
|
this.mRightAxisMin = Infinity;
|
|
102
|
+
// left axis
|
|
41
103
|
const firstLeft = this.getFirstLeft(visibleDatasets);
|
|
42
|
-
if (firstLeft
|
|
43
|
-
this.mLeftAxisMax = firstLeft.
|
|
44
|
-
this.mLeftAxisMin = firstLeft.
|
|
104
|
+
if (firstLeft) {
|
|
105
|
+
this.mLeftAxisMax = firstLeft.yMax;
|
|
106
|
+
this.mLeftAxisMin = firstLeft.yMin;
|
|
45
107
|
for (const dataSet of visibleDatasets) {
|
|
46
|
-
if (dataSet.
|
|
47
|
-
if (dataSet.
|
|
48
|
-
this.mLeftAxisMin = dataSet.
|
|
49
|
-
if (dataSet.
|
|
50
|
-
this.mLeftAxisMax = dataSet.
|
|
108
|
+
if (dataSet.axisDependency === AxisDependency.LEFT) {
|
|
109
|
+
if (dataSet.yMin < this.mLeftAxisMin)
|
|
110
|
+
this.mLeftAxisMin = dataSet.yMin;
|
|
111
|
+
if (dataSet.yMax > this.mLeftAxisMax)
|
|
112
|
+
this.mLeftAxisMax = dataSet.yMax;
|
|
51
113
|
}
|
|
52
114
|
}
|
|
53
115
|
}
|
|
116
|
+
// right axis
|
|
54
117
|
const firstRight = this.getFirstRight(visibleDatasets);
|
|
55
|
-
if (firstRight
|
|
56
|
-
this.mRightAxisMax = firstRight.
|
|
57
|
-
this.mRightAxisMin = firstRight.
|
|
118
|
+
if (firstRight) {
|
|
119
|
+
this.mRightAxisMax = firstRight.yMax;
|
|
120
|
+
this.mRightAxisMin = firstRight.yMin;
|
|
58
121
|
for (const dataSet of visibleDatasets) {
|
|
59
|
-
if (dataSet.
|
|
60
|
-
if (dataSet.
|
|
61
|
-
this.mRightAxisMin = dataSet.
|
|
62
|
-
if (dataSet.
|
|
63
|
-
this.mRightAxisMax = dataSet.
|
|
122
|
+
if (dataSet.axisDependency === AxisDependency.RIGHT) {
|
|
123
|
+
if (dataSet.yMin < this.mRightAxisMin)
|
|
124
|
+
this.mRightAxisMin = dataSet.yMin;
|
|
125
|
+
if (dataSet.yMax > this.mRightAxisMax)
|
|
126
|
+
this.mRightAxisMax = dataSet.yMax;
|
|
64
127
|
}
|
|
65
128
|
}
|
|
66
129
|
}
|
|
67
130
|
}
|
|
68
|
-
|
|
69
|
-
|
|
131
|
+
/** ONLY GETTERS AND SETTERS BELOW THIS */
|
|
132
|
+
/**
|
|
133
|
+
* returns the number of LineDataSets this object contains
|
|
134
|
+
*/
|
|
135
|
+
get dataSetCount() {
|
|
136
|
+
if (!this.mDataSets)
|
|
70
137
|
return 0;
|
|
71
138
|
return this.mDataSets.length;
|
|
72
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns the minimum y-value for the specified axis.
|
|
142
|
+
*
|
|
143
|
+
* @param axis
|
|
144
|
+
* @return
|
|
145
|
+
*/
|
|
73
146
|
getYMin(axis) {
|
|
74
147
|
if (axis === undefined) {
|
|
75
148
|
return this.mYMin;
|
|
@@ -95,6 +168,18 @@ export class ChartData {
|
|
|
95
168
|
return this.mRightAxisMin;
|
|
96
169
|
}
|
|
97
170
|
}
|
|
171
|
+
get yMin() {
|
|
172
|
+
return this.mYMin;
|
|
173
|
+
}
|
|
174
|
+
get yMax() {
|
|
175
|
+
return this.mYMax;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns the maximum y-value for the specified axis.
|
|
179
|
+
*
|
|
180
|
+
* @param axis
|
|
181
|
+
* @return
|
|
182
|
+
*/
|
|
98
183
|
getYMax(axis) {
|
|
99
184
|
if (axis === undefined) {
|
|
100
185
|
return this.mYMax;
|
|
@@ -120,39 +205,68 @@ export class ChartData {
|
|
|
120
205
|
return this.mRightAxisMax;
|
|
121
206
|
}
|
|
122
207
|
}
|
|
123
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Returns the minimum x-value this data object contains.
|
|
210
|
+
*/
|
|
211
|
+
get xMin() {
|
|
124
212
|
return this.mXMin;
|
|
125
213
|
}
|
|
126
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Returns the maximum x-value this data object contains.
|
|
216
|
+
*/
|
|
217
|
+
get xMax() {
|
|
127
218
|
return this.mXMax;
|
|
128
219
|
}
|
|
129
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Returns all DataSet objects this ChartData object holds.
|
|
222
|
+
*/
|
|
223
|
+
get dataSets() {
|
|
130
224
|
return this.mDataSets;
|
|
131
225
|
}
|
|
132
|
-
|
|
133
|
-
return this.mDataSets.filter((s) => s.
|
|
134
|
-
}
|
|
135
|
-
|
|
226
|
+
get visibleDataSets() {
|
|
227
|
+
return this.mDataSets.filter((s) => s.visible);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Retrieve the index of a DataSet with a specific label from the ChartData.
|
|
231
|
+
* Search can be case sensitive or not. IMPORTANT: This method does
|
|
232
|
+
* calculations at runtime, do not over-use in performance critical
|
|
233
|
+
* situations.
|
|
234
|
+
*
|
|
235
|
+
* @param dataSets the DataSet array to search
|
|
236
|
+
* @param label
|
|
237
|
+
* @param ignorecase if true, the search is not case-sensitive
|
|
238
|
+
* @return
|
|
239
|
+
*/
|
|
240
|
+
getDataSetIndexByLabel(dataSets, label, ignorecase = false) {
|
|
136
241
|
if (ignorecase) {
|
|
137
242
|
const toTest = label.toLowerCase();
|
|
138
243
|
for (let i = 0; i < dataSets.length; i++)
|
|
139
|
-
if (toTest === dataSets[i].
|
|
244
|
+
if (toTest === dataSets[i].label?.toLowerCase())
|
|
140
245
|
return i;
|
|
141
246
|
}
|
|
142
247
|
else {
|
|
143
248
|
for (let i = 0; i < dataSets.length; i++)
|
|
144
|
-
if (label === dataSets[i].
|
|
249
|
+
if (label === dataSets[i].label)
|
|
145
250
|
return i;
|
|
146
251
|
}
|
|
147
252
|
return -1;
|
|
148
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Returns the labels of all DataSets as a string array.
|
|
256
|
+
*/
|
|
149
257
|
getDataSetLabels() {
|
|
150
258
|
const types = [];
|
|
151
259
|
for (let i = 0; i < this.mDataSets.length; i++) {
|
|
152
|
-
types[i] = this.mDataSets[i].
|
|
260
|
+
types[i] = this.mDataSets[i].label;
|
|
153
261
|
}
|
|
154
262
|
return types;
|
|
155
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Get the Entry for a corresponding highlight object
|
|
266
|
+
*
|
|
267
|
+
* @param highlight
|
|
268
|
+
* @return the entry that is highlighted
|
|
269
|
+
*/
|
|
156
270
|
getEntryForHighlight(highlight) {
|
|
157
271
|
if (highlight.entry) {
|
|
158
272
|
return highlight.entry;
|
|
@@ -163,6 +277,12 @@ export class ChartData {
|
|
|
163
277
|
return this.mDataSets[highlight.dataSetIndex].getEntryForXValue(highlight.x, highlight.y);
|
|
164
278
|
}
|
|
165
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Get the Entry for a corresponding highlight object
|
|
282
|
+
*
|
|
283
|
+
* @param highlight
|
|
284
|
+
* @return the entry that is highlighted
|
|
285
|
+
*/
|
|
166
286
|
getEntryAndIndexForHighlight(highlight) {
|
|
167
287
|
if (highlight.entry) {
|
|
168
288
|
return { entry: highlight.entry, index: highlight.entryIndex };
|
|
@@ -173,7 +293,16 @@ export class ChartData {
|
|
|
173
293
|
return this.mDataSets[highlight.dataSetIndex].getEntryAndIndexForXValue(highlight.x, highlight.y);
|
|
174
294
|
}
|
|
175
295
|
}
|
|
176
|
-
|
|
296
|
+
/**
|
|
297
|
+
* Returns the DataSet object with the given label. Search can be case
|
|
298
|
+
* sensitive or not. IMPORTANT: This method does calculations at runtime.
|
|
299
|
+
* Use with care in performance critical situations.
|
|
300
|
+
*
|
|
301
|
+
* @param label
|
|
302
|
+
* @param ignorecase
|
|
303
|
+
* @return
|
|
304
|
+
*/
|
|
305
|
+
getDataSetByLabel(label, ignorecase = false) {
|
|
177
306
|
const index = this.getDataSetIndexByLabel(this.mDataSets, label, ignorecase);
|
|
178
307
|
if (index < 0 || index >= this.mDataSets.length)
|
|
179
308
|
return null;
|
|
@@ -181,28 +310,48 @@ export class ChartData {
|
|
|
181
310
|
return this.mDataSets[index];
|
|
182
311
|
}
|
|
183
312
|
getDataSetByIndex(index) {
|
|
184
|
-
if (this.mDataSets
|
|
313
|
+
if (!this.mDataSets || index < 0 || index >= this.mDataSets.length)
|
|
185
314
|
return null;
|
|
186
315
|
return this.mDataSets[index];
|
|
187
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Adds a DataSet dynamically.
|
|
319
|
+
*
|
|
320
|
+
* @param d
|
|
321
|
+
*/
|
|
188
322
|
addDataSet(d) {
|
|
189
|
-
if (d
|
|
323
|
+
if (!d)
|
|
190
324
|
return;
|
|
191
|
-
if (d.
|
|
325
|
+
if (d.visible) {
|
|
192
326
|
this.calcMinMaxForDataSet(d);
|
|
193
327
|
}
|
|
194
328
|
this.mDataSets.push(d);
|
|
195
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Removes the given DataSet from this data object. Also recalculates all
|
|
332
|
+
* minimum and maximum values. Returns true if a DataSet was removed, false
|
|
333
|
+
* if no DataSet could be removed.
|
|
334
|
+
*
|
|
335
|
+
* @param d
|
|
336
|
+
*/
|
|
196
337
|
removeDataSet(d) {
|
|
197
|
-
if (d
|
|
338
|
+
if (!d)
|
|
198
339
|
return false;
|
|
199
340
|
const index = this.mDataSets.indexOf(d);
|
|
341
|
+
// if a DataSet was removed
|
|
200
342
|
if (index >= 0) {
|
|
201
343
|
this.mDataSets.splice(index, 1);
|
|
202
344
|
this.calcMinMax();
|
|
203
345
|
}
|
|
204
346
|
return index >= 0;
|
|
205
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Removes the DataSet at the given index in the DataSet array from the data
|
|
350
|
+
* object. Also recalculates all minimum and maximum values. Returns true if
|
|
351
|
+
* a DataSet was removed, false if no DataSet could be removed.
|
|
352
|
+
*
|
|
353
|
+
* @param index
|
|
354
|
+
*/
|
|
206
355
|
removeDataSetAtIndex(index) {
|
|
207
356
|
if (index >= this.mDataSets.length || index < 0)
|
|
208
357
|
return false;
|
|
@@ -210,20 +359,34 @@ export class ChartData {
|
|
|
210
359
|
this.calcMinMax();
|
|
211
360
|
return true;
|
|
212
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Adds an Entry to the DataSet at the specified index.
|
|
364
|
+
* Entries are added to the end of the list.
|
|
365
|
+
*
|
|
366
|
+
* @param e
|
|
367
|
+
* @param dataSetIndex
|
|
368
|
+
*/
|
|
213
369
|
addEntry(e, dataSetIndex) {
|
|
214
370
|
if (this.mDataSets.length > dataSetIndex && dataSetIndex >= 0) {
|
|
215
371
|
const set = this.mDataSets[dataSetIndex];
|
|
216
|
-
|
|
372
|
+
// add the entry to the dataset
|
|
373
|
+
const length = set.entryCount;
|
|
217
374
|
if (!set.addEntry(e))
|
|
218
375
|
return;
|
|
219
|
-
if (set.
|
|
220
|
-
this.calcMinMaxForEntry(set, e, length, set.
|
|
376
|
+
if (set.visible) {
|
|
377
|
+
this.calcMinMaxForEntry(set, e, length, set.axisDependency);
|
|
221
378
|
}
|
|
222
379
|
}
|
|
223
380
|
else {
|
|
224
381
|
console.error('addEntry', 'Cannot add Entry because dataSetIndex too high or too low.');
|
|
225
382
|
}
|
|
226
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Adjusts the current minimum and maximum values based on the provided Entry object.
|
|
386
|
+
*
|
|
387
|
+
* @param e
|
|
388
|
+
* @param axis
|
|
389
|
+
*/
|
|
227
390
|
calcMinMaxForEntry(set, e, entryIndex, axis) {
|
|
228
391
|
const xKey = set.xProperty;
|
|
229
392
|
const yKey = set.yProperty;
|
|
@@ -250,33 +413,46 @@ export class ChartData {
|
|
|
250
413
|
this.mRightAxisMin = yValue;
|
|
251
414
|
}
|
|
252
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Adjusts the minimum and maximum values based on the given DataSet.
|
|
418
|
+
*
|
|
419
|
+
* @param d
|
|
420
|
+
*/
|
|
253
421
|
calcMinMaxForDataSet(d) {
|
|
254
|
-
if (this.mYMax < d.
|
|
255
|
-
this.mYMax = d.
|
|
256
|
-
if (this.mYMin > d.
|
|
257
|
-
this.mYMin = d.
|
|
258
|
-
if (this.mXMax < d.
|
|
259
|
-
this.mXMax = d.
|
|
260
|
-
if (this.mXMin > d.
|
|
261
|
-
this.mXMin = d.
|
|
262
|
-
if (d.
|
|
263
|
-
if (this.mLeftAxisMax < d.
|
|
264
|
-
this.mLeftAxisMax = d.
|
|
265
|
-
if (this.mLeftAxisMin > d.
|
|
266
|
-
this.mLeftAxisMin = d.
|
|
422
|
+
if (this.mYMax < d.yMax)
|
|
423
|
+
this.mYMax = d.yMax;
|
|
424
|
+
if (this.mYMin > d.yMin)
|
|
425
|
+
this.mYMin = d.yMin;
|
|
426
|
+
if (this.mXMax < d.xMax)
|
|
427
|
+
this.mXMax = d.xMax;
|
|
428
|
+
if (this.mXMin > d.xMin)
|
|
429
|
+
this.mXMin = d.xMin;
|
|
430
|
+
if (d.axisDependency === AxisDependency.LEFT) {
|
|
431
|
+
if (this.mLeftAxisMax < d.yMax)
|
|
432
|
+
this.mLeftAxisMax = d.yMax;
|
|
433
|
+
if (this.mLeftAxisMin > d.yMin)
|
|
434
|
+
this.mLeftAxisMin = d.yMin;
|
|
267
435
|
}
|
|
268
436
|
else {
|
|
269
|
-
if (this.mRightAxisMax < d.
|
|
270
|
-
this.mRightAxisMax = d.
|
|
271
|
-
if (this.mRightAxisMin > d.
|
|
272
|
-
this.mRightAxisMin = d.
|
|
273
|
-
}
|
|
274
|
-
}
|
|
437
|
+
if (this.mRightAxisMax < d.yMax)
|
|
438
|
+
this.mRightAxisMax = d.yMax;
|
|
439
|
+
if (this.mRightAxisMin > d.yMin)
|
|
440
|
+
this.mRightAxisMin = d.yMin;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Removes the given Entry object from the DataSet at the specified index.
|
|
445
|
+
*
|
|
446
|
+
* @param e
|
|
447
|
+
* @param dataSetIndex
|
|
448
|
+
*/
|
|
275
449
|
removeEntry(e, dataSetIndex) {
|
|
276
|
-
|
|
450
|
+
// entry null, outofbounds
|
|
451
|
+
if (!e || dataSetIndex >= this.mDataSets.length)
|
|
277
452
|
return false;
|
|
278
453
|
const set = this.mDataSets[dataSetIndex];
|
|
279
|
-
if (set
|
|
454
|
+
if (set) {
|
|
455
|
+
// remove the entry from the dataset
|
|
280
456
|
const removed = set.removeEntry(e);
|
|
281
457
|
if (removed) {
|
|
282
458
|
this.calcMinMax();
|
|
@@ -286,51 +462,109 @@ export class ChartData {
|
|
|
286
462
|
else
|
|
287
463
|
return false;
|
|
288
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Removes the Entry object closest to the given DataSet at the
|
|
467
|
+
* specified index. Returns true if an Entry was removed, false if no Entry
|
|
468
|
+
* was found that meets the specified requirements.
|
|
469
|
+
*
|
|
470
|
+
* @param xValue
|
|
471
|
+
* @param dataSetIndex
|
|
472
|
+
* @return
|
|
473
|
+
*/
|
|
289
474
|
removeEntryForXValue(xValue, dataSetIndex) {
|
|
290
475
|
if (dataSetIndex >= this.mDataSets.length)
|
|
291
476
|
return false;
|
|
292
477
|
const dataSet = this.mDataSets[dataSetIndex];
|
|
293
478
|
const e = dataSet.getEntryForXValue(xValue, NaN);
|
|
294
|
-
if (e
|
|
479
|
+
if (!e)
|
|
295
480
|
return false;
|
|
296
481
|
return this.removeEntry(e, dataSetIndex);
|
|
297
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Removes the Entry object closest to the given DataSet at the
|
|
485
|
+
* specified index. Returns true if an Entry was removed, false if no Entry
|
|
486
|
+
* was found that meets the specified requirements.
|
|
487
|
+
*
|
|
488
|
+
* @param xValue
|
|
489
|
+
* @param dataSetIndex
|
|
490
|
+
* @return
|
|
491
|
+
*/
|
|
492
|
+
removeEntryAtIndex(index, dataSetIndex) {
|
|
493
|
+
// entry null, outofbounds
|
|
494
|
+
if (dataSetIndex >= this.mDataSets.length)
|
|
495
|
+
return false;
|
|
496
|
+
const set = this.mDataSets[dataSetIndex];
|
|
497
|
+
if (set) {
|
|
498
|
+
// remove the entry from the dataset
|
|
499
|
+
const removed = set.removeEntryAtIndex(index);
|
|
500
|
+
if (removed) {
|
|
501
|
+
this.calcMinMax();
|
|
502
|
+
}
|
|
503
|
+
return removed;
|
|
504
|
+
}
|
|
505
|
+
else
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Returns the DataSet that contains the provided Entry, or null, if no
|
|
510
|
+
* DataSet contains this Entry.
|
|
511
|
+
*
|
|
512
|
+
* @param e
|
|
513
|
+
* @return
|
|
514
|
+
*/
|
|
298
515
|
getDataSetForEntry(e) {
|
|
299
|
-
if (
|
|
516
|
+
// WARNING: wont work if index is used as xKey(xKey not set)
|
|
517
|
+
if (!e)
|
|
300
518
|
return null;
|
|
301
519
|
for (let i = 0; i < this.mDataSets.length; i++) {
|
|
302
520
|
const set = this.mDataSets[i];
|
|
303
521
|
const xKey = set.xProperty;
|
|
304
522
|
const yKey = set.yProperty;
|
|
523
|
+
// for (let j = 0; j < set.entryCount; j++) {
|
|
305
524
|
if (e === set.getEntryForXValue(e[xKey], e[yKey]))
|
|
306
525
|
return set;
|
|
526
|
+
// }
|
|
307
527
|
}
|
|
308
528
|
return null;
|
|
309
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Returns the DataSet that contains the provided Entry and the entry index, or null, if no
|
|
532
|
+
* DataSet contains this Entry.
|
|
533
|
+
*
|
|
534
|
+
* @param e
|
|
535
|
+
* @return
|
|
536
|
+
*/
|
|
310
537
|
getDataSetAndIndexForEntry(e) {
|
|
311
|
-
if (
|
|
538
|
+
// WARNING: wont work if index is used as xKey(xKey not set)
|
|
539
|
+
if (!e)
|
|
312
540
|
return null;
|
|
313
541
|
for (let i = 0; i < this.mDataSets.length; i++) {
|
|
314
542
|
const set = this.mDataSets[i];
|
|
315
543
|
const xKey = set.xProperty;
|
|
316
544
|
const yKey = set.yProperty;
|
|
317
545
|
const r = set.getEntryAndIndexForXValue(e[xKey], e[yKey]);
|
|
546
|
+
// for (let j = 0; j < set.entryCount; j++) {
|
|
318
547
|
if (e === r.entry)
|
|
319
548
|
return { set, index: r.index };
|
|
549
|
+
// }
|
|
320
550
|
}
|
|
321
551
|
return null;
|
|
322
552
|
}
|
|
323
|
-
|
|
324
|
-
|
|
553
|
+
/**
|
|
554
|
+
* Returns all colors used across all DataSet objects this object
|
|
555
|
+
* represents.
|
|
556
|
+
*/
|
|
557
|
+
get colors() {
|
|
558
|
+
if (!this.mDataSets)
|
|
325
559
|
return null;
|
|
326
560
|
let clrcnt = 0;
|
|
327
561
|
for (let i = 0; i < this.mDataSets.length; i++) {
|
|
328
|
-
clrcnt += this.mDataSets[i].
|
|
562
|
+
clrcnt += this.mDataSets[i].colors.length;
|
|
329
563
|
}
|
|
330
564
|
const colors = [];
|
|
331
565
|
let cnt = 0;
|
|
332
566
|
for (let i = 0; i < this.mDataSets.length; i++) {
|
|
333
|
-
const clrs = this.mDataSets[i].
|
|
567
|
+
const clrs = this.mDataSets[i].colors;
|
|
334
568
|
for (const clr of clrs) {
|
|
335
569
|
colors[cnt] = clr;
|
|
336
570
|
cnt++;
|
|
@@ -338,91 +572,162 @@ export class ChartData {
|
|
|
338
572
|
}
|
|
339
573
|
return colors;
|
|
340
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Returns the index of the provided DataSet in the DataSet array of this data object, or -1 if it does not exist.
|
|
577
|
+
*
|
|
578
|
+
* @param dataSet
|
|
579
|
+
* @return
|
|
580
|
+
*/
|
|
341
581
|
getIndexOfDataSet(dataSet) {
|
|
342
582
|
return this.mDataSets.indexOf(dataSet);
|
|
343
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Returns the first DataSet from the datasets-array that has it's dependency on the left axis.
|
|
586
|
+
* Returns null if no DataSet with left dependency could be found.
|
|
587
|
+
*/
|
|
344
588
|
getFirstLeft(sets) {
|
|
345
589
|
for (const dataSet of sets) {
|
|
346
|
-
if (dataSet.
|
|
590
|
+
if (dataSet.axisDependency === AxisDependency.LEFT)
|
|
347
591
|
return dataSet;
|
|
348
592
|
}
|
|
349
593
|
return null;
|
|
350
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Returns the first DataSet from the datasets-array that has it's dependency on the right axis.
|
|
597
|
+
* Returns null if no DataSet with right dependency could be found.
|
|
598
|
+
*/
|
|
351
599
|
getFirstRight(sets) {
|
|
352
600
|
for (const dataSet of sets) {
|
|
353
|
-
if (dataSet.
|
|
601
|
+
if (dataSet.axisDependency === AxisDependency.RIGHT)
|
|
354
602
|
return dataSet;
|
|
355
603
|
}
|
|
356
604
|
return null;
|
|
357
605
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
606
|
+
/**
|
|
607
|
+
* Sets a custom IValueFormatter for all DataSets this data object contains.
|
|
608
|
+
*
|
|
609
|
+
* @param f
|
|
610
|
+
*/
|
|
611
|
+
set valueFormatter(f) {
|
|
612
|
+
for (const set of this.mDataSets) {
|
|
613
|
+
set.valueFormatter = f;
|
|
365
614
|
}
|
|
366
615
|
}
|
|
367
|
-
|
|
616
|
+
/**
|
|
617
|
+
* Sets the color of the value-text (color in which the value-labels are
|
|
618
|
+
* drawn) for all DataSets this data object contains.
|
|
619
|
+
*
|
|
620
|
+
* @param color
|
|
621
|
+
*/
|
|
622
|
+
set valueTextColor(color) {
|
|
368
623
|
for (const set of this.mDataSets) {
|
|
369
|
-
set.
|
|
624
|
+
set.valueTextColor = color;
|
|
370
625
|
}
|
|
371
626
|
}
|
|
372
|
-
|
|
627
|
+
/**
|
|
628
|
+
* Sets the same list of value-colors for all DataSets this
|
|
629
|
+
* data object contains.
|
|
630
|
+
*
|
|
631
|
+
* @param colors
|
|
632
|
+
*/
|
|
633
|
+
set valueTextColors(colors) {
|
|
373
634
|
for (const set of this.mDataSets) {
|
|
374
|
-
set.
|
|
635
|
+
set.valueTextColors = colors;
|
|
375
636
|
}
|
|
376
637
|
}
|
|
377
|
-
|
|
638
|
+
/**
|
|
639
|
+
* Sets the Typeface for all value-labels for all DataSets this data object
|
|
640
|
+
* contains.
|
|
641
|
+
*
|
|
642
|
+
* @param tf
|
|
643
|
+
*/
|
|
644
|
+
set valueTypeface(tf) {
|
|
378
645
|
for (const set of this.mDataSets) {
|
|
379
|
-
set.
|
|
646
|
+
set.valueTypeface = tf;
|
|
380
647
|
}
|
|
381
648
|
}
|
|
382
|
-
|
|
649
|
+
/**
|
|
650
|
+
* Sets the size (in dp) of the value-text for all DataSets this data object
|
|
651
|
+
* contains.
|
|
652
|
+
*
|
|
653
|
+
* @param size
|
|
654
|
+
*/
|
|
655
|
+
set valueTextSize(size) {
|
|
383
656
|
for (const set of this.mDataSets) {
|
|
384
|
-
set.
|
|
657
|
+
set.valueTextSize = size;
|
|
385
658
|
}
|
|
386
659
|
}
|
|
387
|
-
|
|
660
|
+
/**
|
|
661
|
+
* Enables / disables drawing values (value-text) for all DataSets this data
|
|
662
|
+
* object contains.
|
|
663
|
+
*
|
|
664
|
+
* @param enabled
|
|
665
|
+
*/
|
|
666
|
+
set drawValuesEnabled(enabled) {
|
|
388
667
|
for (const set of this.mDataSets) {
|
|
389
|
-
set.
|
|
668
|
+
set.drawValuesEnabled = enabled;
|
|
390
669
|
}
|
|
391
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Enables / disables highlighting values for all DataSets this data object
|
|
673
|
+
* contains. If set to true, this means that values can
|
|
674
|
+
* be highlighted programmatically or by touch gesture.
|
|
675
|
+
*/
|
|
392
676
|
setHighlightEnabled(enabled) {
|
|
393
677
|
for (const set of this.mDataSets) {
|
|
394
|
-
set.
|
|
678
|
+
set.highlightEnabled = enabled;
|
|
395
679
|
}
|
|
396
680
|
}
|
|
397
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Returns true if highlighting of all underlying values is enabled, false
|
|
683
|
+
* if not.
|
|
684
|
+
*/
|
|
685
|
+
get highlightEnabled() {
|
|
398
686
|
for (const set of this.mDataSets) {
|
|
399
|
-
if (!set.
|
|
687
|
+
if (!set.highlightEnabled)
|
|
400
688
|
return false;
|
|
401
689
|
}
|
|
402
690
|
return true;
|
|
403
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Clears this data object from all DataSets and removes all Entries. Don't
|
|
694
|
+
* forget to invalidate the chart after this.
|
|
695
|
+
*/
|
|
404
696
|
clearValues() {
|
|
405
|
-
if (this.mDataSets
|
|
697
|
+
if (this.mDataSets) {
|
|
406
698
|
this.mDataSets = [];
|
|
407
699
|
}
|
|
408
700
|
this.notifyDataChanged();
|
|
409
701
|
}
|
|
702
|
+
/**
|
|
703
|
+
* Checks if this data object contains the specified DataSet. Returns true
|
|
704
|
+
* if so, false if not.
|
|
705
|
+
*
|
|
706
|
+
* @param dataSet
|
|
707
|
+
* @return
|
|
708
|
+
*/
|
|
410
709
|
contains(dataSet) {
|
|
411
710
|
return this.mDataSets.indexOf(dataSet) >= 0;
|
|
412
711
|
}
|
|
413
|
-
|
|
712
|
+
/**
|
|
713
|
+
* Returns the total entry count across all DataSet objects this data object contains.
|
|
714
|
+
*/
|
|
715
|
+
get entryCount() {
|
|
414
716
|
let count = 0;
|
|
415
717
|
for (const set of this.mDataSets) {
|
|
416
|
-
count += set.
|
|
718
|
+
count += set.entryCount;
|
|
417
719
|
}
|
|
418
720
|
return count;
|
|
419
721
|
}
|
|
420
|
-
|
|
421
|
-
|
|
722
|
+
/**
|
|
723
|
+
* Returns the DataSet object with the maximum number of entries or null if there are no DataSets.
|
|
724
|
+
*/
|
|
725
|
+
get maxEntryCountSet() {
|
|
726
|
+
if (!this.mDataSets || this.mDataSets.length === 0)
|
|
422
727
|
return null;
|
|
423
728
|
let max = this.mDataSets[0];
|
|
424
729
|
for (const set of this.mDataSets) {
|
|
425
|
-
if (set.
|
|
730
|
+
if (set.entryCount > max.entryCount)
|
|
426
731
|
max = set;
|
|
427
732
|
}
|
|
428
733
|
return max;
|