@gravity-ui/charts 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/dist/cjs/components/Axis/AxisX.d.ts +2 -1
  2. package/dist/cjs/components/Axis/AxisX.js +147 -141
  3. package/dist/cjs/components/Axis/AxisY.d.ts +2 -1
  4. package/dist/cjs/components/Axis/AxisY.js +118 -116
  5. package/dist/cjs/components/ChartInner/index.js +36 -9
  6. package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +1 -1
  7. package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +8 -5
  8. package/dist/cjs/components/ChartInner/useChartInnerProps.js +59 -10
  9. package/dist/cjs/components/ChartInner/utils.d.ts +3 -0
  10. package/dist/cjs/components/ChartInner/utils.js +28 -0
  11. package/dist/cjs/components/Legend/index.js +202 -191
  12. package/dist/cjs/components/Legend/styles.css +2 -0
  13. package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +1 -1
  14. package/dist/cjs/components/Tooltip/DefaultContent.d.ts +1 -1
  15. package/dist/cjs/components/Tooltip/DefaultContent.js +1 -1
  16. package/dist/cjs/components/Tooltip/index.d.ts +1 -1
  17. package/dist/cjs/constants/chart-types.d.ts +12 -0
  18. package/dist/cjs/constants/chart-types.js +12 -0
  19. package/dist/cjs/constants/defaults/axis.d.ts +3 -1
  20. package/dist/cjs/constants/defaults/axis.js +10 -0
  21. package/dist/cjs/constants/index.d.ts +6 -47
  22. package/dist/cjs/constants/index.js +6 -72
  23. package/dist/cjs/constants/layout-algorithms.d.ts +7 -0
  24. package/dist/cjs/constants/layout-algorithms.js +8 -0
  25. package/dist/cjs/constants/line-styles.d.ts +20 -0
  26. package/dist/cjs/constants/line-styles.js +20 -0
  27. package/dist/cjs/constants/palette.d.ts +1 -0
  28. package/dist/cjs/constants/palette.js +22 -0
  29. package/dist/cjs/constants/symbol-types.d.ts +7 -0
  30. package/dist/cjs/constants/symbol-types.js +8 -0
  31. package/dist/cjs/constants/typography.d.ts +1 -0
  32. package/dist/cjs/constants/typography.js +1 -0
  33. package/dist/cjs/hooks/hooks-utils/index.d.ts +1 -0
  34. package/dist/cjs/hooks/hooks-utils/index.js +1 -0
  35. package/dist/cjs/hooks/hooks-utils/zoom.d.ts +8 -0
  36. package/dist/cjs/hooks/hooks-utils/zoom.js +81 -0
  37. package/dist/cjs/hooks/index.d.ts +1 -0
  38. package/dist/cjs/hooks/index.js +1 -0
  39. package/dist/cjs/hooks/useAxisScales/index.d.ts +4 -2
  40. package/dist/cjs/hooks/useAxisScales/index.js +22 -8
  41. package/dist/cjs/hooks/useBrush/index.d.ts +3 -0
  42. package/dist/cjs/hooks/useBrush/index.js +70 -0
  43. package/dist/cjs/hooks/useBrush/styles.css +10 -0
  44. package/dist/cjs/hooks/useBrush/types.d.ts +24 -0
  45. package/dist/cjs/hooks/useBrush/types.js +1 -0
  46. package/dist/cjs/hooks/useChartDimensions/index.d.ts +3 -3
  47. package/dist/cjs/hooks/useChartDimensions/index.js +2 -2
  48. package/dist/cjs/hooks/useChartDimensions/utils.d.ts +2 -2
  49. package/dist/cjs/hooks/useChartOptions/chart.d.ts +2 -1
  50. package/dist/cjs/hooks/useChartOptions/chart.js +80 -1
  51. package/dist/cjs/hooks/useChartOptions/index.js +3 -2
  52. package/dist/cjs/hooks/useChartOptions/types.d.ts +6 -2
  53. package/dist/cjs/hooks/useChartOptions/x-axis.d.ts +3 -3
  54. package/dist/cjs/hooks/useChartOptions/x-axis.js +22 -13
  55. package/dist/cjs/hooks/useChartOptions/y-axis.d.ts +3 -3
  56. package/dist/cjs/hooks/useChartOptions/y-axis.js +36 -21
  57. package/dist/cjs/hooks/useCrosshair/index.d.ts +17 -0
  58. package/dist/cjs/hooks/useCrosshair/index.js +139 -0
  59. package/dist/cjs/hooks/useCrosshair/useCrosshairHover.d.ts +11 -0
  60. package/dist/cjs/hooks/useCrosshair/useCrosshairHover.js +18 -0
  61. package/dist/cjs/hooks/useSeries/index.d.ts +8 -6
  62. package/dist/cjs/hooks/useSeries/index.js +41 -22
  63. package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +27 -2
  64. package/dist/cjs/hooks/useSeries/prepare-bar-y.js +5 -5
  65. package/dist/cjs/hooks/useSeries/prepare-legend.d.ts +1 -1
  66. package/dist/cjs/hooks/useSeries/prepare-legend.js +27 -9
  67. package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -2
  68. package/dist/cjs/hooks/useSeries/prepare-line.js +3 -3
  69. package/dist/cjs/hooks/useSeries/prepareSeries.d.ts +1 -1
  70. package/dist/cjs/hooks/useSeries/prepareSeries.js +2 -2
  71. package/dist/cjs/hooks/useSeries/types.d.ts +2 -1
  72. package/dist/cjs/hooks/useShapes/area/index.js +1 -1
  73. package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +1 -1
  74. package/dist/cjs/hooks/useShapes/area/prepare-data.js +32 -16
  75. package/dist/cjs/hooks/useShapes/area/types.d.ts +1 -0
  76. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +1 -1
  77. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +17 -13
  78. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
  79. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +6 -6
  80. package/dist/cjs/hooks/useShapes/index.d.ts +1 -1
  81. package/dist/cjs/hooks/useShapes/index.js +40 -31
  82. package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +1 -1
  83. package/dist/cjs/hooks/useShapes/line/prepare-data.js +14 -11
  84. package/dist/cjs/hooks/useShapes/line/types.d.ts +1 -0
  85. package/dist/cjs/hooks/useShapes/marker.js +2 -2
  86. package/dist/cjs/hooks/useShapes/pie/index.js +3 -3
  87. package/dist/cjs/hooks/useShapes/pie/prepare-data.d.ts +1 -1
  88. package/dist/cjs/hooks/useShapes/pie/prepare-data.js +15 -11
  89. package/dist/cjs/hooks/useShapes/radar/prepare-data.d.ts +1 -1
  90. package/dist/cjs/hooks/useShapes/radar/prepare-data.js +6 -7
  91. package/dist/cjs/hooks/useShapes/radar/types.d.ts +1 -0
  92. package/dist/cjs/hooks/useShapes/scatter/index.js +0 -1
  93. package/dist/cjs/hooks/useShapes/scatter/prepare-data.js +2 -0
  94. package/dist/cjs/hooks/useShapes/scatter/types.d.ts +1 -0
  95. package/dist/cjs/hooks/useShapes/treemap/prepare-data.d.ts +1 -1
  96. package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +19 -16
  97. package/dist/cjs/hooks/useShapes/waterfall/index.js +2 -2
  98. package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +1 -1
  99. package/dist/cjs/hooks/useShapes/waterfall/prepare-data.js +8 -7
  100. package/dist/cjs/hooks/useZoom/index.d.ts +18 -0
  101. package/dist/cjs/hooks/useZoom/index.js +54 -0
  102. package/dist/cjs/hooks/useZoom/types.d.ts +19 -0
  103. package/dist/cjs/hooks/useZoom/types.js +1 -0
  104. package/dist/cjs/hooks/useZoom/utils.d.ts +12 -0
  105. package/dist/cjs/hooks/useZoom/utils.js +128 -0
  106. package/dist/cjs/types/chart/axis.d.ts +26 -21
  107. package/dist/cjs/types/chart/chart.d.ts +5 -0
  108. package/dist/cjs/types/chart/line.d.ts +1 -1
  109. package/dist/cjs/types/chart/pie.d.ts +1 -1
  110. package/dist/cjs/types/chart/series.d.ts +1 -1
  111. package/dist/cjs/types/chart/tooltip.d.ts +1 -1
  112. package/dist/cjs/types/chart/zoom.d.ts +36 -0
  113. package/dist/cjs/types/chart/zoom.js +1 -0
  114. package/dist/cjs/types/index.d.ts +1 -0
  115. package/dist/cjs/types/index.js +1 -0
  116. package/dist/cjs/types/misc.d.ts +7 -0
  117. package/dist/cjs/utils/chart/axis-generators/bottom.d.ts +1 -1
  118. package/dist/cjs/utils/chart/axis-generators/bottom.js +25 -25
  119. package/dist/cjs/utils/chart/axis.d.ts +2 -1
  120. package/dist/cjs/utils/chart/axis.js +10 -2
  121. package/dist/cjs/utils/chart/get-closest-data.js +1 -1
  122. package/dist/cjs/utils/chart/text.d.ts +7 -7
  123. package/dist/cjs/utils/chart/text.js +37 -29
  124. package/dist/cjs/utils/chart-ui/pie-center-text.d.ts +1 -1
  125. package/dist/cjs/utils/chart-ui/pie-center-text.js +2 -2
  126. package/dist/cjs/validation/index.d.ts +1 -1
  127. package/dist/cjs/validation/index.js +16 -16
  128. package/dist/esm/components/Axis/AxisX.d.ts +2 -1
  129. package/dist/esm/components/Axis/AxisX.js +147 -141
  130. package/dist/esm/components/Axis/AxisY.d.ts +2 -1
  131. package/dist/esm/components/Axis/AxisY.js +118 -116
  132. package/dist/esm/components/ChartInner/index.js +36 -9
  133. package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +1 -1
  134. package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +8 -5
  135. package/dist/esm/components/ChartInner/useChartInnerProps.js +59 -10
  136. package/dist/esm/components/ChartInner/utils.d.ts +3 -0
  137. package/dist/esm/components/ChartInner/utils.js +28 -0
  138. package/dist/esm/components/Legend/index.js +202 -191
  139. package/dist/esm/components/Legend/styles.css +2 -0
  140. package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +1 -1
  141. package/dist/esm/components/Tooltip/DefaultContent.d.ts +1 -1
  142. package/dist/esm/components/Tooltip/DefaultContent.js +1 -1
  143. package/dist/esm/components/Tooltip/index.d.ts +1 -1
  144. package/dist/esm/constants/chart-types.d.ts +12 -0
  145. package/dist/esm/constants/chart-types.js +12 -0
  146. package/dist/esm/constants/defaults/axis.d.ts +3 -1
  147. package/dist/esm/constants/defaults/axis.js +10 -0
  148. package/dist/esm/constants/index.d.ts +6 -47
  149. package/dist/esm/constants/index.js +6 -72
  150. package/dist/esm/constants/layout-algorithms.d.ts +7 -0
  151. package/dist/esm/constants/layout-algorithms.js +8 -0
  152. package/dist/esm/constants/line-styles.d.ts +20 -0
  153. package/dist/esm/constants/line-styles.js +20 -0
  154. package/dist/esm/constants/palette.d.ts +1 -0
  155. package/dist/esm/constants/palette.js +22 -0
  156. package/dist/esm/constants/symbol-types.d.ts +7 -0
  157. package/dist/esm/constants/symbol-types.js +8 -0
  158. package/dist/esm/constants/typography.d.ts +1 -0
  159. package/dist/esm/constants/typography.js +1 -0
  160. package/dist/esm/hooks/hooks-utils/index.d.ts +1 -0
  161. package/dist/esm/hooks/hooks-utils/index.js +1 -0
  162. package/dist/esm/hooks/hooks-utils/zoom.d.ts +8 -0
  163. package/dist/esm/hooks/hooks-utils/zoom.js +81 -0
  164. package/dist/esm/hooks/index.d.ts +1 -0
  165. package/dist/esm/hooks/index.js +1 -0
  166. package/dist/esm/hooks/useAxisScales/index.d.ts +4 -2
  167. package/dist/esm/hooks/useAxisScales/index.js +22 -8
  168. package/dist/esm/hooks/useBrush/index.d.ts +3 -0
  169. package/dist/esm/hooks/useBrush/index.js +70 -0
  170. package/dist/esm/hooks/useBrush/styles.css +10 -0
  171. package/dist/esm/hooks/useBrush/types.d.ts +24 -0
  172. package/dist/esm/hooks/useBrush/types.js +1 -0
  173. package/dist/esm/hooks/useChartDimensions/index.d.ts +3 -3
  174. package/dist/esm/hooks/useChartDimensions/index.js +2 -2
  175. package/dist/esm/hooks/useChartDimensions/utils.d.ts +2 -2
  176. package/dist/esm/hooks/useChartOptions/chart.d.ts +2 -1
  177. package/dist/esm/hooks/useChartOptions/chart.js +80 -1
  178. package/dist/esm/hooks/useChartOptions/index.js +3 -2
  179. package/dist/esm/hooks/useChartOptions/types.d.ts +6 -2
  180. package/dist/esm/hooks/useChartOptions/x-axis.d.ts +3 -3
  181. package/dist/esm/hooks/useChartOptions/x-axis.js +22 -13
  182. package/dist/esm/hooks/useChartOptions/y-axis.d.ts +3 -3
  183. package/dist/esm/hooks/useChartOptions/y-axis.js +36 -21
  184. package/dist/esm/hooks/useCrosshair/index.d.ts +17 -0
  185. package/dist/esm/hooks/useCrosshair/index.js +139 -0
  186. package/dist/esm/hooks/useCrosshair/useCrosshairHover.d.ts +11 -0
  187. package/dist/esm/hooks/useCrosshair/useCrosshairHover.js +18 -0
  188. package/dist/esm/hooks/useSeries/index.d.ts +8 -6
  189. package/dist/esm/hooks/useSeries/index.js +41 -22
  190. package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +27 -2
  191. package/dist/esm/hooks/useSeries/prepare-bar-y.js +5 -5
  192. package/dist/esm/hooks/useSeries/prepare-legend.d.ts +1 -1
  193. package/dist/esm/hooks/useSeries/prepare-legend.js +27 -9
  194. package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -2
  195. package/dist/esm/hooks/useSeries/prepare-line.js +3 -3
  196. package/dist/esm/hooks/useSeries/prepareSeries.d.ts +1 -1
  197. package/dist/esm/hooks/useSeries/prepareSeries.js +2 -2
  198. package/dist/esm/hooks/useSeries/types.d.ts +2 -1
  199. package/dist/esm/hooks/useShapes/area/index.js +1 -1
  200. package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +1 -1
  201. package/dist/esm/hooks/useShapes/area/prepare-data.js +32 -16
  202. package/dist/esm/hooks/useShapes/area/types.d.ts +1 -0
  203. package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +1 -1
  204. package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +17 -13
  205. package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
  206. package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +6 -6
  207. package/dist/esm/hooks/useShapes/index.d.ts +1 -1
  208. package/dist/esm/hooks/useShapes/index.js +40 -31
  209. package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +1 -1
  210. package/dist/esm/hooks/useShapes/line/prepare-data.js +14 -11
  211. package/dist/esm/hooks/useShapes/line/types.d.ts +1 -0
  212. package/dist/esm/hooks/useShapes/marker.js +2 -2
  213. package/dist/esm/hooks/useShapes/pie/index.js +3 -3
  214. package/dist/esm/hooks/useShapes/pie/prepare-data.d.ts +1 -1
  215. package/dist/esm/hooks/useShapes/pie/prepare-data.js +15 -11
  216. package/dist/esm/hooks/useShapes/radar/prepare-data.d.ts +1 -1
  217. package/dist/esm/hooks/useShapes/radar/prepare-data.js +6 -7
  218. package/dist/esm/hooks/useShapes/radar/types.d.ts +1 -0
  219. package/dist/esm/hooks/useShapes/scatter/index.js +0 -1
  220. package/dist/esm/hooks/useShapes/scatter/prepare-data.js +2 -0
  221. package/dist/esm/hooks/useShapes/scatter/types.d.ts +1 -0
  222. package/dist/esm/hooks/useShapes/treemap/prepare-data.d.ts +1 -1
  223. package/dist/esm/hooks/useShapes/treemap/prepare-data.js +19 -16
  224. package/dist/esm/hooks/useShapes/waterfall/index.js +2 -2
  225. package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +1 -1
  226. package/dist/esm/hooks/useShapes/waterfall/prepare-data.js +8 -7
  227. package/dist/esm/hooks/useZoom/index.d.ts +18 -0
  228. package/dist/esm/hooks/useZoom/index.js +54 -0
  229. package/dist/esm/hooks/useZoom/types.d.ts +19 -0
  230. package/dist/esm/hooks/useZoom/types.js +1 -0
  231. package/dist/esm/hooks/useZoom/utils.d.ts +12 -0
  232. package/dist/esm/hooks/useZoom/utils.js +128 -0
  233. package/dist/esm/types/chart/axis.d.ts +26 -21
  234. package/dist/esm/types/chart/chart.d.ts +5 -0
  235. package/dist/esm/types/chart/line.d.ts +1 -1
  236. package/dist/esm/types/chart/pie.d.ts +1 -1
  237. package/dist/esm/types/chart/series.d.ts +1 -1
  238. package/dist/esm/types/chart/tooltip.d.ts +1 -1
  239. package/dist/esm/types/chart/zoom.d.ts +36 -0
  240. package/dist/esm/types/chart/zoom.js +1 -0
  241. package/dist/esm/types/index.d.ts +1 -0
  242. package/dist/esm/types/index.js +1 -0
  243. package/dist/esm/types/misc.d.ts +7 -0
  244. package/dist/esm/utils/chart/axis-generators/bottom.d.ts +1 -1
  245. package/dist/esm/utils/chart/axis-generators/bottom.js +25 -25
  246. package/dist/esm/utils/chart/axis.d.ts +2 -1
  247. package/dist/esm/utils/chart/axis.js +10 -2
  248. package/dist/esm/utils/chart/get-closest-data.js +1 -1
  249. package/dist/esm/utils/chart/text.d.ts +7 -7
  250. package/dist/esm/utils/chart/text.js +37 -29
  251. package/dist/esm/utils/chart-ui/pie-center-text.d.ts +1 -1
  252. package/dist/esm/utils/chart-ui/pie-center-text.js +2 -2
  253. package/dist/esm/validation/index.d.ts +1 -1
  254. package/dist/esm/validation/index.js +16 -16
  255. package/package.json +2 -1
