@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,487 @@
1
+ import { extend } from "./store";
2
+ import { isUndefined, pick, isNumber } from "../helpers/utils";
3
+ import { isCenterYAxis } from "./axes";
4
+ import { BUTTON_RECT_SIZE } from "../component/exportMenu";
5
+ import { TICK_SIZE } from "../brushes/axis";
6
+ import { SPECTRUM_LEGEND_LABEL_HEIGHT, spectrumLegendBar, spectrumLegendTooltip, } from "../brushes/spectrumLegend";
7
+ import { getYAxisOption } from "../helpers/axes";
8
+ export const padding = { X: 10, Y: 15 };
9
+ export const X_AXIS_HEIGHT = 20;
10
+ const Y_AXIS_MIN_WIDTH = 40;
11
+ export function isVerticalAlign(align) {
12
+ return align === 'top' || align === 'bottom';
13
+ }
14
+ function getValidRectSize(size, width, height) {
15
+ var _a, _b, _c, _d;
16
+ return {
17
+ height: (_b = (_a = size) === null || _a === void 0 ? void 0 : _a.height, (_b !== null && _b !== void 0 ? _b : height)),
18
+ width: (_d = (_c = size) === null || _c === void 0 ? void 0 : _c.width, (_d !== null && _d !== void 0 ? _d : width)),
19
+ };
20
+ }
21
+ function getDefaultXAxisHeight(size) {
22
+ var _a;
23
+ return ((_a = size.xAxis) === null || _a === void 0 ? void 0 : _a.height) && !size.yAxis ? size.xAxis.height : X_AXIS_HEIGHT;
24
+ }
25
+ function getDefaultYAxisXPoint(yAxisRectParam) {
26
+ const { yAxisTitle, isRightSide, visibleSecondaryYAxis } = yAxisRectParam;
27
+ const yAxisWidth = getDefaultYAxisWidth(yAxisRectParam);
28
+ return isRightSide && visibleSecondaryYAxis
29
+ ? Math.max(yAxisTitle.x + yAxisTitle.width - yAxisWidth, 0)
30
+ : yAxisTitle.x;
31
+ }
32
+ function getYAxisXPoint(yAxisRectParam) {
33
+ const { chartSize, legend, circleLegend, hasCenterYAxis, maxLabelWidth } = yAxisRectParam;
34
+ const { width } = chartSize;
35
+ const { align } = legend;
36
+ let yAxisWidth = getDefaultYAxisWidth(yAxisRectParam);
37
+ let x = getDefaultYAxisXPoint(yAxisRectParam);
38
+ if (hasCenterYAxis) {
39
+ yAxisWidth = maxLabelWidth + (TICK_SIZE + padding.X) * 2;
40
+ x = (width - legend.width - yAxisWidth + padding.X * 2) / 2;
41
+ }
42
+ if (legend.visible && align === 'left') {
43
+ x = getDefaultYAxisXPoint(yAxisRectParam);
44
+ }
45
+ if (circleLegend.visible && align === 'left') {
46
+ x = Math.max(circleLegend.width + padding.X, x);
47
+ }
48
+ return x;
49
+ }
50
+ function getYAxisYPoint({ yAxisTitle }) {
51
+ return yAxisTitle.y + yAxisTitle.height;
52
+ }
53
+ function getDefaultYAxisWidth({ maxLabelWidth, size, isRightSide }) {
54
+ var _a, _b, _c;
55
+ return _c = (_b = (_a = size) === null || _a === void 0 ? void 0 : _a[isRightSide ? 'secondaryYAxis' : 'yAxis']) === null || _b === void 0 ? void 0 : _b.width, (_c !== null && _c !== void 0 ? _c : maxLabelWidth);
56
+ }
57
+ function getYAxisWidth(yAxisRectParam) {
58
+ const { hasCenterYAxis, hasXYAxis, maxLabelWidth, visibleSecondaryYAxis = false, isRightSide = false, } = yAxisRectParam;
59
+ let yAxisWidth = getDefaultYAxisWidth(yAxisRectParam);
60
+ if (hasCenterYAxis && !isRightSide) {
61
+ yAxisWidth = maxLabelWidth + (TICK_SIZE + padding.X) * 2;
62
+ }
63
+ else if (!hasXYAxis || (isRightSide && !visibleSecondaryYAxis)) {
64
+ yAxisWidth = 0;
65
+ }
66
+ return yAxisWidth;
67
+ }
68
+ function getYAxisHeight({ chartSize, legend, yAxisTitle, hasXYAxis, size, xAxisTitleHeight, }) {
69
+ var _a, _b, _c, _d;
70
+ const { height } = chartSize;
71
+ const { align, height: legendHeight } = legend;
72
+ const xAxisHeight = getDefaultXAxisHeight(size);
73
+ const y = yAxisTitle.y + yAxisTitle.height;
74
+ let yAxisHeight = height - y - xAxisHeight - xAxisTitleHeight;
75
+ if (!hasXYAxis) {
76
+ yAxisHeight = height - y;
77
+ }
78
+ if (legend.visible) {
79
+ const topArea = Math.max(y, legendHeight);
80
+ if (align === 'top') {
81
+ yAxisHeight = height - topArea - (hasXYAxis ? X_AXIS_HEIGHT + xAxisTitleHeight : 0);
82
+ }
83
+ else if (align === 'bottom') {
84
+ yAxisHeight = height - y - X_AXIS_HEIGHT - xAxisTitleHeight - legendHeight;
85
+ }
86
+ }
87
+ if (!((_b = (_a = size) === null || _a === void 0 ? void 0 : _a.yAxis) === null || _b === void 0 ? void 0 : _b.height) && ((_d = (_c = size) === null || _c === void 0 ? void 0 : _c.plot) === null || _d === void 0 ? void 0 : _d.height)) {
88
+ yAxisHeight = size.plot.height;
89
+ }
90
+ return yAxisHeight;
91
+ }
92
+ function getYAxisRect(yAxisRectParam) {
93
+ var _a, _b;
94
+ const { size, isRightSide = false } = yAxisRectParam;
95
+ const x = getYAxisXPoint(yAxisRectParam);
96
+ const y = getYAxisYPoint(yAxisRectParam);
97
+ const yAxisWidth = getYAxisWidth(yAxisRectParam);
98
+ const yAxisHeight = getYAxisHeight(yAxisRectParam);
99
+ return Object.assign({ x,
100
+ y }, getValidRectSize(isRightSide ? (_a = size) === null || _a === void 0 ? void 0 : _a.secondaryYAxis : (_b = size) === null || _b === void 0 ? void 0 : _b.yAxis, yAxisWidth, yAxisHeight));
101
+ }
102
+ function getXAxisWidth({ chartSize, yAxis, hasCenterYAxis, legend, circleLegend, secondaryYAxis, xAxisData, }) {
103
+ var _a;
104
+ const { width } = chartSize;
105
+ const { align, width: legendWidth } = legend;
106
+ const legendVerticalAlign = isVerticalAlign(align);
107
+ let xAxisWidth;
108
+ if (legendVerticalAlign) {
109
+ xAxisWidth = width - (yAxis.x + yAxis.width + padding.X);
110
+ if (circleLegend.visible) {
111
+ xAxisWidth -= circleLegend.width;
112
+ }
113
+ }
114
+ else {
115
+ xAxisWidth =
116
+ width - (yAxis.width + Math.max(legendWidth, circleLegend.visible ? circleLegend.width : 0));
117
+ }
118
+ if (hasCenterYAxis) {
119
+ xAxisWidth = width - (legendVerticalAlign ? 0 : legendWidth) - padding.X * 2;
120
+ }
121
+ if (secondaryYAxis.width) {
122
+ xAxisWidth -= secondaryYAxis.width;
123
+ }
124
+ if ((_a = xAxisData) === null || _a === void 0 ? void 0 : _a.maxLabelWidth) {
125
+ // subtract half of the maximum label length to secure margin size
126
+ xAxisWidth -= xAxisData.maxLabelWidth * 0.5;
127
+ }
128
+ return xAxisWidth;
129
+ }
130
+ function getXAxisHeight(xAxisData, hasXYAxis = false) {
131
+ var _a, _b;
132
+ if (!hasXYAxis) {
133
+ return 0;
134
+ }
135
+ return _b = (_a = xAxisData) === null || _a === void 0 ? void 0 : _a.maxHeight, (_b !== null && _b !== void 0 ? _b : X_AXIS_HEIGHT);
136
+ }
137
+ function getXAxisRect(xAxisRectParam) {
138
+ var _a;
139
+ const { hasXYAxis, hasCenterYAxis, yAxis, size, xAxisData } = xAxisRectParam;
140
+ const x = hasCenterYAxis ? padding.X * 2 : yAxis.x + yAxis.width;
141
+ const y = yAxis.y + yAxis.height;
142
+ const xAxisWidth = getXAxisWidth(xAxisRectParam);
143
+ const xAxisHeight = getXAxisHeight(xAxisData, hasXYAxis);
144
+ return Object.assign({ x,
145
+ y }, getValidRectSize((_a = size) === null || _a === void 0 ? void 0 : _a.xAxis, xAxisWidth, xAxisHeight));
146
+ }
147
+ function getLegendRect(legendRectParams) {
148
+ const { legend, xAxis, yAxis, chartSize, title, hasXYAxis, secondaryYAxis, xAxisTitleHeight, } = legendRectParams;
149
+ if (!legend.visible) {
150
+ return {
151
+ x: 0,
152
+ y: 0,
153
+ width: 0,
154
+ height: 0,
155
+ };
156
+ }
157
+ const { align, width: legendWidth, height: legendHeight } = legend;
158
+ const { width } = chartSize;
159
+ const verticalAlign = isVerticalAlign(align);
160
+ let x = xAxis.x + xAxis.width + secondaryYAxis.width + padding.X;
161
+ let y = Math.max(yAxis.y, BUTTON_RECT_SIZE);
162
+ if (verticalAlign) {
163
+ x = (width - legendWidth) / 2;
164
+ if (align === 'top') {
165
+ y = title.y + title.height;
166
+ }
167
+ else {
168
+ y = yAxis.y + yAxis.height + (hasXYAxis ? xAxis.height + xAxisTitleHeight : padding.Y);
169
+ }
170
+ }
171
+ else if (align === 'left') {
172
+ x = padding.X;
173
+ }
174
+ return { width: legendWidth, height: legendHeight, x, y };
175
+ }
176
+ function getCircleLegendRect(xAxis, yAxis, align, width) {
177
+ return {
178
+ width,
179
+ height: yAxis.height,
180
+ x: align === 'left' ? padding.X : xAxis.x + xAxis.width + padding.X,
181
+ y: yAxis.y,
182
+ };
183
+ }
184
+ function getPlotRect(xAxis, yAxis, size) {
185
+ return Object.assign({ x: xAxis.x, y: yAxis.y }, getValidRectSize(size, xAxis.width, yAxis.height));
186
+ }
187
+ function getTitleRect(chartSize, exportMenu, visible, titleHeight) {
188
+ const point = { x: padding.X, y: padding.Y };
189
+ const marginBottom = 5;
190
+ const width = visible ? chartSize.width - exportMenu.width : 0;
191
+ const height = visible
192
+ ? Math.max(titleHeight + marginBottom, exportMenu.height)
193
+ : exportMenu.height;
194
+ return Object.assign({ width, height }, point);
195
+ }
196
+ function getTopLegendAreaHeight(useSpectrumLegend, legendHeight) {
197
+ return useSpectrumLegend
198
+ ? SPECTRUM_LEGEND_LABEL_HEIGHT +
199
+ spectrumLegendBar.PADDING * 2 +
200
+ spectrumLegendTooltip.POINT_HEIGHT +
201
+ spectrumLegendTooltip.HEIGHT +
202
+ padding.Y
203
+ : legendHeight + padding.Y;
204
+ }
205
+ function getYAxisTitleRect({ chartSize, visible, title, legend: { align: legendAlign, width: legendWidth, height: legendHeight, visible: legendVisible, useSpectrumLegend, }, hasCenterYAxis, visibleSecondaryYAxis, isRightSide = false, yAxisTitleHeight, }) {
206
+ const marginBottom = 5;
207
+ const height = visible ? yAxisTitleHeight + marginBottom : 0;
208
+ const verticalLegendAlign = isVerticalAlign(legendAlign);
209
+ const width = (chartSize.width - (verticalLegendAlign ? padding.X * 2 : legendWidth)) /
210
+ (visibleSecondaryYAxis ? 2 : 1);
211
+ const point = {
212
+ x: isRightSide ? title.x + width : title.x,
213
+ y: title.y + title.height,
214
+ };
215
+ if (legendVisible) {
216
+ if (legendAlign === 'left') {
217
+ point.x += legendWidth;
218
+ }
219
+ else if (legendAlign === 'top') {
220
+ point.y += getTopLegendAreaHeight(useSpectrumLegend, legendHeight);
221
+ }
222
+ }
223
+ if (hasCenterYAxis) {
224
+ point.x = (width + padding.X * 2) / 2;
225
+ }
226
+ return Object.assign({ height, width }, point);
227
+ }
228
+ function getXAxisTitleRect(visible, xAxis, xAxisTitleHeight) {
229
+ const point = { x: xAxis.x, y: xAxis.y + xAxis.height };
230
+ const height = visible ? xAxisTitleHeight : 0;
231
+ const width = visible ? xAxis.width : 0;
232
+ return Object.assign({ height, width }, point);
233
+ }
234
+ function getExportMenuRect(chartSize, visible) {
235
+ const marginY = 5;
236
+ const x = visible ? padding.X + chartSize.width - BUTTON_RECT_SIZE : padding.X + chartSize.width;
237
+ const y = padding.Y;
238
+ const height = visible ? BUTTON_RECT_SIZE + marginY : 0;
239
+ const width = visible ? BUTTON_RECT_SIZE : 0;
240
+ return { x, y, height, width };
241
+ }
242
+ function getResetButtonRect(exportMenu, useResetButton) {
243
+ const marginY = 5;
244
+ const x = useResetButton ? exportMenu.x - BUTTON_RECT_SIZE - padding.X : 0;
245
+ const y = useResetButton ? exportMenu.y : 0;
246
+ const height = useResetButton ? BUTTON_RECT_SIZE + marginY : 0;
247
+ const width = useResetButton ? BUTTON_RECT_SIZE : 0;
248
+ return { x, y, height, width };
249
+ }
250
+ export function isUsingResetButton(options) {
251
+ var _a;
252
+ return !!((_a = options.series) === null || _a === void 0 ? void 0 : _a.zoomable);
253
+ }
254
+ export function isExportMenuVisible(options) {
255
+ var _a;
256
+ const visible = (_a = options.exportMenu) === null || _a === void 0 ? void 0 : _a.visible;
257
+ return isUndefined(visible) ? true : visible;
258
+ }
259
+ function getYAxisMaxLabelWidth(maxLabelLength) {
260
+ return maxLabelLength ? maxLabelLength + padding.X : Y_AXIS_MIN_WIDTH;
261
+ }
262
+ function pickOptionSize(option) {
263
+ if (!option || (isUndefined(option.width) && isUndefined(option.height))) {
264
+ return null;
265
+ }
266
+ return pick(option, 'width', 'height');
267
+ }
268
+ function validOffsetValue(axis, plot, sizeKey) {
269
+ const axisSize = axis[sizeKey];
270
+ const plotSize = plot[sizeKey];
271
+ if (isNumber(axisSize) && isNumber(plotSize)) {
272
+ return Math.max(axisSize, plotSize);
273
+ }
274
+ }
275
+ function getOptionSize(options) {
276
+ const xAxis = pickOptionSize(options.xAxis);
277
+ const yAxisOptions = getYAxisOption(options);
278
+ const yAxis = pickOptionSize(yAxisOptions.yAxis);
279
+ const secondaryYAxis = pickOptionSize(yAxisOptions.secondaryYAxis);
280
+ const plot = pickOptionSize(options.plot);
281
+ if (plot) {
282
+ /*
283
+ If both the width of the x-axis and the width of the plot are entered,
284
+ set the maximum value.
285
+ */
286
+ if (xAxis) {
287
+ xAxis.width = plot.width = validOffsetValue(xAxis, plot, 'width');
288
+ }
289
+ /*
290
+ If both the height of the y-axis and the height of the plot are entered,
291
+ set the maximum value.
292
+ */
293
+ if (yAxis) {
294
+ yAxis.height = plot.height = validOffsetValue(yAxis, plot, 'height');
295
+ }
296
+ if (secondaryYAxis) {
297
+ secondaryYAxis.height = plot.height = validOffsetValue(secondaryYAxis, plot, 'height');
298
+ }
299
+ }
300
+ return {
301
+ xAxis,
302
+ yAxis,
303
+ plot,
304
+ secondaryYAxis,
305
+ };
306
+ }
307
+ function getAxisTitleHeight(axisTheme, offsetY = 0) {
308
+ const fontSize = Array.isArray(axisTheme)
309
+ ? Math.max(axisTheme[0].title.fontSize, axisTheme[1].title.fontSize)
310
+ : axisTheme.title.fontSize;
311
+ return fontSize + offsetY;
312
+ }
313
+ function adjustAxisSize({ width, height }, layout, legendState) {
314
+ if (width < 0 || height < 0) {
315
+ return;
316
+ }
317
+ const { title, yAxisTitle, yAxis, xAxis, xAxisTitle, legend, secondaryYAxis } = layout;
318
+ const { align } = legendState;
319
+ const hasVerticalLegend = isVerticalAlign(align);
320
+ const legendHeight = hasVerticalLegend ? legend.height : 0;
321
+ const diffHeight = xAxis.height +
322
+ xAxisTitle.height +
323
+ yAxis.height +
324
+ yAxisTitle.height +
325
+ title.height +
326
+ legendHeight -
327
+ height;
328
+ if (diffHeight > 0) {
329
+ yAxis.height -= diffHeight;
330
+ xAxis.y -= diffHeight;
331
+ xAxisTitle.y -= diffHeight;
332
+ if (hasVerticalLegend) {
333
+ legend.y -= diffHeight;
334
+ }
335
+ }
336
+ secondaryYAxis.x = xAxis.x + xAxis.width;
337
+ secondaryYAxis.height = yAxis.height;
338
+ }
339
+ function getCircularAxisTitleRect(plot, axisTheme, circularAxis) {
340
+ var _a, _b;
341
+ if (!circularAxis) {
342
+ return Object.assign({}, plot);
343
+ }
344
+ const { x, y } = plot;
345
+ const { centerX, centerY, axisSize, title, radius: { outer }, } = circularAxis;
346
+ const offsetY = (_b = (_a = title) === null || _a === void 0 ? void 0 : _a.offsetY, (_b !== null && _b !== void 0 ? _b : 0));
347
+ return {
348
+ x: centerX + x - axisSize / 2,
349
+ y: centerY + y - outer / 2,
350
+ width: axisSize,
351
+ height: axisTheme.title.fontSize + offsetY,
352
+ };
353
+ }
354
+ function hasXYAxes(series) {
355
+ return !(series.pie || series.radar || series.treemap || series.radialBar || series.gauge);
356
+ }
357
+ function getYAxisOptions(options, hasXYAxis) {
358
+ return hasXYAxis
359
+ ? getYAxisOption(options)
360
+ : {
361
+ yAxis: null,
362
+ secondaryYAxis: null,
363
+ };
364
+ }
365
+ const layout = {
366
+ name: 'layout',
367
+ state: () => ({
368
+ layout: {},
369
+ }),
370
+ action: {
371
+ setLayout({ state }) {
372
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
373
+ const { legend: legendState, theme, circleLegend: circleLegendState, series, options, chart, axes, radialAxes, } = state;
374
+ const { width, height } = chart;
375
+ const chartSize = {
376
+ height: height - padding.Y * 2,
377
+ width: width - padding.X * 2,
378
+ };
379
+ const hasCenterYAxis = series.bar ? isCenterYAxis(options) : false;
380
+ const hasXYAxis = hasXYAxes(series);
381
+ const optionSize = getOptionSize(options);
382
+ const { yAxis: yAxisOption, secondaryYAxis: secondaryYAxisOption } = getYAxisOptions(options, hasXYAxis);
383
+ const visibleSecondaryYAxis = !!secondaryYAxisOption;
384
+ const titleHeight = theme.title.fontSize;
385
+ const yAxisTitleHeight = (_d = getAxisTitleHeight(theme.yAxis, (_c = (_b = (_a = axes) === null || _a === void 0 ? void 0 : _a.yAxis) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.offsetY), (_d !== null && _d !== void 0 ? _d : 0));
386
+ const xAxisTitleHeight = (_h = getAxisTitleHeight(theme.xAxis, (_g = (_f = (_e = axes) === null || _e === void 0 ? void 0 : _e.xAxis) === null || _f === void 0 ? void 0 : _f.title) === null || _g === void 0 ? void 0 : _g.offsetY), (_h !== null && _h !== void 0 ? _h : 0));
387
+ // Don't change the order!
388
+ // exportMenu -> resetButton -> title -> yAxis.title -> yAxis -> secondaryYAxisTitle -> secondaryYAxis -> xAxis -> xAxis.title -> legend -> circleLegend -> plot -> circularAxis.title
389
+ const exportMenu = getExportMenuRect(chartSize, isExportMenuVisible(options));
390
+ const resetButton = getResetButtonRect(exportMenu, isUsingResetButton(options));
391
+ const btnAreaRect = exportMenu.height ? exportMenu : resetButton;
392
+ const title = getTitleRect(chartSize, btnAreaRect, !!((_j = options.chart) === null || _j === void 0 ? void 0 : _j.title), titleHeight);
393
+ const yAxisTitleVisible = !!((_k = yAxisOption) === null || _k === void 0 ? void 0 : _k.title) || !!((_l = secondaryYAxisOption) === null || _l === void 0 ? void 0 : _l.title);
394
+ const yAxisTitle = getYAxisTitleRect({
395
+ chartSize,
396
+ visible: yAxisTitleVisible,
397
+ title,
398
+ legend: legendState,
399
+ hasCenterYAxis,
400
+ visibleSecondaryYAxis,
401
+ yAxisTitleHeight,
402
+ });
403
+ const yAxis = getYAxisRect({
404
+ chartSize,
405
+ legend: legendState,
406
+ circleLegend: circleLegendState,
407
+ yAxisTitle,
408
+ hasCenterYAxis,
409
+ hasXYAxis,
410
+ maxLabelWidth: getYAxisMaxLabelWidth((_m = axes) === null || _m === void 0 ? void 0 : _m.yAxis.maxLabelWidth),
411
+ size: optionSize,
412
+ xAxisTitleHeight,
413
+ });
414
+ const secondaryYAxisTitle = getYAxisTitleRect({
415
+ chartSize,
416
+ visible: yAxisTitleVisible,
417
+ title,
418
+ legend: legendState,
419
+ hasCenterYAxis,
420
+ isRightSide: true,
421
+ visibleSecondaryYAxis,
422
+ yAxisTitleHeight,
423
+ });
424
+ const secondaryYAxis = getYAxisRect({
425
+ chartSize,
426
+ legend: legendState,
427
+ circleLegend: circleLegendState,
428
+ yAxisTitle: secondaryYAxisTitle,
429
+ hasCenterYAxis,
430
+ hasXYAxis,
431
+ maxLabelWidth: getYAxisMaxLabelWidth((_p = (_o = axes) === null || _o === void 0 ? void 0 : _o.secondaryYAxis) === null || _p === void 0 ? void 0 : _p.maxLabelWidth),
432
+ size: optionSize,
433
+ isRightSide: true,
434
+ visibleSecondaryYAxis,
435
+ xAxisTitleHeight,
436
+ });
437
+ const xAxis = getXAxisRect({
438
+ chartSize,
439
+ yAxis,
440
+ secondaryYAxis,
441
+ legend: legendState,
442
+ circleLegend: circleLegendState,
443
+ hasCenterYAxis,
444
+ hasXYAxis,
445
+ size: optionSize,
446
+ xAxisData: (_q = axes) === null || _q === void 0 ? void 0 : _q.xAxis,
447
+ });
448
+ const xAxisTitle = getXAxisTitleRect(!!((_r = options.xAxis) === null || _r === void 0 ? void 0 : _r.title), xAxis, xAxisTitleHeight);
449
+ const legend = getLegendRect({
450
+ chartSize,
451
+ xAxis,
452
+ yAxis,
453
+ secondaryYAxis,
454
+ title,
455
+ legend: legendState,
456
+ hasXYAxis,
457
+ xAxisTitleHeight,
458
+ });
459
+ adjustAxisSize(chartSize, { title, yAxisTitle, yAxis, xAxis, xAxisTitle, legend, secondaryYAxis }, legendState);
460
+ const circleLegend = getCircleLegendRect(xAxis, yAxis, legendState.align, circleLegendState.width);
461
+ const plot = getPlotRect(xAxis, yAxis, optionSize.plot);
462
+ const circularAxisTitle = getCircularAxisTitleRect(plot, theme.circularAxis, (_s = radialAxes) === null || _s === void 0 ? void 0 : _s.circularAxis);
463
+ extend(state.layout, {
464
+ chart: { x: 0, y: 0, width, height },
465
+ title,
466
+ plot,
467
+ legend,
468
+ circleLegend,
469
+ xAxis,
470
+ xAxisTitle,
471
+ yAxis,
472
+ yAxisTitle,
473
+ exportMenu,
474
+ resetButton,
475
+ secondaryYAxisTitle,
476
+ secondaryYAxis,
477
+ circularAxisTitle,
478
+ });
479
+ },
480
+ },
481
+ observe: {
482
+ updateLayoutObserve() {
483
+ this.dispatch('setLayout');
484
+ },
485
+ },
486
+ };
487
+ export default layout;
@@ -0,0 +1,3 @@
1
+ import { StoreModule } from "../../types/store/store";
2
+ declare const legend: StoreModule;
3
+ export default legend;