@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.
Files changed (365) hide show
  1. package/README.md +6 -0
  2. package/animation/ChartAnimator.d.ts +47 -4
  3. package/animation/ChartAnimator.js +49 -11
  4. package/animation/ChartAnimator.js.map +1 -1
  5. package/animation/Tween.d.ts +1 -1
  6. package/animation/Tween.js +4 -2
  7. package/animation/Tween.js.map +1 -1
  8. package/buffer/AbstractBuffer.d.ts +28 -3
  9. package/buffer/AbstractBuffer.js +22 -3
  10. package/buffer/AbstractBuffer.js.map +1 -1
  11. package/buffer/BarBuffer.d.ts +8 -12
  12. package/buffer/BarBuffer.js +33 -36
  13. package/buffer/BarBuffer.js.map +1 -1
  14. package/buffer/HorizontalBarBuffer.js +13 -10
  15. package/buffer/HorizontalBarBuffer.js.map +1 -1
  16. package/charts/BarChart.d.ts +70 -15
  17. package/charts/BarChart.js +92 -63
  18. package/charts/BarChart.js.map +1 -1
  19. package/charts/BarLineChartBase.d.ts +494 -73
  20. package/charts/BarLineChartBase.js +788 -407
  21. package/charts/BarLineChartBase.js.map +1 -1
  22. package/charts/BubbleChart.d.ts +11 -5
  23. package/charts/BubbleChart.js +10 -8
  24. package/charts/BubbleChart.js.map +1 -1
  25. package/charts/CandleStickChart.d.ts +8 -5
  26. package/charts/CandleStickChart.js +9 -10
  27. package/charts/CandleStickChart.js.map +1 -1
  28. package/charts/Chart.d.ts +420 -91
  29. package/charts/Chart.js +590 -290
  30. package/charts/Chart.js.map +1 -1
  31. package/charts/CombinedChart.d.ts +59 -29
  32. package/charts/CombinedChart.js +74 -67
  33. package/charts/CombinedChart.js.map +1 -1
  34. package/charts/HorizontalBarChart.d.ts +37 -7
  35. package/charts/HorizontalBarChart.js +97 -59
  36. package/charts/HorizontalBarChart.js.map +1 -1
  37. package/charts/LineChart.d.ts +3 -5
  38. package/charts/LineChart.js +6 -10
  39. package/charts/LineChart.js.map +1 -1
  40. package/charts/PieChart.d.ts +218 -64
  41. package/charts/PieChart.js +278 -168
  42. package/charts/PieChart.js.map +1 -1
  43. package/charts/PieRadarChartBase.d.ts +107 -18
  44. package/charts/PieRadarChartBase.js +156 -73
  45. package/charts/PieRadarChartBase.js.map +1 -1
  46. package/charts/RadarChart.d.ts +75 -35
  47. package/charts/RadarChart.js +114 -103
  48. package/charts/RadarChart.js.map +1 -1
  49. package/charts/ScatterChart.d.ts +10 -5
  50. package/charts/ScatterChart.js +11 -10
  51. package/charts/ScatterChart.js.map +1 -1
  52. package/components/AxisBase.d.ts +271 -101
  53. package/components/AxisBase.js +264 -254
  54. package/components/AxisBase.js.map +1 -1
  55. package/components/ComponentBase.d.ts +54 -19
  56. package/components/ComponentBase.js +60 -48
  57. package/components/ComponentBase.js.map +1 -1
  58. package/components/Description.d.ts +18 -9
  59. package/components/Description.js +12 -26
  60. package/components/Description.js.map +1 -1
  61. package/components/IMarker.d.ts +30 -1
  62. package/components/IMarker.js.map +1 -1
  63. package/components/Legend.d.ts +155 -58
  64. package/components/Legend.js +208 -172
  65. package/components/Legend.js.map +1 -1
  66. package/components/LegendEntry.d.ts +38 -0
  67. package/components/LegendEntry.js +34 -0
  68. package/components/LegendEntry.js.map +1 -1
  69. package/components/LimitLine.d.ts +40 -22
  70. package/components/LimitLine.js +44 -56
  71. package/components/LimitLine.js.map +1 -1
  72. package/components/MarkerImage.d.ts +1 -0
  73. package/components/MarkerImage.js +97 -0
  74. package/components/MarkerImage.js.map +1 -0
  75. package/components/XAxis.d.ts +41 -10
  76. package/components/XAxis.js +42 -24
  77. package/components/XAxis.js.map +1 -1
  78. package/components/YAxis.d.ts +114 -37
  79. package/components/YAxis.js +138 -106
  80. package/components/YAxis.js.map +1 -1
  81. package/data/BarData.d.ts +32 -4
  82. package/data/BarData.js +92 -24
  83. package/data/BarData.js.map +1 -1
  84. package/data/BarDataSet.d.ts +35 -18
  85. package/data/BarDataSet.js +42 -47
  86. package/data/BarDataSet.js.map +1 -1
  87. package/data/BarEntry.d.ts +3 -0
  88. package/data/BarEntry.js.map +1 -1
  89. package/data/BarLineScatterCandleBubbleData.d.ts +5 -0
  90. package/data/BarLineScatterCandleBubbleData.js +5 -0
  91. package/data/BarLineScatterCandleBubbleData.js.map +1 -1
  92. package/data/BarLineScatterCandleBubbleDataSet.d.ts +11 -3
  93. package/data/BarLineScatterCandleBubbleDataSet.js +11 -7
  94. package/data/BarLineScatterCandleBubbleDataSet.js.map +1 -1
  95. package/data/BaseDataSet.d.ts +129 -71
  96. package/data/BaseDataSet.js +146 -169
  97. package/data/BaseDataSet.js.map +1 -1
  98. package/data/BaseEntry.d.ts +3 -0
  99. package/data/BaseEntry.js.map +1 -1
  100. package/data/BubbleData.d.ts +7 -1
  101. package/data/BubbleData.js +8 -2
  102. package/data/BubbleData.js.map +1 -1
  103. package/data/BubbleDataSet.d.ts +7 -7
  104. package/data/BubbleDataSet.js +8 -15
  105. package/data/BubbleDataSet.js.map +1 -1
  106. package/data/BubbleEntry.d.ts +1 -0
  107. package/data/BubbleEntry.js.map +1 -1
  108. package/data/CandleData.js.map +1 -1
  109. package/data/CandleDataSet.d.ts +64 -30
  110. package/data/CandleDataSet.js +67 -74
  111. package/data/CandleDataSet.js.map +1 -1
  112. package/data/CandleEntry.d.ts +4 -0
  113. package/data/CandleEntry.js.map +1 -1
  114. package/data/ChartData.d.ts +275 -20
  115. package/data/ChartData.js +400 -95
  116. package/data/ChartData.js.map +1 -1
  117. package/data/CombinedData.d.ts +39 -12
  118. package/data/CombinedData.js +87 -71
  119. package/data/CombinedData.js.map +1 -1
  120. package/data/DataSet.d.ts +59 -8
  121. package/data/DataSet.js +114 -26
  122. package/data/DataSet.js.map +1 -1
  123. package/data/Entry.js.map +1 -1
  124. package/data/LineData.d.ts +5 -0
  125. package/data/LineData.js +5 -0
  126. package/data/LineData.js.map +1 -1
  127. package/data/LineDataSet.d.ts +84 -49
  128. package/data/LineDataSet.js +94 -135
  129. package/data/LineDataSet.js.map +1 -1
  130. package/data/LineRadarDataSet.d.ts +27 -17
  131. package/data/LineRadarDataSet.js +22 -35
  132. package/data/LineRadarDataSet.js.map +1 -1
  133. package/data/LineScatterCandleRadarDataSet.d.ts +30 -15
  134. package/data/LineScatterCandleRadarDataSet.js +36 -39
  135. package/data/LineScatterCandleRadarDataSet.js.map +1 -1
  136. package/data/PieData.d.ts +26 -0
  137. package/data/PieData.js +28 -2
  138. package/data/PieData.js.map +1 -1
  139. package/data/PieDataSet.d.ts +40 -36
  140. package/data/PieDataSet.js +36 -88
  141. package/data/PieDataSet.js.map +1 -1
  142. package/data/PieEntry.d.ts +3 -0
  143. package/data/PieEntry.js.map +1 -1
  144. package/data/RadarData.d.ts +10 -4
  145. package/data/RadarData.js +5 -6
  146. package/data/RadarData.js.map +1 -1
  147. package/data/RadarDataSet.d.ts +7 -21
  148. package/data/RadarDataSet.js +10 -49
  149. package/data/RadarDataSet.js.map +1 -1
  150. package/data/RadarEntry.js.map +1 -1
  151. package/data/ScatterData.d.ts +4 -1
  152. package/data/ScatterData.js +5 -2
  153. package/data/ScatterData.js.map +1 -1
  154. package/data/ScatterDataSet.d.ts +24 -14
  155. package/data/ScatterDataSet.js +26 -31
  156. package/data/ScatterDataSet.js.map +1 -1
  157. package/formatter/DefaultAxisValueFormatter.d.ts +17 -3
  158. package/formatter/DefaultAxisValueFormatter.js +12 -5
  159. package/formatter/DefaultAxisValueFormatter.js.map +1 -1
  160. package/formatter/DefaultFillFormatter.js +7 -7
  161. package/formatter/DefaultFillFormatter.js.map +1 -1
  162. package/formatter/DefaultValueFormatter.js.map +1 -1
  163. package/formatter/IAxisValueFormatter.d.ts +20 -2
  164. package/formatter/IAxisValueFormatter.js.map +1 -1
  165. package/formatter/IFillFormatter.d.ts +25 -0
  166. package/formatter/IFillFormatter.js.map +1 -1
  167. package/formatter/IValueFormatter.d.ts +21 -0
  168. package/formatter/IValueFormatter.js.map +1 -1
  169. package/formatter/ValueFormatter.d.ts +60 -0
  170. package/formatter/ValueFormatter.js +60 -0
  171. package/formatter/ValueFormatter.js.map +1 -1
  172. package/highlight/BarHighlighter.d.ts +22 -2
  173. package/highlight/BarHighlighter.js +43 -17
  174. package/highlight/BarHighlighter.js.map +1 -1
  175. package/highlight/ChartHighlighter.d.ts +87 -5
  176. package/highlight/ChartHighlighter.js +129 -25
  177. package/highlight/ChartHighlighter.js.map +1 -1
  178. package/highlight/CombinedHighlighter.d.ts +6 -0
  179. package/highlight/CombinedHighlighter.js +31 -16
  180. package/highlight/CombinedHighlighter.js.map +1 -1
  181. package/highlight/Highlight.d.ts +54 -1
  182. package/highlight/Highlight.js +5 -0
  183. package/highlight/Highlight.js.map +1 -1
  184. package/highlight/HorizontalBarHighlighter.d.ts +1 -1
  185. package/highlight/HorizontalBarHighlighter.js +14 -13
  186. package/highlight/HorizontalBarHighlighter.js.map +1 -1
  187. package/highlight/IHighlighter.d.ts +11 -1
  188. package/highlight/IHighlighter.js.map +1 -1
  189. package/highlight/PieHighlighter.js +2 -2
  190. package/highlight/PieHighlighter.js.map +1 -1
  191. package/highlight/PieRadarHighlighter.d.ts +12 -1
  192. package/highlight/PieRadarHighlighter.js +12 -4
  193. package/highlight/PieRadarHighlighter.js.map +1 -1
  194. package/highlight/RadarHighlighter.d.ts +12 -0
  195. package/highlight/RadarHighlighter.js +24 -10
  196. package/highlight/RadarHighlighter.js.map +1 -1
  197. package/index.d.ts +11 -0
  198. package/index.js +15 -0
  199. package/index.js.map +1 -0
  200. package/interfaces/dataprovider/BarDataProvider.d.ts +4 -4
  201. package/interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider.d.ts +8 -3
  202. package/interfaces/dataprovider/BubbleDataProvider.d.ts +1 -1
  203. package/interfaces/dataprovider/CandleDataProvider.d.ts +1 -1
  204. package/interfaces/dataprovider/ChartInterface.d.ts +17 -22
  205. package/interfaces/dataprovider/CombinedDataProvider.d.ts +1 -1
  206. package/interfaces/dataprovider/LineDataProvider.d.ts +1 -1
  207. package/interfaces/dataprovider/ScatterDataProvider.d.ts +1 -1
  208. package/interfaces/datasets/IBarDataSet.d.ts +8 -22
  209. package/interfaces/datasets/IBarLineScatterCandleBubbleDataSet.d.ts +1 -3
  210. package/interfaces/datasets/IBubbleDataSet.d.ts +3 -9
  211. package/interfaces/datasets/ICandleDataSet.d.ts +44 -41
  212. package/interfaces/datasets/IDataSet.d.ts +35 -151
  213. package/interfaces/datasets/ILineDataSet.d.ts +15 -54
  214. package/interfaces/datasets/ILineRadarDataSet.d.ts +7 -28
  215. package/interfaces/datasets/ILineScatterCandleRadarDataSet.d.ts +5 -4
  216. package/interfaces/datasets/IPieDataSet.d.ts +22 -40
  217. package/interfaces/datasets/IRadarDataSet.d.ts +7 -13
  218. package/interfaces/datasets/IScatterDataSet.d.ts +17 -16
  219. package/jobs/AnimatedMoveViewJob.d.ts +3 -0
  220. package/jobs/AnimatedMoveViewJob.js +12 -8
  221. package/jobs/AnimatedMoveViewJob.js.map +1 -1
  222. package/jobs/AnimatedViewPortJob.d.ts +7 -8
  223. package/jobs/AnimatedViewPortJob.js +16 -23
  224. package/jobs/AnimatedViewPortJob.js.map +1 -1
  225. package/jobs/AnimatedZoomJob.d.ts +8 -5
  226. package/jobs/AnimatedZoomJob.js +30 -26
  227. package/jobs/AnimatedZoomJob.js.map +1 -1
  228. package/jobs/MoveViewJob.d.ts +3 -0
  229. package/jobs/MoveViewJob.js +10 -7
  230. package/jobs/MoveViewJob.js.map +1 -1
  231. package/jobs/ViewPortJob.d.ts +3 -5
  232. package/jobs/ViewPortJob.js +5 -11
  233. package/jobs/ViewPortJob.js.map +1 -1
  234. package/jobs/ZoomJob.js +14 -14
  235. package/jobs/ZoomJob.js.map +1 -1
  236. package/listener/BarLineChartTouchListener.d.ts +82 -1
  237. package/listener/BarLineChartTouchListener.js +169 -67
  238. package/listener/BarLineChartTouchListener.js.map +1 -1
  239. package/listener/ChartTouchListener.d.ts +39 -5
  240. package/listener/ChartTouchListener.js +38 -11
  241. package/listener/ChartTouchListener.js.map +1 -1
  242. package/listener/PieRadarChartTouchListener.d.ts +56 -1
  243. package/listener/PieRadarChartTouchListener.js +201 -17
  244. package/listener/PieRadarChartTouchListener.js.map +1 -1
  245. package/model/GradientColor.js.map +1 -1
  246. package/package.json +23 -15
  247. package/renderer/AxisRenderer.d.ts +66 -7
  248. package/renderer/AxisRenderer.js +69 -21
  249. package/renderer/AxisRenderer.js.map +1 -1
  250. package/renderer/BarChartRenderer.d.ts +11 -0
  251. package/renderer/BarChartRenderer.js +99 -71
  252. package/renderer/BarChartRenderer.js.map +1 -1
  253. package/renderer/BarLineScatterCandleBubbleRenderer.d.ts +37 -0
  254. package/renderer/BarLineScatterCandleBubbleRenderer.js +36 -8
  255. package/renderer/BarLineScatterCandleBubbleRenderer.js.map +1 -1
  256. package/renderer/BubbleChartRenderer.d.ts +6 -2
  257. package/renderer/BubbleChartRenderer.js +51 -40
  258. package/renderer/BubbleChartRenderer.js.map +1 -1
  259. package/renderer/CandleStickChartRenderer.d.ts +1 -1
  260. package/renderer/CandleStickChartRenderer.js +64 -50
  261. package/renderer/CandleStickChartRenderer.js.map +1 -1
  262. package/renderer/CombinedChartRenderer.d.ts +20 -1
  263. package/renderer/CombinedChartRenderer.js +72 -42
  264. package/renderer/CombinedChartRenderer.js.map +1 -1
  265. package/renderer/DataRenderer.d.ts +78 -4
  266. package/renderer/DataRenderer.js +65 -6
  267. package/renderer/DataRenderer.js.map +1 -1
  268. package/renderer/HorizontalBarChartRenderer.d.ts +5 -2
  269. package/renderer/HorizontalBarChartRenderer.js +87 -66
  270. package/renderer/HorizontalBarChartRenderer.js.map +1 -1
  271. package/renderer/LegendRenderer.d.ts +32 -0
  272. package/renderer/LegendRenderer.js +98 -59
  273. package/renderer/LegendRenderer.js.map +1 -1
  274. package/renderer/LineChartRenderer.d.ts +38 -1
  275. package/renderer/LineChartRenderer.js +198 -113
  276. package/renderer/LineChartRenderer.js.map +1 -1
  277. package/renderer/LineRadarRenderer.d.ts +19 -0
  278. package/renderer/LineRadarRenderer.js +25 -1
  279. package/renderer/LineRadarRenderer.js.map +1 -1
  280. package/renderer/LineScatterCandleRadarRenderer.d.ts +11 -0
  281. package/renderer/LineScatterCandleRadarRenderer.js +26 -9
  282. package/renderer/LineScatterCandleRadarRenderer.js.map +1 -1
  283. package/renderer/PieChartRenderer.d.ts +45 -1
  284. package/renderer/PieChartRenderer.js +195 -122
  285. package/renderer/PieChartRenderer.js.map +1 -1
  286. package/renderer/RadarChartRenderer.d.ts +10 -0
  287. package/renderer/RadarChartRenderer.js +119 -77
  288. package/renderer/RadarChartRenderer.js.map +1 -1
  289. package/renderer/Renderer.d.ts +8 -0
  290. package/renderer/Renderer.js +5 -0
  291. package/renderer/Renderer.js.map +1 -1
  292. package/renderer/ScatterChartRenderer.d.ts +5 -5
  293. package/renderer/ScatterChartRenderer.js +51 -37
  294. package/renderer/ScatterChartRenderer.js.map +1 -1
  295. package/renderer/XAxisRenderer.d.ts +29 -4
  296. package/renderer/XAxisRenderer.js +128 -95
  297. package/renderer/XAxisRenderer.js.map +1 -1
  298. package/renderer/XAxisRendererHorizontalBarChart.d.ts +11 -0
  299. package/renderer/XAxisRendererHorizontalBarChart.js +75 -57
  300. package/renderer/XAxisRendererHorizontalBarChart.js.map +1 -1
  301. package/renderer/XAxisRendererRadarChart.d.ts +5 -0
  302. package/renderer/XAxisRendererRadarChart.js +26 -13
  303. package/renderer/XAxisRendererRadarChart.js.map +1 -1
  304. package/renderer/YAxisRenderer.d.ts +42 -5
  305. package/renderer/YAxisRenderer.js +126 -69
  306. package/renderer/YAxisRenderer.js.map +1 -1
  307. package/renderer/YAxisRendererHorizontalBarChart.d.ts +22 -1
  308. package/renderer/YAxisRendererHorizontalBarChart.js +80 -58
  309. package/renderer/YAxisRendererHorizontalBarChart.js.map +1 -1
  310. package/renderer/YAxisRendererRadarChart.js +62 -32
  311. package/renderer/YAxisRendererRadarChart.js.map +1 -1
  312. package/renderer/scatter/ChevronDownShapeRenderer.d.ts +4 -0
  313. package/renderer/scatter/ChevronDownShapeRenderer.js +5 -1
  314. package/renderer/scatter/ChevronDownShapeRenderer.js.map +1 -1
  315. package/renderer/scatter/ChevronUpShapeRenderer.d.ts +4 -0
  316. package/renderer/scatter/ChevronUpShapeRenderer.js +5 -1
  317. package/renderer/scatter/ChevronUpShapeRenderer.js.map +1 -1
  318. package/renderer/scatter/CircleShapeRenderer.d.ts +4 -0
  319. package/renderer/scatter/CircleShapeRenderer.js +8 -5
  320. package/renderer/scatter/CircleShapeRenderer.js.map +1 -1
  321. package/renderer/scatter/CrossShapeRenderer.d.ts +4 -0
  322. package/renderer/scatter/CrossShapeRenderer.js +5 -1
  323. package/renderer/scatter/CrossShapeRenderer.js.map +1 -1
  324. package/renderer/scatter/IShapeRenderer.d.ts +14 -0
  325. package/renderer/scatter/IShapeRenderer.js.map +1 -1
  326. package/renderer/scatter/SquareShapeRenderer.d.ts +4 -0
  327. package/renderer/scatter/SquareShapeRenderer.js +8 -5
  328. package/renderer/scatter/SquareShapeRenderer.js.map +1 -1
  329. package/renderer/scatter/TriangleShapeRenderer.d.ts +4 -0
  330. package/renderer/scatter/TriangleShapeRenderer.js +9 -5
  331. package/renderer/scatter/TriangleShapeRenderer.js.map +1 -1
  332. package/renderer/scatter/XShapeRenderer.d.ts +4 -0
  333. package/renderer/scatter/XShapeRenderer.js +5 -1
  334. package/renderer/scatter/XShapeRenderer.js.map +1 -1
  335. package/utils/ColorTemplate.d.ts +21 -1
  336. package/utils/ColorTemplate.js +21 -3
  337. package/utils/ColorTemplate.js.map +1 -1
  338. package/utils/HorizontalViewPortHandler.d.ts +3 -0
  339. package/utils/HorizontalViewPortHandler.js +3 -0
  340. package/utils/HorizontalViewPortHandler.js.map +1 -1
  341. package/utils/MPSize.d.ts +7 -0
  342. package/utils/ObjectPool.d.ts +56 -0
  343. package/utils/ObjectPool.js +66 -8
  344. package/utils/ObjectPool.js.map +1 -1
  345. package/utils/Transformer.d.ts +118 -0
  346. package/utils/Transformer.js +141 -7
  347. package/utils/Transformer.js.map +1 -1
  348. package/utils/TransformerHorizontalBarChart.d.ts +10 -0
  349. package/utils/TransformerHorizontalBarChart.js +18 -2
  350. package/utils/TransformerHorizontalBarChart.js.map +1 -1
  351. package/utils/Utils.d.ts +139 -17
  352. package/utils/Utils.js +185 -60
  353. package/utils/Utils.js.map +1 -1
  354. package/utils/ViewPortHandler.d.ts +234 -19
  355. package/utils/ViewPortHandler.js +306 -63
  356. package/utils/ViewPortHandler.js.map +1 -1
  357. package/utils/colors/colorful.js.map +1 -1
  358. package/utils/colors/joyful.js.map +1 -1
  359. package/utils/colors/liberty.js.map +1 -1
  360. package/utils/colors/material.js.map +1 -1
  361. package/utils/colors/pastel.js.map +1 -1
  362. package/utils/colors/vordiplom.js.map +1 -1
  363. package/charts/index.d.ts +0 -11
  364. package/charts/index.js +0 -15
  365. 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
