@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,55 @@
1
+ import { line, rect, pathRect } from "./basic";
2
+ import { BUTTON_RECT_SIZE } from "../component/exportMenu";
3
+ function drawXIcon(ctx, icon, rectSize) {
4
+ const { x: startX, y: startY, theme: { color: strokeStyle, lineWidth }, } = icon;
5
+ const offset = rectSize / 3;
6
+ const x = startX + offset;
7
+ const y = startY + offset;
8
+ const x2 = startX + offset * 2;
9
+ const y2 = startY + offset * 2;
10
+ const points = [
11
+ { x, y, x2, y2 },
12
+ { x, y: y2, x2, y2: y },
13
+ ];
14
+ points.forEach((p) => {
15
+ line(ctx, Object.assign(Object.assign({ type: 'line' }, p), { strokeStyle, lineWidth }));
16
+ });
17
+ }
18
+ function drawMoreIcon(ctx, icon, rectSize) {
19
+ const { x, y, theme: { color, width, height, gap }, } = icon;
20
+ const paddingX = (rectSize - width) / 2;
21
+ const paddingY = (rectSize - (height * 3 + gap * 2)) / 2;
22
+ const centerX = x + paddingX;
23
+ const points = [
24
+ { x: centerX, y: y + paddingY },
25
+ { x: centerX, y: y + paddingY + height + gap },
26
+ { x: centerX, y: y + paddingY + (height + gap) * 2 },
27
+ ];
28
+ points.forEach((p) => {
29
+ rect(ctx, Object.assign(Object.assign({ type: 'rect' }, p), { color, width: width, height: height }));
30
+ });
31
+ }
32
+ export function exportMenuButton(ctx, exportMenuButtonModel) {
33
+ const { opened, x: xPos, y: yPos, theme } = exportMenuButtonModel;
34
+ const { borderColor, backgroundColor, borderWidth, borderRadius, xIcon, dotIcon, } = theme;
35
+ const x = xPos + borderWidth;
36
+ const y = yPos + borderWidth;
37
+ const rectSize = BUTTON_RECT_SIZE - 2 * borderWidth;
38
+ pathRect(ctx, {
39
+ type: 'pathRect',
40
+ x,
41
+ y,
42
+ fill: backgroundColor,
43
+ stroke: borderColor,
44
+ width: rectSize,
45
+ height: rectSize,
46
+ radius: borderRadius,
47
+ lineWidth: borderWidth,
48
+ });
49
+ if (opened) {
50
+ drawXIcon(ctx, { x, y, theme: xIcon }, rectSize);
51
+ }
52
+ else {
53
+ drawMoreIcon(ctx, { x, y, theme: dotIcon }, rectSize);
54
+ }
55
+ }
@@ -0,0 +1,2 @@
1
+ import { ClockHandModel } from "../../types/components/series";
2
+ export declare function clockHand(ctx: CanvasRenderingContext2D, model: ClockHandModel): void;
@@ -0,0 +1,39 @@
1
+ import { calculateDegreeToRadian, getRadialPosition, calculateValidAngle, DEGREE_90, } from "../helpers/sector";
2
+ import { circle } from "./basic";
3
+ import { polygon } from "./polygon";
4
+ function getClockHandPoints(model) {
5
+ const { x, y, x2, y2, degree, baseLine } = model;
6
+ const halfBaseLine = baseLine / 2;
7
+ let startPoint, endPoint;
8
+ if (x === x2) {
9
+ startPoint = { x: x - halfBaseLine, y };
10
+ endPoint = { x: x + halfBaseLine, y };
11
+ }
12
+ else if (y === y2) {
13
+ startPoint = { x, y: y - halfBaseLine };
14
+ endPoint = { x, y: y + halfBaseLine };
15
+ }
16
+ else {
17
+ startPoint = getRadialPosition(x, y, halfBaseLine, calculateDegreeToRadian(calculateValidAngle(degree + DEGREE_90)));
18
+ endPoint = getRadialPosition(x, y, halfBaseLine, calculateDegreeToRadian(calculateValidAngle(degree - DEGREE_90)));
19
+ }
20
+ return [startPoint, { x: x2, y: y2 }, endPoint];
21
+ }
22
+ export function clockHand(ctx, model) {
23
+ const { color, x, y, pin: { color: pinColor, radius, style }, } = model;
24
+ circle(ctx, {
25
+ type: 'circle',
26
+ x,
27
+ y,
28
+ radius,
29
+ color: pinColor,
30
+ style,
31
+ });
32
+ polygon(ctx, {
33
+ type: 'polygon',
34
+ color,
35
+ lineWidth: 1,
36
+ fillColor: color,
37
+ points: getClockHandPoints(model),
38
+ });
39
+ }
@@ -0,0 +1,34 @@
1
+ import { LabelModel, BubbleLabelModel } from "../../types/components/axis";
2
+ export declare const DEFAULT_LABEL_TEXT = "normal 11px Arial";
3
+ export declare const labelStyle: {
4
+ default: {
5
+ font: string;
6
+ fillStyle: string;
7
+ textAlign: string;
8
+ textBaseline: string;
9
+ };
10
+ title: {
11
+ textBaseline: string;
12
+ };
13
+ axisTitle: {
14
+ textBaseline: string;
15
+ };
16
+ rectLabel: {
17
+ font: string;
18
+ fillStyle: string;
19
+ textAlign: string;
20
+ textBaseline: string;
21
+ };
22
+ };
23
+ export declare const strokeLabelStyle: {
24
+ none: {
25
+ lineWidth: number;
26
+ strokeStyle: string;
27
+ };
28
+ stroke: {
29
+ lineWidth: number;
30
+ strokeStyle: string;
31
+ };
32
+ };
33
+ export declare function label(ctx: CanvasRenderingContext2D, labelModel: LabelModel): void;
34
+ export declare function bubbleLabel(ctx: CanvasRenderingContext2D, model: BubbleLabelModel): void;
@@ -0,0 +1,165 @@
1
+ import { makeStyleObj, fillStyle, strokeWithOptions } from "../helpers/style";
2
+ import { isNumber } from "../helpers/utils";
3
+ import { rgba } from "../helpers/color";
4
+ export const DEFAULT_LABEL_TEXT = 'normal 11px Arial';
5
+ export const labelStyle = {
6
+ default: {
7
+ font: DEFAULT_LABEL_TEXT,
8
+ fillStyle: '#333333',
9
+ textAlign: 'left',
10
+ textBaseline: 'middle',
11
+ },
12
+ title: {
13
+ textBaseline: 'top',
14
+ },
15
+ axisTitle: {
16
+ textBaseline: 'top',
17
+ },
18
+ rectLabel: {
19
+ font: DEFAULT_LABEL_TEXT,
20
+ fillStyle: 'rgba(0, 0, 0, 0.3)',
21
+ textAlign: 'center',
22
+ textBaseline: 'middle',
23
+ },
24
+ };
25
+ export const strokeLabelStyle = {
26
+ none: {
27
+ lineWidth: 1,
28
+ strokeStyle: 'rgba(255, 255, 255, 0)',
29
+ },
30
+ stroke: {
31
+ lineWidth: 4,
32
+ strokeStyle: 'rgba(255, 255, 255, 0.5)',
33
+ },
34
+ };
35
+ export function label(ctx, labelModel) {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h;
37
+ const { x, y, text, style, stroke, opacity, radian, rotationPosition } = labelModel;
38
+ if (style) {
39
+ const styleObj = makeStyleObj(style, labelStyle);
40
+ Object.keys(styleObj).forEach((key) => {
41
+ ctx[key] =
42
+ key === 'fillStyle' && isNumber(opacity) ? rgba(styleObj[key], opacity) : styleObj[key];
43
+ });
44
+ }
45
+ ctx.save();
46
+ if (radian) {
47
+ ctx.translate((_b = (_a = rotationPosition) === null || _a === void 0 ? void 0 : _a.x, (_b !== null && _b !== void 0 ? _b : x)), (_d = (_c = rotationPosition) === null || _c === void 0 ? void 0 : _c.y, (_d !== null && _d !== void 0 ? _d : y)));
48
+ ctx.rotate(radian);
49
+ ctx.translate(-(_f = (_e = rotationPosition) === null || _e === void 0 ? void 0 : _e.x, (_f !== null && _f !== void 0 ? _f : x)), -(_h = (_g = rotationPosition) === null || _g === void 0 ? void 0 : _g.y, (_h !== null && _h !== void 0 ? _h : y)));
50
+ }
51
+ if (stroke) {
52
+ const strokeStyleObj = makeStyleObj(stroke, strokeLabelStyle);
53
+ const strokeStyleKeys = Object.keys(strokeStyleObj);
54
+ strokeStyleKeys.forEach((key) => {
55
+ ctx[key] =
56
+ key === 'strokeStyle' && isNumber(opacity)
57
+ ? rgba(strokeStyleObj[key], opacity)
58
+ : strokeStyleObj[key];
59
+ });
60
+ if (strokeStyleKeys.length) {
61
+ ctx.strokeText(text, x, y);
62
+ }
63
+ }
64
+ ctx.fillText(text, x, y);
65
+ ctx.restore();
66
+ }
67
+ const textBubbleStyle = {
68
+ shadow: {
69
+ shadowColor: 'rgba(0, 0, 0, 0.3)',
70
+ shadowOffsetY: 2,
71
+ shadowBlur: 4,
72
+ },
73
+ };
74
+ export function bubbleLabel(ctx, model) {
75
+ var _a, _b, _c, _d;
76
+ const { radian = 0, rotationPosition, bubble: { x, y, width, height, radius = 0, lineWidth = 1, direction, points = [], fill = '#fff', strokeStyle = 'rgba(0, 0, 0, 0)', style: bubbleStyle = null, }, } = model;
77
+ if (width > 0 && height > 0) {
78
+ drawBubble(ctx, {
79
+ x,
80
+ y,
81
+ radius,
82
+ width,
83
+ height,
84
+ style: bubbleStyle,
85
+ fill,
86
+ strokeStyle,
87
+ lineWidth,
88
+ direction,
89
+ points,
90
+ radian,
91
+ rotationPosition: {
92
+ x: (_b = (_a = rotationPosition) === null || _a === void 0 ? void 0 : _a.x, (_b !== null && _b !== void 0 ? _b : x)),
93
+ y: (_d = (_c = rotationPosition) === null || _c === void 0 ? void 0 : _c.y, (_d !== null && _d !== void 0 ? _d : y)),
94
+ },
95
+ });
96
+ }
97
+ if (model.label.text) {
98
+ const { x: labelX, y: labelY, text, strokeStyle: labelStrokeColor = 'rgba(0, 0, 0, 0)', style, } = model.label;
99
+ ctx.shadowColor = 'rgba(0, 0, 0, 0)';
100
+ label(ctx, {
101
+ type: 'label',
102
+ x: labelX,
103
+ y: labelY,
104
+ text,
105
+ style,
106
+ stroke: [{ strokeStyle: labelStrokeColor }],
107
+ radian,
108
+ rotationPosition,
109
+ });
110
+ }
111
+ }
112
+ function drawBubbleArrow(ctx, points) {
113
+ if (!points.length) {
114
+ return;
115
+ }
116
+ ctx.lineTo(points[0].x, points[0].y);
117
+ ctx.lineTo(points[1].x, points[1].y);
118
+ ctx.lineTo(points[2].x, points[2].y);
119
+ }
120
+ function drawBubble(ctx, model) {
121
+ const { x, y, width, height, style, radius = 0, strokeStyle, fill, lineWidth = 1, points = [], direction = '', radian, rotationPosition, } = model;
122
+ const right = x + width;
123
+ const bottom = y + height;
124
+ ctx.beginPath();
125
+ ctx.save();
126
+ if (radian && rotationPosition) {
127
+ ctx.translate(rotationPosition.x, rotationPosition.y);
128
+ ctx.rotate(radian);
129
+ ctx.translate(-rotationPosition.x, -rotationPosition.y);
130
+ }
131
+ ctx.moveTo(x + radius, y);
132
+ if (direction === 'top') {
133
+ drawBubbleArrow(ctx, points);
134
+ }
135
+ ctx.lineTo(right - radius, y);
136
+ ctx.quadraticCurveTo(right, y, right, y + radius);
137
+ if (direction === 'right') {
138
+ drawBubbleArrow(ctx, points);
139
+ }
140
+ ctx.lineTo(right, y + height - radius);
141
+ ctx.quadraticCurveTo(right, bottom, right - radius, bottom);
142
+ if (direction === 'bottom') {
143
+ drawBubbleArrow(ctx, points);
144
+ }
145
+ ctx.lineTo(x + radius, bottom);
146
+ ctx.quadraticCurveTo(x, bottom, x, bottom - radius);
147
+ if (direction === 'left') {
148
+ drawBubbleArrow(ctx, points);
149
+ }
150
+ ctx.lineTo(x, y + radius);
151
+ ctx.quadraticCurveTo(x, y, x + radius, y);
152
+ if (style) {
153
+ const styleObj = makeStyleObj(style, textBubbleStyle);
154
+ Object.keys(styleObj).forEach((key) => {
155
+ ctx[key] = styleObj[key];
156
+ });
157
+ }
158
+ if (fill) {
159
+ fillStyle(ctx, fill);
160
+ }
161
+ if (strokeStyle) {
162
+ strokeWithOptions(ctx, { strokeStyle, lineWidth });
163
+ }
164
+ ctx.restore();
165
+ }
@@ -0,0 +1,7 @@
1
+ import { LegendModel } from "../../types/components/legend";
2
+ export declare const LEGEND_ITEM_MARGIN_X = 40;
3
+ export declare const LEGEND_MARGIN_X = 5;
4
+ export declare const LEGEND_CHECKBOX_SIZE = 12;
5
+ export declare const LEGEND_ICON_SIZE = 12;
6
+ export declare function getLegendItemHeight(fontSize: number): number;
7
+ export declare function legend(ctx: CanvasRenderingContext2D, model: LegendModel): void;
@@ -0,0 +1,162 @@
1
+ import { line, circle, rect } from "./basic";
2
+ import { label } from "./label";
3
+ import { getRGBA } from "../helpers/color";
4
+ import { scatterSeries } from "./scatterSeries";
5
+ import { getTitleFontString } from "../helpers/style";
6
+ import { getTextHeight } from "../helpers/calculator";
7
+ import { padding } from "../store/layout";
8
+ export const LEGEND_ITEM_MARGIN_X = 40;
9
+ export const LEGEND_MARGIN_X = 5;
10
+ export const LEGEND_CHECKBOX_SIZE = 12;
11
+ export const LEGEND_ICON_SIZE = 12;
12
+ const ICON_BORDER_WIDTH = 1.5;
13
+ const INACTIVE_OPACITY = 0.3;
14
+ const RECT_SIZE = 10;
15
+ const LINE_ICON_PADDING = 2;
16
+ const CIRCLE_ICON_RADIUS = 6;
17
+ export function getLegendItemHeight(fontSize) {
18
+ return fontSize + padding.Y;
19
+ }
20
+ function drawLineIcon(ctx, x, y, color) {
21
+ const xCurveOffset = [2, 2, 6, 6, 10, 10];
22
+ const yCurveOffset = [8, 0, 0, 8, 8, 0];
23
+ xCurveOffset.forEach((xOffset, idx) => {
24
+ if (idx === 5) {
25
+ return;
26
+ }
27
+ line(ctx, {
28
+ type: 'line',
29
+ x: x + xOffset,
30
+ y: y + yCurveOffset[idx],
31
+ x2: x + xCurveOffset[idx + 1],
32
+ y2: y + yCurveOffset[idx + 1],
33
+ lineWidth: 2,
34
+ strokeStyle: color,
35
+ });
36
+ });
37
+ }
38
+ function drawCheckIcon(ctx, x, y, active) {
39
+ const color = '#555555';
40
+ const strokeStyle = active ? color : getRGBA(color, INACTIVE_OPACITY);
41
+ line(ctx, {
42
+ type: 'line',
43
+ x: x + 2,
44
+ y: y + 5,
45
+ x2: x + 5,
46
+ y2: y + 8,
47
+ strokeStyle,
48
+ lineWidth: 2,
49
+ });
50
+ line(ctx, {
51
+ type: 'line',
52
+ x: x + 5,
53
+ y: y + 9,
54
+ x2: x + 10,
55
+ y2: y + 3,
56
+ strokeStyle,
57
+ lineWidth: 2,
58
+ });
59
+ }
60
+ function drawCheckbox(ctx, x, y, renderOptions) {
61
+ const { active, checked } = renderOptions;
62
+ const borderColor = active ? '#bbb' : getRGBA('#bbbbbb', INACTIVE_OPACITY);
63
+ rect(ctx, {
64
+ type: 'rect',
65
+ x,
66
+ y,
67
+ width: LEGEND_CHECKBOX_SIZE,
68
+ height: LEGEND_CHECKBOX_SIZE,
69
+ color: '#fff',
70
+ borderColor,
71
+ thickness: 1,
72
+ });
73
+ if (checked) {
74
+ drawCheckIcon(ctx, x, y, active);
75
+ }
76
+ }
77
+ function drawIcon(ctx, x, y, renderOptions) {
78
+ const { iconType, active, color, showCheckbox } = renderOptions;
79
+ const iconX = x + (showCheckbox ? LEGEND_CHECKBOX_SIZE + LEGEND_MARGIN_X : 0);
80
+ const iconColor = active ? color : getRGBA(color, INACTIVE_OPACITY);
81
+ if (iconType === 'rect') {
82
+ rect(ctx, {
83
+ type: 'rect',
84
+ x: iconX,
85
+ y: y + (LEGEND_CHECKBOX_SIZE - RECT_SIZE) / 2,
86
+ width: RECT_SIZE,
87
+ height: RECT_SIZE,
88
+ color: iconColor,
89
+ });
90
+ }
91
+ else if (iconType === 'line') {
92
+ drawLineIcon(ctx, iconX, y + LINE_ICON_PADDING, iconColor);
93
+ }
94
+ else if (iconType === 'circle') {
95
+ circle(ctx, {
96
+ type: 'circle',
97
+ x: iconX + CIRCLE_ICON_RADIUS,
98
+ y: y + CIRCLE_ICON_RADIUS,
99
+ radius: CIRCLE_ICON_RADIUS,
100
+ color: iconColor,
101
+ style: ['default'],
102
+ });
103
+ }
104
+ }
105
+ function drawScatterIcon(ctx, x, y, renderOptions) {
106
+ const { iconType, active, color, showCheckbox } = renderOptions;
107
+ const iconX = x + (showCheckbox ? LEGEND_CHECKBOX_SIZE + LEGEND_MARGIN_X : 0);
108
+ const iconColor = active ? color : getRGBA(color, INACTIVE_OPACITY);
109
+ scatterSeries(ctx, {
110
+ type: 'scatterSeries',
111
+ iconType: iconType,
112
+ x: iconX + CIRCLE_ICON_RADIUS,
113
+ y: y + CIRCLE_ICON_RADIUS,
114
+ borderColor: iconColor,
115
+ size: CIRCLE_ICON_RADIUS * 2,
116
+ fillColor: 'rgba(255, 255, 255, 0)',
117
+ borderWidth: ICON_BORDER_WIDTH,
118
+ });
119
+ }
120
+ function drawLabel(ctx, x, y, text, renderOptions) {
121
+ const { active, showCheckbox, font, fontColor } = renderOptions;
122
+ const fillStyle = active ? fontColor : getRGBA(fontColor, INACTIVE_OPACITY);
123
+ label(ctx, {
124
+ type: 'label',
125
+ x: x +
126
+ LEGEND_ICON_SIZE +
127
+ LEGEND_MARGIN_X +
128
+ (showCheckbox ? LEGEND_CHECKBOX_SIZE + LEGEND_MARGIN_X : 0),
129
+ y,
130
+ text,
131
+ style: ['default', { font, textBaseline: 'top', fillStyle }],
132
+ });
133
+ }
134
+ export function legend(ctx, model) {
135
+ const { data, showCheckbox, align, fontSize, fontFamily, fontWeight } = model;
136
+ const font = getTitleFontString({ fontSize, fontFamily, fontWeight });
137
+ const fontColor = model.color;
138
+ data.forEach((datum) => {
139
+ const { x, y, checked, active, color, iconType, useScatterChartIcon, viewLabel: legendLabel, } = datum;
140
+ const iconY = y - 1 + (getTextHeight(legendLabel, font) - 11) / 4;
141
+ const renderOptions = {
142
+ iconType,
143
+ checked,
144
+ active,
145
+ color,
146
+ showCheckbox,
147
+ align,
148
+ font,
149
+ fontColor,
150
+ };
151
+ if (showCheckbox) {
152
+ drawCheckbox(ctx, x, iconY, renderOptions);
153
+ }
154
+ if (useScatterChartIcon && iconType !== 'line') {
155
+ drawScatterIcon(ctx, x, iconY, renderOptions);
156
+ }
157
+ else {
158
+ drawIcon(ctx, x, iconY, renderOptions);
159
+ }
160
+ drawLabel(ctx, x, y, legendLabel, renderOptions);
161
+ });
162
+ }
@@ -0,0 +1,5 @@
1
+ import { AreaPointsModel, LinePointsModel } from "../../types/components/series";
2
+ declare type PointsModel = LinePointsModel | AreaPointsModel;
3
+ export declare function linePoints(ctx: CanvasRenderingContext2D, pointsModel: PointsModel): void;
4
+ export declare function areaPoints(ctx: CanvasRenderingContext2D, areaPointsModel: AreaPointsModel): void;
5
+ export {};
@@ -0,0 +1,41 @@
1
+ import { setLineDash, fillStyle, strokeWithOptions } from "../helpers/style";
2
+ import { isNull } from "../helpers/utils";
3
+ export function linePoints(ctx, pointsModel) {
4
+ const { color: strokeStyle, lineWidth, points, dashSegments = [] } = pointsModel;
5
+ ctx.lineCap = 'round';
6
+ ctx.beginPath();
7
+ if (dashSegments) {
8
+ setLineDash(ctx, dashSegments);
9
+ }
10
+ let start = false;
11
+ points.forEach((point, idx) => {
12
+ var _a, _b;
13
+ if (isNull(point)) {
14
+ start = false;
15
+ return;
16
+ }
17
+ if (!start) {
18
+ ctx.moveTo(point.x, point.y);
19
+ start = true;
20
+ return;
21
+ }
22
+ if (point.controlPoint && ((_b = (_a = points[idx - 1]) === null || _a === void 0 ? void 0 : _a.controlPoint) === null || _b === void 0 ? void 0 : _b.next)) {
23
+ const { x: prevX, y: prevY } = points[idx - 1].controlPoint.next;
24
+ const { controlPoint, x, y } = point;
25
+ ctx.bezierCurveTo(prevX, prevY, controlPoint.prev.x, controlPoint.prev.y, x, y);
26
+ }
27
+ else {
28
+ ctx.lineTo(point.x, point.y);
29
+ }
30
+ });
31
+ strokeWithOptions(ctx, { lineWidth, strokeStyle });
32
+ ctx.closePath();
33
+ setLineDash(ctx, []);
34
+ }
35
+ export function areaPoints(ctx, areaPointsModel) {
36
+ const { fillColor } = areaPointsModel;
37
+ ctx.beginPath();
38
+ linePoints(ctx, areaPointsModel);
39
+ fillStyle(ctx, fillColor);
40
+ ctx.closePath();
41
+ }
@@ -0,0 +1,2 @@
1
+ import { PolygonModel } from "../../types/components/series";
2
+ export declare function polygon(ctx: CanvasRenderingContext2D, polygonModel: PolygonModel): void;
@@ -0,0 +1,24 @@
1
+ import { setLineDash, fillStyle, strokeWithOptions } from "../helpers/style";
2
+ export function polygon(ctx, polygonModel) {
3
+ const { color: strokeStyle, points, lineWidth, fillColor, dashSegments = [] } = polygonModel;
4
+ if (!points.length) {
5
+ return;
6
+ }
7
+ ctx.beginPath();
8
+ if (dashSegments) {
9
+ setLineDash(ctx, dashSegments);
10
+ }
11
+ points.forEach(({ x, y }, idx) => {
12
+ if (idx === 0) {
13
+ ctx.moveTo(x, y);
14
+ return;
15
+ }
16
+ ctx.lineTo(x, y);
17
+ });
18
+ ctx.lineTo(points[0].x, points[0].y);
19
+ if (fillColor) {
20
+ fillStyle(ctx, fillColor);
21
+ }
22
+ strokeWithOptions(ctx, { lineWidth, strokeStyle });
23
+ ctx.closePath();
24
+ }
@@ -0,0 +1,3 @@
1
+ import { BackButtonModel, ResetButtonModel } from "../../types/components/resetButton";
2
+ export declare function backButton(ctx: CanvasRenderingContext2D, backButtonModel: BackButtonModel): void;
3
+ export declare function resetButton(ctx: CanvasRenderingContext2D, resetButtonModel: ResetButtonModel): void;
@@ -0,0 +1,112 @@
1
+ import { BUTTON_RECT_SIZE } from "../component/exportMenu";
2
+ import { circle, line, pathRect } from "./basic";
3
+ import { areaPoints } from "./lineSeries";
4
+ const ARROW_HEIGHT = 3;
5
+ const ARROW_WIDTH = 6;
6
+ function drawResetIcon(ctx, point) {
7
+ const { x, y } = point;
8
+ const centerX = x + BUTTON_RECT_SIZE / 2;
9
+ const centerY = y + BUTTON_RECT_SIZE / 2;
10
+ const tickSize = BUTTON_RECT_SIZE / 10;
11
+ const color = '#545454';
12
+ circle(ctx, {
13
+ type: 'circle',
14
+ x: centerX,
15
+ y: centerY,
16
+ radius: tickSize * 2,
17
+ angle: { start: 0, end: Math.PI / 2 },
18
+ color: 'transparent',
19
+ style: [{ lineWidth: 2, strokeStyle: color }],
20
+ });
21
+ const pointStartX = centerX + tickSize * 2;
22
+ const pointStartY = centerY;
23
+ const points = [
24
+ { x: pointStartX - ARROW_WIDTH / 2, y: pointStartY },
25
+ { x: pointStartX + ARROW_WIDTH / 2, y: pointStartY },
26
+ { x: pointStartX, y: pointStartY + ARROW_HEIGHT },
27
+ ];
28
+ areaPoints(ctx, {
29
+ type: 'areaPoints',
30
+ points,
31
+ lineWidth: 1,
32
+ color,
33
+ fillColor: color,
34
+ });
35
+ }
36
+ function drawBackIcon(ctx, point) {
37
+ const barWidth = 4;
38
+ const radius = BUTTON_RECT_SIZE / 7;
39
+ const { x, y } = point;
40
+ const centerX = x + BUTTON_RECT_SIZE / 2;
41
+ const centerY = y + BUTTON_RECT_SIZE / 2;
42
+ const color = '#545454';
43
+ line(ctx, {
44
+ type: 'line',
45
+ lineWidth: 2,
46
+ x: centerX - barWidth / 2,
47
+ y: centerY + radius,
48
+ x2: centerX + barWidth / 2,
49
+ y2: centerY + radius,
50
+ strokeStyle: color,
51
+ });
52
+ line(ctx, {
53
+ type: 'line',
54
+ lineWidth: 2,
55
+ x: centerX - barWidth / 2,
56
+ y: centerY - radius,
57
+ x2: centerX + barWidth / 2,
58
+ y2: centerY - radius,
59
+ strokeStyle: color,
60
+ });
61
+ circle(ctx, {
62
+ type: 'circle',
63
+ x: centerX + barWidth / 2,
64
+ y: centerY,
65
+ radius,
66
+ angle: { start: Math.PI / 2, end: (Math.PI * 3) / 2 },
67
+ color: 'transparent',
68
+ style: [{ lineWidth: 2, strokeStyle: color }],
69
+ });
70
+ const pointStartX = centerX - barWidth / 2;
71
+ const pointStartY = centerY - radius;
72
+ const points = [
73
+ { x: pointStartX - ARROW_HEIGHT, y: pointStartY },
74
+ { x: pointStartX, y: pointStartY - ARROW_WIDTH / 2 },
75
+ { x: pointStartX, y: pointStartY + ARROW_WIDTH / 2 },
76
+ ];
77
+ areaPoints(ctx, {
78
+ type: 'areaPoints',
79
+ points,
80
+ lineWidth: 1,
81
+ color,
82
+ fillColor: color,
83
+ });
84
+ }
85
+ export function backButton(ctx, backButtonModel) {
86
+ const { x, y } = backButtonModel;
87
+ pathRect(ctx, {
88
+ type: 'pathRect',
89
+ x,
90
+ y,
91
+ fill: '#f4f4f4',
92
+ stroke: '#f4f4f4',
93
+ width: BUTTON_RECT_SIZE,
94
+ height: BUTTON_RECT_SIZE,
95
+ radius: 5,
96
+ });
97
+ drawBackIcon(ctx, { x, y });
98
+ }
99
+ export function resetButton(ctx, resetButtonModel) {
100
+ const { x, y } = resetButtonModel;
101
+ pathRect(ctx, {
102
+ type: 'pathRect',
103
+ x,
104
+ y,
105
+ fill: '#f4f4f4',
106
+ stroke: '#f4f4f4',
107
+ width: BUTTON_RECT_SIZE,
108
+ height: BUTTON_RECT_SIZE,
109
+ radius: 5,
110
+ });
111
+ drawResetIcon(ctx, { x, y });
112
+ }
@@ -0,0 +1,2 @@
1
+ import { ScatterSeriesModel } from "../../types/components/series";
2
+ export declare function scatterSeries(ctx: CanvasRenderingContext2D, model: ScatterSeriesModel): void;