@@ -1,74 +1,8 @@
1
1
  export * from './defaults';
2
2
  export * from './misc';
3
- export const SeriesType = {
4
- Area: 'area',
5
- BarX: 'bar-x',
6
- BarY: 'bar-y',
7
- Line: 'line',
8
- Pie: 'pie',
9
- Scatter: 'scatter',
10
- Treemap: 'treemap',
11
- Waterfall: 'waterfall',
12
- Sankey: 'sankey',
13
- Radar: 'radar',
14
- };
15
- export var DashStyle;
16
- (function (DashStyle) {
17
- DashStyle["Dash"] = "Dash";
18
- DashStyle["DashDot"] = "DashDot";
19
- DashStyle["Dot"] = "Dot";
20
- DashStyle["LongDash"] = "LongDash";
21
- DashStyle["LongDashDot"] = "LongDashDot";
22
- DashStyle["LongDashDotDot"] = "LongDashDotDot";
23
- DashStyle["ShortDash"] = "ShortDash";
24
- DashStyle["ShortDashDot"] = "ShortDashDot";
25
- DashStyle["ShortDashDotDot"] = "ShortDashDotDot";
26
- DashStyle["ShortDot"] = "ShortDot";
27
- DashStyle["Solid"] = "Solid";
28
- })(DashStyle || (DashStyle = {}));
29
- export var SymbolType;
30
- (function (SymbolType) {
31
- SymbolType["Circle"] = "circle";
32
- SymbolType["Diamond"] = "diamond";
33
- SymbolType["Square"] = "square";
34
- SymbolType["Triangle"] = "triangle";
35
- SymbolType["TriangleDown"] = "triangle-down";
36
- })(SymbolType || (SymbolType = {}));
37
- export var LineCap;
38
- (function (LineCap) {
39
- LineCap["Butt"] = "butt";
40
- LineCap["Round"] = "round";
41
- LineCap["Square"] = "square";
42
- LineCap["None"] = "none";
43
- })(LineCap || (LineCap = {}));
44
- export var LayoutAlgorithm;
45
- (function (LayoutAlgorithm) {
46
- LayoutAlgorithm["Binary"] = "binary";
47
- LayoutAlgorithm["Dice"] = "dice";
48
- LayoutAlgorithm["Slice"] = "slice";
49
- LayoutAlgorithm["SliceDice"] = "slice-dice";
50
- LayoutAlgorithm["Squarify"] = "squarify";
51
- })(LayoutAlgorithm || (LayoutAlgorithm = {}));
52
- export const DEFAULT_PALETTE = [
53
- '#4DA2F1',
54
- '#FF3D64',
55
- '#8AD554',
56
- '#FFC636',
57
- '#FFB9DD',
58
- '#84D1EE',
59
- '#FF91A1',
60
- '#54A520',
61
- '#DB9100',
62
- '#BA74B3',
63
- '#1F68A9',
64
- '#ED65A9',
65
- '#0FA08D',
66
- '#FF7E00',
67
- '#E8B0A4',
68
- '#52A6C5',
69
- '#BE2443',
70
- '#70C1AF',
71
- '#FFB46C',
72
- '#DCA3D7',
73
- ];
74
- export const DEFAULT_AXIS_LABEL_FONT_SIZE = '11px';
3
+ export * from './chart-types';
4
+ export * from './line-styles';
5
+ export * from './symbol-types';
6
+ export * from './layout-algorithms';
7
+ export * from './palette';
8
+ export * from './typography';
@@ -0,0 +1,7 @@
1
+ export declare enum LayoutAlgorithm {
2
+ Binary = "binary",
3
+ Dice = "dice",
4
+ Slice = "slice",
5
+ SliceDice = "slice-dice",
6
+ Squarify = "squarify"
7
+ }
@@ -0,0 +1,8 @@
1
+ export var LayoutAlgorithm;
2
+ (function (LayoutAlgorithm) {
3
+ LayoutAlgorithm["Binary"] = "binary";
4
+ LayoutAlgorithm["Dice"] = "dice";
5
+ LayoutAlgorithm["Slice"] = "slice";
6
+ LayoutAlgorithm["SliceDice"] = "slice-dice";
7
+ LayoutAlgorithm["Squarify"] = "squarify";
8
+ })(LayoutAlgorithm || (LayoutAlgorithm = {}));
@@ -0,0 +1,20 @@
1
+ export declare const DASH_STYLE: {
2
+ readonly Dash: "Dash";
3
+ readonly DashDot: "DashDot";
4
+ readonly Dot: "Dot";
5
+ readonly LongDash: "LongDash";
6
+ readonly LongDashDot: "LongDashDot";
7
+ readonly LongDashDotDot: "LongDashDotDot";
8
+ readonly ShortDash: "ShortDash";
9
+ readonly ShortDashDot: "ShortDashDot";
10
+ readonly ShortDashDotDot: "ShortDashDotDot";
11
+ readonly ShortDot: "ShortDot";
12
+ readonly Solid: "Solid";
13
+ };
14
+ export type DashStyle = keyof typeof DASH_STYLE;
15
+ export declare enum LineCap {
16
+ Butt = "butt",
17
+ Round = "round",
18
+ Square = "square",
19
+ None = "none"
20
+ }
@@ -0,0 +1,20 @@
1
+ export const DASH_STYLE = {
2
+ Dash: 'Dash',
3
+ DashDot: 'DashDot',
4
+ Dot: 'Dot',
5
+ LongDash: 'LongDash',
6
+ LongDashDot: 'LongDashDot',
7
+ LongDashDotDot: 'LongDashDotDot',
8
+ ShortDash: 'ShortDash',
9
+ ShortDashDot: 'ShortDashDot',
10
+ ShortDashDotDot: 'ShortDashDotDot',
11
+ ShortDot: 'ShortDot',
12
+ Solid: 'Solid',
13
+ };
14
+ export var LineCap;
15
+ (function (LineCap) {
16
+ LineCap["Butt"] = "butt";
17
+ LineCap["Round"] = "round";
18
+ LineCap["Square"] = "square";
19
+ LineCap["None"] = "none";
20
+ })(LineCap || (LineCap = {}));
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_PALETTE: string[];
@@ -0,0 +1,22 @@
1
+ export const DEFAULT_PALETTE = [
2
+ '#4DA2F1',
3
+ '#FF3D64',
4
+ '#8AD554',
5
+ '#FFC636',
6
+ '#FFB9DD',
7
+ '#84D1EE',
8
+ '#FF91A1',
9
+ '#54A520',
10
+ '#DB9100',
11
+ '#BA74B3',
12
+ '#1F68A9',
13
+ '#ED65A9',
14
+ '#0FA08D',
15
+ '#FF7E00',
16
+ '#E8B0A4',
17
+ '#52A6C5',
18
+ '#BE2443',
19
+ '#70C1AF',
20
+ '#FFB46C',
21
+ '#DCA3D7',
22
+ ];
@@ -0,0 +1,7 @@
1
+ export declare enum SymbolType {
2
+ Circle = "circle",
3
+ Diamond = "diamond",
4
+ Square = "square",
5
+ Triangle = "triangle",
6
+ TriangleDown = "triangle-down"
7
+ }
@@ -0,0 +1,8 @@
1
+ export var SymbolType;
2
+ (function (SymbolType) {
3
+ SymbolType["Circle"] = "circle";
4
+ SymbolType["Diamond"] = "diamond";
5
+ SymbolType["Square"] = "square";
6
+ SymbolType["Triangle"] = "triangle";
7
+ SymbolType["TriangleDown"] = "triangle-down";
8
+ })(SymbolType || (SymbolType = {}));
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_AXIS_LABEL_FONT_SIZE = "11px";
@@ -0,0 +1 @@
1
+ export const DEFAULT_AXIS_LABEL_FONT_SIZE = '11px';
@@ -0,0 +1 @@
1
+ export * from './zoom';
@@ -0,0 +1 @@
1
+ export * from './zoom';
@@ -0,0 +1,8 @@
1
+ import type { ChartSeries, ChartXAxis, ChartYAxis } from '../../types';
2
+ import type { ZoomState } from '../useZoom/types';
3
+ export declare function getZoomedSeriesData(args: {
4
+ seriesData: ChartSeries[];
5
+ zoomState: Partial<ZoomState>;
6
+ xAxis?: ChartXAxis;
7
+ yAxises?: ChartYAxis[];
8
+ }): ChartSeries[];
@@ -0,0 +1,81 @@
1
+ // eslint-disable-next-line complexity
2
+ function isValueInRange(args) {
3
+ const { axis, max, min, value } = args;
4
+ if (value === undefined) {
5
+ return false;
6
+ }
7
+ const axisType = (axis === null || axis === void 0 ? void 0 : axis.type) || 'linear';
8
+ switch (axisType) {
9
+ case 'datetime':
10
+ case 'linear':
11
+ case 'logarithmic': {
12
+ const numValue = typeof value === 'string' ? Number(value) : value;
13
+ const numMin = typeof min === 'string' ? Number(min) : min;
14
+ const numMax = typeof max === 'string' ? Number(max) : max;
15
+ if (Number.isNaN(numValue) || Number.isNaN(numMin) || Number.isNaN(numMax)) {
16
+ return false;
17
+ }
18
+ return numValue >= numMin && numValue <= numMax;
19
+ }
20
+ case 'category': {
21
+ const categories = (axis === null || axis === void 0 ? void 0 : axis.categories) || [];
22
+ if (typeof value === 'string' && typeof min === 'number' && typeof max === 'number') {
23
+ const valueIndex = categories.indexOf(value);
24
+ if (min === -1 || max === -1 || valueIndex === -1) {
25
+ return false;
26
+ }
27
+ return valueIndex >= Math.min(min, max) && valueIndex <= Math.max(min, max);
28
+ }
29
+ if (typeof value === 'number' && typeof min === 'number' && typeof max === 'number') {
30
+ if (min === -1 || max === -1) {
31
+ return false;
32
+ }
33
+ return value >= Math.min(min, max) && value <= Math.max(min, max);
34
+ }
35
+ return false;
36
+ }
37
+ default: {
38
+ return false;
39
+ }
40
+ }
41
+ }
42
+ export function getZoomedSeriesData(args) {
43
+ const { seriesData, xAxis, yAxises, zoomState } = args;
44
+ if (Object.keys(zoomState).length < 0) {
45
+ return seriesData;
46
+ }
47
+ return seriesData.map((seriesItem) => {
48
+ const filteredData = seriesItem.data.reduce((acc, point) => {
49
+ let inXRange = true;
50
+ let inYRange = true;
51
+ if (zoomState.x) {
52
+ const [xMin, xMax] = zoomState.x;
53
+ const x = 'x' in point ? point.x : undefined;
54
+ inXRange = isValueInRange({
55
+ axis: xAxis,
56
+ value: x,
57
+ min: xMin,
58
+ max: xMax,
59
+ });
60
+ }
61
+ if (zoomState.y) {
62
+ const yAxisIndex = 'yAxis' in seriesItem && typeof seriesItem.yAxis === 'number'
63
+ ? seriesItem.yAxis
64
+ : 0;
65
+ const [yMin, yMax] = zoomState.y[yAxisIndex];
66
+ const y = 'y' in point ? point.y : undefined;
67
+ inYRange = isValueInRange({
68
+ axis: yAxises === null || yAxises === void 0 ? void 0 : yAxises[yAxisIndex],
69
+ value: y,
70
+ min: yMin,
71
+ max: yMax,
72
+ });
73
+ }
74
+ if (inXRange && inYRange) {
75
+ acc.push(point);
76
+ }
77
+ return acc;
78
+ }, []);
79
+ return Object.assign(Object.assign({}, seriesItem), { data: filteredData });
80
+ });
81
+ }
@@ -9,3 +9,4 @@ export * from './useShapes';
9
9
  export * from './useTooltip';
