@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,299 @@
1
+ import { deepCopy, getFirstValidValue, includes, isBoolean, isNumber, isUndefined, range, } from "../helpers/utils";
2
+ import { makeRawCategories } from "./category";
3
+ import { getCoordinateXValue, isCoordinateSeries } from "../helpers/coordinate";
4
+ import { isZooming } from "../helpers/range";
5
+ import { message } from "../message";
6
+ import { hasNestedPieSeries } from "../helpers/pieSeries";
7
+ import { extend } from "./store";
8
+ function initRange(series, categories) {
9
+ let rawCategoriesLength;
10
+ if (categories) {
11
+ rawCategoriesLength = Array.isArray(categories) ? categories.length : categories.x.length;
12
+ }
13
+ else {
14
+ rawCategoriesLength = Object.keys(makeRawCategories(series, categories)).length;
15
+ }
16
+ return [0, rawCategoriesLength - 1];
17
+ }
18
+ function initSelectionRange(series, options, categories) {
19
+ var _a;
20
+ if (!(series.line || series.area || series.column) ||
21
+ !((_a = options.series) === null || _a === void 0 ? void 0 : _a.rangeSelectable)) {
22
+ return;
23
+ }
24
+ return initRange(series, categories);
25
+ }
26
+ function initZoomRange(series, options, categories) {
27
+ var _a;
28
+ if (!(series.line || series.area) || !((_a = options.series) === null || _a === void 0 ? void 0 : _a.zoomable)) {
29
+ return;
30
+ }
31
+ return initRange(series, categories);
32
+ }
33
+ function initShiftRange(series, options, categories) {
34
+ var _a;
35
+ if (!(series.line || series.area || series.column || series.heatmap) ||
36
+ !((_a = options.series) === null || _a === void 0 ? void 0 : _a.shift)) {
37
+ return;
38
+ }
39
+ return initRange(series, categories);
40
+ }
41
+ function getCoordinateDataRange(data, rawCategories, zoomRange) {
42
+ const [zoomStart, zoomEnd] = zoomRange;
43
+ let start, end;
44
+ range(zoomStart, zoomEnd + 1).forEach((i) => {
45
+ const idx = data.findIndex((datum) => getCoordinateXValue(datum).toString() === rawCategories[i]);
46
+ if (idx !== -1) {
47
+ if (isUndefined(start)) {
48
+ start = idx;
49
+ }
50
+ if (!isUndefined(start)) {
51
+ end = Math.max(idx, (end !== null && end !== void 0 ? end : 0));
52
+ }
53
+ }
54
+ });
55
+ return [start, end];
56
+ }
57
+ function getSeriesColors(colors, colorIndex, size, isColorByCategories) {
58
+ return isColorByCategories ? colors.slice(0, size + 1) : colors[colorIndex % colors.length];
59
+ }
60
+ function getSeriesDataInRange(data, rawCategories, chartType, zoomRange) {
61
+ if (!zoomRange) {
62
+ return data;
63
+ }
64
+ let [startIdx, endIdx] = zoomRange;
65
+ const firstValidValue = getFirstValidValue(data);
66
+ const isCoordinateChart = chartType !== 'area' && !isUndefined(firstValidValue) && !isNumber(firstValidValue);
67
+ if (isCoordinateChart) {
68
+ [startIdx, endIdx] = getCoordinateDataRange(data, rawCategories, zoomRange);
69
+ }
70
+ else {
71
+ startIdx = startIdx > 1 ? startIdx - 1 : startIdx;
72
+ endIdx = endIdx < rawCategories.length - 1 ? endIdx + 1 : endIdx;
73
+ }
74
+ return data.slice(startIdx, endIdx + 1);
75
+ }
76
+ function isCoordinateTypeSeries(series, chartType) {
77
+ return (isCoordinateSeries(series) &&
78
+ (isUndefined(chartType) || chartType === 'line' || chartType === 'scatter'));
79
+ }
80
+ function isSeriesAlreadyExist(series, seriesName, data) {
81
+ return series[seriesName].some(({ label }) => label === data.name);
82
+ }
83
+ function isTreemapSeriesAlreadyExist(series, data) {
84
+ return series.treemap.some(({ label }) => label === data.label);
85
+ }
86
+ function isHeatmapSeriesAlreadyExist(categories, category) {
87
+ return includes(categories.y, category);
88
+ }
89
+ function initDisabledSeries(series) {
90
+ const nestedPieChart = hasNestedPieSeries(series);
91
+ const disabledSeries = [];
92
+ if (nestedPieChart) {
93
+ series.pie.forEach(({ data }) => {
94
+ data.forEach((datum) => {
95
+ if (isBoolean(datum.visible) && !datum.visible) {
96
+ disabledSeries.push(datum.name);
97
+ }
98
+ });
99
+ });
100
+ }
101
+ else {
102
+ Object.keys(series).forEach((type) => {
103
+ series[type].forEach(({ name, visible }) => {
104
+ if (isBoolean(visible) && !visible) {
105
+ disabledSeries.push(name);
106
+ }
107
+ });
108
+ });
109
+ }
110
+ return disabledSeries;
111
+ }
112
+ const seriesData = {
113
+ name: 'seriesData',
114
+ state: ({ series, categories, options }) => ({
115
+ rawCategories: makeRawCategories(series, categories),
116
+ series: Object.assign({}, series),
117
+ selectionRange: initSelectionRange(series, options, categories),
118
+ zoomRange: initZoomRange(series, options, categories),
119
+ shiftRange: initShiftRange(series, options, categories),
120
+ disabledSeries: initDisabledSeries(series),
121
+ }),
122
+ action: {
123
+ setSeriesData({ state, initStoreState }) {
124
+ const rawSeries = deepCopy(initStoreState.series);
125
+ const { disabledSeries, theme, zoomRange, rawCategories } = state;
126
+ const newSeriesData = {};
127
+ let colorIndex = 0;
128
+ Object.keys(rawSeries).forEach((seriesName) => {
129
+ var _a, _b, _c;
130
+ const { colors, iconTypes } = theme.series[seriesName];
131
+ let originSeriesData = rawSeries[seriesName].map((series) => {
132
+ const isColorByCategories = !!series.colorByCategories;
133
+ const size = isColorByCategories ? rawCategories.length : 1;
134
+ const color = colors
135
+ ? getSeriesColors(colors, colorIndex, size, isColorByCategories)
136
+ : '';
137
+ colorIndex += size;
138
+ return Object.assign(Object.assign({}, series), { rawData: series.data, data: getSeriesDataInRange(series.data, rawCategories, seriesName, zoomRange), color });
139
+ });
140
+ if (seriesName === 'scatter') {
141
+ originSeriesData = originSeriesData.map((series, idx) => (Object.assign(Object.assign({}, series), { iconType: iconTypes ? iconTypes[idx] : 'circle' })));
142
+ }
143
+ const seriesCount = originSeriesData.length;
144
+ const seriesGroupCount = (_c = (_b = (_a = originSeriesData[0]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length, (_c !== null && _c !== void 0 ? _c : 0));
145
+ const data = originSeriesData.filter(({ name }) => !disabledSeries.includes(name));
146
+ newSeriesData[seriesName] = {
147
+ seriesCount,
148
+ seriesGroupCount,
149
+ data,
150
+ colors,
151
+ };
152
+ });
153
+ extend(state.series, newSeriesData);
154
+ },
155
+ disableSeries({ state }, name) {
156
+ state.disabledSeries.push(name);
157
+ this.notify(state, 'disabledSeries');
158
+ if (state.series.bullet) {
159
+ this.dispatch('removeCategoryByName', name);
160
+ }
161
+ },
162
+ enableSeries({ state }, name) {
163
+ const index = state.disabledSeries.findIndex((disabled) => disabled === name);
164
+ state.disabledSeries.splice(index, 1);
165
+ this.notify(state, 'disabledSeries');
166
+ if (state.series.bullet) {
167
+ state.categories = state.series.bullet.data.map(({ name: seriesName }) => seriesName);
168
+ this.notify(state, 'axes');
169
+ }
170
+ },
171
+ selection({ state }, rangeCategories) {
172
+ const rawCategories = state.rawCategories;
173
+ state.selectionRange = rangeCategories.map((rangeCategory) => rawCategories.findIndex((category) => category === rangeCategory));
174
+ this.notify(state, 'selectionRange');
175
+ },
176
+ zoom({ state }, rangeCategories) {
177
+ const rawCategories = state.rawCategories;
178
+ state.zoomRange = rangeCategories.map((rangeCategory) => rawCategories.findIndex((category) => category === rangeCategory));
179
+ this.notify(state, 'zoomRange');
180
+ },
181
+ resetZoom({ state, initStoreState }) {
182
+ const { series, options } = initStoreState;
183
+ const rawCategories = state.rawCategories;
184
+ state.zoomRange = initZoomRange(series, options, rawCategories);
185
+ this.notify(state, 'zoomRange');
186
+ },
187
+ addData({ state, initStoreState }, { data, category, chartType }) {
188
+ const { series } = initStoreState;
189
+ const coordinateChart = isCoordinateTypeSeries(state.series, chartType);
190
+ let { categories } = initStoreState;
191
+ categories = series.heatmap ? categories.x : categories;
192
+ if (category && Array.isArray(categories)) {
193
+ const isExist = categories.some((c) => c === category);
194
+ if (!isExist) {
195
+ categories.push(category);
196
+ if (Array.isArray(state.shiftRange)) {
197
+ const [start, end] = state.shiftRange;
198
+ state.shiftRange = [start + 1, end + 1];
199
+ }
200
+ }
201
+ }
202
+ if (chartType) {
203
+ series[chartType].forEach((datum, idx) => {
204
+ datum.data.push(data[idx]);
205
+ });
206
+ }
207
+ else {
208
+ const [seriesName] = Object.keys(initStoreState.series);
209
+ series[seriesName].forEach((datum, idx) => {
210
+ datum.data.push(data[idx]);
211
+ });
212
+ }
213
+ this.notify(state, 'series');
214
+ this.notify(state, 'rawCategories');
215
+ if (Array.isArray(state.zoomRange)) {
216
+ this.dispatch('resetZoom');
217
+ }
218
+ if (coordinateChart) {
219
+ this.dispatch('initCategory');
220
+ }
221
+ },
222
+ addSeries({ state, initStoreState }, { data, chartType, category, }) {
223
+ const { series, categories } = initStoreState;
224
+ const coordinateChart = isCoordinateTypeSeries(state.series, chartType);
225
+ const seriesName = chartType || Object.keys(series)[0];
226
+ const isExist = isSeriesAlreadyExist(series, seriesName, data);
227
+ if (!isExist) {
228
+ series[seriesName].push(data);
229
+ if (Array.isArray(categories) && category) {
230
+ categories.push(category);
231
+ }
232
+ }
233
+ this.dispatch('initThemeState');
234
+ this.dispatch('initLegendState');
235
+ this.notify(state, 'series');
236
+ if (coordinateChart || seriesName === 'bullet') {
237
+ this.dispatch('initCategory');
238
+ }
239
+ },
240
+ addHeatmapSeries({ state, initStoreState }, { data, category }) {
241
+ const { series, categories } = initStoreState;
242
+ const isExist = isHeatmapSeriesAlreadyExist(categories, category);
243
+ if (!isExist) {
244
+ series.heatmap.push({ data, yCategory: category });
245
+ }
246
+ if (!isExist && category) {
247
+ categories.y.push(category);
248
+ this.notify(state, 'rawCategories');
249
+ }
250
+ this.notify(state, 'series');
251
+ this.dispatch('initThemeState');
252
+ this.dispatch('initLegendState');
253
+ },
254
+ addTreemapSeries({ state, initStoreState }, { data }) {
255
+ const { series } = initStoreState;
256
+ const isExist = isTreemapSeriesAlreadyExist(series, data);
257
+ if (!isExist) {
258
+ series.treemap.push(data);
259
+ }
260
+ this.notify(state, 'series');
261
+ this.notify(state, 'treemapSeries');
262
+ this.dispatch('initThemeState');
263
+ this.dispatch('initLegendState');
264
+ },
265
+ setData({ state, initStoreState }, { series, categories }) {
266
+ initStoreState.series = series;
267
+ const isNestedPieChart = hasNestedPieSeries(series);
268
+ if (!isNestedPieChart) {
269
+ state.rawCategories = makeRawCategories(series, categories);
270
+ }
271
+ this.dispatch('initThemeState');
272
+ this.dispatch('initLegendState');
273
+ },
274
+ addOutlier({ state, initStoreState }, { seriesIndex, outliers }) {
275
+ var _a;
276
+ const { series } = initStoreState;
277
+ const seriesRawData = series.boxPlot[seriesIndex];
278
+ if (!seriesRawData) {
279
+ throw new Error(message.SERIES_INDEX_ERROR);
280
+ }
281
+ seriesRawData.outliers = [...(_a = seriesRawData.outliers, (_a !== null && _a !== void 0 ? _a : [])), ...outliers];
282
+ this.notify(state, 'series');
283
+ },
284
+ },
285
+ observe: {
286
+ updateSeriesData() {
287
+ this.dispatch('setSeriesData');
288
+ },
289
+ },
290
+ computed: {
291
+ isLineTypeSeriesZooming: ({ zoomRange, rawCategories }) => {
292
+ return isZooming(rawCategories, zoomRange);
293
+ },
294
+ viewRange: ({ zoomRange, shiftRange }) => {
295
+ return zoomRange || shiftRange;
296
+ },
297
+ },
298
+ };
299
+ export default seriesData;
@@ -0,0 +1,8 @@
1
+ import { StoreModule, StackDataType, StackGroupData, Options, Stack, StackSeries } from "../../types/store/store";
2
+ import { StackOptionType } from "../../types/options";
3
+ export declare function isPercentStack(stack?: Stack): boolean;
4
+ export declare function isGroupStack(rawData: StackDataType): rawData is StackGroupData;
5
+ export declare function hasPercentStackSeries(stackSeries: StackSeries): boolean;
6
+ export declare function pickStackOption(options: Options): StackOptionType;
7
+ declare const stackSeriesData: StoreModule;
8
+ export default stackSeriesData;
@@ -0,0 +1,192 @@
1
+ import { extend } from "./store";
2
+ import { pickProperty, isObject, sum } from "../helpers/utils";
3
+ export function isPercentStack(stack) {
4
+ var _a;
5
+ return !!(((_a = stack) === null || _a === void 0 ? void 0 : _a.type) === 'percent');
6
+ }
7
+ export function isGroupStack(rawData) {
8
+ return !Array.isArray(rawData);
9
+ }
10
+ export function hasPercentStackSeries(stackSeries) {
11
+ if (!stackSeries) {
12
+ return false;
13
+ }
14
+ return Object.keys(stackSeries).some((seriesName) => isPercentStack(stackSeries[seriesName].stack));
15
+ }
16
+ export function pickStackOption(options) {
17
+ return (pickProperty(options, ['series', 'stack']) ||
18
+ pickProperty(options, ['series', 'column', 'stack']) ||
19
+ pickProperty(options, ['series', 'area', 'stack']));
20
+ }
21
+ function makeStackData(seriesData) {
22
+ const seriesCount = seriesData.length;
23
+ const groupCountLengths = seriesData.map(({ rawData }) => rawData.length);
24
+ const seriesGroupCount = Math.max(...groupCountLengths);
25
+ const stackData = [];
26
+ for (let i = 0; i < seriesGroupCount; i += 1) {
27
+ const stackValues = [];
28
+ for (let j = 0; j < seriesCount; j += 1) {
29
+ stackValues.push(seriesData[j].rawData[i]);
30
+ }
31
+ stackData[i] = {
32
+ values: stackValues,
33
+ sum: sum(stackValues),
34
+ total: {
35
+ positive: sum(stackValues.filter((value) => value >= 0)),
36
+ negative: sum(stackValues.filter((value) => value < 0)),
37
+ },
38
+ };
39
+ }
40
+ return stackData;
41
+ }
42
+ function makeStackGroupData(seriesData) {
43
+ const stackData = {};
44
+ const stackGroupIds = [...new Set(seriesData.map(({ stackGroup }) => stackGroup))];
45
+ stackGroupIds.forEach((groupId) => {
46
+ const filtered = seriesData.filter(({ stackGroup }) => groupId === stackGroup);
47
+ stackData[groupId] = makeStackData(filtered);
48
+ });
49
+ return stackData;
50
+ }
51
+ function initializeStack(stackOption) {
52
+ if (!stackOption) {
53
+ return;
54
+ }
55
+ const defaultStackOption = {
56
+ type: 'normal',
57
+ connector: false,
58
+ };
59
+ if (isStackObject(stackOption)) {
60
+ return Object.assign(Object.assign({}, defaultStackOption), stackOption);
61
+ }
62
+ return defaultStackOption;
63
+ }
64
+ function isStackObject(stackOption) {
65
+ return isObject(stackOption);
66
+ }
67
+ function hasStackGrouped(seriesRawData) {
68
+ return seriesRawData.some((rawData) => rawData.hasOwnProperty('stackGroup'));
69
+ }
70
+ function getStackDataRangeValues(stackData) {
71
+ let values = [];
72
+ if (Array.isArray(stackData)) {
73
+ values = [0, ...getSumValues(stackData)];
74
+ }
75
+ else {
76
+ for (const groupId in stackData) {
77
+ if (Object.prototype.hasOwnProperty.call(stackData, groupId)) {
78
+ values = [0, ...values, ...getSumValues(stackData[groupId])];
79
+ }
80
+ }
81
+ }
82
+ return values;
83
+ }
84
+ function getSumValues(stackData) {
85
+ const positiveSum = stackData.map(({ total }) => total.positive);
86
+ const negativeSum = stackData.map(({ total }) => total.negative);
87
+ return [...negativeSum, ...positiveSum];
88
+ }
89
+ function getStackDataValues(stackData) {
90
+ if (!isGroupStack(stackData)) {
91
+ return stackData;
92
+ }
93
+ let stackDataValues = [];
94
+ if (isGroupStack(stackData)) {
95
+ Object.keys(stackData).forEach((groupId) => {
96
+ stackDataValues = [...stackDataValues, ...stackData[groupId]];
97
+ });
98
+ }
99
+ return stackDataValues;
100
+ }
101
+ function checkIfNegativeAndPositiveValues(stackData) {
102
+ return {
103
+ hasNegative: stackData.map(({ total }) => total.negative).some((total) => total < 0),
104
+ hasPositive: stackData.map(({ total }) => total.positive).some((total) => total >= 0),
105
+ };
106
+ }
107
+ function getScaleType(stackData, stackType, diverging) {
108
+ const { hasPositive, hasNegative } = checkIfNegativeAndPositiveValues(stackData);
109
+ if (stackType === 'percent') {
110
+ if (diverging) {
111
+ return 'divergingPercentStack';
112
+ }
113
+ if (hasNegative && hasPositive) {
114
+ return 'dualPercentStack';
115
+ }
116
+ if (!hasNegative && hasPositive) {
117
+ return 'percentStack';
118
+ }
119
+ if (hasNegative && !hasPositive) {
120
+ return 'minusPercentStack';
121
+ }
122
+ }
123
+ }
124
+ function initStackSeries(series, options) {
125
+ const stackSeries = {};
126
+ Object.keys(series).forEach((seriesName) => {
127
+ const chartType = seriesName;
128
+ const stackOption = pickStackOption(options);
129
+ if (stackOption) {
130
+ if (!stackSeries[chartType]) {
131
+ stackSeries[chartType] = {};
132
+ }
133
+ stackSeries[chartType].stack = initializeStack(stackOption);
134
+ }
135
+ else if (seriesName === 'radialBar') {
136
+ stackSeries[seriesName] = { stack: true };
137
+ }
138
+ });
139
+ return stackSeries;
140
+ }
141
+ const stackSeriesData = {
142
+ name: 'stackSeriesData',
143
+ state: ({ series, options }) => ({
144
+ stackSeries: initStackSeries(series, options),
145
+ }),
146
+ action: {
147
+ setStackSeriesData({ state }) {
148
+ const { series, stackSeries, options } = state;
149
+ const stackOption = pickStackOption(options);
150
+ const newStackSeries = {};
151
+ Object.keys(series).forEach((seriesName) => {
152
+ var _a, _b;
153
+ const seriesData = series[seriesName];
154
+ const { data, seriesCount, seriesGroupCount } = seriesData;
155
+ const isRadialBar = seriesName === 'radialBar';
156
+ if (stackOption) {
157
+ if (!stackSeries[seriesName]) {
158
+ stackSeries[seriesName] = {};
159
+ }
160
+ stackSeries[seriesName].stack = initializeStack(stackOption);
161
+ }
162
+ else if (!isRadialBar) {
163
+ stackSeries[seriesName] = null;
164
+ delete stackSeries[seriesName];
165
+ }
166
+ const { stack } = stackSeries[seriesName] || {};
167
+ const diverging = !!((_a = options.series) === null || _a === void 0 ? void 0 : _a.diverging);
168
+ if (stack) {
169
+ const stackData = hasStackGrouped(data) ? makeStackGroupData(data) : makeStackData(data);
170
+ const stackType = (_b = stack.type, (_b !== null && _b !== void 0 ? _b : 'normal'));
171
+ const dataRangeValues = getStackDataRangeValues(stackData);
172
+ newStackSeries[seriesName] = {
173
+ data,
174
+ seriesCount,
175
+ seriesGroupCount,
176
+ stackData,
177
+ dataRangeValues,
178
+ scaleType: getScaleType(getStackDataValues(stackData), stackType, diverging),
179
+ };
180
+ state.stackSeries[seriesName].stackData = stackData;
181
+ }
182
+ extend(state.stackSeries, newStackSeries);
183
+ });
184
+ },
185
+ },
186
+ observe: {
187
+ updateStackSeriesData() {
188
+ this.dispatch('setStackSeriesData');
189
+ },
190
+ },
191
+ };
192
+ export default stackSeriesData;
@@ -0,0 +1,20 @@
1
+ import { ChartState, InitStoreState, ActionFunc, StoreOptions, ComputedFunc, WatchFunc, StoreModule, ObserveFunc, Options } from "../../types/store/store";
2
+ export default class Store<T extends Options> {
3
+ state: ChartState<T>;
4
+ initStoreState: InitStoreState<T>;
5
+ computed: Record<string, any>;
6
+ actions: Record<string, ActionFunc>;
7
+ constructor(initStoreState: InitStoreState<T>);
8
+ setRootState(state: Partial<ChartState<T>>): void;
9
+ setComputed(namePath: string, fn: ComputedFunc, holder?: any): void;
10
+ setWatch(namePath: string, fn: WatchFunc): Function | null;
11
+ setAction(name: string, fn: ActionFunc): void;
12
+ dispatch(name: string, payload?: any, isInvisible?: boolean): void;
13
+ observe(fn: ObserveFunc): Function;
14
+ observable(target: Record<string, any>): Record<string, any>;
15
+ notifyByPath(namePath: string): void;
16
+ notify<T extends Record<string, any>, K extends keyof T>(target: T, key: K): void;
17
+ setModule(name: string | StoreModule, param?: StoreOptions | StoreModule): void;
18
+ setValue(target: Record<string, any>, key: string, source: Record<string, any>): void;
19
+ }
20
+ export declare function extend<T extends Record<string, any>>(target: T, source: Partial<T>): void;
@@ -0,0 +1,112 @@
1
+ import { observable, observe, notify, notifyByPath, computed, watch, extend as reactiveExtend, invisibleWork, } from "./reactive";
2
+ import { isUndefined, forEach, pickPropertyWithMakeup, deepCopy } from "../helpers/utils";
3
+ export default class Store {
4
+ constructor(initStoreState) {
5
+ this.computed = {};
6
+ this.actions = {};
7
+ this.initStoreState = deepCopy(initStoreState);
8
+ this.setRootState({});
9
+ }
10
+ setRootState(state) {
11
+ observable(state);
12
+ this.state = state;
13
+ }
14
+ setComputed(namePath, fn, holder = this.computed) {
15
+ const splited = namePath.split('.');
16
+ const key = splited.splice(splited.length - 1, 1)[0];
17
+ const target = pickPropertyWithMakeup(holder, splited);
18
+ computed(target, key, fn.bind(null, this.state, this.computed));
19
+ }
20
+ setWatch(namePath, fn) {
21
+ return watch(this, namePath, fn);
22
+ }
23
+ setAction(name, fn) {
24
+ this.actions[name] = fn;
25
+ }
26
+ dispatch(name, payload, isInvisible) {
27
+ // observe.setlayout 안에서 setLayout 액션이 실행되니까 여기서 state.layout getter가 실행되고
28
+ // state.layout의 옵져버로 observe.setLayout이 등록된다. 여기서 무한루프
29
+ // 즉 observe하고 안에서 특정 대상을 쓸때
30
+ // extend(state.layout, layouts); 이런식으로 하게되면 layout의 getter실행되어
31
+ // layout을 업데이트하려고 만든 observe를 옵저버로 등록해서 무한루프
32
+ if (isInvisible) {
33
+ invisibleWork(() => {
34
+ // console.log('dispatch', name, ...args);
35
+ this.actions[name].call(this, this, payload);
36
+ // console.log('dispatch end', name);
37
+ });
38
+ }
39
+ else {
40
+ this.actions[name].call(this, this, payload);
41
+ }
42
+ }
43
+ observe(fn) {
44
+ return observe(fn.bind(this, this.state, this.computed));
45
+ }
46
+ observable(target) {
47
+ return observable(target);
48
+ }
49
+ notifyByPath(namePath) {
50
+ notifyByPath(this, namePath);
51
+ }
52
+ notify(target, key) {
53
+ notify(target, key);
54
+ }
55
+ setModule(name, param) {
56
+ if (!param) {
57
+ param = name;
58
+ name = param.name;
59
+ }
60
+ if (param.state) {
61
+ const moduleState = typeof param.state === 'function' ? param.state(this.initStoreState) : param.state;
62
+ extend(this.state, moduleState);
63
+ }
64
+ if (param.computed) {
65
+ forEach(param.computed, (item, key) => {
66
+ this.setComputed(key, item);
67
+ });
68
+ }
69
+ if (param.watch) {
70
+ forEach(param.watch, (item, key) => {
71
+ this.setWatch(key, item);
72
+ });
73
+ }
74
+ if (param.action) {
75
+ forEach(param.action, (item, key) => {
76
+ this.setAction(key, item);
77
+ });
78
+ }
79
+ if (param.observe) {
80
+ forEach(param.observe, (item) => {
81
+ this.observe(item);
82
+ });
83
+ }
84
+ }
85
+ setValue(target, key, source) {
86
+ extend(target, {
87
+ [key]: source,
88
+ });
89
+ }
90
+ }
91
+ export function extend(target, source) {
92
+ const newItems = {};
93
+ for (const k in source) {
94
+ if (!source.hasOwnProperty(k)) {
95
+ continue;
96
+ }
97
+ if (!isUndefined(target[k])) {
98
+ if (typeof source[k] === 'object' && !Array.isArray(source[k])) {
99
+ extend(target[k], source[k]);
100
+ }
101
+ else {
102
+ target[k] = source[k];
103
+ }
104
+ }
105
+ else {
106
+ newItems[k] = source[k];
107
+ }
108
+ }
109
+ if (Object.keys(newItems).length) {
110
+ reactiveExtend(target, newItems);
111
+ }
112
+ }
@@ -0,0 +1,3 @@
1
+ import { StoreModule } from "../../types/store/store";
2
+ declare const theme: StoreModule;
3
+ export default theme;