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