10
10
  export * from './useSplit';
11
11
  export * from './useSplit/types';
12
+ export * from './useCrosshair';
@@ -9,3 +9,4 @@ export * from './useShapes';
9
9
  export * from './useTooltip';
10
10
  export * from './useSplit';
11
11
  export * from './useSplit/types';
12
+ export * from './useCrosshair';
@@ -8,16 +8,18 @@ type Args = {
8
8
  boundsWidth: number;
9
9
  boundsHeight: number;
10
10
  series: PreparedSeries[];
11
- xAxis: PreparedAxis;
11
+ xAxis: PreparedAxis | null;
12
12
  yAxis: PreparedAxis[];
13
13
  split: PreparedSplit;
14
+ hasZoomX?: boolean;
15
+ hasZoomY?: boolean;
14
16
  };
15
17
  type ReturnValue = {
16
18
  xScale?: ChartScale;
17
19
  yScale?: ChartScale[];
18
20
  };
19
21
  export declare function createYScale(axis: PreparedAxis, series: PreparedSeries[], boundsHeight: number): ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
20
- export declare function createXScale(axis: PreparedAxis | ChartAxis, series: (PreparedSeries | ChartSeries)[], boundsWidth: number): ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
22
+ export declare function createXScale(axis: PreparedAxis | ChartAxis, series: (PreparedSeries | ChartSeries)[], boundsWidth: number, hasZoomX?: boolean): ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
21
23
  /**
22
24
  * Uses to create scales for axis related series
23
25
  */
