@nativescript-community/ui-chart 1.2.35 → 2.0.0
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 +424 -92
- 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 +273 -18
- package/data/ChartData.js +398 -93
- 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 +80 -49
- package/data/LineDataSet.js +90 -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 +126 -23
- 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 +83 -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 +81 -1
- package/listener/PieRadarChartTouchListener.js +212 -16
- 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 +185 -110
- 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/animation/ChartAnimator2.d.ts +0 -18
- package/animation/ChartAnimator2.js +0 -69
- package/animation/ChartAnimator2.js.map +0 -1
- package/charts/index.d.ts +0 -11
- package/charts/index.js +0 -15
- package/charts/index.js.map +0 -1
- package/utils/Curve.d.ts +0 -12
- package/utils/Curve.js +0 -156
- package/utils/Curve.js.map +0 -1
- package/utils/MPPointD.js +0 -1
- package/utils/MPPointD.js.map +0 -1
- package/utils/MPPointF.js +0 -1
- package/utils/MPPointF.js.map +0 -1
package/charts/Chart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Align, CanvasView } from '@nativescript-community/ui-canvas';
|
|
1
|
+
import { Align, Canvas, CanvasView } from '@nativescript-community/ui-canvas';
|
|
2
2
|
import { Utils as NUtils, Trace } from '@nativescript/core';
|
|
3
3
|
import { ChartAnimator } from '../animation/ChartAnimator';
|
|
4
4
|
import { Description } from '../components/Description';
|
|
@@ -9,39 +9,124 @@ import { LegendRenderer } from '../renderer/LegendRenderer';
|
|
|
9
9
|
import { CLog, CLogTypes, Utils } from '../utils/Utils';
|
|
10
10
|
import { ViewPortHandler } from '../utils/ViewPortHandler';
|
|
11
11
|
const LOG_TAG = 'NSChart';
|
|
12
|
+
/**
|
|
13
|
+
* Baseclass of all Chart-Views.
|
|
14
|
+
*
|
|
15
|
+
|
|
16
|
+
*/
|
|
12
17
|
export class Chart extends CanvasView {
|
|
18
|
+
/**
|
|
19
|
+
* default constructor for initialization in code
|
|
20
|
+
*/
|
|
13
21
|
constructor() {
|
|
14
22
|
super();
|
|
23
|
+
/**
|
|
24
|
+
* object that holds all data that was originally set for the chart, before
|
|
25
|
+
* it was modified or any filtering algorithms had been applied
|
|
26
|
+
*/
|
|
15
27
|
this.mData = null;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* If set to true, chart continues to scroll after touch up
|
|
30
|
+
*/
|
|
31
|
+
this.dragDecelerationEnabled = true;
|
|
32
|
+
/**
|
|
33
|
+
* Deceleration friction coefficient in [0 ; 1] interval, higher values
|
|
34
|
+
* indicate that speed will decrease slowly, for example if it set to 0, it
|
|
35
|
+
* will stop immediately. value must be < 1.0
|
|
36
|
+
*/
|
|
37
|
+
this.dragDecelerationFrictionCoef = 0.9;
|
|
38
|
+
/**
|
|
39
|
+
* the default IValueFormatter that has been determined by the chart
|
|
40
|
+
* considering the provided minimum and maximum values, number of digits depends on provided chart-data
|
|
41
|
+
*/
|
|
42
|
+
this.defaultValueFormatter = new DefaultValueFormatter(0);
|
|
43
|
+
/**
|
|
44
|
+
* if true, touch gestures are enabled on the chart
|
|
45
|
+
*/
|
|
46
|
+
this.touchEnabled = true;
|
|
47
|
+
/**
|
|
48
|
+
* text that is displayed when the chart is empty
|
|
49
|
+
*/
|
|
50
|
+
this.noDataText = null;
|
|
51
|
+
/**
|
|
52
|
+
* object that manages the bounds and drawing constraints of the chart
|
|
53
|
+
*/
|
|
54
|
+
this.viewPortHandler = new ViewPortHandler();
|
|
55
|
+
/**
|
|
56
|
+
* Extra offsets to be appended to the viewport
|
|
57
|
+
*/
|
|
58
|
+
this.extraTopOffset = 0;
|
|
59
|
+
this.extraRightOffset = 0;
|
|
60
|
+
this.extraBottomOffset = 0;
|
|
61
|
+
this.extraLeftOffset = 0;
|
|
62
|
+
/**
|
|
63
|
+
* let the chart know it does not need to compute autoScale
|
|
64
|
+
* (it can used the cached ones)
|
|
65
|
+
*/
|
|
66
|
+
this.noComputeAutoScaleOnNextDraw = false;
|
|
67
|
+
/**
|
|
68
|
+
* let the chart know it does not need to compute axis and legends
|
|
69
|
+
* (it can used the cached ones)
|
|
70
|
+
*/
|
|
71
|
+
this.noComputeAxisOnNextDraw = false;
|
|
72
|
+
/**
|
|
73
|
+
* The maximum distance in dp away from an entry causing it to highlight.
|
|
74
|
+
*/
|
|
75
|
+
this.maxHighlightDistance = 500;
|
|
76
|
+
/**
|
|
77
|
+
* Wether to filter highlights by axis. Default is true
|
|
78
|
+
*/
|
|
79
|
+
this.highlightsFilterByAxis = true;
|
|
80
|
+
/**
|
|
81
|
+
* tasks to be done after the view is setup
|
|
82
|
+
*/
|
|
83
|
+
this.jobs = [];
|
|
84
|
+
// /**
|
|
85
|
+
// * Set a new (e.g. custom) ChartTouchListener NOTE: make sure to
|
|
86
|
+
// * setTouchEnabled(true); if you need touch gestures on the chart
|
|
87
|
+
// *
|
|
88
|
+
// * @param l
|
|
89
|
+
// */
|
|
90
|
+
// public setOnTouchListener(ChartTouchListener l) {
|
|
91
|
+
// this.chartTouchListener = l;
|
|
92
|
+
// }
|
|
93
|
+
// /**
|
|
94
|
+
// * Returns an instance of the currently active touch listener.
|
|
95
|
+
// *
|
|
96
|
+
// * @return
|
|
97
|
+
// */
|
|
98
|
+
// public ChartTouchListener getOnTouchListener() {
|
|
99
|
+
// return this.chartTouchListener;
|
|
100
|
+
// }
|
|
101
|
+
/**
|
|
102
|
+
* ################ ################ ################ ################
|
|
103
|
+
*/
|
|
104
|
+
/** BELOW CODE IS FOR THE MARKER VIEW */
|
|
105
|
+
/**
|
|
106
|
+
* if set to true, the marker view is drawn when a value is clicked
|
|
107
|
+
*/
|
|
108
|
+
this.drawMarkersEnabled = true;
|
|
29
109
|
this.init();
|
|
30
110
|
}
|
|
31
111
|
initNativeView() {
|
|
32
112
|
super.initNativeView();
|
|
33
|
-
this.
|
|
113
|
+
this.chartTouchListener && this.chartTouchListener.init();
|
|
34
114
|
}
|
|
35
115
|
disposeNativeView() {
|
|
36
116
|
super.disposeNativeView();
|
|
37
|
-
this.
|
|
117
|
+
this.chartTouchListener && this.chartTouchListener.dispose();
|
|
38
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* initialize all paints and stuff
|
|
121
|
+
*/
|
|
39
122
|
init() {
|
|
40
|
-
this.
|
|
41
|
-
|
|
123
|
+
this.animator = new ChartAnimator((state) => {
|
|
124
|
+
// during animations we dont need to compute autoScale nor axis things
|
|
125
|
+
this.noComputeAutoScaleOnNextDraw = true;
|
|
126
|
+
this.noComputeAxisOnNextDraw = true;
|
|
42
127
|
this.invalidate();
|
|
43
128
|
});
|
|
44
|
-
this.
|
|
129
|
+
this.xAxis = new XAxis(new WeakRef(this));
|
|
45
130
|
if (Trace.isEnabled()) {
|
|
46
131
|
CLog(CLogTypes.log, this.constructor.name, 'init()');
|
|
47
132
|
}
|
|
@@ -54,409 +139,616 @@ export class Chart extends CanvasView {
|
|
|
54
139
|
}
|
|
55
140
|
return this.mInfoPaint;
|
|
56
141
|
}
|
|
57
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Sets a new data object for the chart. The data object contains all values
|
|
144
|
+
* and information needed for displaying.
|
|
145
|
+
*
|
|
146
|
+
* @param data
|
|
147
|
+
*/
|
|
148
|
+
set data(data) {
|
|
58
149
|
this.mData = data;
|
|
59
|
-
this.
|
|
60
|
-
if (data
|
|
150
|
+
this.offsetsCalculated = false;
|
|
151
|
+
if (!data) {
|
|
61
152
|
return;
|
|
62
153
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
154
|
+
// Calculate how many digits are needed
|
|
155
|
+
this.setupDefaultFormatter(data.yMin, data.yMax);
|
|
156
|
+
for (const set of this.mData.dataSets) {
|
|
157
|
+
if (set.needsFormatter || set.valueFormatter === this.defaultValueFormatter) {
|
|
158
|
+
set.valueFormatter = this.defaultValueFormatter;
|
|
67
159
|
}
|
|
68
160
|
}
|
|
161
|
+
// let the chart know there is new data
|
|
69
162
|
this.notifyDataSetChanged();
|
|
70
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Returns the ChartData object that has been set for the chart.
|
|
166
|
+
*/
|
|
167
|
+
get data() {
|
|
168
|
+
return this.mData;
|
|
169
|
+
}
|
|
170
|
+
get viewPortScaleX() {
|
|
171
|
+
return this.viewPortHandler.scaleX;
|
|
172
|
+
}
|
|
173
|
+
get viewPortScaleY() {
|
|
174
|
+
return this.viewPortHandler.scaleY;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Clears the chart from all data (sets it to null) and refreshes it (by
|
|
178
|
+
* calling invalidate()).
|
|
179
|
+
*/
|
|
71
180
|
clear() {
|
|
72
181
|
this.mData = null;
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
|
|
182
|
+
this.offsetsCalculated = false;
|
|
183
|
+
this.indicesToHighlight = null;
|
|
184
|
+
if (this.chartTouchListener) {
|
|
185
|
+
this.chartTouchListener.lastHighlighted = null;
|
|
186
|
+
}
|
|
76
187
|
this.invalidate();
|
|
77
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Removes all DataSets (and thereby Entries) from the chart. Does not set the data object to null. Also refreshes the
|
|
191
|
+
* chart by calling invalidate().
|
|
192
|
+
*/
|
|
78
193
|
clearValues() {
|
|
79
194
|
this.mData.clearValues();
|
|
80
195
|
this.invalidate();
|
|
81
196
|
}
|
|
82
|
-
|
|
83
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Returns true if the chart is empty (meaning it's data object is either
|
|
199
|
+
* null or contains no entries).
|
|
200
|
+
*/
|
|
201
|
+
get length() {
|
|
202
|
+
if (!this.mData)
|
|
84
203
|
return true;
|
|
85
204
|
else {
|
|
86
|
-
if (this.mData.
|
|
205
|
+
if (this.mData.entryCount <= 0)
|
|
87
206
|
return true;
|
|
88
207
|
else
|
|
89
208
|
return false;
|
|
90
209
|
}
|
|
91
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Calculates the required number of digits for the values that might be
|
|
213
|
+
* drawn in the chart (if enabled), and creates the default-value-formatter
|
|
214
|
+
*/
|
|
92
215
|
setupDefaultFormatter(min, max) {
|
|
93
216
|
let reference = 0;
|
|
94
|
-
if (this.mData
|
|
217
|
+
if (!this.mData || this.mData.entryCount < 2) {
|
|
95
218
|
reference = Math.max(Math.abs(min), Math.abs(max));
|
|
96
219
|
}
|
|
97
220
|
else {
|
|
98
221
|
reference = Math.abs(max - min);
|
|
99
222
|
}
|
|
100
223
|
const digits = Utils.getDecimals(reference);
|
|
101
|
-
|
|
224
|
+
// setup the formatter with a new number of digits
|
|
225
|
+
this.defaultValueFormatter.setup(digits);
|
|
102
226
|
}
|
|
103
227
|
onDraw(canvas) {
|
|
104
228
|
super.onDraw(canvas);
|
|
105
|
-
if (this.mData
|
|
106
|
-
const hasText = this.
|
|
229
|
+
if (!this.mData) {
|
|
230
|
+
const hasText = this.noDataText && this.noDataText.length > 0;
|
|
107
231
|
if (hasText) {
|
|
108
|
-
const c = this.
|
|
109
|
-
canvas.drawText(this.
|
|
232
|
+
const c = this.center;
|
|
233
|
+
canvas.drawText(this.noDataText, c.x, c.y, this.infoPaint);
|
|
110
234
|
}
|
|
111
|
-
return;
|
|
112
235
|
}
|
|
113
236
|
this.notify({ eventName: 'postDraw', object: this, canvas });
|
|
114
|
-
this.calculateOffsets(false);
|
|
115
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Draws the description text in the bottom right corner of the chart (per default)
|
|
240
|
+
*/
|
|
116
241
|
drawDescription(c) {
|
|
117
|
-
|
|
118
|
-
|
|
242
|
+
// check if description should be drawn
|
|
243
|
+
if (this.mDescription?.enabled) {
|
|
244
|
+
const position = this.mDescription.position;
|
|
119
245
|
const paint = Utils.getTempPaint();
|
|
120
|
-
paint.setFont(this.mDescription.
|
|
121
|
-
paint.setColor(this.mDescription.
|
|
122
|
-
paint.setTextAlign(this.mDescription.
|
|
246
|
+
paint.setFont(this.mDescription.typeface);
|
|
247
|
+
paint.setColor(this.mDescription.textColor);
|
|
248
|
+
paint.setTextAlign(this.mDescription.textAlign);
|
|
123
249
|
let x, y;
|
|
124
|
-
const vph = this.
|
|
125
|
-
if
|
|
126
|
-
|
|
127
|
-
|
|
250
|
+
const vph = this.viewPortHandler;
|
|
251
|
+
// if no position specified, draw on default position
|
|
252
|
+
if (!position) {
|
|
253
|
+
x = vph.chartWidth - vph.offsetRight - this.mDescription.xOffset;
|
|
254
|
+
y = vph.chartHeight - vph.offsetBottom - this.mDescription.yOffset;
|
|
128
255
|
}
|
|
129
256
|
else {
|
|
130
257
|
x = position.x;
|
|
131
258
|
y = position.y;
|
|
132
259
|
}
|
|
133
|
-
c.drawText(this.mDescription.
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
260
|
+
c.drawText(this.mDescription.text, x, y, paint);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Returns the array of currently highlighted values. This might a null or
|
|
265
|
+
* empty array if nothing is highlighted.
|
|
266
|
+
*/
|
|
267
|
+
get highlighted() {
|
|
268
|
+
return this.indicesToHighlight;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Returns true if there are values to highlight, false if there are no
|
|
272
|
+
* values to highlight. Checks if the highlight array is null, has a length
|
|
273
|
+
* of zero or if the first object is null.
|
|
274
|
+
*
|
|
275
|
+
*/
|
|
276
|
+
get hasValuesToHighlight() {
|
|
277
|
+
return this.indicesToHighlight?.[0] !== undefined;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Sets the last highlighted value for the touchlistener.
|
|
281
|
+
*
|
|
282
|
+
* @param highs
|
|
283
|
+
*/
|
|
284
|
+
set lastHighlighted(highs) {
|
|
285
|
+
if (!this.chartTouchListener) {
|
|
156
286
|
return;
|
|
157
287
|
}
|
|
158
|
-
if (highs
|
|
159
|
-
this.
|
|
288
|
+
if (highs?.[0] === undefined) {
|
|
289
|
+
this.chartTouchListener.lastHighlighted = null;
|
|
160
290
|
}
|
|
161
291
|
else {
|
|
162
|
-
this.
|
|
292
|
+
this.chartTouchListener.lastHighlighted = highs[0];
|
|
163
293
|
}
|
|
164
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Highlights the values at the given indices in the given DataSets. Provide
|
|
297
|
+
* null or an empty array to undo all highlighting. This should be used to
|
|
298
|
+
* programmatically highlight values.
|
|
299
|
+
* This method *will not* call the listener.
|
|
300
|
+
*
|
|
301
|
+
* @param highs
|
|
302
|
+
*/
|
|
165
303
|
highlightValues(highs) {
|
|
166
|
-
|
|
167
|
-
this.
|
|
168
|
-
this.
|
|
304
|
+
// set the indices to highlight
|
|
305
|
+
this.indicesToHighlight = highs;
|
|
306
|
+
this.lastHighlighted = highs;
|
|
307
|
+
// redraw the chart
|
|
308
|
+
this.noComputeAutoScaleOnNextDraw = true;
|
|
309
|
+
this.noComputeAxisOnNextDraw = true;
|
|
169
310
|
this.invalidate();
|
|
170
311
|
}
|
|
312
|
+
// /**
|
|
313
|
+
// * Highlights any y-value at the given x-value in the given DataSet.
|
|
314
|
+
// * Provide -1 as the dataSetIndex to undo all highlighting.
|
|
315
|
+
// * This method will call the listener.
|
|
316
|
+
// * @param x The x-value to highlight
|
|
317
|
+
// * @param dataSetIndex The dataset index to search in
|
|
318
|
+
// */
|
|
319
|
+
// public highlightValue( x, dataSetIndex) {
|
|
320
|
+
// this.highlightValue(x, dataSetIndex, true);
|
|
321
|
+
// }
|
|
322
|
+
// /**
|
|
323
|
+
// * Highlights the value at the given x-value and y-value in the given DataSet.
|
|
324
|
+
// * Provide -1 as the dataSetIndex to undo all highlighting.
|
|
325
|
+
// * This method will call the listener.
|
|
326
|
+
// * @param x The x-value to highlight
|
|
327
|
+
// * @param y The y-value to highlight. Supply `NaN` for "any"
|
|
328
|
+
// * @param dataSetIndex The dataset index to search in
|
|
329
|
+
// */
|
|
330
|
+
// public highlightValue(x, y, dataSetIndex) {
|
|
331
|
+
// this.highlightValue(x, y, dataSetIndex, true);
|
|
332
|
+
// }
|
|
333
|
+
// /**
|
|
334
|
+
// * Highlights any y-value at the given x-value in the given DataSet.
|
|
335
|
+
// * Provide -1 as the dataSetIndex to undo all highlighting.
|
|
336
|
+
// * @param x The x-value to highlight
|
|
337
|
+
// * @param dataSetIndex The dataset index to search in
|
|
338
|
+
// * @param callListener Should the listener be called for this change
|
|
339
|
+
// */
|
|
340
|
+
// public highlightValue(x, dataSetIndex, callListener = true) {
|
|
341
|
+
// this.highlightValue(x, NaN, dataSetIndex, callListener);
|
|
342
|
+
// }
|
|
343
|
+
/**
|
|
344
|
+
* Highlights any y-value at the given x-value in the given DataSet.
|
|
345
|
+
* Provide -1 as the dataSetIndex to undo all highlighting.
|
|
346
|
+
* @param x The x-value to highlight
|
|
347
|
+
* @param y The y-value to highlight. Supply `NaN` for "any"
|
|
348
|
+
* @param dataSetIndex The dataset index to search in
|
|
349
|
+
* @param callListener Should the listener be called for this change
|
|
350
|
+
*/
|
|
171
351
|
highlightValue(x, y, dataSetIndex, callListener = false) {
|
|
172
|
-
if (dataSetIndex < 0 || dataSetIndex >= this.mData.
|
|
352
|
+
if (dataSetIndex < 0 || dataSetIndex >= this.mData.dataSetCount) {
|
|
173
353
|
this.highlight(null, callListener);
|
|
174
354
|
}
|
|
175
355
|
else {
|
|
176
356
|
this.highlight({ x, y, dataSetIndex }, callListener);
|
|
177
357
|
}
|
|
178
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Highlights the value selected by touch gesture. Unlike
|
|
361
|
+
* highlightValues(...), this generates a callback to the
|
|
362
|
+
* OnChartValueSelectedListener.
|
|
363
|
+
*
|
|
364
|
+
* @param high - the highlight object
|
|
365
|
+
* @param callListener - call the listener
|
|
366
|
+
*/
|
|
179
367
|
highlight(high, callListener = false) {
|
|
180
368
|
let e = null;
|
|
181
|
-
|
|
182
|
-
|
|
369
|
+
let highlight = Array.isArray(high) ? high[0] : high;
|
|
370
|
+
if (!high) {
|
|
371
|
+
this.indicesToHighlight = null;
|
|
183
372
|
}
|
|
184
373
|
else {
|
|
185
|
-
e = this.mData.getEntryForHighlight(
|
|
186
|
-
if (e
|
|
187
|
-
this.
|
|
188
|
-
|
|
374
|
+
e = this.mData.getEntryForHighlight(highlight);
|
|
375
|
+
if (!e) {
|
|
376
|
+
this.indicesToHighlight = null;
|
|
377
|
+
highlight = null;
|
|
189
378
|
}
|
|
190
379
|
else {
|
|
191
|
-
|
|
192
|
-
|
|
380
|
+
highlight.entry = e;
|
|
381
|
+
// set the indices to highlight
|
|
382
|
+
this.indicesToHighlight = [highlight];
|
|
193
383
|
}
|
|
194
384
|
}
|
|
195
|
-
this.
|
|
385
|
+
this.lastHighlighted = this.indicesToHighlight;
|
|
196
386
|
if (callListener) {
|
|
197
|
-
this.notify({ eventName: 'highlight', object: this, entry: e, highlight: high });
|
|
387
|
+
this.notify({ eventName: 'highlight', object: this, entry: e, highlight, highlights: Array.isArray(high) ? high : [highlight] });
|
|
198
388
|
}
|
|
199
|
-
|
|
389
|
+
// redraw the chart
|
|
390
|
+
this.noComputeAutoScaleOnNextDraw = true;
|
|
391
|
+
this.noComputeAxisOnNextDraw = true;
|
|
200
392
|
this.invalidate();
|
|
201
393
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Highlights the value selected by touch gesture. Unlike
|
|
396
|
+
* highlightValues(...), this generates a callback to the
|
|
397
|
+
* OnChartValueSelectedListener.
|
|
398
|
+
*
|
|
399
|
+
* @param high - the highlight object
|
|
400
|
+
* @param callListener - call the listener
|
|
401
|
+
*/
|
|
402
|
+
highlights(highs, callListener = false) {
|
|
403
|
+
const e = null;
|
|
404
|
+
if (highs.length === 0) {
|
|
405
|
+
this.indicesToHighlight = null;
|
|
206
406
|
}
|
|
207
|
-
else
|
|
208
|
-
|
|
407
|
+
else {
|
|
408
|
+
highs = highs
|
|
409
|
+
.map((h) => {
|
|
410
|
+
if (!h.entry) {
|
|
411
|
+
h.entry = this.mData.getEntryForHighlight(h);
|
|
412
|
+
}
|
|
413
|
+
return h;
|
|
414
|
+
})
|
|
415
|
+
.filter((h) => !!h.entry);
|
|
416
|
+
this.indicesToHighlight = highs.length ? highs : null;
|
|
417
|
+
}
|
|
418
|
+
this.lastHighlighted = this.indicesToHighlight;
|
|
419
|
+
if (callListener) {
|
|
420
|
+
this.notify({ eventName: 'highlight', object: this, entry: highs?.[0]?.entry, highlight: highs?.[0], highlights: highs });
|
|
421
|
+
}
|
|
422
|
+
// redraw the chart
|
|
423
|
+
this.noComputeAutoScaleOnNextDraw = true;
|
|
424
|
+
this.noComputeAxisOnNextDraw = true;
|
|
425
|
+
this.invalidate();
|
|
209
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* Returns the Highlights (contains x-index and DataSet index) of the
|
|
429
|
+
* selected value at the given touch polet inside the Line-, Scatter-, or
|
|
430
|
+
* CandleStick-Chart.
|
|
431
|
+
*
|
|
432
|
+
* @param x
|
|
433
|
+
* @param y
|
|
434
|
+
* @return
|
|
435
|
+
*/
|
|
436
|
+
getHighlightsByTouchPoint(x, y) {
|
|
437
|
+
return this.highlighter.getHighlight(x, y);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Returns the Highlight object (contains x-index and DataSet index) of the
|
|
441
|
+
* selected value at the given touch polet inside the Line-, Scatter-, or
|
|
442
|
+
* CandleStick-Chart.
|
|
443
|
+
*
|
|
444
|
+
* @param x
|
|
445
|
+
* @param y
|
|
446
|
+
* @return
|
|
447
|
+
*/
|
|
448
|
+
getHighlightByTouchPoint(x, y) {
|
|
449
|
+
return this.getHighlightsByTouchPoint(x, y)?.[0];
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Returns the Highlight object (contains x-index and DataSet index) of the
|
|
453
|
+
* selected value at the given touch polet inside the Line-, Scatter-, or
|
|
454
|
+
* CandleStick-Chart.
|
|
455
|
+
*
|
|
456
|
+
* @param x
|
|
457
|
+
* @param y
|
|
458
|
+
* @return
|
|
459
|
+
*/
|
|
210
460
|
getHighlightByXValue(xValue) {
|
|
211
|
-
if (this.mData
|
|
461
|
+
if (!this.mData) {
|
|
212
462
|
return null;
|
|
213
463
|
}
|
|
214
464
|
else {
|
|
215
|
-
return this.
|
|
465
|
+
return this.highlighter.getHighlightsAtXValue(xValue);
|
|
216
466
|
}
|
|
217
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* draws all MarkerViews on the highlighted positions
|
|
470
|
+
*/
|
|
218
471
|
drawMarkers(canvas) {
|
|
219
|
-
if
|
|
472
|
+
// if there is no marker view or drawing marker is disabled
|
|
473
|
+
if (!this.marker || !this.drawMarkersEnabled || !this.hasValuesToHighlight)
|
|
220
474
|
return;
|
|
221
|
-
for (let i = 0; i < this.
|
|
222
|
-
const highlight = this.
|
|
475
|
+
for (let i = 0; i < this.indicesToHighlight.length; i++) {
|
|
476
|
+
const highlight = this.indicesToHighlight[i];
|
|
223
477
|
const set = this.mData.getDataSetByIndex(highlight.dataSetIndex);
|
|
224
478
|
const e = highlight.entry || this.mData.getEntryForHighlight(highlight);
|
|
225
479
|
const entryIndex = set.getEntryIndex(e);
|
|
226
|
-
|
|
480
|
+
// make sure entry not null
|
|
481
|
+
if (!e || entryIndex > set.entryCount * this.animator.phaseX)
|
|
227
482
|
continue;
|
|
228
483
|
const pos = this.getMarkerPosition(highlight);
|
|
229
|
-
|
|
484
|
+
// check bounds
|
|
485
|
+
if (!this.viewPortHandler.isInBounds(pos[0], pos[1]))
|
|
230
486
|
continue;
|
|
231
|
-
|
|
232
|
-
this.
|
|
233
|
-
|
|
234
|
-
|
|
487
|
+
// callbacks to update the content
|
|
488
|
+
this.marker.refreshContent(e, highlight);
|
|
489
|
+
// draw the marker
|
|
490
|
+
this.marker.draw(canvas, pos[0], pos[1]);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Returns the actual position in pixels of the MarkerView for the given
|
|
495
|
+
* Highlight object.
|
|
496
|
+
*
|
|
497
|
+
* @param high
|
|
498
|
+
* @return
|
|
499
|
+
*/
|
|
235
500
|
getMarkerPosition(high) {
|
|
236
501
|
return [high.drawX, high.drawY];
|
|
237
502
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (newValue < 0)
|
|
252
|
-
newValue = 0;
|
|
253
|
-
if (newValue >= 1)
|
|
254
|
-
newValue = 0.999;
|
|
255
|
-
this.mDragDecelerationFrictionCoef = newValue;
|
|
503
|
+
/**
|
|
504
|
+
* ################ ################ ################ ################
|
|
505
|
+
* ANIMATIONS ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
|
506
|
+
*/
|
|
507
|
+
/** CODE BELOW THIS RELATED TO ANIMATION */
|
|
508
|
+
/**
|
|
509
|
+
* Returns the animator responsible for animating chart values.
|
|
510
|
+
*/
|
|
511
|
+
get description() {
|
|
512
|
+
if (!this.mDescription) {
|
|
513
|
+
this.mDescription = new Description();
|
|
514
|
+
}
|
|
515
|
+
return this.mDescription;
|
|
256
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* ################ ################ ################ ################
|
|
519
|
+
* ANIMATIONS ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
|
520
|
+
*/
|
|
521
|
+
/** CODE BELOW FOR PROVIDING EASING FUNCTIONS */
|
|
522
|
+
/**
|
|
523
|
+
* Animates the drawing / rendering of the chart on both x- and y-axis with
|
|
524
|
+
* the specified animation time. If animate(...) is called, no further
|
|
525
|
+
* calling of invalidate() is necessary to refresh the chart. ANIMATIONS
|
|
526
|
+
* ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
|
527
|
+
*
|
|
528
|
+
* @param durationMillisX
|
|
529
|
+
* @param durationMillisY
|
|
530
|
+
* @param easingX a custom easing function to be used on the animation phase
|
|
531
|
+
* @param easingY a custom easing function to be used on the animation phase
|
|
532
|
+
*/
|
|
257
533
|
animateXY(durationMillisX, durationMillisY, easingX, easingY) {
|
|
258
|
-
this.
|
|
259
|
-
}
|
|
534
|
+
this.animator.animateXY(durationMillisX, durationMillisY, easingX, easingY);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Animates the rendering of the chart on the x-axis with the specified
|
|
538
|
+
* animation time. If animate(...) is called, no further calling of
|
|
539
|
+
* invalidate() is necessary to refresh the chart. ANIMATIONS ONLY WORK FOR
|
|
540
|
+
* API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
|
541
|
+
*
|
|
542
|
+
* @param durationMillis
|
|
543
|
+
* @param easing a custom easing function to be used on the animation phase
|
|
544
|
+
*/
|
|
260
545
|
animateX(durationMillis, easing) {
|
|
261
|
-
this.
|
|
262
|
-
}
|
|
546
|
+
this.animator.animateX(durationMillis, easing);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Animates the rendering of the chart on the y-axis with the specified
|
|
550
|
+
* animation time. If animate(...) is called, no further calling of
|
|
551
|
+
* invalidate() is necessary to refresh the chart. ANIMATIONS ONLY WORK FOR
|
|
552
|
+
* API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
|
553
|
+
*
|
|
554
|
+
* @param durationMillis
|
|
555
|
+
* @param easing a custom easing function to be used on the animation phase
|
|
556
|
+
*/
|
|
263
557
|
animateY(durationMillis, easing) {
|
|
264
|
-
this.
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
558
|
+
this.animator.animateY(durationMillis, easing);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* ################ ################ ################ ################
|
|
562
|
+
*/
|
|
563
|
+
/** BELOW THIS ONLY GETTERS AND SETTERS */
|
|
564
|
+
/**
|
|
565
|
+
* returns the current y-max value across all DataSets
|
|
566
|
+
*/
|
|
567
|
+
get yMax() {
|
|
568
|
+
return this.mData.yMax;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* returns the current y-min value across all DataSets
|
|
572
|
+
*/
|
|
573
|
+
get yMin() {
|
|
574
|
+
return this.mData.yMin;
|
|
575
|
+
}
|
|
576
|
+
get xChartMax() {
|
|
577
|
+
return this.xAxis.axisMaximum;
|
|
578
|
+
}
|
|
579
|
+
get xChartMin() {
|
|
580
|
+
return this.xAxis.axisMinimum;
|
|
581
|
+
}
|
|
582
|
+
get xRange() {
|
|
583
|
+
return this.xAxis.axisRange;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Returns a recyclable MPPointF instance.
|
|
587
|
+
* Returns the center polet of the chart (the whole View) in pixels.
|
|
588
|
+
*/
|
|
589
|
+
get center() {
|
|
590
|
+
return { x: this.viewPortHandler.chartWidth / 2, y: this.viewPortHandler.chartHeight / 2 };
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Returns a recyclable MPPointF instance.
|
|
594
|
+
* Returns the center of the chart taking offsets under consideration.
|
|
595
|
+
* (returns the center of the content rectangle)
|
|
596
|
+
*/
|
|
597
|
+
get centerOffsets() {
|
|
598
|
+
return this.viewPortHandler.contentCenter;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Sets extra offsets (around the chart view) to be appended to the
|
|
602
|
+
* auto-calculated offsets.
|
|
603
|
+
*
|
|
604
|
+
* @param left
|
|
605
|
+
* @param top
|
|
606
|
+
* @param right
|
|
607
|
+
* @param bottom
|
|
608
|
+
*/
|
|
293
609
|
setExtraOffsets(left, top, right, bottom) {
|
|
294
|
-
this.
|
|
295
|
-
this.
|
|
296
|
-
this.
|
|
297
|
-
this.
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
getExtraLeftOffset() {
|
|
321
|
-
return this.mExtraLeftOffset;
|
|
322
|
-
}
|
|
323
|
-
setNoDataText(text) {
|
|
324
|
-
this.mNoDataText = text;
|
|
325
|
-
}
|
|
326
|
-
setNoDataTextColor(color) {
|
|
610
|
+
this.extraLeftOffset = left;
|
|
611
|
+
this.extraTopOffset = top;
|
|
612
|
+
this.extraRightOffset = right;
|
|
613
|
+
this.extraBottomOffset = bottom;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Sets extra offsets (around the chart view) to be appended to the
|
|
617
|
+
* auto-calculated offsets.
|
|
618
|
+
*
|
|
619
|
+
* @param left
|
|
620
|
+
* @param top
|
|
621
|
+
* @param right
|
|
622
|
+
* @param bottom
|
|
623
|
+
*/
|
|
624
|
+
set extraOffsets(value) {
|
|
625
|
+
this.extraLeftOffset = value[0];
|
|
626
|
+
this.extraTopOffset = value[1];
|
|
627
|
+
this.extraRightOffset = value[2];
|
|
628
|
+
this.extraBottomOffset = value[3];
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Sets the color of the no data text.
|
|
632
|
+
*
|
|
633
|
+
* @param color
|
|
634
|
+
*/
|
|
635
|
+
set noDataTextColor(color) {
|
|
327
636
|
this.infoPaint.setColor(color);
|
|
328
637
|
}
|
|
329
|
-
|
|
638
|
+
/**
|
|
639
|
+
* Sets the typeface to be used for the no data text.
|
|
640
|
+
*/
|
|
641
|
+
set noDataTextTypeface(tf) {
|
|
330
642
|
this.infoPaint.setTypeface(tf);
|
|
331
643
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
getMarker() {
|
|
339
|
-
return this.mMarker;
|
|
340
|
-
}
|
|
341
|
-
setMarkerView(v) {
|
|
342
|
-
this.setMarker(v);
|
|
343
|
-
}
|
|
344
|
-
getMarkerView() {
|
|
345
|
-
return this.getMarker();
|
|
346
|
-
}
|
|
347
|
-
setDescription(desc) {
|
|
348
|
-
this.mDescription = desc;
|
|
349
|
-
}
|
|
350
|
-
getDescription() {
|
|
351
|
-
if (!this.mDescription) {
|
|
352
|
-
this.mDescription = new Description();
|
|
353
|
-
}
|
|
354
|
-
return this.mDescription;
|
|
355
|
-
}
|
|
356
|
-
getLegend() {
|
|
644
|
+
/**
|
|
645
|
+
* Returns the Legend object of the chart. This method can be used to get an
|
|
646
|
+
* instance of the legend in order to customize the automatically generated
|
|
647
|
+
* Legend.
|
|
648
|
+
*/
|
|
649
|
+
get legend() {
|
|
357
650
|
if (!this.mLegend) {
|
|
358
651
|
this.mLegend = new Legend();
|
|
359
|
-
this.
|
|
652
|
+
this.legendRenderer = new LegendRenderer(this.viewPortHandler, this.mLegend);
|
|
360
653
|
}
|
|
361
654
|
return this.mLegend;
|
|
362
655
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
getCenterOfView() {
|
|
401
|
-
return this.getCenter();
|
|
402
|
-
}
|
|
403
|
-
getChartBitmap() {
|
|
404
|
-
}
|
|
405
|
-
saveToPath(title, pathOnSD) {
|
|
406
|
-
return true;
|
|
407
|
-
}
|
|
408
|
-
saveToGallery(fileName, subFolderPath, fileDescription, format, quality) {
|
|
656
|
+
/**
|
|
657
|
+
* Returns the rectangle that defines the borders of the chart-value surface
|
|
658
|
+
* (into which the actual values are drawn).
|
|
659
|
+
*/
|
|
660
|
+
get contentRect() {
|
|
661
|
+
return this.viewPortHandler.contentRect;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Returns a recyclable MPPointF instance.
|
|
665
|
+
*/
|
|
666
|
+
get centerOfView() {
|
|
667
|
+
return this.center;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Flag that indicates if highlighting per tap (touch) is enabled
|
|
671
|
+
*/
|
|
672
|
+
get highlightPerTapEnabled() {
|
|
673
|
+
return this.mHighlightPerTapEnabled;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Flag that indicates if highlighting per tap (touch) is enabled
|
|
677
|
+
*/
|
|
678
|
+
set highlightPerTapEnabled(value) {
|
|
679
|
+
this.mHighlightPerTapEnabled = value;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Returns the bitmap that represents the chart.
|
|
683
|
+
*/
|
|
684
|
+
get chartBitmap() {
|
|
685
|
+
//Define a bitmap with the same size as the view
|
|
686
|
+
const canvas = new Canvas(this.getMeasuredWidth(), this.getMeasuredHeight());
|
|
687
|
+
canvas.drawColor(this.backgroundColor);
|
|
688
|
+
// draw the view on the canvas
|
|
689
|
+
this.onDraw(canvas);
|
|
690
|
+
// return the bitmap
|
|
691
|
+
return canvas.getImage();
|
|
409
692
|
}
|
|
410
693
|
removeViewportJob(job) {
|
|
411
|
-
const index = this.
|
|
694
|
+
const index = this.jobs.indexOf(job);
|
|
412
695
|
if (index >= 0) {
|
|
413
|
-
this.
|
|
696
|
+
this.jobs.splice(index, 1);
|
|
414
697
|
}
|
|
415
698
|
}
|
|
416
699
|
clearAllViewportJobs() {
|
|
417
|
-
this.
|
|
418
|
-
}
|
|
700
|
+
this.jobs = [];
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Either posts a job immediately if the chart has already setup it's
|
|
704
|
+
* dimensions or adds the job to the execution queue.
|
|
705
|
+
*
|
|
706
|
+
* @param job
|
|
707
|
+
*/
|
|
419
708
|
addViewportJob(job) {
|
|
420
|
-
if (this.
|
|
709
|
+
if (this.viewPortHandler.hasChartDimens) {
|
|
421
710
|
setTimeout(() => {
|
|
422
711
|
job.run();
|
|
423
712
|
}, 0);
|
|
424
713
|
}
|
|
425
714
|
else {
|
|
426
|
-
this.
|
|
715
|
+
this.jobs.push(job);
|
|
427
716
|
}
|
|
428
717
|
}
|
|
718
|
+
/**
|
|
719
|
+
* Returns all jobs that are scheduled to be executed after
|
|
720
|
+
* onSizeChanged(...).
|
|
721
|
+
*/
|
|
429
722
|
getJobs() {
|
|
430
|
-
return this.
|
|
723
|
+
return this.jobs;
|
|
431
724
|
}
|
|
432
725
|
onSetWidthHeight(w, h) {
|
|
433
|
-
const needsDataSetChanged = !this.
|
|
726
|
+
const needsDataSetChanged = !this.viewPortHandler.hasChartDimens;
|
|
434
727
|
if (Trace.isEnabled()) {
|
|
435
|
-
CLog(CLogTypes.info, LOG_TAG, '
|
|
728
|
+
CLog(CLogTypes.info, LOG_TAG, 'onSetWidthHeight', w, h, needsDataSetChanged);
|
|
436
729
|
}
|
|
437
|
-
if (w > 0 && h > 0
|
|
730
|
+
if (w > 0 && h > 0) {
|
|
438
731
|
if (Trace.isEnabled()) {
|
|
439
732
|
CLog(CLogTypes.info, LOG_TAG, 'Setting chart dimens, width: ' + w + ', height: ' + h);
|
|
440
733
|
}
|
|
441
|
-
this.
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
if (Trace.isEnabled()) {
|
|
445
|
-
CLog(CLogTypes.warning, LOG_TAG, '*Avoiding* setting chart dimens! width: ' + w + ', height: ' + h);
|
|
446
|
-
}
|
|
734
|
+
this.viewPortHandler.setChartDimens(w, h);
|
|
447
735
|
}
|
|
736
|
+
// This may cause the chart view to mutate properties affecting the view port --
|
|
737
|
+
// lets do this before we try to run any pending jobs on the view port itself
|
|
738
|
+
// this.notifyDataSetChanged();
|
|
448
739
|
if (needsDataSetChanged) {
|
|
449
740
|
this.notifyDataSetChanged();
|
|
450
741
|
}
|
|
451
742
|
else {
|
|
452
|
-
this.
|
|
743
|
+
this.offsetsCalculated = false;
|
|
744
|
+
this.invalidate(); // needs chart size
|
|
453
745
|
}
|
|
454
|
-
for (const r of this.
|
|
746
|
+
for (const r of this.jobs) {
|
|
455
747
|
setTimeout(() => {
|
|
456
748
|
r.run();
|
|
457
749
|
}, 0);
|
|
458
750
|
}
|
|
459
|
-
this.
|
|
751
|
+
this.jobs = [];
|
|
460
752
|
this.notify({ eventName: 'sizeChanged', object: this });
|
|
461
753
|
}
|
|
462
754
|
onLayout(left, top, right, bottom) {
|
|
@@ -471,23 +763,31 @@ export class Chart extends CanvasView {
|
|
|
471
763
|
this.onSetWidthHeight(Math.round(w), Math.round(h));
|
|
472
764
|
}
|
|
473
765
|
}
|
|
474
|
-
|
|
766
|
+
/**
|
|
767
|
+
* Setting this to true will set the layer-type HARDWARE for the view, false
|
|
768
|
+
* will set layer-type SOFTWARE.
|
|
769
|
+
*
|
|
770
|
+
* @param enabled
|
|
771
|
+
*/
|
|
772
|
+
set hardwareAccelerationEnabled(enabled) {
|
|
475
773
|
this.hardwareAccelerated = enabled;
|
|
476
774
|
}
|
|
775
|
+
/**
|
|
776
|
+
* disables intercept touchevents
|
|
777
|
+
*/
|
|
477
778
|
disableScroll() {
|
|
478
779
|
if (__ANDROID__) {
|
|
479
780
|
const parent = this.nativeViewProtected?.getParent();
|
|
480
|
-
|
|
481
|
-
parent.requestDisallowInterceptTouchEvent(true);
|
|
482
|
-
}
|
|
781
|
+
parent?.requestDisallowInterceptTouchEvent(true);
|
|
483
782
|
}
|
|
484
783
|
}
|
|
784
|
+
/**
|
|
785
|
+
* enables intercept touchevents
|
|
786
|
+
*/
|
|
485
787
|
enableScroll() {
|
|
486
788
|
if (__ANDROID__) {
|
|
487
789
|
const parent = this.nativeViewProtected?.getParent();
|
|
488
|
-
|
|
489
|
-
parent.requestDisallowInterceptTouchEvent(false);
|
|
490
|
-
}
|
|
790
|
+
parent?.requestDisallowInterceptTouchEvent(false);
|
|
491
791
|
}
|
|
492
792
|
}
|
|
493
793
|
}
|