@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
|
@@ -20,34 +20,81 @@ const LOG_TAG = 'BarLineChartBase';
|
|
|
20
20
|
export class BarLineChartBase extends Chart {
|
|
21
21
|
constructor() {
|
|
22
22
|
super(...arguments);
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* the maximum number of entries to which values will be drawn
|
|
25
|
+
* (entry numbers greater than this value will cause value-labels to disappear)
|
|
26
|
+
*/
|
|
27
|
+
this.maxVisibleValueCount = 100;
|
|
28
|
+
/**
|
|
29
|
+
* flag that indicates if auto scaling on the y axis is enabled
|
|
30
|
+
*/
|
|
31
|
+
this.autoScaleMinMaxEnabled = true;
|
|
32
|
+
/**
|
|
33
|
+
* flag that indicates zoomed pan gesture should only work with 2 pointers
|
|
34
|
+
*/
|
|
24
35
|
this.zoomedPanWith2Pointers = false;
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
|
|
36
|
+
this.clipValuesToContent = true;
|
|
37
|
+
this.clipDataToContent = true;
|
|
38
|
+
this.drawHighlight = true;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the minimum offset (padding) around the chart, defaults to 15
|
|
41
|
+
*/
|
|
42
|
+
this.minOffset = 15;
|
|
43
|
+
// for performance tracking
|
|
29
44
|
this.totalTime = 0;
|
|
30
45
|
this.drawCycles = 0;
|
|
46
|
+
// public onTouchEvent( event) {
|
|
47
|
+
// super.onTouchEvent(event);
|
|
48
|
+
// if (mChartTouchListener == null || this.mData == null)
|
|
49
|
+
// return false;
|
|
50
|
+
// // check if touch gestures are enabled
|
|
51
|
+
// if (!mTouchEnabled)
|
|
52
|
+
// return false;
|
|
53
|
+
// else
|
|
54
|
+
// return this.chartTouchListener.onTouch(this, event);
|
|
55
|
+
// }
|
|
56
|
+
// public computeScroll() {
|
|
57
|
+
// if (this.chartTouchListener instanceof BarLineChartTouchListener)
|
|
58
|
+
// (this.chartTouchListener).computeScroll();
|
|
59
|
+
// }
|
|
60
|
+
/**
|
|
61
|
+
* ################ ################ ################ ################
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* CODE BELOW THIS RELATED TO SCALING AND GESTURES AND MODIFICATION OF THE
|
|
65
|
+
* VIEWPORT
|
|
66
|
+
*/
|
|
31
67
|
this.mZoomMatrixBuffer = new Matrix();
|
|
32
68
|
this.mFitScreenMatrixBuffer = new Matrix();
|
|
33
|
-
|
|
69
|
+
/**
|
|
70
|
+
* wheter to highlight drawing will be clipped to contentRect,
|
|
71
|
+
* otherwise they can bleed outside the content rect.
|
|
72
|
+
*/
|
|
34
73
|
this.clipHighlightToContent = true;
|
|
74
|
+
/**
|
|
75
|
+
* buffer for storing lowest visible x point
|
|
76
|
+
*/
|
|
35
77
|
this.posForGetLowestVisibleX = { x: 0, y: 0 };
|
|
78
|
+
/**
|
|
79
|
+
* buffer for storing highest visible x point
|
|
80
|
+
*/
|
|
36
81
|
this.posForGetHighestVisibleX = { x: 0, y: 0 };
|
|
37
82
|
this.mOnSizeChangedBuffer = Utils.createArrayBuffer(2);
|
|
38
83
|
}
|
|
84
|
+
// /** the approximator object used for data filtering */
|
|
85
|
+
// private Approximator this.mApproximator;
|
|
39
86
|
init() {
|
|
40
87
|
super.init();
|
|
41
|
-
this.mAxisLeft = new YAxis(AxisDependency.LEFT);
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
88
|
+
this.mAxisLeft = new YAxis(AxisDependency.LEFT, new WeakRef(this));
|
|
89
|
+
this.leftAxisTransformer = new Transformer(this.viewPortHandler);
|
|
90
|
+
this.rendererLeftYAxis = new YAxisRenderer(this.viewPortHandler, this.mAxisLeft, this.leftAxisTransformer);
|
|
91
|
+
this.rendererXAxis = new XAxisRenderer(this.viewPortHandler, this.xAxis, this.leftAxisTransformer);
|
|
92
|
+
this.highlighter = new ChartHighlighter(this);
|
|
46
93
|
}
|
|
47
94
|
get gridBackgroundPaint() {
|
|
48
95
|
if (!this.mGridBackgroundPaint) {
|
|
49
96
|
this.mGridBackgroundPaint = Utils.getTemplatePaint('black-fill');
|
|
50
|
-
this.mGridBackgroundPaint.setColor('#F0F0F0');
|
|
97
|
+
this.mGridBackgroundPaint.setColor('#F0F0F0'); // light
|
|
51
98
|
}
|
|
52
99
|
return this.mGridBackgroundPaint;
|
|
53
100
|
}
|
|
@@ -58,110 +105,114 @@ export class BarLineChartBase extends Chart {
|
|
|
58
105
|
return this.mBorderPaint;
|
|
59
106
|
}
|
|
60
107
|
getOrCreateBarTouchListener() {
|
|
61
|
-
if (!this.
|
|
62
|
-
this.
|
|
108
|
+
if (!this.chartTouchListener) {
|
|
109
|
+
this.chartTouchListener = new BarLineChartTouchListener(this, this.viewPortHandler.getMatrixTouch(), 3);
|
|
63
110
|
if (!!this.nativeViewProtected) {
|
|
64
|
-
this.
|
|
111
|
+
this.chartTouchListener.init();
|
|
65
112
|
}
|
|
66
113
|
}
|
|
67
|
-
return this.
|
|
114
|
+
return this.chartTouchListener;
|
|
68
115
|
}
|
|
69
116
|
onDraw(canvas) {
|
|
70
117
|
const startTime = Date.now();
|
|
71
118
|
super.onDraw(canvas);
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
119
|
+
const noComputeAutoScaleOnNextDraw = this.noComputeAutoScaleOnNextDraw;
|
|
120
|
+
const noComputeAxisOnNextDraw = this.noComputeAxisOnNextDraw;
|
|
121
|
+
this.noComputeAxisOnNextDraw = false;
|
|
122
|
+
this.noComputeAutoScaleOnNextDraw = false;
|
|
123
|
+
if (!this.mData)
|
|
75
124
|
return;
|
|
125
|
+
// execute all drawing commands
|
|
76
126
|
this.drawGridBackground(canvas);
|
|
77
|
-
|
|
127
|
+
const xAxis = this.xAxis;
|
|
128
|
+
const axisLeft = this.mAxisLeft;
|
|
129
|
+
const axisRight = this.mAxisRight;
|
|
130
|
+
// the order is important:
|
|
131
|
+
// * computeAxis needs axis.axisMinimum set in autoScale
|
|
132
|
+
// * calculateOffsets needs computeAxis because it needs axis longestLabel
|
|
133
|
+
if (!noComputeAutoScaleOnNextDraw && this.autoScaleMinMaxEnabled) {
|
|
78
134
|
this.autoScale();
|
|
79
135
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
this.
|
|
106
|
-
if (
|
|
107
|
-
this.
|
|
108
|
-
if (
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (xEnabled && this.mXAxis.isDrawLabelsBehindDataEnabled())
|
|
113
|
-
this.mXAxisRenderer.renderAxisLabels(canvas);
|
|
114
|
-
if (leftEnabled && this.mAxisLeft.isDrawLabelsBehindDataEnabled())
|
|
115
|
-
this.mAxisRendererLeft.renderAxisLabels(canvas);
|
|
116
|
-
if (rightEnabled && this.mAxisRight.isDrawLabelsBehindDataEnabled())
|
|
117
|
-
this.mAxisRendererRight.renderAxisLabels(canvas);
|
|
118
|
-
if (this.isClipDataToContentEnabled()) {
|
|
136
|
+
if (!noComputeAxisOnNextDraw) {
|
|
137
|
+
this.rendererLeftYAxis?.computeAxis(axisLeft.axisMinimum, axisLeft.axisMaximum, axisLeft.inverted);
|
|
138
|
+
this.rendererRightYAxis?.computeAxis(axisRight.axisMinimum, axisRight.axisMaximum, axisRight.inverted);
|
|
139
|
+
this.rendererXAxis?.computeAxis(this.xAxis.axisMinimum, this.xAxis.axisMaximum, false);
|
|
140
|
+
}
|
|
141
|
+
if (!this.offsetsCalculated) {
|
|
142
|
+
this.calculateOffsets(false);
|
|
143
|
+
this.offsetsCalculated = true;
|
|
144
|
+
}
|
|
145
|
+
if (xAxis.drawGridLinesBehindData)
|
|
146
|
+
this.rendererXAxis.renderGridLines(canvas);
|
|
147
|
+
if (axisLeft.drawGridLinesBehindData)
|
|
148
|
+
this.rendererLeftYAxis.renderGridLines(canvas);
|
|
149
|
+
if (axisRight?.drawGridLinesBehindData)
|
|
150
|
+
this.rendererRightYAxis.renderGridLines(canvas);
|
|
151
|
+
if (xAxis.drawLimitLinesBehindData)
|
|
152
|
+
this.rendererXAxis.renderLimitLines(canvas);
|
|
153
|
+
if (axisLeft.drawLimitLinesBehindData)
|
|
154
|
+
this.rendererLeftYAxis.renderLimitLines(canvas);
|
|
155
|
+
if (axisRight?.drawLimitLinesBehindData)
|
|
156
|
+
this.rendererRightYAxis.renderLimitLines(canvas);
|
|
157
|
+
this.rendererXAxis.renderAxisLine(canvas);
|
|
158
|
+
this.rendererLeftYAxis.renderAxisLine(canvas);
|
|
159
|
+
this.rendererRightYAxis?.renderAxisLine(canvas);
|
|
160
|
+
if (xAxis.drawLabelsBehindData)
|
|
161
|
+
this.rendererXAxis.renderAxisLabels(canvas);
|
|
162
|
+
if (axisLeft.drawLabelsBehindData)
|
|
163
|
+
this.rendererLeftYAxis.renderAxisLabels(canvas);
|
|
164
|
+
if (axisRight?.drawLabelsBehindData)
|
|
165
|
+
this.rendererRightYAxis.renderAxisLabels(canvas);
|
|
166
|
+
// make sure the data cannot be drawn outside the content-rect
|
|
167
|
+
if (this.clipDataToContent) {
|
|
119
168
|
canvas.save();
|
|
120
|
-
canvas.clipRect(this.
|
|
121
|
-
this.
|
|
169
|
+
canvas.clipRect(this.viewPortHandler.contentRect);
|
|
170
|
+
this.renderer.drawData(canvas);
|
|
122
171
|
}
|
|
123
172
|
else {
|
|
124
|
-
this.
|
|
125
|
-
}
|
|
126
|
-
if (
|
|
127
|
-
this.
|
|
128
|
-
if (
|
|
129
|
-
this.
|
|
130
|
-
if (
|
|
131
|
-
this.
|
|
132
|
-
if (!this.clipHighlightToContent && this.
|
|
173
|
+
this.renderer.drawData(canvas);
|
|
174
|
+
}
|
|
175
|
+
if (!xAxis.drawGridLinesBehindData)
|
|
176
|
+
this.rendererXAxis.renderGridLines(canvas);
|
|
177
|
+
if (!axisLeft.drawGridLinesBehindData)
|
|
178
|
+
this.rendererLeftYAxis.renderGridLines(canvas);
|
|
179
|
+
if (axisRight?.drawGridLinesBehindData === false)
|
|
180
|
+
this.rendererRightYAxis.renderGridLines(canvas);
|
|
181
|
+
if (!this.clipHighlightToContent && this.clipDataToContent) {
|
|
182
|
+
// restore before drawing highlight
|
|
133
183
|
canvas.restore();
|
|
134
184
|
}
|
|
135
|
-
if (this.
|
|
136
|
-
this.
|
|
185
|
+
if (this.hasValuesToHighlight && this.drawHighlight) {
|
|
186
|
+
this.renderer.drawHighlighted(canvas, this.indicesToHighlight, this.drawHighlight);
|
|
137
187
|
}
|
|
138
|
-
|
|
188
|
+
// Removes clipping rectangle
|
|
189
|
+
if (this.clipHighlightToContent && this.clipDataToContent) {
|
|
139
190
|
canvas.restore();
|
|
140
191
|
}
|
|
141
|
-
this.
|
|
142
|
-
if (
|
|
143
|
-
this.
|
|
144
|
-
if (
|
|
145
|
-
this.
|
|
146
|
-
if (
|
|
147
|
-
this.
|
|
148
|
-
if (
|
|
149
|
-
this.
|
|
150
|
-
if (
|
|
151
|
-
this.
|
|
152
|
-
if (
|
|
153
|
-
this.
|
|
154
|
-
if (this.
|
|
192
|
+
this.renderer.drawExtras(canvas);
|
|
193
|
+
if (!xAxis.drawLimitLinesBehindData)
|
|
194
|
+
this.rendererXAxis.renderLimitLines(canvas);
|
|
195
|
+
if (!axisLeft.drawLimitLinesBehindData)
|
|
196
|
+
this.rendererLeftYAxis.renderLimitLines(canvas);
|
|
197
|
+
if (axisRight?.drawLimitLinesBehindData === false)
|
|
198
|
+
this.rendererRightYAxis.renderLimitLines(canvas);
|
|
199
|
+
if (!xAxis.drawLabelsBehindData)
|
|
200
|
+
this.rendererXAxis.renderAxisLabels(canvas);
|
|
201
|
+
if (!axisLeft.drawLabelsBehindData)
|
|
202
|
+
this.rendererLeftYAxis.renderAxisLabels(canvas);
|
|
203
|
+
if (axisRight?.drawLabelsBehindData === false)
|
|
204
|
+
this.rendererRightYAxis.renderAxisLabels(canvas);
|
|
205
|
+
if (this.clipValuesToContent) {
|
|
155
206
|
canvas.save();
|
|
156
|
-
canvas.clipRect(this.
|
|
157
|
-
this.
|
|
207
|
+
canvas.clipRect(this.viewPortHandler.contentRect);
|
|
208
|
+
this.renderer.drawValues(canvas);
|
|
158
209
|
canvas.restore();
|
|
159
210
|
}
|
|
160
211
|
else {
|
|
161
|
-
this.
|
|
212
|
+
this.renderer.drawValues(canvas);
|
|
162
213
|
}
|
|
163
|
-
if (this.
|
|
164
|
-
this.
|
|
214
|
+
if (this.legendRenderer) {
|
|
215
|
+
this.legendRenderer.renderLegend(canvas);
|
|
165
216
|
}
|
|
166
217
|
this.drawDescription(canvas);
|
|
167
218
|
this.drawMarkers(canvas);
|
|
@@ -174,37 +225,40 @@ export class BarLineChartBase extends Chart {
|
|
|
174
225
|
CLog(CLogTypes.log, this.constructor.name, 'Drawtime: ' + drawtime + ' ms, average: ' + average + ' ms, cycles: ' + this.drawCycles);
|
|
175
226
|
}
|
|
176
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* RESET PERFORMANCE TRACKING FIELDS
|
|
230
|
+
*/
|
|
177
231
|
resetTracking() {
|
|
178
232
|
this.totalTime = 0;
|
|
179
233
|
this.drawCycles = 0;
|
|
180
234
|
}
|
|
181
235
|
prepareValuePxMatrix() {
|
|
182
236
|
if (Trace.isEnabled()) {
|
|
183
|
-
CLog(CLogTypes.info, LOG_TAG, 'Preparing Value-Px Matrix, xmin: ' + this.
|
|
237
|
+
CLog(CLogTypes.info, LOG_TAG, 'Preparing Value-Px Matrix, xmin: ' + this.xAxis.axisMinimum + ', xmax: ' + this.xAxis.axisMaximum + ', xdelta: ' + this.xAxis.axisRange);
|
|
184
238
|
}
|
|
185
|
-
if (this.mAxisRight
|
|
186
|
-
this.
|
|
239
|
+
if (this.mAxisRight?.enabled) {
|
|
240
|
+
this.rightAxisTransformer.prepareMatrixValuePx(this.xAxis.axisMinimum, this.xAxis.axisRange, this.mAxisRight.axisRange, this.mAxisRight.axisMinimum);
|
|
187
241
|
}
|
|
188
|
-
if (
|
|
189
|
-
this.
|
|
242
|
+
if (this.mAxisLeft?.enabled || this.xAxis.enabled) {
|
|
243
|
+
this.leftAxisTransformer.prepareMatrixValuePx(this.xAxis.axisMinimum, this.xAxis.axisRange, this.mAxisLeft.axisRange, this.mAxisLeft.axisMinimum);
|
|
190
244
|
}
|
|
191
245
|
}
|
|
192
246
|
prepareOffsetMatrix() {
|
|
193
|
-
if (this.mAxisRight
|
|
194
|
-
this.
|
|
247
|
+
if (this.mAxisRight?.enabled) {
|
|
248
|
+
this.rightAxisTransformer.prepareMatrixOffset(this.mAxisRight.inverted);
|
|
195
249
|
}
|
|
196
|
-
if (
|
|
197
|
-
this.
|
|
250
|
+
if (this.mAxisLeft?.enabled || this.xAxis.enabled) {
|
|
251
|
+
this.leftAxisTransformer.prepareMatrixOffset(this.mAxisLeft.inverted);
|
|
198
252
|
}
|
|
199
253
|
}
|
|
200
254
|
notifyDataSetChanged() {
|
|
201
|
-
if (this.mData
|
|
255
|
+
if (!this.mData || this.mData.dataSetCount === 0) {
|
|
202
256
|
if (Trace.isEnabled()) {
|
|
203
257
|
CLog(CLogTypes.info, LOG_TAG, 'Preparing... DATA NOT SET.');
|
|
204
258
|
}
|
|
205
259
|
return;
|
|
206
260
|
}
|
|
207
|
-
else if (!this.
|
|
261
|
+
else if (!this.viewPortHandler.hasChartDimens) {
|
|
208
262
|
if (Trace.isEnabled()) {
|
|
209
263
|
CLog(CLogTypes.info, LOG_TAG, 'Preparing... NOT SIZED YET.');
|
|
210
264
|
}
|
|
@@ -215,43 +269,47 @@ export class BarLineChartBase extends Chart {
|
|
|
215
269
|
CLog(CLogTypes.info, LOG_TAG, 'Preparing...');
|
|
216
270
|
}
|
|
217
271
|
}
|
|
218
|
-
|
|
219
|
-
this.mRenderer.initBuffers();
|
|
272
|
+
this.renderer?.initBuffers();
|
|
220
273
|
this.calcMinMax();
|
|
221
|
-
if (this.mAxisLeft
|
|
222
|
-
this.
|
|
274
|
+
if (this.mAxisLeft?.enabled) {
|
|
275
|
+
this.rendererLeftYAxis.computeAxis(this.mAxisLeft.axisMinimum, this.mAxisLeft.axisMaximum, this.mAxisLeft.inverted);
|
|
223
276
|
}
|
|
224
|
-
if (this.mAxisRight
|
|
225
|
-
this.
|
|
277
|
+
if (this.mAxisRight?.enabled) {
|
|
278
|
+
this.rendererRightYAxis.computeAxis(this.mAxisRight.axisMinimum, this.mAxisRight.axisMaximum, this.mAxisRight.inverted);
|
|
226
279
|
}
|
|
227
|
-
if (this.
|
|
228
|
-
this.
|
|
280
|
+
if (this.xAxis.enabled) {
|
|
281
|
+
this.rendererXAxis.computeAxis(this.xAxis.axisMinimum, this.xAxis.axisMaximum, false);
|
|
229
282
|
}
|
|
230
|
-
if (this.mLegend
|
|
231
|
-
this.
|
|
283
|
+
if (this.mLegend?.enabled) {
|
|
284
|
+
this.legendRenderer.computeLegend(this.mData);
|
|
232
285
|
}
|
|
233
|
-
|
|
286
|
+
// offsets will be calculated on draw
|
|
287
|
+
this.offsetsCalculated = false;
|
|
234
288
|
this.invalidate();
|
|
235
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Performs auto scaling of the axis by recalculating the minimum and maximum y-values based on the entries currently in view.
|
|
292
|
+
*/
|
|
236
293
|
autoScale() {
|
|
237
|
-
const fromX = this.
|
|
238
|
-
const toX = this.
|
|
294
|
+
const fromX = this.lowestVisibleX;
|
|
295
|
+
const toX = this.highestVisibleX;
|
|
239
296
|
this.mData.calcMinMaxYRange(fromX, toX);
|
|
240
|
-
this.
|
|
241
|
-
|
|
297
|
+
this.xAxis.calculate(this.mData.xMin, this.mData.xMax);
|
|
298
|
+
// calculate axis range (min / max) according to provided data
|
|
299
|
+
if (this.mAxisLeft?.enabled) {
|
|
242
300
|
this.mAxisLeft.calculate(this.mData.getYMin(AxisDependency.LEFT), this.mData.getYMax(AxisDependency.LEFT));
|
|
243
301
|
}
|
|
244
|
-
if (this.mAxisRight
|
|
302
|
+
if (this.mAxisRight?.enabled) {
|
|
245
303
|
this.mAxisRight.calculate(this.mData.getYMin(AxisDependency.RIGHT), this.mData.getYMax(AxisDependency.RIGHT));
|
|
246
304
|
}
|
|
247
|
-
this.calculateOffsets();
|
|
248
305
|
}
|
|
249
306
|
calcMinMax() {
|
|
250
|
-
this.
|
|
251
|
-
|
|
307
|
+
this.xAxis.calculate(this.mData.xMin, this.mData.xMax);
|
|
308
|
+
// calculate axis range (min / max) according to provided data
|
|
309
|
+
if (this.mAxisLeft?.enabled) {
|
|
252
310
|
this.mAxisLeft.calculate(this.mData.getYMin(AxisDependency.LEFT), this.mData.getYMax(AxisDependency.LEFT));
|
|
253
311
|
}
|
|
254
|
-
if (this.mAxisRight
|
|
312
|
+
if (this.mAxisRight?.enabled) {
|
|
255
313
|
this.mAxisRight.calculate(this.mData.getYMin(AxisDependency.RIGHT), this.mData.getYMax(AxisDependency.RIGHT));
|
|
256
314
|
}
|
|
257
315
|
}
|
|
@@ -260,23 +318,24 @@ export class BarLineChartBase extends Chart {
|
|
|
260
318
|
offsets.right = 0;
|
|
261
319
|
offsets.top = 0;
|
|
262
320
|
offsets.bottom = 0;
|
|
263
|
-
|
|
264
|
-
|
|
321
|
+
// setup offsets for legend
|
|
322
|
+
if (this.mLegend?.enabled && !this.mLegend.drawInside) {
|
|
323
|
+
switch (this.mLegend.orientation) {
|
|
265
324
|
case LegendOrientation.VERTICAL:
|
|
266
|
-
switch (this.mLegend.
|
|
325
|
+
switch (this.mLegend.horizontalAlignment) {
|
|
267
326
|
case LegendHorizontalAlignment.LEFT:
|
|
268
|
-
offsets.left += Math.min(this.mLegend.mNeededWidth, this.
|
|
327
|
+
offsets.left += Math.min(this.mLegend.mNeededWidth, this.viewPortHandler.chartWidth * this.mLegend.maxSizePercent) + this.mLegend.xOffset;
|
|
269
328
|
break;
|
|
270
329
|
case LegendHorizontalAlignment.RIGHT:
|
|
271
|
-
offsets.right += Math.min(this.mLegend.mNeededWidth, this.
|
|
330
|
+
offsets.right += Math.min(this.mLegend.mNeededWidth, this.viewPortHandler.chartWidth * this.mLegend.maxSizePercent) + this.mLegend.xOffset;
|
|
272
331
|
break;
|
|
273
332
|
case LegendHorizontalAlignment.CENTER:
|
|
274
|
-
switch (this.mLegend.
|
|
333
|
+
switch (this.mLegend.verticalAlignment) {
|
|
275
334
|
case LegendVerticalAlignment.TOP:
|
|
276
|
-
offsets.top += Math.min(this.mLegend.mNeededHeight, this.
|
|
335
|
+
offsets.top += Math.min(this.mLegend.mNeededHeight, this.viewPortHandler.chartHeight * this.mLegend.maxSizePercent) + this.mLegend.yOffset;
|
|
277
336
|
break;
|
|
278
337
|
case LegendVerticalAlignment.BOTTOM:
|
|
279
|
-
offsets.bottom += Math.min(this.mLegend.mNeededHeight, this.
|
|
338
|
+
offsets.bottom += Math.min(this.mLegend.mNeededHeight, this.viewPortHandler.chartHeight * this.mLegend.maxSizePercent) + this.mLegend.yOffset;
|
|
280
339
|
break;
|
|
281
340
|
default:
|
|
282
341
|
break;
|
|
@@ -284,12 +343,12 @@ export class BarLineChartBase extends Chart {
|
|
|
284
343
|
}
|
|
285
344
|
break;
|
|
286
345
|
case LegendOrientation.HORIZONTAL:
|
|
287
|
-
switch (this.mLegend.
|
|
346
|
+
switch (this.mLegend.verticalAlignment) {
|
|
288
347
|
case LegendVerticalAlignment.TOP:
|
|
289
|
-
offsets.top += Math.min(this.mLegend.mNeededHeight, this.
|
|
348
|
+
offsets.top += Math.min(this.mLegend.mNeededHeight, this.viewPortHandler.chartHeight * this.mLegend.maxSizePercent) + this.mLegend.yOffset;
|
|
290
349
|
break;
|
|
291
350
|
case LegendVerticalAlignment.BOTTOM:
|
|
292
|
-
offsets.bottom += Math.min(this.mLegend.mNeededHeight, this.
|
|
351
|
+
offsets.bottom += Math.min(this.mLegend.mNeededHeight, this.viewPortHandler.chartHeight * this.mLegend.maxSizePercent) + this.mLegend.yOffset;
|
|
293
352
|
break;
|
|
294
353
|
default:
|
|
295
354
|
break;
|
|
@@ -299,10 +358,10 @@ export class BarLineChartBase extends Chart {
|
|
|
299
358
|
}
|
|
300
359
|
}
|
|
301
360
|
calculateOffsets(force = true) {
|
|
302
|
-
if (this.
|
|
361
|
+
if (this.offsetsCalculated && !force) {
|
|
303
362
|
return;
|
|
304
363
|
}
|
|
305
|
-
this.
|
|
364
|
+
this.offsetsCalculated = true;
|
|
306
365
|
if (!this.mCustomViewPortEnabled) {
|
|
307
366
|
const offsetBuffer = Utils.getTempRectF();
|
|
308
367
|
this.calculateLegendOffsets(offsetBuffer);
|
|
@@ -310,407 +369,737 @@ export class BarLineChartBase extends Chart {
|
|
|
310
369
|
let offsetTop = offsetBuffer.top;
|
|
311
370
|
let offsetRight = offsetBuffer.right;
|
|
312
371
|
let offsetBottom = offsetBuffer.bottom;
|
|
313
|
-
|
|
314
|
-
|
|
372
|
+
// offsets for y-labels
|
|
373
|
+
if (this.mAxisLeft?.needsOffset) {
|
|
374
|
+
offsetLeft += this.mAxisLeft.getRequiredWidthSpace(this.rendererLeftYAxis.axisLabelsPaint);
|
|
315
375
|
}
|
|
316
|
-
if (this.mAxisRight
|
|
317
|
-
offsetRight += this.mAxisRight.getRequiredWidthSpace(this.
|
|
376
|
+
if (this.mAxisRight?.needsOffset) {
|
|
377
|
+
offsetRight += this.mAxisRight.getRequiredWidthSpace(this.rendererRightYAxis.axisLabelsPaint);
|
|
318
378
|
}
|
|
319
|
-
if (this.
|
|
320
|
-
const xLabelHeight = this.
|
|
321
|
-
|
|
379
|
+
if (this.xAxis.enabled && this.xAxis.drawLabels) {
|
|
380
|
+
const xLabelHeight = this.xAxis.mLabelRotatedHeight + this.xAxis.yOffset;
|
|
381
|
+
// offsets for x-labels
|
|
382
|
+
if (this.xAxis.position === XAxisPosition.BOTTOM) {
|
|
322
383
|
offsetBottom += xLabelHeight;
|
|
323
384
|
}
|
|
324
|
-
else if (this.
|
|
385
|
+
else if (this.xAxis.position === XAxisPosition.TOP) {
|
|
325
386
|
offsetTop += xLabelHeight;
|
|
326
387
|
}
|
|
327
|
-
else if (this.
|
|
388
|
+
else if (this.xAxis.position === XAxisPosition.BOTH_SIDED) {
|
|
328
389
|
offsetBottom += xLabelHeight;
|
|
329
390
|
offsetTop += xLabelHeight;
|
|
330
391
|
}
|
|
331
392
|
}
|
|
332
|
-
offsetTop += this.
|
|
333
|
-
offsetRight += this.
|
|
334
|
-
offsetBottom += this.
|
|
335
|
-
offsetLeft += this.
|
|
336
|
-
const minOffset = this.
|
|
337
|
-
this.
|
|
393
|
+
offsetTop += this.extraTopOffset;
|
|
394
|
+
offsetRight += this.extraRightOffset;
|
|
395
|
+
offsetBottom += this.extraBottomOffset;
|
|
396
|
+
offsetLeft += this.extraLeftOffset;
|
|
397
|
+
const minOffset = this.minOffset;
|
|
398
|
+
this.viewPortHandler.restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom));
|
|
338
399
|
if (Trace.isEnabled()) {
|
|
339
400
|
CLog(CLogTypes.info, LOG_TAG, 'offsetLeft: ' + offsetLeft + ', offsetTop: ' + offsetTop + ', offsetRight: ' + offsetRight + ', offsetBottom: ' + offsetBottom);
|
|
340
|
-
CLog(CLogTypes.info, LOG_TAG, 'Content: ' + this.
|
|
401
|
+
CLog(CLogTypes.info, LOG_TAG, 'Content: ' + this.viewPortHandler.contentRect.toString());
|
|
341
402
|
}
|
|
342
403
|
}
|
|
343
404
|
this.prepareOffsetMatrix();
|
|
344
405
|
this.prepareValuePxMatrix();
|
|
345
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* draws the grid background
|
|
409
|
+
*/
|
|
346
410
|
drawGridBackground(c) {
|
|
347
|
-
if (this.
|
|
348
|
-
|
|
411
|
+
if (this.drawGridBackgroundEnabled) {
|
|
412
|
+
// draw the grid background
|
|
413
|
+
c.drawRect(this.viewPortHandler.contentRect, this.gridBackgroundPaint);
|
|
349
414
|
}
|
|
350
|
-
if (this.
|
|
351
|
-
c.drawRect(this.
|
|
415
|
+
if (this.drawBorders) {
|
|
416
|
+
c.drawRect(this.viewPortHandler.contentRect, this.borderPaint);
|
|
352
417
|
}
|
|
353
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Returns the Transformer class that contains all matrices and is
|
|
421
|
+
* responsible for transforming values into pixels on the screen and
|
|
422
|
+
* backwards.
|
|
423
|
+
*/
|
|
354
424
|
getTransformer(which) {
|
|
355
425
|
if (which === undefined) {
|
|
356
|
-
|
|
357
|
-
return this.mLeftAxisTransformer;
|
|
358
|
-
}
|
|
359
|
-
return this.mRightAxisTransformer;
|
|
426
|
+
return this.transformer;
|
|
360
427
|
}
|
|
361
428
|
if (which === AxisDependency.LEFT)
|
|
362
|
-
return this.
|
|
429
|
+
return this.leftAxisTransformer;
|
|
363
430
|
else
|
|
364
|
-
return this.
|
|
431
|
+
return this.rightAxisTransformer;
|
|
432
|
+
}
|
|
433
|
+
get transformer() {
|
|
434
|
+
if (this.mAxisLeft.enabled) {
|
|
435
|
+
return this.leftAxisTransformer;
|
|
436
|
+
}
|
|
437
|
+
return this.rightAxisTransformer;
|
|
365
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Zooms in by 1.4f, into the charts center.
|
|
441
|
+
*/
|
|
366
442
|
zoomIn() {
|
|
367
|
-
const center = this.
|
|
368
|
-
this.
|
|
369
|
-
this.
|
|
443
|
+
const center = this.viewPortHandler.contentCenter;
|
|
444
|
+
this.viewPortHandler.zoomIn(center.x, -center.y, this.mZoomMatrixBuffer);
|
|
445
|
+
this.viewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
|
|
446
|
+
// Range might have changed, which means that Y-axis labels
|
|
447
|
+
// could have changed in size, affecting Y-axis size.
|
|
448
|
+
// So we need to recalculate offsets.
|
|
370
449
|
this.calculateOffsets();
|
|
371
450
|
this.invalidate();
|
|
372
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Zooms out by 0.7f, from the charts center.
|
|
454
|
+
*/
|
|
373
455
|
zoomOut() {
|
|
374
|
-
const center = this.
|
|
375
|
-
this.
|
|
376
|
-
this.
|
|
456
|
+
const center = this.viewPortHandler.contentCenter;
|
|
457
|
+
this.viewPortHandler.zoomOut(center.x, -center.y, this.mZoomMatrixBuffer);
|
|
458
|
+
this.viewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
|
|
459
|
+
// Range might have changed, which means that Y-axis labels
|
|
460
|
+
// could have changed in size, affecting Y-axis size.
|
|
461
|
+
// So we need to recalculate offsets.
|
|
377
462
|
this.calculateOffsets();
|
|
378
463
|
this.invalidate();
|
|
379
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Zooms out to original size.
|
|
467
|
+
*/
|
|
380
468
|
resetZoom() {
|
|
381
|
-
this.
|
|
382
|
-
this.
|
|
383
|
-
this.
|
|
469
|
+
this.viewPortHandler.mMatrixTouch.reset();
|
|
470
|
+
this.viewPortHandler.resetZoom(this.mZoomMatrixBuffer);
|
|
471
|
+
this.viewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
|
|
472
|
+
// Range might have changed, which means that Y-axis labels
|
|
473
|
+
// could have changed in size, affecting Y-axis size.
|
|
474
|
+
// So we need to recalculate offsets.
|
|
384
475
|
this.calculateOffsets();
|
|
385
476
|
this.invalidate();
|
|
386
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Zooms in or out by the given scale factor. x and y are the coordinates
|
|
480
|
+
* (in pixels) of the zoom center.
|
|
481
|
+
*
|
|
482
|
+
* @param scaleX if < 1 --> zoom out, if > 1 --> zoom in
|
|
483
|
+
* @param scaleY if < 1 --> zoom out, if > 1 --> zoom in
|
|
484
|
+
* @param x
|
|
485
|
+
* @param y
|
|
486
|
+
*/
|
|
387
487
|
zoom(scaleX, scaleY, x, y) {
|
|
388
|
-
this.
|
|
389
|
-
this.
|
|
488
|
+
this.viewPortHandler.zoomAtPosition(scaleX, scaleY, x, y, this.mZoomMatrixBuffer);
|
|
489
|
+
this.viewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
|
|
490
|
+
// Range might have changed, which means that Y-axis labels
|
|
491
|
+
// could have changed in size, affecting Y-axis size.
|
|
492
|
+
// So we need to recalculate offsets.
|
|
390
493
|
this.calculateOffsets();
|
|
391
494
|
this.invalidate();
|
|
392
495
|
if (this.hasListeners('zoom')) {
|
|
393
496
|
this.notify({ eventName: 'zoom', object: this, scaleX, scaleY, x, y });
|
|
394
497
|
}
|
|
395
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Zooms in or out by the given scale factor.
|
|
501
|
+
* x and y are the values (NOT PIXELS) of the zoom center..
|
|
502
|
+
*
|
|
503
|
+
* @param scaleX
|
|
504
|
+
* @param scaleY
|
|
505
|
+
* @param xValue
|
|
506
|
+
* @param yValue
|
|
507
|
+
* @param axis the axis relative to which the zoom should take place
|
|
508
|
+
*/
|
|
396
509
|
zoomAtValue(scaleX, scaleY, xValue, yValue, axis) {
|
|
397
|
-
const job = ZoomJob.getInstance(this.
|
|
510
|
+
const job = ZoomJob.getInstance(this.viewPortHandler, scaleX, scaleY, xValue, yValue, this.getTransformer(axis), axis, this);
|
|
398
511
|
this.addViewportJob(job);
|
|
399
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Zooms to the center of the chart with the given scale factor.
|
|
515
|
+
*
|
|
516
|
+
* @param scaleX
|
|
517
|
+
* @param scaleY
|
|
518
|
+
*/
|
|
400
519
|
zoomToCenter(scaleX, scaleY) {
|
|
401
|
-
const center = this.
|
|
520
|
+
const center = this.centerOffsets;
|
|
402
521
|
const save = this.mZoomMatrixBuffer;
|
|
403
|
-
this.
|
|
404
|
-
this.
|
|
405
|
-
}
|
|
522
|
+
this.viewPortHandler.zoomAtPosition(scaleX, scaleY, center.x, -center.y, save);
|
|
523
|
+
this.viewPortHandler.refresh(save, this, false);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Zooms by the specified scale factor to the specified values on the specified axis.
|
|
527
|
+
*
|
|
528
|
+
* @param scaleX
|
|
529
|
+
* @param scaleY
|
|
530
|
+
* @param xValue
|
|
531
|
+
* @param yValue
|
|
532
|
+
* @param axis
|
|
533
|
+
* @param duration
|
|
534
|
+
*/
|
|
406
535
|
zoomAndCenterAnimated(scaleX, scaleY, xValue, yValue, axis, duration) {
|
|
407
|
-
const origin = this.getValuesByTouchPoint(this.
|
|
408
|
-
const job = AnimatedZoomJob.getInstance(this.
|
|
536
|
+
const origin = this.getValuesByTouchPoint(this.viewPortHandler.contentLeft, this.viewPortHandler.contentTop, axis);
|
|
537
|
+
const job = AnimatedZoomJob.getInstance(this.viewPortHandler, this, this.getTransformer(axis), this.getAxis(axis), this.xAxis.axisRange, scaleX, scaleY, this.viewPortHandler.getScaleX(), this.viewPortHandler.getScaleY(), xValue, yValue, origin.x, origin.y, duration);
|
|
409
538
|
this.addViewportJob(job);
|
|
410
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Zooms by the specified scale factor to the specified values on the specified axis.
|
|
542
|
+
*
|
|
543
|
+
* @param scaleX
|
|
544
|
+
* @param scaleY
|
|
545
|
+
* @param xValue
|
|
546
|
+
* @param yValue
|
|
547
|
+
* @param axis
|
|
548
|
+
*/
|
|
411
549
|
zoomAndCenter(scaleX, scaleY, xValue, yValue, axis) {
|
|
412
|
-
const origin = this.getValuesByTouchPoint(this.
|
|
413
|
-
const job = AnimatedZoomJob.getInstance(this.
|
|
414
|
-
job.
|
|
550
|
+
const origin = this.getValuesByTouchPoint(this.viewPortHandler.contentLeft, this.viewPortHandler.contentTop, axis);
|
|
551
|
+
const job = AnimatedZoomJob.getInstance(this.viewPortHandler, this, this.getTransformer(axis), this.getAxis(axis), this.xAxis.axisRange, scaleX, scaleY, this.viewPortHandler.getScaleX(), this.viewPortHandler.getScaleY(), xValue, yValue, origin.x, origin.y, 0);
|
|
552
|
+
job.phase = 1;
|
|
415
553
|
job.onAnimationUpdate(0);
|
|
416
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Resets all zooming and dragging and makes the chart fit exactly it's
|
|
557
|
+
* bounds.
|
|
558
|
+
*/
|
|
417
559
|
fitScreen() {
|
|
418
560
|
const save = this.mFitScreenMatrixBuffer;
|
|
419
|
-
this.
|
|
420
|
-
this.
|
|
561
|
+
this.viewPortHandler.fitScreen(save);
|
|
562
|
+
this.viewPortHandler.refresh(save, this, false);
|
|
421
563
|
this.calculateOffsets();
|
|
422
564
|
this.invalidate();
|
|
423
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* Sets the minimum scale factor value to which can be zoomed out. 1 =
|
|
568
|
+
* fitScreen
|
|
569
|
+
*
|
|
570
|
+
* @param scaleX
|
|
571
|
+
* @param scaleY
|
|
572
|
+
*/
|
|
424
573
|
setScaleMinima(scaleX, scaleY) {
|
|
425
|
-
this.
|
|
426
|
-
this.
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
574
|
+
this.viewPortHandler.setMinimumScaleX(scaleX);
|
|
575
|
+
this.viewPortHandler.setMinimumScaleY(scaleY);
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Sets the scale factor. 1 =
|
|
579
|
+
* fitScreen
|
|
580
|
+
*
|
|
581
|
+
* @param scaleX
|
|
582
|
+
* @param scaleY
|
|
583
|
+
*/
|
|
584
|
+
setScale(scaleX, scaleY) {
|
|
585
|
+
this.viewPortHandler.setScale(scaleX, scaleY);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Sets the size of the area (range on the x-axis) that should be maximum
|
|
589
|
+
* visible at once (no further zooming out allowed). If this is e.g. set to
|
|
590
|
+
* 10, no more than a range of 10 on the x-axis can be viewed at once without
|
|
591
|
+
* scrolling.
|
|
592
|
+
*
|
|
593
|
+
* @param maxXRange The maximum visible range of x-values.
|
|
594
|
+
*/
|
|
595
|
+
set visibleXRangeMaximum(maxXRange) {
|
|
596
|
+
const xScale = this.xAxis.axisRange / maxXRange;
|
|
597
|
+
this.viewPortHandler.setMinimumScaleX(xScale);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Sets the size of the area (range on the x-axis) that should be minimum
|
|
601
|
+
* visible at once (no further zooming in allowed). If this is e.g. set to
|
|
602
|
+
* 10, no less than a range of 10 on the x-axis can be viewed at once without
|
|
603
|
+
* scrolling.
|
|
604
|
+
*
|
|
605
|
+
* @param minXRange The minimum visible range of x-values.
|
|
606
|
+
*/
|
|
607
|
+
set visibleXRangeMinimum(minXRange) {
|
|
608
|
+
const xScale = this.xAxis.axisRange / minXRange;
|
|
609
|
+
this.viewPortHandler.setMaximumScaleX(xScale);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Limits the maximum and minimum x range that can be visible by pinching and zooming. e.g. minRange=10, maxRange=100 the
|
|
613
|
+
* smallest range to be displayed at once is 10, and no more than a range of 100 values can be viewed at once without
|
|
614
|
+
* scrolling
|
|
615
|
+
*
|
|
616
|
+
* @param minXRange
|
|
617
|
+
* @param maxXRange
|
|
618
|
+
*/
|
|
436
619
|
setVisibleXRange(minXRange, maxXRange) {
|
|
437
|
-
const minScale = this.
|
|
438
|
-
const maxScale = this.
|
|
439
|
-
this.
|
|
440
|
-
}
|
|
620
|
+
const minScale = this.xAxis.axisRange / minXRange;
|
|
621
|
+
const maxScale = this.xAxis.axisRange / maxXRange;
|
|
622
|
+
this.viewPortHandler.setMinMaxScaleX(minScale, maxScale);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Sets the size of the area (range on the y-axis) that should be maximum
|
|
626
|
+
* visible at once.
|
|
627
|
+
*
|
|
628
|
+
* @param maxYRange the maximum visible range on the y-axis
|
|
629
|
+
* @param axis the axis for which this limit should apply
|
|
630
|
+
*/
|
|
441
631
|
setVisibleYRangeMaximum(maxYRange, axis) {
|
|
442
632
|
const yScale = this.getAxisRange(axis) / maxYRange;
|
|
443
|
-
this.
|
|
444
|
-
}
|
|
633
|
+
this.viewPortHandler.setMinimumScaleY(yScale);
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Sets the size of the area (range on the y-axis) that should be minimum visible at once, no further zooming in possible.
|
|
637
|
+
*
|
|
638
|
+
* @param minYRange
|
|
639
|
+
* @param axis the axis for which this limit should apply
|
|
640
|
+
*/
|
|
445
641
|
setVisibleYRangeMinimum(minYRange, axis) {
|
|
446
642
|
const yScale = this.getAxisRange(axis) / minYRange;
|
|
447
|
-
this.
|
|
448
|
-
}
|
|
643
|
+
this.viewPortHandler.setMaximumScaleY(yScale);
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Limits the maximum and minimum y range that can be visible by pinching and zooming.
|
|
647
|
+
*
|
|
648
|
+
* @param minYRange
|
|
649
|
+
* @param maxYRange
|
|
650
|
+
* @param axis
|
|
651
|
+
*/
|
|
449
652
|
setVisibleYRange(minYRange, maxYRange, axis) {
|
|
450
653
|
const minScale = this.getAxisRange(axis) / minYRange;
|
|
451
654
|
const maxScale = this.getAxisRange(axis) / maxYRange;
|
|
452
|
-
this.
|
|
453
|
-
}
|
|
655
|
+
this.viewPortHandler.setMinMaxScaleY(minScale, maxScale);
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Moves the left side of the current viewport to the specified x-position.
|
|
659
|
+
* This also refreshes the chart by calling invalidate().
|
|
660
|
+
*
|
|
661
|
+
* @param xValue
|
|
662
|
+
*/
|
|
454
663
|
moveViewToX(xValue) {
|
|
455
|
-
const job = MoveViewJob.getInstance(this.
|
|
664
|
+
const job = MoveViewJob.getInstance(this.viewPortHandler, xValue, 0, this.transformer, this);
|
|
456
665
|
this.addViewportJob(job);
|
|
457
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* This will move the left side of the current viewport to the specified
|
|
669
|
+
* x-value on the x-axis, and center the viewport to the specified y value on the y-axis.
|
|
670
|
+
* This also refreshes the chart by calling invalidate().
|
|
671
|
+
*
|
|
672
|
+
* @param xValue
|
|
673
|
+
* @param yValue
|
|
674
|
+
* @param axis - which axis should be used as a reference for the y-axis
|
|
675
|
+
*/
|
|
458
676
|
moveViewTo(xValue, yValue, axis) {
|
|
459
|
-
const yInView = this.getAxisRange(axis) / this.
|
|
460
|
-
const job = MoveViewJob.getInstance(this.
|
|
677
|
+
const yInView = this.getAxisRange(axis) / this.viewPortHandler.getScaleY();
|
|
678
|
+
const job = MoveViewJob.getInstance(this.viewPortHandler, xValue, yValue + yInView / 2, this.getTransformer(axis), this);
|
|
461
679
|
this.addViewportJob(job);
|
|
462
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* This will move the left side of the current viewport to the specified x-value
|
|
683
|
+
* and center the viewport to the y value animated.
|
|
684
|
+
* This also refreshes the chart by calling invalidate().
|
|
685
|
+
*
|
|
686
|
+
* @param xValue
|
|
687
|
+
* @param yValue
|
|
688
|
+
* @param axis
|
|
689
|
+
* @param duration the duration of the animation in milliseconds
|
|
690
|
+
*/
|
|
463
691
|
moveViewToAnimated(xValue, yValue, axis, duration) {
|
|
464
|
-
const bounds = this.getValuesByTouchPoint(this.
|
|
465
|
-
const yInView = this.getAxisRange(axis) / this.
|
|
466
|
-
const job = AnimatedMoveViewJob.getInstance(this.
|
|
692
|
+
const bounds = this.getValuesByTouchPoint(this.viewPortHandler.contentLeft, this.viewPortHandler.contentTop, axis);
|
|
693
|
+
const yInView = this.getAxisRange(axis) / this.viewPortHandler.getScaleY();
|
|
694
|
+
const job = AnimatedMoveViewJob.getInstance(this.viewPortHandler, xValue, yValue + yInView / 2, this.getTransformer(axis), this, bounds.x, bounds.y, duration);
|
|
467
695
|
this.addViewportJob(job);
|
|
468
|
-
|
|
696
|
+
// MPPointD.recycleInstance(bounds);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Centers the viewport to the specified y value on the y-axis.
|
|
700
|
+
* This also refreshes the chart by calling invalidate().
|
|
701
|
+
*
|
|
702
|
+
* @param yValue
|
|
703
|
+
* @param axis - which axis should be used as a reference for the y-axis
|
|
704
|
+
*/
|
|
469
705
|
centerViewToY(yValue, axis) {
|
|
470
|
-
const valsInView = this.getAxisRange(axis) / this.
|
|
471
|
-
const job = MoveViewJob.getInstance(this.
|
|
706
|
+
const valsInView = this.getAxisRange(axis) / this.viewPortHandler.getScaleY();
|
|
707
|
+
const job = MoveViewJob.getInstance(this.viewPortHandler, 0, yValue + valsInView / 2, this.getTransformer(axis), this);
|
|
472
708
|
this.addViewportJob(job);
|
|
473
709
|
}
|
|
710
|
+
/**
|
|
711
|
+
* This will move the center of the current viewport to the specified
|
|
712
|
+
* x and y value.
|
|
713
|
+
* This also refreshes the chart by calling invalidate().
|
|
714
|
+
*
|
|
715
|
+
* @param xValue
|
|
716
|
+
* @param yValue
|
|
717
|
+
* @param axis - which axis should be used as a reference for the y axis
|
|
718
|
+
*/
|
|
474
719
|
centerViewTo(xValue, yValue, axis) {
|
|
475
|
-
const yInView = this.getAxisRange(axis) / this.
|
|
476
|
-
const xInView = this.
|
|
477
|
-
const job = MoveViewJob.getInstance(this.
|
|
720
|
+
const yInView = this.getAxisRange(axis) / this.viewPortHandler.getScaleY();
|
|
721
|
+
const xInView = this.xAxis.axisRange / this.viewPortHandler.getScaleX();
|
|
722
|
+
const job = MoveViewJob.getInstance(this.viewPortHandler, xValue - xInView / 2, yValue + yInView / 2, this.getTransformer(axis), this);
|
|
478
723
|
this.addViewportJob(job);
|
|
479
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* This will move the center of the current viewport to the specified
|
|
727
|
+
* x and y value animated.
|
|
728
|
+
*
|
|
729
|
+
* @param xValue
|
|
730
|
+
* @param yValue
|
|
731
|
+
* @param axis
|
|
732
|
+
* @param duration the duration of the animation in milliseconds
|
|
733
|
+
*/
|
|
480
734
|
centerViewToAnimated(xValue, yValue, axis, duration) {
|
|
481
|
-
const bounds = this.getValuesByTouchPoint(this.
|
|
482
|
-
const yInView = this.getAxisRange(axis) / this.
|
|
483
|
-
const xInView = this.
|
|
484
|
-
const job = AnimatedMoveViewJob.getInstance(this.
|
|
735
|
+
const bounds = this.getValuesByTouchPoint(this.viewPortHandler.contentLeft, this.viewPortHandler.contentTop, axis);
|
|
736
|
+
const yInView = this.getAxisRange(axis) / this.viewPortHandler.getScaleY();
|
|
737
|
+
const xInView = this.xAxis.axisRange / this.viewPortHandler.getScaleX();
|
|
738
|
+
const job = AnimatedMoveViewJob.getInstance(this.viewPortHandler, xValue - xInView / 2, yValue + yInView / 2, this.getTransformer(axis), this, bounds.x, bounds.y, duration);
|
|
485
739
|
this.addViewportJob(job);
|
|
486
|
-
|
|
740
|
+
// MPPointD.recycleInstance(bounds);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Sets custom offsets for the current ViewPort (the offsets on the sides of
|
|
744
|
+
* the actual chart window). Setting this will prevent the chart from
|
|
745
|
+
* automatically calculating it's offsets. Use resetViewPortOffsets() to
|
|
746
|
+
* undo this. ONLY USE THIS WHEN YOU KNOW WHAT YOU ARE DOING, else use
|
|
747
|
+
* setExtraOffsets(...).
|
|
748
|
+
*
|
|
749
|
+
* @param left
|
|
750
|
+
* @param top
|
|
751
|
+
* @param right
|
|
752
|
+
* @param bottom
|
|
753
|
+
*/
|
|
487
754
|
setViewPortOffsets(left, top, right, bottom) {
|
|
488
755
|
this.mCustomViewPortEnabled = true;
|
|
489
|
-
|
|
756
|
+
// post(new Runnable() {
|
|
757
|
+
// public run() {
|
|
758
|
+
this.viewPortHandler.restrainViewPort(left, top, right, bottom);
|
|
490
759
|
this.prepareOffsetMatrix();
|
|
491
760
|
this.prepareValuePxMatrix();
|
|
761
|
+
// }
|
|
762
|
+
// });
|
|
492
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Resets all custom offsets set via setViewPortOffsets(...) method. Allows
|
|
766
|
+
* the chart to again calculate all offsets automatically.
|
|
767
|
+
*/
|
|
493
768
|
resetViewPortOffsets() {
|
|
494
769
|
this.mCustomViewPortEnabled = false;
|
|
495
770
|
this.calculateOffsets();
|
|
496
771
|
}
|
|
772
|
+
/**
|
|
773
|
+
* ################ ################ ################ ################
|
|
774
|
+
*/
|
|
775
|
+
/** CODE BELOW IS GETTERS AND SETTERS */
|
|
776
|
+
/**
|
|
777
|
+
* Returns the range of the specified axis.
|
|
778
|
+
*
|
|
779
|
+
* @param axis
|
|
780
|
+
* @return
|
|
781
|
+
*/
|
|
497
782
|
getAxisRange(axis) {
|
|
498
783
|
if (axis === AxisDependency.LEFT)
|
|
499
|
-
return this.mAxisLeft.
|
|
784
|
+
return this.mAxisLeft.axisRange;
|
|
500
785
|
else
|
|
501
|
-
return this.mAxisRight && this.mAxisRight.
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
786
|
+
return this.mAxisRight && this.mAxisRight.axisRange;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Returns a recyclable MPPointF instance.
|
|
790
|
+
* Returns the position (in pixels) the provided Entry has inside the chart
|
|
791
|
+
* view or null, if the provided Entry is null.
|
|
792
|
+
*
|
|
793
|
+
* @param e
|
|
794
|
+
* @return
|
|
795
|
+
*/
|
|
796
|
+
getPosition(e, axis) {
|
|
797
|
+
if (!e)
|
|
798
|
+
return null;
|
|
799
|
+
const pts = Utils.getTempArray(2);
|
|
800
|
+
pts[0] = e.getX();
|
|
801
|
+
pts[1] = e.getY();
|
|
802
|
+
this.getTransformer(axis).pointValuesToPixel(pts);
|
|
803
|
+
return { x: pts[0], y: pts[1] };
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Set this to true to allow highlighting per dragging over the chart
|
|
807
|
+
* surface when it is fully zoomed out. Default: true
|
|
808
|
+
*
|
|
809
|
+
* @param enabled
|
|
810
|
+
*/
|
|
811
|
+
set highlightPerDragEnabled(enabled) {
|
|
510
812
|
this.mHighlightPerDragEnabled = enabled;
|
|
511
813
|
if (enabled) {
|
|
512
814
|
this.getOrCreateBarTouchListener().setPan(true);
|
|
513
815
|
}
|
|
514
|
-
else if (this.
|
|
515
|
-
this.
|
|
816
|
+
else if (this.chartTouchListener) {
|
|
817
|
+
this.chartTouchListener.setPan(false);
|
|
516
818
|
}
|
|
517
819
|
}
|
|
518
|
-
|
|
820
|
+
get highlightPerDragEnabled() {
|
|
519
821
|
return this.mHighlightPerDragEnabled;
|
|
520
822
|
}
|
|
521
|
-
|
|
823
|
+
/**
|
|
824
|
+
* Sets the color for the background of the chart-drawing area (everything
|
|
825
|
+
* behind the grid lines).
|
|
826
|
+
*
|
|
827
|
+
* @param color
|
|
828
|
+
*/
|
|
829
|
+
set gridBackgroundColor(color) {
|
|
522
830
|
this.gridBackgroundPaint.setColor(color);
|
|
523
831
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
832
|
+
/**
|
|
833
|
+
* Set this to true to enable dragging (moving the chart with the finger)
|
|
834
|
+
* for the chart (this does not effect scaling).
|
|
835
|
+
*
|
|
836
|
+
* @param enabled
|
|
837
|
+
*/
|
|
838
|
+
set dragEnabled(enabled) {
|
|
839
|
+
this.dragXEnabled = enabled;
|
|
840
|
+
this.dragYEnabled = enabled;
|
|
527
841
|
if (enabled) {
|
|
528
842
|
this.getOrCreateBarTouchListener().setPan(true);
|
|
529
843
|
}
|
|
530
|
-
else if (this.
|
|
531
|
-
this.
|
|
844
|
+
else if (this.chartTouchListener) {
|
|
845
|
+
this.chartTouchListener.setPan(false);
|
|
532
846
|
}
|
|
533
847
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
this.
|
|
848
|
+
/**
|
|
849
|
+
* Returns true if dragging is enabled for the chart, false if not.
|
|
850
|
+
*/
|
|
851
|
+
get dragEnabled() {
|
|
852
|
+
return this.dragXEnabled || this.dragYEnabled;
|
|
539
853
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
return this.mDragYEnabled;
|
|
548
|
-
}
|
|
549
|
-
setScaleEnabled(enabled) {
|
|
854
|
+
/**
|
|
855
|
+
* Set this to true to enable scaling (zooming in and out by gesture) for
|
|
856
|
+
* the chart (this does not effect dragging) on both X- and Y-Axis.
|
|
857
|
+
*
|
|
858
|
+
* @param enabled
|
|
859
|
+
*/
|
|
860
|
+
set scaleEnabled(enabled) {
|
|
550
861
|
this.mScaleXEnabled = enabled;
|
|
551
862
|
this.mScaleYEnabled = enabled;
|
|
552
863
|
if (enabled) {
|
|
553
864
|
this.getOrCreateBarTouchListener().setPinch(true);
|
|
554
865
|
}
|
|
555
|
-
else if (this.
|
|
556
|
-
this.
|
|
866
|
+
else if (this.chartTouchListener) {
|
|
867
|
+
this.chartTouchListener.setPinch(false);
|
|
557
868
|
}
|
|
558
869
|
}
|
|
559
|
-
|
|
870
|
+
set scaleXEnabled(enabled) {
|
|
560
871
|
this.mScaleXEnabled = enabled;
|
|
561
872
|
if (enabled) {
|
|
562
873
|
this.getOrCreateBarTouchListener().setPinch(true);
|
|
563
874
|
}
|
|
564
|
-
else if (!this.mScaleYEnabled && this.
|
|
565
|
-
this.
|
|
875
|
+
else if (!this.mScaleYEnabled && this.chartTouchListener) {
|
|
876
|
+
this.chartTouchListener.setPinch(false);
|
|
566
877
|
}
|
|
567
878
|
}
|
|
568
|
-
|
|
879
|
+
get scaleXEnabled() {
|
|
880
|
+
return this.mScaleXEnabled;
|
|
881
|
+
}
|
|
882
|
+
set scaleYEnabled(enabled) {
|
|
569
883
|
this.mScaleYEnabled = enabled;
|
|
570
884
|
if (enabled) {
|
|
571
885
|
this.getOrCreateBarTouchListener().setPinch(true);
|
|
572
886
|
}
|
|
573
|
-
else if (!this.mScaleXEnabled && this.
|
|
574
|
-
this.
|
|
887
|
+
else if (!this.mScaleXEnabled && this.chartTouchListener) {
|
|
888
|
+
this.chartTouchListener.setPinch(false);
|
|
575
889
|
}
|
|
576
890
|
}
|
|
577
|
-
|
|
578
|
-
return this.mScaleXEnabled;
|
|
579
|
-
}
|
|
580
|
-
isScaleYEnabled() {
|
|
891
|
+
get scaleYEnabled() {
|
|
581
892
|
return this.mScaleYEnabled;
|
|
582
893
|
}
|
|
583
|
-
|
|
894
|
+
/**
|
|
895
|
+
* Set this to true to enable zooming in by double-tap on the chart.
|
|
896
|
+
* Default: enabled
|
|
897
|
+
*
|
|
898
|
+
* @param enabled
|
|
899
|
+
*/
|
|
900
|
+
set doubleTapToZoomEnabled(enabled) {
|
|
584
901
|
this.mDoubleTapToZoomEnabled = enabled;
|
|
585
902
|
if (enabled) {
|
|
586
903
|
this.getOrCreateBarTouchListener().setDoubleTap(true);
|
|
587
904
|
}
|
|
588
|
-
else if (this.
|
|
589
|
-
this.
|
|
905
|
+
else if (this.chartTouchListener) {
|
|
906
|
+
this.chartTouchListener.setDoubleTap(false);
|
|
590
907
|
}
|
|
591
908
|
}
|
|
592
|
-
|
|
593
|
-
|
|
909
|
+
/**
|
|
910
|
+
* Returns true if zooming via double-tap is enabled false if not.
|
|
911
|
+
*/
|
|
912
|
+
get doubleTapToZoomEnabled() {
|
|
913
|
+
return this.mDoubleTapToZoomEnabled;
|
|
914
|
+
}
|
|
915
|
+
set highlightPerTapEnabled(enabled) {
|
|
916
|
+
this.mHighlightPerTapEnabled = enabled;
|
|
594
917
|
if (enabled) {
|
|
595
918
|
this.getOrCreateBarTouchListener().setTap(true);
|
|
596
919
|
}
|
|
597
|
-
else if (this.
|
|
598
|
-
this.
|
|
920
|
+
else if (this.chartTouchListener) {
|
|
921
|
+
this.chartTouchListener.setTap(false);
|
|
599
922
|
}
|
|
600
923
|
}
|
|
601
|
-
|
|
602
|
-
return this.
|
|
603
|
-
}
|
|
604
|
-
setDrawGridBackground(enabled) {
|
|
605
|
-
this.mDrawGridBackground = enabled;
|
|
606
|
-
}
|
|
607
|
-
setDrawBorders(enabled) {
|
|
608
|
-
this.mDrawBorders = enabled;
|
|
609
|
-
}
|
|
610
|
-
isDrawBordersEnabled() {
|
|
611
|
-
return this.mDrawBorders;
|
|
612
|
-
}
|
|
613
|
-
setClipValuesToContent(enabled) {
|
|
614
|
-
this.mClipValuesToContent = enabled;
|
|
615
|
-
}
|
|
616
|
-
isClipValuesToContentEnabled() {
|
|
617
|
-
return this.mClipValuesToContent;
|
|
618
|
-
}
|
|
619
|
-
setClipDataToContent(enabled) {
|
|
620
|
-
this.mClipDataToContent = enabled;
|
|
621
|
-
}
|
|
622
|
-
isClipDataToContentEnabled() {
|
|
623
|
-
return this.mClipDataToContent;
|
|
624
|
-
}
|
|
625
|
-
setDrawHighlight(enabled) {
|
|
626
|
-
this.mDrawHighlight = enabled;
|
|
627
|
-
}
|
|
628
|
-
isDrawHighlightEnabled() {
|
|
629
|
-
return this.mDrawHighlight;
|
|
924
|
+
get highlightPerTapEnabled() {
|
|
925
|
+
return this.mHighlightPerTapEnabled;
|
|
630
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* Sets the width of the border lines in dp.
|
|
929
|
+
*
|
|
930
|
+
* @param width
|
|
931
|
+
*/
|
|
631
932
|
setBorderWidth(width) {
|
|
632
933
|
this.borderPaint.setStrokeWidth(width);
|
|
633
934
|
}
|
|
935
|
+
/**
|
|
936
|
+
* Sets the color of the chart border lines.
|
|
937
|
+
*
|
|
938
|
+
* @param color
|
|
939
|
+
*/
|
|
634
940
|
setBorderColor(color) {
|
|
635
941
|
this.borderPaint.setColor(color);
|
|
636
942
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
943
|
+
/**
|
|
944
|
+
* Returns a recyclable MPPointD instance
|
|
945
|
+
* Returns the x and y values in the chart at the given touch point
|
|
946
|
+
* (encapsulated in a MPPointD). This method transforms pixel coordinates to
|
|
947
|
+
* coordinates / values in the chart. This is the opposite method to
|
|
948
|
+
* getPixelForValues(...).
|
|
949
|
+
*
|
|
950
|
+
* @param x
|
|
951
|
+
* @param y
|
|
952
|
+
* @return
|
|
953
|
+
*/
|
|
954
|
+
// public getValuesByTouchPoint( x ,y, axis) {
|
|
955
|
+
// const result = {x:0, y:0};
|
|
956
|
+
// this.getValuesByTouchPoint(x, y, axis, result);
|
|
957
|
+
// return result;
|
|
958
|
+
// }
|
|
649
959
|
getValuesByTouchPoint(x, y, axis) {
|
|
650
960
|
return this.getTransformer(axis).getValuesByTouchPoint(x, y);
|
|
651
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* Returns a recyclable MPPointD instance
|
|
964
|
+
* Transforms the given chart values into pixels. This is the opposite
|
|
965
|
+
* method to getValuesByTouchPoint(...).
|
|
966
|
+
*
|
|
967
|
+
* @param x
|
|
968
|
+
* @param y
|
|
969
|
+
* @return
|
|
970
|
+
*/
|
|
652
971
|
getPixelForValues(x, y, axis) {
|
|
653
972
|
return this.getTransformer(axis).getPixelForValues(x, y);
|
|
654
973
|
}
|
|
974
|
+
/**
|
|
975
|
+
* Returns a recyclable MPPointD instance
|
|
976
|
+
* Transforms the given chart values into pixels. This is the opposite
|
|
977
|
+
* method to getValuesByTouchPoint(...).
|
|
978
|
+
*
|
|
979
|
+
* @param set
|
|
980
|
+
* @param entry
|
|
981
|
+
* @param entry
|
|
982
|
+
* @return
|
|
983
|
+
*/
|
|
984
|
+
getPixelForEntry(set, entry, index) {
|
|
985
|
+
const xVal = set.getEntryXValue(entry, index);
|
|
986
|
+
return this.getTransformer(set.axisDependency).getPixelForValues(xVal, set.getEntryYValue(entry));
|
|
987
|
+
// return this.getTransformer(axis).getPixelForValues(x, y);
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* returns the Entry object displayed at the touched position of the chart
|
|
991
|
+
*
|
|
992
|
+
* @param x
|
|
993
|
+
* @param y
|
|
994
|
+
* @return
|
|
995
|
+
*/
|
|
655
996
|
getEntryByTouchPoint(x, y) {
|
|
656
997
|
const h = this.getHighlightByTouchPoint(x, y);
|
|
657
|
-
if (h
|
|
998
|
+
if (h) {
|
|
658
999
|
return this.mData.getEntryForHighlight(h);
|
|
659
1000
|
}
|
|
660
1001
|
return null;
|
|
661
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* returns the DataSet object displayed at the touched position of the chart
|
|
1005
|
+
*
|
|
1006
|
+
* @param x
|
|
1007
|
+
* @param y
|
|
1008
|
+
* @return
|
|
1009
|
+
*/
|
|
662
1010
|
getDataSetByTouchPoint(x, y) {
|
|
663
1011
|
const h = this.getHighlightByTouchPoint(x, y);
|
|
664
|
-
if (h
|
|
1012
|
+
if (h) {
|
|
665
1013
|
return this.mData.getDataSetByIndex(h.dataSetIndex);
|
|
666
1014
|
}
|
|
667
1015
|
return null;
|
|
668
1016
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
1017
|
+
/**
|
|
1018
|
+
* Returns the lowest x-index (value on the x-axis) that is still visible on
|
|
1019
|
+
* the chart.
|
|
1020
|
+
*/
|
|
1021
|
+
get lowestVisibleX() {
|
|
1022
|
+
this.transformer.getValuesByTouchPoint(this.viewPortHandler.contentLeft, this.viewPortHandler.contentBottom, this.posForGetLowestVisibleX);
|
|
1023
|
+
const result = Math.max(this.xAxis.axisMinimum, this.posForGetLowestVisibleX.x);
|
|
672
1024
|
return result;
|
|
673
1025
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
1026
|
+
/**
|
|
1027
|
+
* Returns the highest x-index (value on the x-axis) that is still visible
|
|
1028
|
+
* on the chart.
|
|
1029
|
+
*/
|
|
1030
|
+
get highestVisibleX() {
|
|
1031
|
+
this.transformer.getValuesByTouchPoint(this.viewPortHandler.contentRight, this.viewPortHandler.contentBottom, this.posForGetHighestVisibleX);
|
|
1032
|
+
const result = Math.min(this.xAxis.axisMaximum, this.posForGetHighestVisibleX.x);
|
|
677
1033
|
return result;
|
|
678
1034
|
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Returns the range visible on the x-axis.
|
|
1037
|
+
*/
|
|
679
1038
|
getVisibleXRange() {
|
|
680
|
-
return Math.abs(this.
|
|
1039
|
+
return Math.abs(this.highestVisibleX - this.lowestVisibleX);
|
|
681
1040
|
}
|
|
1041
|
+
/**
|
|
1042
|
+
* returns the current x-scale factor
|
|
1043
|
+
*/
|
|
682
1044
|
getScaleX() {
|
|
683
|
-
if (this.
|
|
1045
|
+
if (this.viewPortHandler == null)
|
|
684
1046
|
return 1;
|
|
685
1047
|
else
|
|
686
|
-
return this.
|
|
1048
|
+
return this.viewPortHandler.getScaleX();
|
|
687
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* returns the current y-scale factor
|
|
1052
|
+
*/
|
|
688
1053
|
getScaleY() {
|
|
689
|
-
if (this.
|
|
1054
|
+
if (this.viewPortHandler == null)
|
|
690
1055
|
return 1;
|
|
691
1056
|
else
|
|
692
|
-
return this.
|
|
1057
|
+
return this.viewPortHandler.getScaleY();
|
|
693
1058
|
}
|
|
1059
|
+
/**
|
|
1060
|
+
* if the chart is fully zoomed out, return true
|
|
1061
|
+
*/
|
|
694
1062
|
isFullyZoomedOut() {
|
|
695
|
-
return this.
|
|
1063
|
+
return this.viewPortHandler.isFullyZoomedOut();
|
|
696
1064
|
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Returns the left y-axis object. In the horizontal bar-chart, this is the
|
|
1067
|
+
* top axis.
|
|
1068
|
+
*/
|
|
1069
|
+
get leftAxis() {
|
|
1070
|
+
return this.mAxisLeft;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* @deprecated use leftAxis
|
|
1074
|
+
*/
|
|
697
1075
|
get axisLeft() {
|
|
698
1076
|
return this.mAxisLeft;
|
|
699
1077
|
}
|
|
700
|
-
|
|
1078
|
+
/**
|
|
1079
|
+
* Returns the right y-axis object. In the horizontal bar-chart, this is the
|
|
1080
|
+
* bottom axis.
|
|
1081
|
+
*/
|
|
1082
|
+
get rightAxis() {
|
|
701
1083
|
if (!this.mAxisRight) {
|
|
702
|
-
this.mAxisRight = new YAxis(AxisDependency.RIGHT);
|
|
703
|
-
this.
|
|
704
|
-
this.
|
|
1084
|
+
this.mAxisRight = new YAxis(AxisDependency.RIGHT, new WeakRef(this));
|
|
1085
|
+
this.rightAxisTransformer = new Transformer(this.viewPortHandler);
|
|
1086
|
+
this.rendererRightYAxis = new YAxisRenderer(this.viewPortHandler, this.mAxisRight, this.rightAxisTransformer);
|
|
705
1087
|
}
|
|
706
1088
|
return this.mAxisRight;
|
|
707
1089
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
return this.
|
|
713
|
-
}
|
|
1090
|
+
/**
|
|
1091
|
+
* @deprecated use rightAxis
|
|
1092
|
+
*/
|
|
1093
|
+
get axisRight() {
|
|
1094
|
+
return this.rightAxis;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Returns the y-axis object to the corresponding AxisDependency. In the
|
|
1098
|
+
* horizontal bar-chart, LEFT == top, RIGHT == BOTTOM
|
|
1099
|
+
*
|
|
1100
|
+
* @param axis
|
|
1101
|
+
* @return
|
|
1102
|
+
*/
|
|
714
1103
|
getAxis(axis) {
|
|
715
1104
|
if (axis === AxisDependency.LEFT)
|
|
716
1105
|
return this.mAxisLeft;
|
|
@@ -718,88 +1107,80 @@ export class BarLineChartBase extends Chart {
|
|
|
718
1107
|
return this.mAxisRight;
|
|
719
1108
|
}
|
|
720
1109
|
isInverted(axis) {
|
|
721
|
-
return this.getAxis(axis).
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
1110
|
+
return this.getAxis(axis).inverted;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Set an offset in dp that allows the user to drag the chart over it's
|
|
1114
|
+
* bounds on the x-axis.
|
|
1115
|
+
*
|
|
1116
|
+
* @param offset
|
|
1117
|
+
*/
|
|
729
1118
|
setDragOffsetX(offset) {
|
|
730
|
-
this.
|
|
731
|
-
}
|
|
1119
|
+
this.viewPortHandler.setDragOffsetX(offset);
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Set an offset in dp that allows the user to drag the chart over it's
|
|
1123
|
+
* bounds on the y-axis.
|
|
1124
|
+
*
|
|
1125
|
+
* @param offset
|
|
1126
|
+
*/
|
|
732
1127
|
setDragOffsetY(offset) {
|
|
733
|
-
this.
|
|
1128
|
+
this.viewPortHandler.setDragOffsetY(offset);
|
|
734
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Returns true if both drag offsets (x and y) are zero or smaller.
|
|
1132
|
+
*/
|
|
735
1133
|
hasNoDragOffset() {
|
|
736
|
-
return this.
|
|
737
|
-
}
|
|
738
|
-
getRendererXAxis() {
|
|
739
|
-
return this.mXAxisRenderer;
|
|
1134
|
+
return this.viewPortHandler.hasNoDragOffset();
|
|
740
1135
|
}
|
|
741
|
-
|
|
742
|
-
this.mXAxisRenderer = xAxisRenderer;
|
|
743
|
-
}
|
|
744
|
-
getRendererLeftYAxis() {
|
|
745
|
-
return this.mAxisRendererLeft;
|
|
746
|
-
}
|
|
747
|
-
setRendererLeftYAxis(rendererLeftYAxis) {
|
|
748
|
-
this.mAxisRendererLeft = rendererLeftYAxis;
|
|
749
|
-
}
|
|
750
|
-
getRendererRightYAxis() {
|
|
751
|
-
return this.mAxisRendererRight;
|
|
752
|
-
}
|
|
753
|
-
setRendererRightYAxis(rendererRightYAxis) {
|
|
754
|
-
this.mAxisRendererRight = rendererRightYAxis;
|
|
755
|
-
}
|
|
756
|
-
getYChartMax() {
|
|
1136
|
+
get yChartMax() {
|
|
757
1137
|
let max = -Infinity;
|
|
758
|
-
if (this.mAxisLeft.
|
|
759
|
-
max = Math.max(this.mAxisLeft.
|
|
1138
|
+
if (this.mAxisLeft.enabled) {
|
|
1139
|
+
max = Math.max(this.mAxisLeft.axisMaximum, max);
|
|
760
1140
|
}
|
|
761
|
-
if (this.mAxisRight
|
|
762
|
-
max = Math.max(this.mAxisRight.
|
|
1141
|
+
if (this.mAxisRight?.enabled) {
|
|
1142
|
+
max = Math.max(this.mAxisRight.axisMaximum, max);
|
|
763
1143
|
}
|
|
764
1144
|
return max;
|
|
765
1145
|
}
|
|
766
|
-
|
|
1146
|
+
get yChartMin() {
|
|
767
1147
|
let min = Infinity;
|
|
768
|
-
if (this.mAxisLeft.
|
|
769
|
-
min = Math.min(this.mAxisLeft.
|
|
1148
|
+
if (this.mAxisLeft.enabled) {
|
|
1149
|
+
min = Math.min(this.mAxisLeft.axisMinimum, min);
|
|
770
1150
|
}
|
|
771
|
-
if (this.mAxisRight
|
|
772
|
-
min = Math.min(this.mAxisRight.
|
|
1151
|
+
if (this.mAxisRight?.enabled) {
|
|
1152
|
+
min = Math.min(this.mAxisRight.axisMinimum, min);
|
|
773
1153
|
}
|
|
774
1154
|
return min;
|
|
775
1155
|
}
|
|
776
|
-
|
|
777
|
-
|
|
1156
|
+
/**
|
|
1157
|
+
* Returns true if either the left or the right or both axes are inverted.
|
|
1158
|
+
*/
|
|
1159
|
+
get anyAxisInverted() {
|
|
1160
|
+
if (this.mAxisLeft.enabled && this.mAxisLeft.inverted)
|
|
778
1161
|
return true;
|
|
779
|
-
if (this.mAxisRight && this.mAxisRight.
|
|
1162
|
+
if (this.mAxisRight?.enabled && this.mAxisRight.inverted)
|
|
780
1163
|
return true;
|
|
781
1164
|
return false;
|
|
782
1165
|
}
|
|
783
|
-
setAutoScaleMinMaxEnabled(enabled) {
|
|
784
|
-
this.mAutoScaleMinMaxEnabled = enabled;
|
|
785
|
-
}
|
|
786
|
-
isAutoScaleMinMaxEnabled() {
|
|
787
|
-
return this.mAutoScaleMinMaxEnabled;
|
|
788
|
-
}
|
|
789
1166
|
onSizeChanged(w, h, oldw, oldh) {
|
|
1167
|
+
// Saving current position of chart.
|
|
790
1168
|
this.mOnSizeChangedBuffer[0] = this.mOnSizeChangedBuffer[1] = 0;
|
|
791
|
-
if (this.
|
|
792
|
-
this.mOnSizeChangedBuffer[0] = this.
|
|
793
|
-
this.mOnSizeChangedBuffer[1] = this.
|
|
794
|
-
this.
|
|
1169
|
+
if (this.keepPositionOnRotation) {
|
|
1170
|
+
this.mOnSizeChangedBuffer[0] = this.viewPortHandler.contentLeft;
|
|
1171
|
+
this.mOnSizeChangedBuffer[1] = this.viewPortHandler.contentTop;
|
|
1172
|
+
this.transformer.pixelsToValue(this.mOnSizeChangedBuffer);
|
|
795
1173
|
}
|
|
1174
|
+
//Superclass transforms chart.
|
|
796
1175
|
super.onSizeChanged(w, h, oldw, oldh);
|
|
797
|
-
if (this.
|
|
798
|
-
|
|
799
|
-
this.
|
|
1176
|
+
if (this.keepPositionOnRotation) {
|
|
1177
|
+
//Restoring old position of chart.
|
|
1178
|
+
this.transformer.pointValuesToPixel(this.mOnSizeChangedBuffer);
|
|
1179
|
+
this.viewPortHandler.centerViewPort(this.mOnSizeChangedBuffer, this);
|
|
800
1180
|
}
|
|
801
1181
|
else {
|
|
802
|
-
|
|
1182
|
+
// a resize of the view will redraw the view anyway?
|
|
1183
|
+
this.viewPortHandler.refresh(this.viewPortHandler.getMatrixTouch(), this, false);
|
|
803
1184
|
}
|
|
804
1185
|
}
|
|
805
1186
|
addEventListener(arg, callback, thisArg) {
|
|
@@ -842,17 +1223,17 @@ export class BarLineChartBase extends Chart {
|
|
|
842
1223
|
if (events.length > 0) {
|
|
843
1224
|
for (let i = 0; i < events.length; i++) {
|
|
844
1225
|
const evt = events[i].trim();
|
|
845
|
-
if (arg === 'tap' && !this.
|
|
846
|
-
this.
|
|
1226
|
+
if (arg === 'tap' && !this.highlightPerTapEnabled) {
|
|
1227
|
+
this.chartTouchListener && this.chartTouchListener.setTap(false);
|
|
847
1228
|
}
|
|
848
|
-
else if (arg === 'doubleTap' && !this.
|
|
849
|
-
this.
|
|
1229
|
+
else if (arg === 'doubleTap' && !this.doubleTapToZoomEnabled) {
|
|
1230
|
+
this.chartTouchListener && this.chartTouchListener.setDoubleTap(false);
|
|
850
1231
|
}
|
|
851
|
-
else if (arg === 'pan' && !this.
|
|
852
|
-
this.
|
|
1232
|
+
else if (arg === 'pan' && !this.highlightPerDragEnabled && !this.dragEnabled) {
|
|
1233
|
+
this.chartTouchListener && this.chartTouchListener.setPan(false);
|
|
853
1234
|
}
|
|
854
|
-
else if (arg === 'pinch' && !this.
|
|
855
|
-
this.
|
|
1235
|
+
else if (arg === 'pinch' && !this.pinchZoomEnabled) {
|
|
1236
|
+
this.chartTouchListener && this.chartTouchListener.setPinch(false);
|
|
856
1237
|
}
|
|
857
1238
|
Observable.prototype.removeEventListener.call(this, evt, callback, thisArg);
|
|
858
1239
|
}
|