@@ -86,7 +86,7 @@ function calculateXAxisPadding(series) {
86
86
  });
87
87
  return result;
88
88
  }
89
- export function createXScale(axis, series, boundsWidth) {
89
+ export function createXScale(axis, series, boundsWidth, hasZoomX) {
90
90
  const xMin = get(axis, 'min');
91
91
  const xMax = getDefaultMaxXAxisValue(series);
92
92
  const xType = get(axis, 'type', DEFAULT_AXIS_TYPE);
@@ -104,7 +104,11 @@ export function createXScale(axis, series, boundsWidth) {
104
104
  const xMinValue = typeof xMin === 'number' ? xMin : domainXMin;
105
105
  const xMaxValue = typeof xMax === 'number' ? Math.max(xMax, domainXMax) : domainXMax;
106
106
  const scaleFn = xType === 'logarithmic' ? scaleLog : scaleLinear;
107
- return scaleFn().domain([xMinValue, xMaxValue]).range(xRange).nice();
107
+ const scale = scaleFn().domain([xMinValue, xMaxValue]).range(xRange);
108
+ if (!hasZoomX) {
109
+ scale.nice();
110
+ }
111
+ return scale;
108
112
  }
109
113
  break;
110
114
  }
@@ -126,13 +130,21 @@ export function createXScale(axis, series, boundsWidth) {
126
130
  case 'datetime': {
127
131
  if (xTimestamps) {
128
132
  const [xMin, xMax] = extent(xTimestamps);
129
- return scaleUtc().domain([xMin, xMax]).range(xRange).nice();
133
+ const scale = scaleUtc().domain([xMin, xMax]).range(xRange);
134
+ if (!hasZoomX) {
135
+ scale.nice();
136
+ }
137
+ return scale;
130
138
  }
131
139
  else {
132
140
  const domain = getDomainDataXBySeries(series);
133
141
  if (isNumericalArrayData(domain)) {
134
142
  const [xMin, xMax] = extent(domain);
135
- return scaleUtc().domain([xMin, xMax]).range(xRange).nice();
143
+ const scale = scaleUtc().domain([xMin, xMax]).range(xRange);
144
+ if (!hasZoomX) {
145
+ scale.nice();
146
+ }
147
+ return scale;
136
148
  }
137
149
  }
138
150
  break;
@@ -141,13 +153,13 @@ export function createXScale(axis, series, boundsWidth) {
141
153
  throw new Error('Failed to create xScale');
142
154
  }
143
155
  const createScales = (args) => {
144
- const { boundsWidth, boundsHeight, series, xAxis, yAxis, split } = args;
156
+ const { boundsWidth, boundsHeight, series, xAxis, yAxis, split, hasZoomX } = args;
145
157
  let visibleSeries = getOnlyVisibleSeries(series);
146
158
  // Reassign to all series in case of all series unselected,
147
159
  // otherwise we will get an empty space without grid
148
160
  visibleSeries = visibleSeries.length === 0 ? series : visibleSeries;
149
161
  return {
150
- xScale: createXScale(xAxis, visibleSeries, boundsWidth),
162
+ xScale: xAxis ? createXScale(xAxis, visibleSeries, boundsWidth, hasZoomX) : undefined,
151
163
  yScale: yAxis.map((axis, index) => {
152
164
  const axisSeries = series.filter((s) => {
153
165
  const seriesAxisIndex = get(s, 'yAxis', 0);
@@ -163,7 +175,7 @@ const createScales = (args) => {
163
175
  * Uses to create scales for axis related series
164
176
  */
165
177
  export const useAxisScales = (args) => {
166
- const { boundsWidth, boundsHeight, series, xAxis, yAxis, split } = args;
178
+ const { boundsWidth, boundsHeight, series, xAxis, yAxis, split, hasZoomX, hasZoomY } = args;
167
179
  return React.useMemo(() => {
168
180
  let xScale;
169
181
  let yScale;
@@ -176,8 +188,10 @@ export const useAxisScales = (args) => {
176
188
  xAxis,
177
189
  yAxis,
178
190
  split,
191
+ hasZoomX,
192
+ hasZoomY,
179
193
  }));
180
194
  }
181
195
  return { xScale, yScale };
182
- }, [boundsWidth, boundsHeight, series, xAxis, yAxis, split]);
196
+ }, [boundsWidth, boundsHeight, series, xAxis, yAxis, split, hasZoomX, hasZoomY]);
183
197
  };
@@ -0,0 +1,3 @@
1
+ import type { UseBrushProps } from './types';
2
+ import './styles.css';
3
+ export declare function useBrush(props: UseBrushProps): void;
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { brush, brushX, brushY, select } from 'd3';
3
+ import { block } from '../../utils';
4
+ import './styles.css';
5
+ const b = block('brush');
6
+ export function useBrush(props) {
7
+ const { areas, brushOptions, node, type, onBrushStart, onBrush, onBrushEnd } = props;
8
+ React.useEffect(() => {
9
+ if (!node || !areas.length) {
10
+ return () => { };
11
+ }
12
+ const brushes = [];
13
+ const brushGroupSelections = [];
14
+ const nodeSelection = select(node);
15
+ areas.forEach((area) => {
16
+ let brushFn;
17
+ switch (type) {
18
+ case 'x': {
19
+ brushFn = brushX;
20
+ break;
21
+ }
22
+ case 'y': {
23
+ brushFn = brushY;
24
+ break;
25
+ }
26
+ case 'xy':
27
+ default: {
28
+ brushFn = brush;
29
+ break;
30
+ }
31
+ }
32
+ const brushInstance = brushFn()
33
+ .extent(area.extent)
34
+ .on('start', function () {
35
+ onBrushStart === null || onBrushStart === void 0 ? void 0 : onBrushStart.call(this, brushInstance);
36
+ })
37
+ .on('brush', function (event) {
38
+ onBrush === null || onBrush === void 0 ? void 0 : onBrush.call(this, brushInstance, event.selection);
39
+ })
40
+ .on('end', function (event) {
41
+ onBrushEnd === null || onBrushEnd === void 0 ? void 0 : onBrushEnd.call(this, brushInstance, event.selection);
42
+ });
43
+ brushes.push(brushInstance);
44
+ const brushGroupSelection = nodeSelection
45
+ .append('g')
46
+ .attr('class', b())
47
+ .on('pointerdown', function () {
48
+ this.setAttribute('data-gc-brush-pressed', 'true');
49
+ })
50
+ .on('pointerup', function () {
51
+ this.removeAttribute('data-gc-brush-pressed');
52
+ });
53
+ brushGroupSelection.call(brushInstance);
54
+ if (brushOptions) {
55
+ brushGroupSelection
56
+ .selectAll('.selection')
57
+ .attr('fill-opacity', brushOptions.style.fillOpacity);
58
+ }
59
+ brushGroupSelections.push(brushGroupSelection);
60
+ });
61
+ return () => {
62
+ brushes.forEach((brushInstance) => {
63
+ brushInstance.on('start', null).on('brush', null).on('end', null);
64
+ });
65
+ brushGroupSelections.forEach((selection) => {
66
+ selection === null || selection === void 0 ? void 0 : selection.remove();
67
+ });
68
+ };
69
+ }, [areas, brushOptions, node, type, onBrushStart, onBrush, onBrushEnd]);
70
+ }
@@ -0,0 +1,10 @@
1
+ .gcharts-brush {
2
+ --gcharts-brush-color: rgba(51, 92, 173, 0.25);
3
+ }
4
+ .gcharts-brush:not([data-gc-brush-pressed=true]) .overlay {
5
+ cursor: default;
6
+ }
7
+ .gcharts-brush .selection {
8
+ fill: var(--gcharts-brush-color);
9
+ stroke: none;
10
+ }
@@ -0,0 +1,24 @@
1
+ import type { BrushBehavior } from 'd3';
2
+ import type { PreparedZoom } from '../useChartOptions/types';
3
+ type BrushType = PreparedZoom['type'];
4
+ type BrushSelection = [number, number] | [[number, number], [number, number]];
5
+ export interface BrushArea {
6
+ /**
7
+ * Array of points [[x0, y0], [x1, y1]], where [x0, y0] is the top-left corner
8
+ * and [x1, y1] is the bottom-right corner.
9
+ *
10
+ * The brush extent determines the size of the invisible overlay and also constrains the brush selection;
11
+ * the brush selection cannot go outside the brush extent.
12
+ */
13
+ extent: [[number, number], [number, number]];
14
+ }
15
+ export interface UseBrushProps {
16
+ areas: BrushArea[];
17
+ node: SVGGElement | null;
18
+ type?: BrushType;
19
+ brushOptions?: PreparedZoom['brush'];
20
+ onBrushStart?: (this: SVGGElement, brushInstance: BrushBehavior<unknown>) => void;
21
+ onBrush?: (this: SVGGElement, brushInstance: BrushBehavior<unknown>, selection: BrushSelection) => void;
22
+ onBrushEnd?: (this: SVGGElement, brushInstance: BrushBehavior<unknown>, selection: BrushSelection | null) => void;
23
+ }
24
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -5,9 +5,9 @@ type Args = {
5
5
  width: number;
6
6
  height: number;
7
7
  margin: ChartMargin;
8
- preparedLegend: PreparedLegend;
9
- preparedXAxis: PreparedAxis;
10
- preparedYAxis: PreparedAxis[];
8
+ preparedLegend: PreparedLegend | null;
9
+ preparedXAxis: PreparedAxis | null;
10
+ preparedYAxis: PreparedAxis[] | null;
11
11
  preparedSeries: PreparedSeries[];
12
12
  };
13
13
  export declare const useChartDimensions: (args: Args) => {
@@ -5,10 +5,10 @@ export { getBoundsWidth } from './utils';
5
5
  const getBottomOffset = (args) => {
6
6
  const { hasAxisRelatedSeries, preparedLegend, preparedXAxis } = args;
7
7
  let result = 0;
8
- if (preparedLegend.enabled) {
8
+ if (preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) {
9
9
  result += preparedLegend.height + preparedLegend.margin;
10
10
  }
11
- if (!preparedXAxis.visible) {
11
+ if (!(preparedXAxis === null || preparedXAxis === void 0 ? void 0 : preparedXAxis.visible)) {
12
12
  return result;
13
13
  }
14
14
  if (hasAxisRelatedSeries) {
@@ -2,9 +2,9 @@ import type { PreparedAxis, PreparedChart } from '../../hooks';
2
2
  export declare const getBoundsWidth: (args: {
3
3
  chartWidth: number;
4
4
  chartMargin: PreparedChart["margin"];
5
- preparedYAxis: PreparedAxis[];
5
+ preparedYAxis: PreparedAxis[] | null;
6
6
  }) => number;
7
7
  export declare function getYAxisWidth(axis: PreparedAxis | undefined): number;
8
8
  export declare function getWidthOccupiedByYAxis(args: {
9
- preparedAxis: PreparedAxis[];
9
+ preparedAxis: PreparedAxis[] | null;
10
10
  }): number;
@@ -1,6 +1,7 @@
1
- import type { ChartData } from '../../types';
1
+ import type { ChartData, ChartSeries } from '../../types';
2
2
  import type { PreparedChart, PreparedTitle } from './types';
3
3
  export declare const getPreparedChart: (args: {
4
4
  chart: ChartData["chart"];
5
+ seriesData: ChartSeries[];
5
6
  preparedTitle?: PreparedTitle;
6
7
  }) => PreparedChart;