@techie_doubts/tui.chart.2026 4.6.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 (284) hide show
  1. package/README.md +165 -0
  2. package/dist/esm/animator.d.ts +32 -0
  3. package/dist/esm/animator.js +102 -0
  4. package/dist/esm/brushes/axis.d.ts +3 -0
  5. package/dist/esm/brushes/axis.js +21 -0
  6. package/dist/esm/brushes/basic.d.ts +9 -0
  7. package/dist/esm/brushes/basic.js +95 -0
  8. package/dist/esm/brushes/boxPlot.d.ts +2 -0
  9. package/dist/esm/brushes/boxPlot.js +22 -0
  10. package/dist/esm/brushes/circleLegend.d.ts +2 -0
  11. package/dist/esm/brushes/circleLegend.js +26 -0
  12. package/dist/esm/brushes/dataLabel.d.ts +6 -0
  13. package/dist/esm/brushes/dataLabel.js +176 -0
  14. package/dist/esm/brushes/exportMenu.d.ts +2 -0
  15. package/dist/esm/brushes/exportMenu.js +55 -0
  16. package/dist/esm/brushes/gauge.d.ts +2 -0
  17. package/dist/esm/brushes/gauge.js +39 -0
  18. package/dist/esm/brushes/label.d.ts +34 -0
  19. package/dist/esm/brushes/label.js +165 -0
  20. package/dist/esm/brushes/legend.d.ts +7 -0
  21. package/dist/esm/brushes/legend.js +162 -0
  22. package/dist/esm/brushes/lineSeries.d.ts +5 -0
  23. package/dist/esm/brushes/lineSeries.js +41 -0
  24. package/dist/esm/brushes/polygon.d.ts +2 -0
  25. package/dist/esm/brushes/polygon.js +24 -0
  26. package/dist/esm/brushes/resetButton.d.ts +3 -0
  27. package/dist/esm/brushes/resetButton.js +112 -0
  28. package/dist/esm/brushes/scatterSeries.d.ts +2 -0
  29. package/dist/esm/brushes/scatterSeries.js +125 -0
  30. package/dist/esm/brushes/sector.d.ts +2 -0
  31. package/dist/esm/brushes/sector.js +54 -0
  32. package/dist/esm/brushes/spectrumLegend.d.ts +14 -0
  33. package/dist/esm/brushes/spectrumLegend.js +199 -0
  34. package/dist/esm/charts/areaChart.d.ts +254 -0
  35. package/dist/esm/charts/areaChart.js +358 -0
  36. package/dist/esm/charts/barChart.d.ts +203 -0
  37. package/dist/esm/charts/barChart.js +300 -0
  38. package/dist/esm/charts/boxPlotChart.d.ts +209 -0
  39. package/dist/esm/charts/boxPlotChart.js +288 -0
  40. package/dist/esm/charts/bubbleChart.d.ts +188 -0
  41. package/dist/esm/charts/bubbleChart.js +263 -0
  42. package/dist/esm/charts/bulletChart.d.ts +199 -0
  43. package/dist/esm/charts/bulletChart.js +278 -0
  44. package/dist/esm/charts/chart.d.ts +133 -0
  45. package/dist/esm/charts/chart.js +484 -0
  46. package/dist/esm/charts/columnChart.d.ts +205 -0
  47. package/dist/esm/charts/columnChart.js +299 -0
  48. package/dist/esm/charts/columnLineChart.d.ts +271 -0
  49. package/dist/esm/charts/columnLineChart.js +386 -0
  50. package/dist/esm/charts/gaugeChart.d.ts +191 -0
  51. package/dist/esm/charts/gaugeChart.js +279 -0
  52. package/dist/esm/charts/heatmapChart.d.ts +199 -0
  53. package/dist/esm/charts/heatmapChart.js +292 -0
  54. package/dist/esm/charts/lineAreaChart.d.ts +271 -0
  55. package/dist/esm/charts/lineAreaChart.js +374 -0
  56. package/dist/esm/charts/lineChart.d.ts +253 -0
  57. package/dist/esm/charts/lineChart.js +360 -0
  58. package/dist/esm/charts/lineScatterChart.d.ts +200 -0
  59. package/dist/esm/charts/lineScatterChart.js +285 -0
  60. package/dist/esm/charts/nestedPieChart.d.ts +192 -0
  61. package/dist/esm/charts/nestedPieChart.js +268 -0
  62. package/dist/esm/charts/pieChart.d.ts +156 -0
  63. package/dist/esm/charts/pieChart.js +224 -0
  64. package/dist/esm/charts/radarChart.d.ts +169 -0
  65. package/dist/esm/charts/radarChart.js +240 -0
  66. package/dist/esm/charts/radialBarChart.d.ts +172 -0
  67. package/dist/esm/charts/radialBarChart.js +251 -0
  68. package/dist/esm/charts/scatterChart.d.ts +184 -0
  69. package/dist/esm/charts/scatterChart.js +279 -0
  70. package/dist/esm/charts/treemapChart.d.ts +166 -0
  71. package/dist/esm/charts/treemapChart.js +239 -0
  72. package/dist/esm/component/areaSeries.d.ts +96 -0
  73. package/dist/esm/component/areaSeries.js +474 -0
  74. package/dist/esm/component/axis.d.ts +40 -0
  75. package/dist/esm/component/axis.js +176 -0
  76. package/dist/esm/component/axisTitle.d.ts +25 -0
  77. package/dist/esm/component/axisTitle.js +67 -0
  78. package/dist/esm/component/axisUsingCenterY.d.ts +32 -0
  79. package/dist/esm/component/axisUsingCenterY.js +175 -0
  80. package/dist/esm/component/backButton.d.ts +13 -0
  81. package/dist/esm/component/backButton.js +26 -0
  82. package/dist/esm/component/background.d.ts +10 -0
  83. package/dist/esm/component/background.js +15 -0
  84. package/dist/esm/component/boxPlotSeries.d.ts +126 -0
  85. package/dist/esm/component/boxPlotSeries.js +410 -0
  86. package/dist/esm/component/boxSeries.d.ts +211 -0
  87. package/dist/esm/component/boxSeries.js +603 -0
  88. package/dist/esm/component/boxStackSeries.d.ts +62 -0
  89. package/dist/esm/component/boxStackSeries.js +447 -0
  90. package/dist/esm/component/bubbleSeries.d.ts +35 -0
  91. package/dist/esm/component/bubbleSeries.js +174 -0
  92. package/dist/esm/component/bulletSeries.d.ts +89 -0
  93. package/dist/esm/component/bulletSeries.js +392 -0
  94. package/dist/esm/component/circleLegend.d.ts +10 -0
  95. package/dist/esm/component/circleLegend.js +37 -0
  96. package/dist/esm/component/component.d.ts +64 -0
  97. package/dist/esm/component/component.js +170 -0
  98. package/dist/esm/component/componentManager.d.ts +23 -0
  99. package/dist/esm/component/componentManager.js +45 -0
  100. package/dist/esm/component/dataLabels.d.ts +23 -0
  101. package/dist/esm/component/dataLabels.js +134 -0
  102. package/dist/esm/component/exportMenu.d.ts +38 -0
  103. package/dist/esm/component/exportMenu.js +147 -0
  104. package/dist/esm/component/gaugeSeries.d.ts +160 -0
  105. package/dist/esm/component/gaugeSeries.js +447 -0
  106. package/dist/esm/component/heatmapSeries.d.ts +64 -0
  107. package/dist/esm/component/heatmapSeries.js +152 -0
  108. package/dist/esm/component/hoveredSeries.d.ts +27 -0
  109. package/dist/esm/component/hoveredSeries.js +95 -0
  110. package/dist/esm/component/legend.d.ts +26 -0
  111. package/dist/esm/component/legend.js +149 -0
  112. package/dist/esm/component/lineSeries.d.ts +69 -0
  113. package/dist/esm/component/lineSeries.js +319 -0
  114. package/dist/esm/component/noDataText.d.ts +9 -0
  115. package/dist/esm/component/noDataText.js +31 -0
  116. package/dist/esm/component/pieSeries.d.ts +137 -0
  117. package/dist/esm/component/pieSeries.js +390 -0
  118. package/dist/esm/component/plot.d.ts +37 -0
  119. package/dist/esm/component/plot.js +163 -0
  120. package/dist/esm/component/radarSeries.d.ts +85 -0
  121. package/dist/esm/component/radarSeries.js +222 -0
  122. package/dist/esm/component/radialAxis.d.ts +26 -0
  123. package/dist/esm/component/radialAxis.js +210 -0
  124. package/dist/esm/component/radialBarSeries.d.ts +111 -0
  125. package/dist/esm/component/radialBarSeries.js +349 -0
  126. package/dist/esm/component/radialPlot.d.ts +55 -0
  127. package/dist/esm/component/radialPlot.js +188 -0
  128. package/dist/esm/component/rangeSelection.d.ts +61 -0
  129. package/dist/esm/component/rangeSelection.js +150 -0
  130. package/dist/esm/component/resetButton.d.ts +13 -0
  131. package/dist/esm/component/resetButton.js +26 -0
  132. package/dist/esm/component/scatterSeries.d.ts +34 -0
  133. package/dist/esm/component/scatterSeries.js +159 -0
  134. package/dist/esm/component/selectedSeries.d.ts +26 -0
  135. package/dist/esm/component/selectedSeries.js +109 -0
  136. package/dist/esm/component/spectrumLegend.d.ts +15 -0
  137. package/dist/esm/component/spectrumLegend.js +76 -0
  138. package/dist/esm/component/title.d.ts +12 -0
  139. package/dist/esm/component/title.js +53 -0
  140. package/dist/esm/component/tooltip.d.ts +41 -0
  141. package/dist/esm/component/tooltip.js +131 -0
  142. package/dist/esm/component/treemapSeries.d.ts +57 -0
  143. package/dist/esm/component/treemapSeries.js +191 -0
  144. package/dist/esm/component/zeroAxis.d.ts +9 -0
  145. package/dist/esm/component/zeroAxis.js +49 -0
  146. package/dist/esm/eventEmitter.d.ts +8 -0
  147. package/dist/esm/eventEmitter.js +15 -0
  148. package/dist/esm/helpers/arrayUtil.d.ts +10 -0
  149. package/dist/esm/helpers/arrayUtil.js +54 -0
  150. package/dist/esm/helpers/axes.d.ts +67 -0
  151. package/dist/esm/helpers/axes.js +345 -0
  152. package/dist/esm/helpers/boxSeries.d.ts +5 -0
  153. package/dist/esm/helpers/boxSeries.js +71 -0
  154. package/dist/esm/helpers/calculator.d.ts +19 -0
  155. package/dist/esm/helpers/calculator.js +153 -0
  156. package/dist/esm/helpers/color.d.ts +153 -0
  157. package/dist/esm/helpers/color.js +218 -0
  158. package/dist/esm/helpers/colorSpectrum.d.ts +5 -0
  159. package/dist/esm/helpers/colorSpectrum.js +17 -0
  160. package/dist/esm/helpers/coordinate.d.ts +9 -0
  161. package/dist/esm/helpers/coordinate.js +51 -0
  162. package/dist/esm/helpers/dataLabels.d.ts +36 -0
  163. package/dist/esm/helpers/dataLabels.js +405 -0
  164. package/dist/esm/helpers/dom.d.ts +2 -0
  165. package/dist/esm/helpers/dom.js +8 -0
  166. package/dist/esm/helpers/downloader.d.ts +7 -0
  167. package/dist/esm/helpers/downloader.js +287 -0
  168. package/dist/esm/helpers/formatDate.d.ts +16 -0
  169. package/dist/esm/helpers/formatDate.js +140 -0
  170. package/dist/esm/helpers/geometric.d.ts +3 -0
  171. package/dist/esm/helpers/geometric.js +35 -0
  172. package/dist/esm/helpers/googleAnalytics.d.ts +1 -0
  173. package/dist/esm/helpers/googleAnalytics.js +39 -0
  174. package/dist/esm/helpers/htmlSanitizer.d.ts +1 -0
  175. package/dist/esm/helpers/htmlSanitizer.js +86 -0
  176. package/dist/esm/helpers/legend.d.ts +9 -0
  177. package/dist/esm/helpers/legend.js +47 -0
  178. package/dist/esm/helpers/pieSeries.d.ts +15 -0
  179. package/dist/esm/helpers/pieSeries.js +72 -0
  180. package/dist/esm/helpers/plot.d.ts +2 -0
  181. package/dist/esm/helpers/plot.js +4 -0
  182. package/dist/esm/helpers/radarSeries.d.ts +1 -0
  183. package/dist/esm/helpers/radarSeries.js +7 -0
  184. package/dist/esm/helpers/range.d.ts +6 -0
  185. package/dist/esm/helpers/range.js +16 -0
  186. package/dist/esm/helpers/responders.d.ts +37 -0
  187. package/dist/esm/helpers/responders.js +197 -0
  188. package/dist/esm/helpers/sector.d.ts +55 -0
  189. package/dist/esm/helpers/sector.js +117 -0
  190. package/dist/esm/helpers/squarifier.d.ts +8 -0
  191. package/dist/esm/helpers/squarifier.js +110 -0
  192. package/dist/esm/helpers/style.d.ts +14 -0
  193. package/dist/esm/helpers/style.js +48 -0
  194. package/dist/esm/helpers/theme.d.ts +58 -0
  195. package/dist/esm/helpers/theme.js +557 -0
  196. package/dist/esm/helpers/tooltip.d.ts +2 -0
  197. package/dist/esm/helpers/tooltip.js +18 -0
  198. package/dist/esm/helpers/tooltipTemplate.d.ts +21 -0
  199. package/dist/esm/helpers/tooltipTemplate.js +147 -0
  200. package/dist/esm/helpers/utils.d.ts +42 -0
  201. package/dist/esm/helpers/utils.js +268 -0
  202. package/dist/esm/helpers/validation.d.ts +6 -0
  203. package/dist/esm/helpers/validation.js +16 -0
  204. package/dist/esm/index.d.ts +40 -0
  205. package/dist/esm/index.js +75 -0
  206. package/dist/esm/message.d.ts +11 -0
  207. package/dist/esm/message.js +11 -0
  208. package/dist/esm/painter.d.ts +27 -0
  209. package/dist/esm/painter.js +88 -0
  210. package/dist/esm/responderDetectors.d.ts +6 -0
  211. package/dist/esm/responderDetectors.js +124 -0
  212. package/dist/esm/scale/coordinateScaleCalculator.d.ts +24 -0
  213. package/dist/esm/scale/coordinateScaleCalculator.js +174 -0
  214. package/dist/esm/scale/datetimeScaleCalculator.d.ts +20 -0
  215. package/dist/esm/scale/datetimeScaleCalculator.js +59 -0
  216. package/dist/esm/store/axes.d.ts +30 -0
  217. package/dist/esm/store/axes.js +282 -0
  218. package/dist/esm/store/category.d.ts +4 -0
  219. package/dist/esm/store/category.js +73 -0
  220. package/dist/esm/store/colorValueScale.d.ts +3 -0
  221. package/dist/esm/store/colorValueScale.js +56 -0
  222. package/dist/esm/store/dataRange.d.ts +4 -0
  223. package/dist/esm/store/dataRange.js +170 -0
  224. package/dist/esm/store/gaugeAxes.d.ts +4 -0
  225. package/dist/esm/store/gaugeAxes.js +175 -0
  226. package/dist/esm/store/heatmapAxes.d.ts +3 -0
  227. package/dist/esm/store/heatmapAxes.js +98 -0
  228. package/dist/esm/store/heatmapSeriesData.d.ts +3 -0
  229. package/dist/esm/store/heatmapSeriesData.js +34 -0
  230. package/dist/esm/store/layout.d.ts +12 -0
  231. package/dist/esm/store/layout.js +487 -0
  232. package/dist/esm/store/legend.d.ts +3 -0
  233. package/dist/esm/store/legend.js +435 -0
  234. package/dist/esm/store/nestedPieSeriesData.d.ts +3 -0
  235. package/dist/esm/store/nestedPieSeriesData.js +49 -0
  236. package/dist/esm/store/options.d.ts +3 -0
  237. package/dist/esm/store/options.js +62 -0
  238. package/dist/esm/store/plot.d.ts +3 -0
  239. package/dist/esm/store/plot.js +102 -0
  240. package/dist/esm/store/radialAxes.d.ts +8 -0
  241. package/dist/esm/store/radialAxes.js +199 -0
  242. package/dist/esm/store/reactive.d.ts +11 -0
  243. package/dist/esm/store/reactive.js +196 -0
  244. package/dist/esm/store/root.d.ts +3 -0
  245. package/dist/esm/store/root.js +46 -0
  246. package/dist/esm/store/scale.d.ts +3 -0
  247. package/dist/esm/store/scale.js +102 -0
  248. package/dist/esm/store/seriesData.d.ts +3 -0
  249. package/dist/esm/store/seriesData.js +299 -0
  250. package/dist/esm/store/stackSeriesData.d.ts +8 -0
  251. package/dist/esm/store/stackSeriesData.js +192 -0
  252. package/dist/esm/store/store.d.ts +20 -0
  253. package/dist/esm/store/store.js +112 -0
  254. package/dist/esm/store/theme.d.ts +3 -0
  255. package/dist/esm/store/theme.js +139 -0
  256. package/dist/esm/store/treemapSeriesData.d.ts +4 -0
  257. package/dist/esm/store/treemapSeriesData.js +93 -0
  258. package/dist/td-chart.css +127 -0
  259. package/dist/td-chart.js +41463 -0
  260. package/dist/td-chart.min.css +6 -0
  261. package/dist/td-chart.min.js +9 -0
  262. package/package.json +112 -0
  263. package/types/brushes.d.ts +30 -0
  264. package/types/charts.d.ts +152 -0
  265. package/types/components/axis.d.ts +71 -0
  266. package/types/components/circleLegend.d.ts +9 -0
  267. package/types/components/dataLabels.d.ts +119 -0
  268. package/types/components/exportMenu.d.ts +14 -0
  269. package/types/components/legend.d.ts +27 -0
  270. package/types/components/plot.d.ts +8 -0
  271. package/types/components/radialAxis.d.ts +22 -0
  272. package/types/components/radialPlot.d.ts +11 -0
  273. package/types/components/rangeSelection.d.ts +3 -0
  274. package/types/components/resetButton.d.ts +13 -0
  275. package/types/components/series.d.ts +386 -0
  276. package/types/components/spectrumLegend.d.ts +25 -0
  277. package/types/components/tooltip.d.ts +58 -0
  278. package/types/components/zoom.d.ts +3 -0
  279. package/types/eventEmitter.d.ts +12 -0
  280. package/types/index.d.ts +615 -0
  281. package/types/options.d.ts +833 -0
  282. package/types/resizeObserver.d.ts +54 -0
  283. package/types/store/store.d.ts +564 -0
  284. package/types/theme.d.ts +670 -0