- this.mMaxVisibleCount = 100;
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.mClipValuesToContent = true;
26
- this.mClipDataToContent = true;
27
- this.mDrawHighlight = true;
28
- this.mMinOffset = 15;
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
- this.mGetPositionBuffer = [];
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.mLeftAxisTransformer = new Transformer(this.mViewPortHandler);
43
- this.mAxisRendererLeft = new YAxisRenderer(this.mViewPortHandler, this.mAxisLeft, this.mLeftAxisTransformer);
44
- this.mXAxisRenderer = new XAxisRenderer(this.mViewPortHandler, this.mXAxis, this.mLeftAxisTransformer);
45
- this.setHighlighter(new ChartHighlighter(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.mChartTouchListener) {
62
- this.mChartTouchListener = new BarLineChartTouchListener(this, this.mViewPortHandler.getMatrixTouch(), 3);
108
+ if (!this.chartTouchListener) {
109
+ this.chartTouchListener = new BarLineChartTouchListener(this, this.viewPortHandler.getMatrixTouch(), 3);
63
110
  if (!!this.nativeViewProtected) {
64
- this.mChartTouchListener.init();
111
+ this.chartTouchListener.init();
65
112
  }
66
113
  }
67
- return this.mChartTouchListener;
114
+ return this.chartTouchListener;
68
115
  }
69
116
  onDraw(canvas) {
70
117
  const startTime = Date.now();
71
118
  super.onDraw(canvas);
72
- const noComputeOnNextDraw = this.noComputeOnNextDraw;
73
- this.noComputeOnNextDraw = false;
74
- if (this.mData === null)
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
- if (!noComputeOnNextDraw && this.mAutoScaleMinMaxEnabled) {
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
- const leftEnabled = this.mAxisLeft.isEnabled();
81
- const rightEnabled = this.mAxisRight && this.mAxisRight.isEnabled();
82
- const xEnabled = this.mXAxis.isEnabled();
83
- const leftLimitEnabled = leftEnabled && this.mAxisLeft.isDrawLimitLinesEnabled();
84
- const rightLimitEnabled = rightEnabled && this.mAxisRight.isDrawLimitLinesEnabled();
85
- const xLimitEnabled = xEnabled && this.mXAxis.isDrawLimitLinesEnabled();
86
- if (!noComputeOnNextDraw) {
87
- if (leftEnabled)
88
- this.mAxisRendererLeft.computeAxis(this.mAxisLeft.mAxisMinimum, this.mAxisLeft.mAxisMaximum, this.mAxisLeft.isInverted());
89
- if (rightEnabled)
90
- this.mAxisRendererRight.computeAxis(this.mAxisRight.mAxisMinimum, this.mAxisRight.mAxisMaximum, this.mAxisRight.isInverted());
91
- if (xEnabled)
92
- this.mXAxisRenderer.computeAxis(this.mXAxis.mAxisMinimum, this.mXAxis.mAxisMaximum, false);
93
- }
94
- if (xEnabled && this.mXAxis.isDrawGridLinesBehindDataEnabled())
95
- this.mXAxisRenderer.renderGridLines(canvas);
96
- if (leftEnabled && this.mAxisLeft.isDrawGridLinesBehindDataEnabled())
97
- this.mAxisRendererLeft.renderGridLines(canvas);
98
- if (rightEnabled && this.mAxisRight.isDrawGridLinesBehindDataEnabled())
99
- this.mAxisRendererRight.renderGridLines(canvas);
100
- if (xLimitEnabled && this.mXAxis.isDrawLimitLinesBehindDataEnabled())
101
- this.mXAxisRenderer.renderLimitLines(canvas);
102
- if (leftLimitEnabled && this.mAxisLeft.isDrawLimitLinesBehindDataEnabled())
103
- this.mAxisRendererLeft.renderLimitLines(canvas);
104
- if (rightLimitEnabled && this.mAxisRight.isDrawLimitLinesBehindDataEnabled())
105
- this.mAxisRendererRight.renderLimitLines(canvas);
106
- if (xEnabled)
107
- this.mXAxisRenderer.renderAxisLine(canvas);
108
- if (leftEnabled)
109
- this.mAxisRendererLeft.renderAxisLine(canvas);
110
- if (rightEnabled)
111
- this.mAxisRendererRight.renderAxisLine(canvas);
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.mViewPortHandler.getContentRect());
121
- this.mRenderer.drawData(canvas);
169
+ canvas.clipRect(this.viewPortHandler.contentRect);
170
+ this.renderer.drawData(canvas);
122
171
  }
123
172
  else {
124
- this.mRenderer.drawData(canvas);
125
- }
126
- if (xEnabled && !this.mXAxis.isDrawGridLinesBehindDataEnabled())
127
- this.mXAxisRenderer.renderGridLines(canvas);
128
- if (leftEnabled && !this.mAxisLeft.isDrawGridLinesBehindDataEnabled())
129
- this.mAxisRendererLeft.renderGridLines(canvas);
130
- if (rightEnabled && !this.mAxisRight.isDrawGridLinesBehindDataEnabled())
131
- this.mAxisRendererRight.renderGridLines(canvas);
132
- if (!this.clipHighlightToContent && this.isClipDataToContentEnabled()) {
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.valuesToHighlight()) {
136
- this.mRenderer.drawHighlighted(canvas, this.mIndicesToHighlight, this.isDrawHighlightEnabled());
185
+ if (this.hasValuesToHighlight && this.drawHighlight) {
186
+ this.renderer.drawHighlighted(canvas, this.indicesToHighlight, this.drawHighlight);
137
187
  }
138
- if (this.clipHighlightToContent && this.isClipDataToContentEnabled()) {
188
+ // Removes clipping rectangle
189
+ if (this.clipHighlightToContent && this.clipDataToContent) {
139
190
  canvas.restore();
140
191
  }
141
- this.mRenderer.drawExtras(canvas);
142
- if (xLimitEnabled && !this.mXAxis.isDrawLimitLinesBehindDataEnabled())
143
- this.mXAxisRenderer.renderLimitLines(canvas);
144
- if (leftLimitEnabled && !this.mAxisLeft.isDrawLimitLinesBehindDataEnabled())
145
- this.mAxisRendererLeft.renderLimitLines(canvas);
146
- if (rightLimitEnabled && !this.mAxisRight.isDrawLimitLinesBehindDataEnabled())
147
- this.mAxisRendererRight.renderLimitLines(canvas);
148
- if (xEnabled && !this.mXAxis.isDrawLabelsBehindDataEnabled())
149
- this.mXAxisRenderer.renderAxisLabels(canvas);
150
- if (leftEnabled && !this.mAxisLeft.isDrawLabelsBehindDataEnabled())
151
- this.mAxisRendererLeft.renderAxisLabels(canvas);
152
- if (rightEnabled && !this.mAxisRight.isDrawLabelsBehindDataEnabled())
153
- this.mAxisRendererRight.renderAxisLabels(canvas);
154
- if (this.isClipValuesToContentEnabled()) {
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.mViewPortHandler.getContentRect());
157
- this.mRenderer.drawValues(canvas);
207
+ canvas.clipRect(this.viewPortHandler.contentRect);
208
+ this.renderer.drawValues(canvas);
158
209
  canvas.restore();
159
210
  }
160
211
  else {
161
- this.mRenderer.drawValues(canvas);
212
+ this.renderer.drawValues(canvas);
162
213
  }
163
- if (this.mLegendRenderer) {
164
- this.mLegendRenderer.renderLegend(canvas);
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.mXAxis.mAxisMinimum + ', xmax: ' + this.mXAxis.mAxisMaximum + ', xdelta: ' + this.mXAxis.mAxisRange);
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 && this.mAxisRight.isEnabled()) {
186
- this.mRightAxisTransformer.prepareMatrixValuePx(this.mXAxis.mAxisMinimum, this.mXAxis.mAxisRange, this.mAxisRight.mAxisRange, this.mAxisRight.mAxisMinimum);
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 ((this.mAxisLeft && this.mAxisLeft.isEnabled()) || this.mXAxis.isEnabled()) {
189
- this.mLeftAxisTransformer.prepareMatrixValuePx(this.mXAxis.mAxisMinimum, this.mXAxis.mAxisRange, this.mAxisLeft.mAxisRange, this.mAxisLeft.mAxisMinimum);
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 && this.mAxisRight.isEnabled()) {
194
- this.mRightAxisTransformer.prepareMatrixOffset(this.mAxisRight.isInverted());
247
+ if (this.mAxisRight?.enabled) {
248
+ this.rightAxisTransformer.prepareMatrixOffset(this.mAxisRight.inverted);
195
249
  }
196
- if ((this.mAxisLeft && this.mAxisLeft.isEnabled()) || this.mXAxis.isEnabled()) {
197
- this.mLeftAxisTransformer.prepareMatrixOffset(this.mAxisLeft.isInverted());
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 == null) {
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.mViewPortHandler.hasChartDimens()) {
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
- if (this.mRenderer != null)
219
- this.mRenderer.initBuffers();
272
+ this.renderer?.initBuffers();
220
273
  this.calcMinMax();
221
- if (this.mAxisLeft && this.mAxisLeft.isEnabled()) {
222
- this.mAxisRendererLeft.computeAxis(this.mAxisLeft.mAxisMinimum, this.mAxisLeft.mAxisMaximum, this.mAxisLeft.isInverted());
274
+ if (this.mAxisLeft?.enabled) {
275
+ this.rendererLeftYAxis.computeAxis(this.mAxisLeft.axisMinimum, this.mAxisLeft.axisMaximum, this.mAxisLeft.inverted);
223
276
  }
224
- if (this.mAxisRight && this.mAxisRight.isEnabled()) {
225
- this.mAxisRendererRight.computeAxis(this.mAxisRight.mAxisMinimum, this.mAxisRight.mAxisMaximum, this.mAxisRight.isInverted());
277
+ if (this.mAxisRight?.enabled) {
278
+ this.rendererRightYAxis.computeAxis(this.mAxisRight.axisMinimum, this.mAxisRight.axisMaximum, this.mAxisRight.inverted);
226
279
  }
227
- if (this.mXAxis.isEnabled()) {
228
- this.mXAxisRenderer.computeAxis(this.mXAxis.mAxisMinimum, this.mXAxis.mAxisMaximum, false);
280
+ if (this.xAxis.enabled) {
281
+ this.rendererXAxis.computeAxis(this.xAxis.axisMinimum, this.xAxis.axisMaximum, false);
229
282
  }
230
- if (this.mLegend != null && this.mLegend.isEnabled()) {
231
- this.mLegendRenderer.computeLegend(this.mData);
283
+ if (this.mLegend?.enabled) {
284
+ this.legendRenderer.computeLegend(this.mData);
232
285
  }
233
- this.calculateOffsets();
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.getLowestVisibleX();
238
- const toX = this.getHighestVisibleX();
294
+ const fromX = this.lowestVisibleX;
295
+ const toX = this.highestVisibleX;
239
296
  this.mData.calcMinMaxYRange(fromX, toX);
240
- this.mXAxis.calculate(this.mData.getXMin(), this.mData.getXMax());
241
- if (this.mAxisLeft && this.mAxisLeft.isEnabled()) {
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 && this.mAxisRight.isEnabled()) {
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.mXAxis.calculate(this.mData.getXMin(), this.mData.getXMax());
251
- if (this.mAxisLeft && this.mAxisLeft.isEnabled()) {
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 && this.mAxisRight.isEnabled()) {
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
- if (this.mLegend != null && this.mLegend.isEnabled() && !this.mLegend.isDrawInsideEnabled()) {
264
- switch (this.mLegend.getOrientation()) {
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.getHorizontalAlignment()) {
325
+ switch (this.mLegend.horizontalAlignment) {
267
326
  case LegendHorizontalAlignment.LEFT:
268
- offsets.left += Math.min(this.mLegend.mNeededWidth, this.mViewPortHandler.getChartWidth() * this.mLegend.getMaxSizePercent()) + this.mLegend.getXOffset();
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.mViewPortHandler.getChartWidth() * this.mLegend.getMaxSizePercent()) + this.mLegend.getXOffset();
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.getVerticalAlignment()) {
333
+ switch (this.mLegend.verticalAlignment) {
275
334
  case LegendVerticalAlignment.TOP:
276
- offsets.top += Math.min(this.mLegend.mNeededHeight, this.mViewPortHandler.getChartHeight() * this.mLegend.getMaxSizePercent()) + this.mLegend.getYOffset();
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.mViewPortHandler.getChartHeight() * this.mLegend.getMaxSizePercent()) + this.mLegend.getYOffset();
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.getVerticalAlignment()) {
346
+ switch (this.mLegend.verticalAlignment) {
288
347
  case LegendVerticalAlignment.TOP:
289
- offsets.top += Math.min(this.mLegend.mNeededHeight, this.mViewPortHandler.getChartHeight() * this.mLegend.getMaxSizePercent()) + this.mLegend.getYOffset();
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.mViewPortHandler.getChartHeight() * this.mLegend.getMaxSizePercent()) + this.mLegend.getYOffset();
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.mOffsetsCalculated && !force) {
361
+ if (this.offsetsCalculated && !force) {
303
362
  return;
304
363
  }
305
- this.mOffsetsCalculated = true;
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
- if (this.mAxisLeft && this.mAxisLeft.needsOffset()) {
314
- offsetLeft += this.mAxisLeft.getRequiredWidthSpace(this.mAxisRendererLeft.axisLabelsPaint);
372
+ // offsets for y-labels
373
+ if (this.mAxisLeft?.needsOffset) {
374
+ offsetLeft += this.mAxisLeft.getRequiredWidthSpace(this.rendererLeftYAxis.axisLabelsPaint);
315
375
  }
316
- if (this.mAxisRight && this.mAxisRight.needsOffset()) {
317
- offsetRight += this.mAxisRight.getRequiredWidthSpace(this.mAxisRendererRight.axisLabelsPaint);
376
+ if (this.mAxisRight?.needsOffset) {
377
+ offsetRight += this.mAxisRight.getRequiredWidthSpace(this.rendererRightYAxis.axisLabelsPaint);
318
378
  }
319
- if (this.mXAxis.isEnabled() && this.mXAxis.isDrawLabelsEnabled()) {
320
- const xLabelHeight = this.mXAxis.mLabelRotatedHeight + this.mXAxis.getYOffset();
321
- if (this.mXAxis.getPosition() === XAxisPosition.BOTTOM) {
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.mXAxis.getPosition() === XAxisPosition.TOP) {
385
+ else if (this.xAxis.position === XAxisPosition.TOP) {
325
386
  offsetTop += xLabelHeight;
326
387
  }
327
- else if (this.mXAxis.getPosition() === XAxisPosition.BOTH_SIDED) {
388
+ else if (this.xAxis.position === XAxisPosition.BOTH_SIDED) {
328
389
  offsetBottom += xLabelHeight;
329
390
  offsetTop += xLabelHeight;
330
391
  }
331
392
  }
332
- offsetTop += this.getExtraTopOffset();
333
- offsetRight += this.getExtraRightOffset();
334
- offsetBottom += this.getExtraBottomOffset();
335
- offsetLeft += this.getExtraLeftOffset();
336
- const minOffset = this.mMinOffset;
337
- this.mViewPortHandler.restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom));
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.mViewPortHandler.getContentRect().toString());
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.mDrawGridBackground) {
348
- c.drawRect(this.mViewPortHandler.getContentRect(), this.gridBackgroundPaint);
411
+ if (this.drawGridBackgroundEnabled) {
412
+ // draw the grid background
413
+ c.drawRect(this.viewPortHandler.contentRect, this.gridBackgroundPaint);
349
414
  }
350
- if (this.mDrawBorders) {
351
- c.drawRect(this.mViewPortHandler.getContentRect(), this.borderPaint);
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
- if (this.getAxisLeft().isEnabled()) {
357
- return this.mLeftAxisTransformer;
358
- }
359
- return this.mRightAxisTransformer;
426
+ return this.transformer;
360
427
  }
361
428
  if (which === AxisDependency.LEFT)
362
- return this.mLeftAxisTransformer;
429
+ return this.leftAxisTransformer;
363
430
  else
364
- return this.mRightAxisTransformer;
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.mViewPortHandler.getContentCenter();
368
- this.mViewPortHandler.zoomIn(center.x, -center.y, this.mZoomMatrixBuffer);
369
- this.mViewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
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.mViewPortHandler.getContentCenter();
375
- this.mViewPortHandler.zoomOut(center.x, -center.y, this.mZoomMatrixBuffer);
376
- this.mViewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
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.mViewPortHandler.mMatrixTouch.reset();
382
- this.mViewPortHandler.resetZoom(this.mZoomMatrixBuffer);
383
- this.mViewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
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.mViewPortHandler.zoomAtPosition(scaleX, scaleY, x, y, this.mZoomMatrixBuffer);
389
- this.mViewPortHandler.refresh(this.mZoomMatrixBuffer, this, false);
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.mViewPortHandler, scaleX, scaleY, xValue, yValue, this.getTransformer(axis), axis, 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.getCenterOffsets();
520
+ const center = this.centerOffsets;
402
521
  const save = this.mZoomMatrixBuffer;
403
- this.mViewPortHandler.zoomAtPosition(scaleX, scaleY, center.x, -center.y, save);
404
- this.mViewPortHandler.refresh(save, this, false);
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.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentTop(), axis);
408
- const job = AnimatedZoomJob.getInstance(this.mViewPortHandler, this, this.getTransformer(axis), this.getAxis(axis), this.mXAxis.mAxisRange, scaleX, scaleY, this.mViewPortHandler.getScaleX(), this.mViewPortHandler.getScaleY(), xValue, yValue, origin.x, origin.y, duration);
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.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentTop(), axis);
413
- const job = AnimatedZoomJob.getInstance(this.mViewPortHandler, this, this.getTransformer(axis), this.getAxis(axis), this.mXAxis.mAxisRange, scaleX, scaleY, this.mViewPortHandler.getScaleX(), this.mViewPortHandler.getScaleY(), xValue, yValue, origin.x, origin.y, 0);
414
- job.setPhase(1);
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.mViewPortHandler.fitScreen(save);
420
- this.mViewPortHandler.refresh(save, this, false);
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.mViewPortHandler.setMinimumScaleX(scaleX);
426
- this.mViewPortHandler.setMinimumScaleY(scaleY);
427
- }
428
- setVisibleXRangeMaximum(maxXRange) {
429
- const xScale = this.mXAxis.mAxisRange / maxXRange;
430
- this.mViewPortHandler.setMinimumScaleX(xScale);
431
- }
432
- setVisibleXRangeMinimum(minXRange) {
433
- const xScale = this.mXAxis.mAxisRange / minXRange;
434
- this.mViewPortHandler.setMaximumScaleX(xScale);
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.mXAxis.mAxisRange / minXRange;
438
- const maxScale = this.mXAxis.mAxisRange / maxXRange;
439
- this.mViewPortHandler.setMinMaxScaleX(minScale, maxScale);
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.mViewPortHandler.setMinimumScaleY(yScale);
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.mViewPortHandler.setMaximumScaleY(yScale);
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.mViewPortHandler.setMinMaxScaleY(minScale, maxScale);
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.mViewPortHandler, xValue, 0, this.getTransformer(), 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.mViewPortHandler.getScaleY();
460
- const job = MoveViewJob.getInstance(this.mViewPortHandler, xValue, yValue + yInView / 2, this.getTransformer(axis), 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.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentTop(), axis);
465
- const yInView = this.getAxisRange(axis) / this.mViewPortHandler.getScaleY();
466
- const job = AnimatedMoveViewJob.getInstance(this.mViewPortHandler, xValue, yValue + yInView / 2, this.getTransformer(axis), this, bounds.x, bounds.y, duration);
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.mViewPortHandler.getScaleY();
471
- const job = MoveViewJob.getInstance(this.mViewPortHandler, 0, yValue + valsInView / 2, this.getTransformer(axis), 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.mViewPortHandler.getScaleY();
476
- const xInView = this.getXAxis().mAxisRange / this.mViewPortHandler.getScaleX();
477
- const job = MoveViewJob.getInstance(this.mViewPortHandler, xValue - xInView / 2, yValue + yInView / 2, this.getTransformer(axis), 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.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentTop(), axis);
482
- const yInView = this.getAxisRange(axis) / this.mViewPortHandler.getScaleY();
483
- const xInView = this.getXAxis().mAxisRange / this.mViewPortHandler.getScaleX();
484
- const job = AnimatedMoveViewJob.getInstance(this.mViewPortHandler, xValue - xInView / 2, yValue + yInView / 2, this.getTransformer(axis), this, bounds.x, bounds.y, duration);
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
- this.mViewPortHandler.restrainViewPort(left, top, right, bottom);
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.mAxisRange;
784
+ return this.mAxisLeft.axisRange;
500
785
  else
501
- return this.mAxisRight && this.mAxisRight.mAxisRange;
502
- }
503
- setMaxVisibleValueCount(count) {
504
- this.mMaxVisibleCount = count;
505
- }
506
- getMaxVisibleCount() {
507
- return this.mMaxVisibleCount;
508
- }
509
- setHighlightPerDragEnabled(enabled) {
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.mChartTouchListener) {
515
- this.mChartTouchListener.setPan(false);
816
+ else if (this.chartTouchListener) {
817
+ this.chartTouchListener.setPan(false);
516
818
  }
517
819
  }
518
- isHighlightPerDragEnabled() {
820
+ get highlightPerDragEnabled() {
519
821
  return this.mHighlightPerDragEnabled;
520
822
  }
521
- setGridBackgroundColor(color) {
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
- setDragEnabled(enabled) {
525
- this.mDragXEnabled = enabled;
526
- this.mDragYEnabled = enabled;
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.mChartTouchListener) {
531
- this.mChartTouchListener.setPan(false);
844
+ else if (this.chartTouchListener) {
845
+ this.chartTouchListener.setPan(false);
532
846
  }
533
847
  }
534
- isDragEnabled() {
535
- return this.mDragXEnabled || this.mDragYEnabled;
536
- }
537
- setDragXEnabled(enabled) {
538
- this.mDragXEnabled = enabled;
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
- isDragXEnabled() {
541
- return this.mDragXEnabled;
542
- }
543
- setDragYEnabled(enabled) {
544
- this.mDragYEnabled = enabled;
545
- }
546
- isDragYEnabled() {
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.mChartTouchListener) {
556
- this.mChartTouchListener.setPinch(false);
866
+ else if (this.chartTouchListener) {
867
+ this.chartTouchListener.setPinch(false);
557
868
  }
558
869
  }
559
- setScaleXEnabled(enabled) {
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.mChartTouchListener) {
565
- this.mChartTouchListener.setPinch(false);
875
+ else if (!this.mScaleYEnabled && this.chartTouchListener) {
876
+ this.chartTouchListener.setPinch(false);
566
877
  }
567
878
  }
568
- setScaleYEnabled(enabled) {
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.mChartTouchListener) {
574
- this.mChartTouchListener.setPinch(false);
887
+ else if (!this.mScaleXEnabled && this.chartTouchListener) {
888
+ this.chartTouchListener.setPinch(false);
575
889
  }
576
890
  }
577
- isScaleXEnabled() {
578
- return this.mScaleXEnabled;
579
- }
580
- isScaleYEnabled() {
891
+ get scaleYEnabled() {
581
892
  return this.mScaleYEnabled;
582
893
  }
583
- setDoubleTapToZoomEnabled(enabled) {
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.mChartTouchListener) {
589
- this.mChartTouchListener.setDoubleTap(false);
905
+ else if (this.chartTouchListener) {
906
+ this.chartTouchListener.setDoubleTap(false);
590
907
  }
591
908
  }
592
- setHighlightPerTapEnabled(enabled) {
593
- super.setHighlightPerTapEnabled(enabled);
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.mChartTouchListener) {
598
- this.mChartTouchListener.setTap(false);
920
+ else if (this.chartTouchListener) {
921
+ this.chartTouchListener.setTap(false);
599
922
  }
600
923
  }
601
- isDoubleTapToZoomEnabled() {
602
- return this.mDoubleTapToZoomEnabled;
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
- getMinOffset() {
638
- return this.mMinOffset;
639
- }
640
- setMinOffset(minOffset) {
641
- this.mMinOffset = minOffset;
642
- }
643
- isKeepPositionOnRotation() {
644
- return this.mKeepPositionOnRotation;
645
- }
646
- setKeepPositionOnRotation(keepPositionOnRotation) {
647
- this.mKeepPositionOnRotation = keepPositionOnRotation;
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 != null) {
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 != null) {
1012
+ if (h) {
665
1013
  return this.mData.getDataSetByIndex(h.dataSetIndex);
666
1014
  }
667
1015
  return null;
668
1016
  }
669
- getLowestVisibleX() {
670
- this.getTransformer().getValuesByTouchPoint(this.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentBottom(), this.posForGetLowestVisibleX);
671
- const result = Math.max(this.mXAxis.mAxisMinimum, this.posForGetLowestVisibleX.x);
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
- getHighestVisibleX() {
675
- this.getTransformer().getValuesByTouchPoint(this.mViewPortHandler.contentRight(), this.mViewPortHandler.contentBottom(), this.posForGetHighestVisibleX);
676
- const result = Math.min(this.mXAxis.mAxisMaximum, this.posForGetHighestVisibleX.x);
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.getHighestVisibleX() - this.getLowestVisibleX());
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.mViewPortHandler == null)
1045
+ if (this.viewPortHandler == null)
684
1046
  return 1;
685
1047
  else
686
- return this.mViewPortHandler.getScaleX();
1048
+ return this.viewPortHandler.getScaleX();
687
1049
  }
1050
+ /**
1051
+ * returns the current y-scale factor
1052
+ */
688
1053
  getScaleY() {
689
- if (this.mViewPortHandler == null)
1054
+ if (this.viewPortHandler == null)
690
1055
  return 1;
691
1056
  else
692
- return this.mViewPortHandler.getScaleY();
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.mViewPortHandler.isFullyZoomedOut();
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
- get axisRight() {
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.mRightAxisTransformer = new Transformer(this.mViewPortHandler);
704
- this.mAxisRendererRight = new YAxisRenderer(this.mViewPortHandler, this.mAxisRight, this.mRightAxisTransformer);
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
- getAxisLeft() {
709
- return this.axisLeft;
710
- }
711
- getAxisRight() {
712
- return this.axisRight;
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).isInverted();
722
- }
723
- setPinchZoom(enabled) {
724
- this.mPinchZoomEnabled = enabled;
725
- }
726
- isPinchZoomEnabled() {
727
- return this.mPinchZoomEnabled;
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.mViewPortHandler.setDragOffsetX(offset);
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.mViewPortHandler.setDragOffsetY(offset);
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.mViewPortHandler.hasNoDragOffset();
737
- }
738
- getRendererXAxis() {
739
- return this.mXAxisRenderer;
1134
+ return this.viewPortHandler.hasNoDragOffset();
740
1135
  }
741
- setXAxisRenderer(xAxisRenderer) {
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.isEnabled()) {
759
- max = Math.max(this.mAxisLeft.mAxisMaximum, max);
1138
+ if (this.mAxisLeft.enabled) {
1139
+ max = Math.max(this.mAxisLeft.axisMaximum, max);
760
1140
  }
761
- if (this.mAxisRight && this.mAxisRight.isEnabled()) {
762
- max = Math.max(this.mAxisRight.mAxisMaximum, max);
1141
+ if (this.mAxisRight?.enabled) {
1142
+ max = Math.max(this.mAxisRight.axisMaximum, max);
763
1143
  }
764
1144
  return max;
765
1145
  }
766
- getYChartMin() {
1146
+ get yChartMin() {
767
1147
  let min = Infinity;
768
- if (this.mAxisLeft.isEnabled()) {
769
- min = Math.min(this.mAxisLeft.mAxisMinimum, min);
1148
+ if (this.mAxisLeft.enabled) {
1149
+ min = Math.min(this.mAxisLeft.axisMinimum, min);
770
1150
  }
771
- if (this.mAxisRight && this.mAxisRight.isEnabled()) {
772
- min = Math.min(this.mAxisRight.mAxisMinimum, min);
1151
+ if (this.mAxisRight?.enabled) {
1152
+ min = Math.min(this.mAxisRight.axisMinimum, min);
773
1153
  }
774
1154
  return min;
775
1155
  }
776
- isAnyAxisInverted() {
777
- if (this.mAxisLeft.isEnabled() && this.mAxisLeft.isInverted())
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.isEnabled() && this.mAxisRight.isInverted())
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.mKeepPositionOnRotation) {
792
- this.mOnSizeChangedBuffer[0] = this.mViewPortHandler.contentLeft();
793
- this.mOnSizeChangedBuffer[1] = this.mViewPortHandler.contentTop();
794
- this.getTransformer().pixelsToValue(this.mOnSizeChangedBuffer);
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.mKeepPositionOnRotation) {
798
- this.getTransformer().pointValuesToPixel(this.mOnSizeChangedBuffer);
799
- this.mViewPortHandler.centerViewPort(this.mOnSizeChangedBuffer, 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
- this.mViewPortHandler.refresh(this.mViewPortHandler.getMatrixTouch(), this, false);
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.isHighlightPerTapEnabled()) {
846
- this.mChartTouchListener && this.mChartTouchListener.setTap(false);
1226
+ if (arg === 'tap' && !this.highlightPerTapEnabled) {
1227
+ this.chartTouchListener && this.chartTouchListener.setTap(false);
847
1228
  }
848
- else if (arg === 'doubleTap' && !this.isDoubleTapToZoomEnabled()) {
849
- this.mChartTouchListener && this.mChartTouchListener.setDoubleTap(false);
1229
+ else if (arg === 'doubleTap' && !this.doubleTapToZoomEnabled) {
1230
+ this.chartTouchListener && this.chartTouchListener.setDoubleTap(false);
850
1231
  }
851
- else if (arg === 'pan' && !this.isHighlightPerDragEnabled() && !this.isDragEnabled()) {
852
- this.mChartTouchListener && this.mChartTouchListener.setPan(false);
1232
+ else if (arg === 'pan' && !this.highlightPerDragEnabled && !this.dragEnabled) {
1233
+ this.chartTouchListener && this.chartTouchListener.setPan(false);
853
1234
  }
854
- else if (arg === 'pinch' && !this.isPinchZoomEnabled()) {
855
- this.mChartTouchListener && this.mChartTouchListener.setPinch(false);
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
  }