@nativescript-community/ui-chart 1.2.36 → 2.0.0

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