@@ -0,0 +1,27 @@
1
+ import Chart from "./charts/chart";
2
+ import { CircleModel, ClipRectAreaModel, LinePointsModel, PathRectModel } from "../types/components/series";
3
+ import { TooltipModel } from "../types/components/tooltip";
4
+ import { Options } from "../types/store/store";
5
+ declare type BrushModel = ClipRectAreaModel | LinePointsModel | PathRectModel | CircleModel | TooltipModel;
6
+ declare type Brush = (ctx: CanvasRenderingContext2D, brushModel: BrushModel) => void;
7
+ export default class Painter {
8
+ width: number;
9
+ height: number;
10
+ brushes: Record<string, Brush>;
11
+ chart: Chart<Options>;
12
+ canvas: HTMLCanvasElement;
13
+ ctx: CanvasRenderingContext2D;
14
+ constructor(chart: Chart<Options>);
15
+ showUnsupportedCanvasFeatureError(): void;
16
+ setup(): void;
17
+ setSize(width: number, height: number): void;
18
+ scaleCanvasRatio(ratio: number): void;
19
+ add(name: string, brush: Brush): void;
20
+ addGroups(groups: any[]): void;
21
+ paint(name: string, brushModel: any): void;
22
+ paintForEach(brushModels: any[]): void;
23
+ beforeFrame(): void;
24
+ beforeDraw(transX: number, transY: number): void;
25
+ afterDraw(): void;
26
+ }
27
+ export {};
@@ -0,0 +1,88 @@
1
+ import { message } from "./message";
2
+ export default class Painter {
3
+ constructor(chart) {
4
+ this.width = 0;
5
+ this.height = 0;
6
+ this.brushes = {};
7
+ this.chart = chart;
8
+ }
9
+ showUnsupportedCanvasFeatureError() {
10
+ if (!this.ctx.setLineDash) {
11
+ console.warn(message.DASH_SEGMENTS_UNAVAILABLE_ERROR);
12
+ }
13
+ }
14
+ setup() {
15
+ const { height, width } = this.chart.store.state.chart;
16
+ if (!this.canvas) {
17
+ const canvas = document.createElement('canvas');
18
+ this.canvas = canvas;
19
+ this.chart.el.appendChild(canvas);
20
+ canvas.addEventListener('click', this.chart);
21
+ canvas.addEventListener('mousemove', this.chart);
22
+ canvas.addEventListener('mousedown', this.chart);
23
+ canvas.addEventListener('mouseup', this.chart);
24
+ canvas.addEventListener('mouseout', this.chart);
25
+ const ctx = canvas.getContext('2d');
26
+ if (ctx) {
27
+ this.ctx = ctx;
28
+ }
29
+ }
30
+ this.setSize(width, height);
31
+ this.showUnsupportedCanvasFeatureError();
32
+ }
33
+ setSize(width, height) {
34
+ this.canvas.style.width = `${width}px`;
35
+ this.canvas.style.height = `${height}px`;
36
+ let ratio = 1;
37
+ if ('deviceXDPI' in window.screen) {
38
+ // IE mobile or IE
39
+ ratio =
40
+ window.screen.deviceXDPI /
41
+ window.screen.logicalXDPI;
42
+ }
43
+ else if (window.hasOwnProperty('devicePixelRatio')) {
44
+ ratio = window.devicePixelRatio;
45
+ }
46
+ this.width = width * ratio || 0;
47
+ this.height = height * ratio || 0;
48
+ this.scaleCanvasRatio(ratio);
49
+ }
50
+ scaleCanvasRatio(ratio) {
51
+ this.canvas.width = this.width;
52
+ this.canvas.height = this.height;
53
+ this.ctx.scale(ratio, ratio);
54
+ }
55
+ add(name, brush) {
56
+ this.brushes[name] = brush;
57
+ }
58
+ addGroups(groups) {
59
+ groups.forEach((group) => {
60
+ Object.keys(group).forEach((key) => {
61
+ this.add(key, group[key]);
62
+ });
63
+ });
64
+ }
65
+ paint(name, brushModel) {
66
+ if (this.brushes[name]) {
67
+ this.brushes[name](this.ctx, brushModel);
68
+ }
69
+ else {
70
+ throw new Error(message.noBrushError(name));
71
+ }
72
+ }
73
+ paintForEach(brushModels) {
74
+ brushModels.forEach((m) => this.paint(m.type, m));
75
+ }
76
+ beforeFrame() {
77
+ this.ctx.clearRect(0, 0, this.width, this.height);
78
+ this.ctx.fillStyle = 'transparent';
79
+ this.ctx.fillRect(0, 0, this.width, this.height);
80
+ }
81
+ beforeDraw(transX, transY) {
82
+ this.ctx.save();
83
+ this.ctx.translate(transX, transY);
84
+ }
85
+ afterDraw() {
86
+ this.ctx.restore();
87
+ }
88
+ }
@@ -0,0 +1,6 @@
1
+ declare type DetectorType = 'circle' | 'rect' | 'sector' | 'boxPlot' | 'line' | 'clockHand';
2
+ declare type ResponderDetectors = {
3
+ [key in DetectorType]: Function;
4
+ };
5
+ export declare const responderDetectors: ResponderDetectors;
6
+ export {};
@@ -0,0 +1,124 @@
1
+ import { isUndefined } from "./helpers/utils";
2
+ import { calculateRadianToDegree, withinRadian } from "./helpers/sector";
3
+ function withinRotationRect({ slope, yIntercept, mouseX, mouseY, modelXPositions, compX, compY, detectionSize = 0, }) {
4
+ const [x1, x2] = modelXPositions;
5
+ const posY = slope * (mouseX - compX) + yIntercept;
6
+ const withinRadius = (x1 > x2 && mouseX >= compX + x2 && mouseX <= compX + x1) ||
7
+ (x1 < x2 && mouseX <= compX + x2 && mouseX >= compX + x1);
8
+ const withinDetectionSize = posY - detectionSize + compY <= mouseY && mouseY <= posY + detectionSize + compY;
9
+ return withinRadius && withinDetectionSize;
10
+ }
11
+ export const responderDetectors = {
12
+ circle: (mousePosition, model, componentRect) => {
13
+ const { x, y } = mousePosition;
14
+ const { x: modelX, y: modelY, radius, detectionSize } = model;
15
+ const { x: compX, y: compY } = componentRect;
16
+ const radiusAdjustment = isUndefined(detectionSize) ? 10 : detectionSize;
17
+ return (Math.pow((x - (modelX + compX)), 2) + Math.pow((y - (modelY + compY)), 2) < Math.pow((radius + radiusAdjustment), 2));
18
+ },
19
+ rect: (mousePosition, model, componentRect = { x: 0, y: 0, width: 0, height: 0 }) => {
20
+ const { x, y } = mousePosition;
21
+ const { x: modelX, y: modelY, width, height } = model;
22
+ const { x: compX, y: compY } = componentRect;
23
+ return (x >= modelX + compX &&
24
+ x <= modelX + compX + width &&
25
+ y >= modelY + compY &&
26
+ y <= modelY + compY + height);
27
+ },
28
+ sector: (mousePosition, model, componentRect = { x: 0, y: 0, width: 0, height: 0 }) => {
29
+ const { x, y } = mousePosition;
30
+ const { x: modelX, y: modelY, radius: { outer, inner }, degree: { start, end }, drawingStartAngle, clockwise, } = model;
31
+ const { x: compX, y: compY } = componentRect;
32
+ const xPos = x - (modelX + compX);
33
+ const yPos = y - (modelY + compY);
34
+ const insideOuterRadius = Math.pow(xPos, 2) + Math.pow(yPos, 2) < Math.pow(outer, 2);
35
+ const outsideInnerRadius = Math.pow(xPos, 2) + Math.pow(yPos, 2) > Math.pow(inner, 2);
36
+ const withinRadius = insideOuterRadius && outsideInnerRadius;
37
+ const detectionDegree = calculateRadianToDegree(Math.atan2(yPos, xPos), drawingStartAngle);
38
+ return withinRadius && withinRadian(clockwise, start, end, detectionDegree);
39
+ },
40
+ line: (mousePosition, model, componentRect = { x: 0, y: 0, width: 0, height: 0 }) => {
41
+ const { x, y } = mousePosition;
42
+ const { x: compX, y: compY } = componentRect;
43
+ const { x: modelX, y: modelY, x2, y2, detectionSize = 3 } = model;
44
+ const numerator = y2 - modelY;
45
+ const denominator = x2 - modelX;
46
+ let withinLine = false;
47
+ if (numerator === 0) {
48
+ const minX = Math.min(modelX, x2);
49
+ const maxX = Math.max(modelX, x2);
50
+ withinLine =
51
+ x - compX >= minX &&
52
+ x - compX <= maxX &&
53
+ y >= modelY + compY - detectionSize &&
54
+ y <= modelY + compY + detectionSize;
55
+ }
56
+ else if (denominator === 0) {
57
+ const minY = Math.min(modelY, y2);
58
+ const maxY = Math.max(modelY, y2);
59
+ withinLine =
60
+ y - compY >= minY &&
61
+ y - compY <= maxY &&
62
+ x >= modelX + compX - detectionSize &&
63
+ x <= modelX + compX + detectionSize;
64
+ }
65
+ else {
66
+ const slope = numerator / denominator;
67
+ const xPos = x - (modelX + compX);
68
+ const yPos = y - (modelY + compY);
69
+ withinLine = slope * xPos === yPos;
70
+ }
71
+ return withinLine;
72
+ },
73
+ boxPlot: (mousePosition, model, componentRect = { x: 0, y: 0, width: 0, height: 0 }) => {
74
+ return ['rect', 'median', 'minimum', 'maximum', 'upperWhisker', 'lowerWhisker'].some((prop) => {
75
+ if (!model[prop]) {
76
+ return false;
77
+ }
78
+ return prop === 'rect'
79
+ ? responderDetectors.rect(mousePosition, model[prop], componentRect)
80
+ : responderDetectors.line(mousePosition, model[prop], componentRect);
81
+ });
82
+ },
83
+ clockHand: (mousePosition, model, componentRect = { x: 0, y: 0, width: 0, height: 0 }) => {
84
+ const { x, y } = mousePosition;
85
+ const { x: compX, y: compY } = componentRect;
86
+ const { x: centerX, y: centerY, x2, y2, detectionSize = 5 } = model;
87
+ const numerator = y2 - centerY;
88
+ const denominator = x2 - centerX;
89
+ let withinClockHand = false;
90
+ if (numerator === 0) {
91
+ const minX = Math.min(centerX, x2);
92
+ const maxX = Math.max(centerX, x2);
93
+ withinClockHand =
94
+ x - compX >= minX &&
95
+ x - compX <= maxX &&
96
+ y >= centerY + compY - detectionSize &&
97
+ y <= centerY + compY + detectionSize;
98
+ }
99
+ else if (denominator === 0) {
100
+ const minY = Math.min(centerY, y2);
101
+ const maxY = Math.max(centerY, y2);
102
+ withinClockHand =
103
+ y - compY >= minY &&
104
+ y - compY <= maxY &&
105
+ x >= centerX + compX - detectionSize &&
106
+ x <= centerX + compX + detectionSize;
107
+ }
108
+ else {
109
+ const slope = numerator / denominator;
110
+ const yIntercept = centerY - slope * centerX;
111
+ withinClockHand = withinRotationRect({
112
+ slope,
113
+ yIntercept,
114
+ mouseX: x,
115
+ mouseY: y,
116
+ modelXPositions: [centerX, x2],
117
+ compX,
118
+ compY,
119
+ detectionSize,
120
+ });
121
+ }
122
+ return withinClockHand;
123
+ },
124
+ };
@@ -0,0 +1,24 @@
1
+ import { ValueEdge, ScaleData } from "../../types/store/store";
2
+ import { LineChartOptions, Scale } from "../../types/options";
3
+ declare type stackScaleType = 'percentStack' | 'minusPercentStack' | 'dualPercentStack' | 'divergingPercentStack';
4
+ export declare function getNormalizedStepCount(limitSize: number, stepSize: number): number;
5
+ export declare function makeScaleOption(dataRange: ValueEdge, scaleOptions?: Scale): Required<Scale>;
6
+ export declare function calculateCoordinateScale(options: {
7
+ dataRange: ValueEdge;
8
+ offsetSize: number;
9
+ useSpectrumLegend?: boolean;
10
+ scaleOption?: Scale;
11
+ minStepSize?: number;
12
+ }): ScaleData;
13
+ export declare function getStackScaleData(type: stackScaleType): ScaleData;
14
+ export declare function calculateXAxisScaleForCoordinateLineType(scale: ScaleData, options: LineChartOptions, categories: string[]): {
15
+ limit: {
16
+ max: number;
17
+ min: number;
18
+ };
19
+ stepCount: number;
20
+ stepSize: number;
21
+ positionRatio: number;
22
+ sizeRatio: number;
23
+ };
24
+ export {};
@@ -0,0 +1,174 @@
1
+ import { isNumber } from "../helpers/utils";
2
+ import { isDateType } from "../helpers/axes";
3
+ import { AxisType } from "../component/axis";
4
+ const SNAP_VALUES = [1, 2, 5, 10];
5
+ const DEFAULT_PIXELS_PER_STEP = 88;
6
+ function adjustLimitForOverflow({ min, max }, stepSize, overflowed) {
7
+ return {
8
+ min: overflowed.min ? min - stepSize : min,
9
+ max: overflowed.max ? max + stepSize : max,
10
+ };
11
+ }
12
+ function isSeriesOverflowed(scaleData, { min, max }, scaleOption) {
13
+ var _a, _b;
14
+ const scaleDataLimit = scaleData.limit;
15
+ const hasMinOption = isNumber((_a = scaleOption) === null || _a === void 0 ? void 0 : _a.min);
16
+ const hasMaxOption = isNumber((_b = scaleOption) === null || _b === void 0 ? void 0 : _b.max);
17
+ const isOverflowedMin = !hasMinOption && scaleDataLimit.min === min && scaleDataLimit.min !== 0;
18
+ const isOverflowedMax = !hasMaxOption && scaleDataLimit.max === max && scaleDataLimit.max !== 0;
19
+ if (!isOverflowedMin && !isOverflowedMax) {
20
+ return null;
21
+ }
22
+ return {
23
+ min: isOverflowedMin,
24
+ max: isOverflowedMax,
25
+ };
26
+ }
27
+ function getDigits(num) {
28
+ const logNumberDividedLN10 = num === 0 ? 1 : Math.log(Math.abs(num)) / Math.LN10;
29
+ return Math.pow(10, Math.floor(logNumberDividedLN10));
30
+ }
31
+ function getSnappedNumber(num) {
32
+ let snapNumber = 0;
33
+ for (let i = 0, t = SNAP_VALUES.length; i < t; i += 1) {
34
+ snapNumber = SNAP_VALUES[i];
35
+ const guideValue = (snapNumber + (SNAP_VALUES[i + 1] || snapNumber)) / 2;
36
+ if (num <= guideValue) {
37
+ break;
38
+ }
39
+ }
40
+ return snapNumber;
41
+ }
42
+ function getNormalizedStep(stepSize) {
43
+ const placeNumber = getDigits(stepSize);
44
+ const simplifiedStepValue = stepSize / placeNumber;
45
+ return getSnappedNumber(simplifiedStepValue) * placeNumber;
46
+ }
47
+ /**
48
+ * Get normalized limit values
49
+ * max = 155 and step = 10 ---> max = 160
50
+ */
51
+ function getNormalizedLimit(limit, stepSize) {
52
+ let { min, max } = limit;
53
+ const minNumber = Math.min(getDigits(max), getDigits(stepSize));
54
+ const placeNumber = minNumber > 1 ? 1 : 1 / minNumber;
55
+ const fixedStep = stepSize * placeNumber;
56
+ // ceil max value step digits
57
+ max = (Math.ceil((max * placeNumber) / fixedStep) * fixedStep) / placeNumber;
58
+ if (min > stepSize) {
59
+ // floor min value to multiples of step
60
+ min = (Math.floor((min * placeNumber) / fixedStep) * fixedStep) / placeNumber;
61
+ }
62
+ else if (min < 0) {
63
+ min = -(Math.ceil((Math.abs(min) * placeNumber) / fixedStep) * fixedStep) / placeNumber;
64
+ }
65
+ else {
66
+ min = 0;
67
+ }
68
+ return { min, max };
69
+ }
70
+ export function getNormalizedStepCount(limitSize, stepSize) {
71
+ const multiplier = 1 / Math.min(getDigits(limitSize), getDigits(stepSize));
72
+ return Math.ceil((limitSize * multiplier) / (stepSize * multiplier));
73
+ }
74
+ function hasStepSize(stepSize) {
75
+ return isNumber(stepSize);
76
+ }
77
+ function getNormalizedScale(scaleData, scale) {
78
+ const stepSize = hasStepSize(scale.stepSize)
79
+ ? scaleData.stepSize
80
+ : getNormalizedStep(scaleData.stepSize);
81
+ const edge = getNormalizedLimit(scaleData.limit, stepSize);
82
+ const limitSize = Math.abs(edge.max - edge.min);
83
+ const stepCount = getNormalizedStepCount(limitSize, stepSize);
84
+ return {
85
+ limit: {
86
+ min: edge.min,
87
+ max: edge.max,
88
+ },
89
+ stepSize,
90
+ stepCount,
91
+ };
92
+ }
93
+ function getRoughScale(scale, offsetSize, minStepSize = 1) {
94
+ const { min, max } = scale;
95
+ const limitSize = Math.abs(max - min);
96
+ const valuePerPixel = limitSize / offsetSize;
97
+ let stepCount = Math.ceil(offsetSize / DEFAULT_PIXELS_PER_STEP);
98
+ const pixelsPerStep = offsetSize / stepCount;
99
+ let stepSize = valuePerPixel * pixelsPerStep;
100
+ if (hasStepSize(scale.stepSize)) {
101
+ stepSize = scale.stepSize;
102
+ stepCount = limitSize / stepSize;
103
+ }
104
+ else if (isNumber(minStepSize) && stepSize < minStepSize) {
105
+ stepSize = minStepSize;
106
+ stepCount = limitSize / stepSize;
107
+ }
108
+ return { limit: { min, max }, stepSize, stepCount };
109
+ }
110
+ export function makeScaleOption(dataRange, scaleOptions) {
111
+ var _a, _b, _c, _d, _e, _f;
112
+ return {
113
+ max: (_b = (_a = scaleOptions) === null || _a === void 0 ? void 0 : _a.max, (_b !== null && _b !== void 0 ? _b : dataRange.max)),
114
+ min: (_d = (_c = scaleOptions) === null || _c === void 0 ? void 0 : _c.min, (_d !== null && _d !== void 0 ? _d : dataRange.min)),
115
+ stepSize: (_f = (_e = scaleOptions) === null || _e === void 0 ? void 0 : _e.stepSize, (_f !== null && _f !== void 0 ? _f : 'auto')),
116
+ };
117
+ }
118
+ export function calculateCoordinateScale(options) {
119
+ const { dataRange, scaleOption, offsetSize, minStepSize, useSpectrumLegend } = options;
120
+ const scale = makeScaleOption(dataRange, scaleOption);
121
+ const roughScale = getRoughScale(scale, offsetSize, minStepSize);
122
+ const normalizedScale = getNormalizedScale(roughScale, scale);
123
+ const overflowed = useSpectrumLegend
124
+ ? null
125
+ : isSeriesOverflowed(normalizedScale, scale, scaleOption);
126
+ if (overflowed) {
127
+ const { stepSize, limit } = normalizedScale;
128
+ normalizedScale.limit = adjustLimitForOverflow(limit, stepSize, overflowed);
129
+ }
130
+ return normalizedScale;
131
+ }
132
+ export function getStackScaleData(type) {
133
+ if (type === 'minusPercentStack') {
134
+ return { limit: { min: -100, max: 0 }, stepSize: 25, stepCount: 5 };
135
+ }
136
+ if (type === 'dualPercentStack') {
137
+ return { limit: { min: -100, max: 100 }, stepSize: 25, stepCount: 9 };
138
+ }
139
+ if (type === 'divergingPercentStack') {
140
+ return { limit: { min: -100, max: 100 }, stepSize: 25, stepCount: 9 };
141
+ }
142
+ return { limit: { min: 0, max: 100 }, stepSize: 25, stepCount: 5 };
143
+ }
144
+ export function calculateXAxisScaleForCoordinateLineType(scale, options, categories) {
145
+ const dateType = isDateType(options, AxisType.X);
146
+ const values = categories.map((value) => (dateType ? Number(new Date(value)) : Number(value)));
147
+ const { limit, stepSize } = scale;
148
+ const min = Math.min(...values);
149
+ const max = Math.max(...values);
150
+ const newLimit = Object.assign({}, limit);
151
+ const distance = max - min;
152
+ let positionRatio = 0;
153
+ let sizeRatio = 1;
154
+ if (distance) {
155
+ if (limit.min < min) {
156
+ newLimit.min += stepSize;
157
+ positionRatio = (newLimit.min - min) / distance;
158
+ sizeRatio -= positionRatio;
159
+ }
160
+ if (limit.max > max) {
161
+ newLimit.max -= stepSize;
162
+ sizeRatio -= (max - newLimit.max) / distance;
163
+ }
164
+ }
165
+ const limitSize = Math.abs(newLimit.max - newLimit.min);
166
+ const newStepCount = getNormalizedStepCount(limitSize, stepSize);
167
+ return {
168
+ limit: newLimit,
169
+ stepCount: newStepCount,
170
+ stepSize,
171
+ positionRatio,
172
+ sizeRatio,
173
+ };
174
+ }
@@ -0,0 +1,20 @@
1
+ import { ValueEdge } from "../../types/store/store";
2
+ import { Scale } from "../../types/options";
3
+ interface LabelOptions {
4
+ dataRange: ValueEdge;
5
+ offsetSize: number;
6
+ rawCategoriesSize: number;
7
+ scaleOption?: Scale;
8
+ showLabel?: boolean;
9
+ }
10
+ export declare function calculateDatetimeScale(options: LabelOptions): {
11
+ stepSize: number;
12
+ limit: {
13
+ min: number;
14
+ max: number;
15
+ };
16
+ stepCount: number;
17
+ sizeRatio?: number | undefined;
18
+ positionRatio?: number | undefined;
19
+ };
20
+ export {};
@@ -0,0 +1,59 @@
1
+ import { isExist, omit } from "../helpers/utils";
2
+ import { add, multiply, divide } from "../helpers/calculator";
3
+ import { calculateCoordinateScale, makeScaleOption } from "./coordinateScaleCalculator";
4
+ const msMap = {
5
+ year: 31536000000,
6
+ month: 2678400000,
7
+ week: 604800000,
8
+ date: 86400000,
9
+ hour: 3600000,
10
+ minute: 60000,
11
+ second: 1000,
12
+ };
13
+ export function calculateDatetimeScale(options) {
14
+ const { dataRange, rawCategoriesSize, scaleOption } = options;
15
+ const datetimeInfo = makeDatetimeInfo(dataRange, rawCategoriesSize, scaleOption);
16
+ const { minDate, divisionNumber, limit } = datetimeInfo;
17
+ const scale = calculateCoordinateScale(Object.assign(Object.assign({}, omit(options, 'scaleOption')), { dataRange: limit, minStepSize: 1 }));
18
+ return restoreScaleToDatetimeType(scale, minDate, divisionNumber);
19
+ }
20
+ const msTypes = ['year', 'month', 'week', 'date', 'hour', 'minute', 'second'];
21
+ function restoreScaleToDatetimeType(scale, minDate, divisionNumber) {
22
+ const { limit, stepSize } = scale;
23
+ const { min, max } = limit;
24
+ return Object.assign(Object.assign({}, scale), { stepSize: multiply(stepSize, divisionNumber), limit: {
25
+ min: multiply(add(min, minDate), divisionNumber),
26
+ max: multiply(add(max, minDate), divisionNumber),
27
+ } });
28
+ }
29
+ function makeDatetimeInfo(limit, count, scaleOption) {
30
+ var _a, _b;
31
+ const dateType = findDateType(limit, count);
32
+ const divisionNumber = (_b = (_a = scaleOption) === null || _a === void 0 ? void 0 : _a.stepSize, (_b !== null && _b !== void 0 ? _b : msMap[dateType]));
33
+ const scale = makeScaleOption(limit, scaleOption);
34
+ const minDate = divide(Number(new Date(scale.min)), divisionNumber);
35
+ const maxDate = divide(Number(new Date(scale.max)), divisionNumber);
36
+ return { divisionNumber, minDate, limit: { min: 0, max: maxDate - minDate } };
37
+ }
38
+ function findDateType({ max, min }, count) {
39
+ const diff = max - min;
40
+ const lastTypeIndex = msTypes.length - 1;
41
+ let foundType;
42
+ if (diff) {
43
+ msTypes.every((type, index) => {
44
+ const millisecond = msMap[type];
45
+ const dividedCount = Math.floor(diff / millisecond);
46
+ let foundIndex;
47
+ if (dividedCount) {
48
+ foundIndex =
49
+ index < lastTypeIndex && dividedCount < 2 && dividedCount < count ? index + 1 : index;
50
+ foundType = msTypes[foundIndex];
51
+ }
52
+ return !isExist(foundIndex);
53
+ });
54
+ }
55
+ else {
56
+ foundType = 'second';
57
+ }
58
+ return foundType;
59
+ }
@@ -0,0 +1,30 @@
1
+ import { CenterYAxisData, ChartOptionsUsingYAxis, InitAxisData, LabelAxisData, Layout, Options, ScaleData, Series, StoreModule } from "../../types/store/store";
2
+ import { BaseAxisOptions, BaseXAxisOptions, LineTypeXAxisOptions } from "../../types/options";
3
+ import { AxisTheme } from "../../types/theme";
4
+ interface StateProp {
5
+ scale: ScaleData;
6
+ axisSize: number;
7
+ options: Options;
8
+ series: Series;
9
+ theme: Required<AxisTheme>;
10
+ centerYAxis?: Pick<CenterYAxisData, 'xAxisHalfSize'> | null;
11
+ initialAxisData: InitAxisData;
12
+ labelOnYAxis?: boolean;
13
+ axisName: string;
14
+ }
15
+ declare type ValueStateProp = StateProp & {
16
+ categories: string[];
17
+ isCoordinateTypeChart: boolean;
18
+ };
19
+ declare type LabelAxisState = Omit<LabelAxisData, 'tickInterval' | 'labelInterval'>;
20
+ export interface AxisDataParams {
21
+ axis?: BaseAxisOptions | BaseXAxisOptions | LineTypeXAxisOptions;
22
+ categories?: string[];
23
+ layout?: Layout;
24
+ shift?: boolean;
25
+ isCoordinateTypeChart?: boolean;
26
+ }
27
+ export declare function isCenterYAxis(options: ChartOptionsUsingYAxis): boolean;
28
+ export declare function getLabelAxisData(stateProp: ValueStateProp): LabelAxisState;
29
+ declare const axes: StoreModule;
30
+ export default axes;