@gravity-ui/charts 1.22.0 → 1.24.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 (361) hide show
  1. package/dist/cjs/components/AxisX/AxisX.d.ts +3 -3
  2. package/dist/cjs/components/ChartInner/index.js +94 -27
  3. package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +3 -3
  4. package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +41 -20
  5. package/dist/cjs/components/ChartInner/useChartInnerProps.js +21 -9
  6. package/dist/cjs/components/ChartInner/useChartInnerState.d.ts +6 -1
  7. package/dist/cjs/components/ChartInner/useChartInnerState.js +17 -1
  8. package/dist/cjs/components/ChartInner/utils.d.ts +5 -2
  9. package/dist/cjs/components/ChartInner/utils.js +13 -0
  10. package/dist/cjs/components/RangeSlider/index.d.ts +6 -0
  11. package/dist/cjs/components/RangeSlider/index.js +41 -0
  12. package/dist/cjs/components/RangeSlider/styles.css +6 -0
  13. package/dist/cjs/components/RangeSlider/utils.d.ts +5 -0
  14. package/dist/cjs/components/RangeSlider/utils.js +18 -0
  15. package/dist/cjs/components/Tooltip/DefaultTooltipContent/index.js +2 -1
  16. package/dist/cjs/components/Tooltip/DefaultTooltipContent/utils.d.ts +2 -2
  17. package/dist/cjs/components/Tooltip/DefaultTooltipContent/utils.js +3 -2
  18. package/dist/cjs/components/Tooltip/index.d.ts +3 -3
  19. package/dist/cjs/constants/chart-types.d.ts +3 -1
  20. package/dist/cjs/constants/chart-types.js +2 -1
  21. package/dist/cjs/constants/defaults/brush.d.ts +2 -0
  22. package/dist/cjs/constants/defaults/brush.js +15 -0
  23. package/dist/cjs/constants/defaults/index.d.ts +1 -0
  24. package/dist/cjs/constants/defaults/index.js +1 -0
  25. package/dist/cjs/constants/defaults/series-options.d.ts +2 -1
  26. package/dist/cjs/constants/defaults/series-options.js +11 -0
  27. package/dist/cjs/constants/index.d.ts +1 -0
  28. package/dist/cjs/constants/index.js +1 -0
  29. package/dist/cjs/constants/zoom.d.ts +6 -0
  30. package/dist/cjs/constants/zoom.js +5 -0
  31. package/dist/cjs/hooks/index.d.ts +5 -0
  32. package/dist/cjs/hooks/index.js +5 -0
  33. package/dist/cjs/hooks/useAxis/index.d.ts +4 -3
  34. package/dist/cjs/hooks/useAxis/index.js +2 -2
  35. package/dist/cjs/hooks/useAxis/range-slider.d.ts +5 -0
  36. package/dist/cjs/hooks/useAxis/range-slider.js +16 -0
  37. package/dist/cjs/hooks/useAxis/types.d.ts +66 -0
  38. package/dist/cjs/hooks/useAxis/types.js +1 -0
  39. package/dist/cjs/hooks/{useChartOptions → useAxis}/utils.d.ts +1 -2
  40. package/dist/cjs/hooks/useAxis/utils.js +9 -0
  41. package/dist/{esm/hooks/useChartOptions → cjs/hooks/useAxis}/x-axis.d.ts +2 -2
  42. package/dist/{esm/hooks/useChartOptions → cjs/hooks/useAxis}/x-axis.js +5 -3
  43. package/dist/cjs/hooks/{useChartOptions → useAxis}/y-axis.d.ts +2 -2
  44. package/dist/cjs/hooks/{useChartOptions → useAxis}/y-axis.js +3 -3
  45. package/dist/cjs/hooks/useAxisScales/index.d.ts +3 -3
  46. package/dist/cjs/hooks/useAxisScales/index.js +41 -15
  47. package/dist/cjs/hooks/useBrush/index.js +87 -24
  48. package/dist/cjs/hooks/useBrush/styles.css +1 -0
  49. package/dist/cjs/hooks/useBrush/types.d.ts +8 -7
  50. package/dist/cjs/hooks/useBrush/utils.d.ts +19 -0
  51. package/dist/cjs/hooks/useBrush/utils.js +172 -0
  52. package/dist/cjs/hooks/useChartDimensions/index.d.ts +4 -4
  53. package/dist/cjs/hooks/useChartDimensions/index.js +14 -4
  54. package/dist/cjs/hooks/useChartDimensions/utils.d.ts +4 -4
  55. package/dist/cjs/hooks/useChartOptions/chart.js +1 -82
  56. package/dist/cjs/hooks/useChartOptions/index.d.ts +9 -3
  57. package/dist/cjs/hooks/useChartOptions/tooltip.js +1 -1
  58. package/dist/cjs/hooks/useChartOptions/types.d.ts +4 -64
  59. package/dist/cjs/hooks/useChartOptions/zoom.d.ts +11 -0
  60. package/dist/cjs/hooks/useChartOptions/zoom.js +91 -0
  61. package/dist/cjs/hooks/useCrosshair/index.d.ts +3 -3
  62. package/dist/cjs/hooks/useNormalizedOriginalData/index.d.ts +1 -0
  63. package/dist/cjs/hooks/useNormalizedOriginalData/index.js +1 -2
  64. package/dist/cjs/hooks/useRangeSlider/index.d.ts +4 -0
  65. package/dist/cjs/hooks/useRangeSlider/index.js +129 -0
  66. package/dist/cjs/hooks/useRangeSlider/types.d.ts +42 -0
  67. package/dist/cjs/hooks/useRangeSlider/types.js +1 -0
  68. package/dist/cjs/hooks/useRangeSlider/utils.d.ts +16 -0
  69. package/dist/cjs/hooks/useRangeSlider/utils.js +19 -0
  70. package/dist/cjs/hooks/useSeries/prepare-area.js +17 -2
  71. package/dist/cjs/hooks/useSeries/prepare-bar-x.js +21 -9
  72. package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +3 -2
  73. package/dist/cjs/hooks/useSeries/prepare-bar-y.js +20 -7
  74. package/dist/cjs/hooks/useSeries/prepare-funnel.d.ts +10 -0
  75. package/dist/cjs/hooks/useSeries/prepare-funnel.js +50 -0
  76. package/dist/cjs/hooks/useSeries/prepare-heatmap.js +13 -1
  77. package/dist/cjs/hooks/useSeries/prepare-legend.js +5 -2
  78. package/dist/cjs/hooks/useSeries/prepare-line.js +17 -2
  79. package/dist/cjs/hooks/useSeries/prepare-pie.js +17 -3
  80. package/dist/cjs/hooks/useSeries/prepare-scatter.js +18 -1
  81. package/dist/cjs/hooks/useSeries/prepare-waterfall.js +18 -2
  82. package/dist/cjs/hooks/useSeries/prepareSeries.js +9 -0
  83. package/dist/cjs/hooks/useSeries/types.d.ts +22 -6
  84. package/dist/cjs/hooks/useShapes/area/index.d.ts +3 -3
  85. package/dist/cjs/hooks/useShapes/area/index.js +4 -2
  86. package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +3 -3
  87. package/dist/cjs/hooks/useShapes/area/prepare-data.js +37 -22
  88. package/dist/cjs/hooks/useShapes/area/types.d.ts +5 -2
  89. package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +3 -3
  90. package/dist/cjs/hooks/useShapes/bar-x/index.js +2 -2
  91. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +3 -3
  92. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +26 -15
  93. package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +4 -4
  94. package/dist/cjs/hooks/useShapes/bar-y/index.js +21 -24
  95. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +3 -3
  96. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +26 -8
  97. package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +2 -2
  98. package/dist/cjs/hooks/useShapes/bar-y/utils.d.ts +3 -0
  99. package/dist/cjs/hooks/useShapes/bar-y/utils.js +44 -0
  100. package/dist/cjs/hooks/useShapes/funnel/index.d.ts +13 -0
  101. package/dist/cjs/hooks/useShapes/funnel/index.js +95 -0
  102. package/dist/cjs/hooks/useShapes/funnel/prepare-data.d.ts +9 -0
  103. package/dist/cjs/hooks/useShapes/funnel/prepare-data.js +120 -0
  104. package/dist/cjs/hooks/useShapes/funnel/types.d.ts +32 -0
  105. package/dist/cjs/hooks/useShapes/funnel/types.js +1 -0
  106. package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +2 -2
  107. package/dist/cjs/hooks/useShapes/heatmap/index.js +2 -2
  108. package/dist/cjs/hooks/useShapes/heatmap/prepare-data.d.ts +3 -3
  109. package/dist/cjs/hooks/useShapes/heatmap/prepare-data.js +7 -3
  110. package/dist/cjs/hooks/useShapes/index.d.ts +15 -10
  111. package/dist/cjs/hooks/useShapes/index.js +47 -25
  112. package/dist/cjs/hooks/useShapes/line/index.d.ts +3 -3
  113. package/dist/cjs/hooks/useShapes/line/index.js +3 -2
  114. package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +3 -3
  115. package/dist/cjs/hooks/useShapes/line/prepare-data.js +58 -44
  116. package/dist/cjs/hooks/useShapes/line/types.d.ts +7 -3
  117. package/dist/cjs/hooks/useShapes/pie/index.d.ts +2 -2
  118. package/dist/cjs/hooks/useShapes/pie/index.js +2 -2
  119. package/dist/cjs/hooks/useShapes/pie/prepare-data.js +8 -4
  120. package/dist/cjs/hooks/useShapes/radar/index.d.ts +2 -2
  121. package/dist/cjs/hooks/useShapes/radar/index.js +2 -2
  122. package/dist/cjs/hooks/useShapes/sankey/index.d.ts +2 -2
  123. package/dist/cjs/hooks/useShapes/sankey/index.js +2 -2
  124. package/dist/cjs/hooks/useShapes/scatter/index.d.ts +3 -2
  125. package/dist/cjs/hooks/useShapes/scatter/index.js +4 -4
  126. package/dist/cjs/hooks/useShapes/scatter/prepare-data.d.ts +3 -3
  127. package/dist/cjs/hooks/useShapes/scatter/prepare-data.js +1 -1
  128. package/dist/cjs/hooks/useShapes/styles.css +8 -0
  129. package/dist/cjs/hooks/useShapes/treemap/index.d.ts +2 -2
  130. package/dist/cjs/hooks/useShapes/treemap/index.js +2 -2
  131. package/dist/cjs/hooks/useShapes/utils.d.ts +17 -9
  132. package/dist/cjs/hooks/useShapes/utils.js +66 -18
  133. package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +3 -3
  134. package/dist/cjs/hooks/useShapes/waterfall/index.js +2 -2
  135. package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +3 -3
  136. package/dist/cjs/hooks/useShapes/waterfall/prepare-data.js +18 -8
  137. package/dist/cjs/hooks/useTooltip/index.js +8 -4
  138. package/dist/cjs/hooks/useZoom/index.d.ts +4 -3
  139. package/dist/cjs/hooks/useZoom/index.js +2 -0
  140. package/dist/cjs/hooks/useZoom/utils.d.ts +5 -4
  141. package/dist/cjs/hooks/useZoom/utils.js +4 -3
  142. package/dist/cjs/hooks/utils/bar-x.d.ts +2 -2
  143. package/dist/cjs/hooks/utils/bar-y.d.ts +10 -3
  144. package/dist/cjs/hooks/utils/bar-y.js +4 -0
  145. package/dist/cjs/i18n/keysets/en.json +2 -2
  146. package/dist/cjs/i18n/keysets/ru.json +2 -2
  147. package/dist/cjs/types/chart/area.d.ts +18 -3
  148. package/dist/cjs/types/chart/axis.d.ts +45 -0
  149. package/dist/cjs/types/chart/bar-x.d.ts +17 -4
  150. package/dist/cjs/types/chart/bar-y.d.ts +12 -3
  151. package/dist/cjs/types/chart/base.d.ts +26 -25
  152. package/dist/cjs/types/chart/brush.d.ts +22 -0
  153. package/dist/cjs/types/chart/brush.js +1 -0
  154. package/dist/cjs/types/chart/funnel.d.ts +46 -0
  155. package/dist/cjs/types/chart/funnel.js +1 -0
  156. package/dist/cjs/types/chart/heatmap.d.ts +12 -3
  157. package/dist/cjs/types/chart/legend.d.ts +6 -0
  158. package/dist/cjs/types/chart/line.d.ts +18 -3
  159. package/dist/cjs/types/chart/pie.d.ts +12 -3
  160. package/dist/cjs/types/chart/radar.d.ts +2 -2
  161. package/dist/cjs/types/chart/sankey.d.ts +2 -2
  162. package/dist/cjs/types/chart/scatter.d.ts +18 -4
  163. package/dist/cjs/types/chart/series.d.ts +17 -2
  164. package/dist/cjs/types/chart/tooltip.d.ts +10 -2
  165. package/dist/cjs/types/chart/treemap.d.ts +2 -2
  166. package/dist/cjs/types/chart/waterfall.d.ts +12 -3
  167. package/dist/cjs/types/chart/zoom.d.ts +4 -6
  168. package/dist/cjs/types/index.d.ts +2 -0
  169. package/dist/cjs/types/index.js +2 -0
  170. package/dist/cjs/types/misc.d.ts +6 -0
  171. package/dist/cjs/utils/chart/axis.d.ts +5 -2
  172. package/dist/cjs/utils/chart/axis.js +47 -1
  173. package/dist/cjs/utils/chart/color.js +2 -1
  174. package/dist/cjs/utils/chart/get-closest-data.js +30 -8
  175. package/dist/cjs/utils/chart/index.js +3 -3
  176. package/dist/cjs/utils/chart/series/sorting.js +20 -7
  177. package/dist/cjs/utils/chart/zoom.d.ts +3 -3
  178. package/dist/cjs/utils/chart/zoom.js +6 -4
  179. package/dist/cjs/validation/index.js +6 -6
  180. package/dist/esm/components/AxisX/AxisX.d.ts +3 -3
  181. package/dist/esm/components/ChartInner/index.js +94 -27
  182. package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +3 -3
  183. package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +41 -20
  184. package/dist/esm/components/ChartInner/useChartInnerProps.js +21 -9
  185. package/dist/esm/components/ChartInner/useChartInnerState.d.ts +6 -1
  186. package/dist/esm/components/ChartInner/useChartInnerState.js +17 -1
  187. package/dist/esm/components/ChartInner/utils.d.ts +5 -2
  188. package/dist/esm/components/ChartInner/utils.js +13 -0
  189. package/dist/esm/components/RangeSlider/index.d.ts +6 -0
  190. package/dist/esm/components/RangeSlider/index.js +41 -0
  191. package/dist/esm/components/RangeSlider/styles.css +6 -0
  192. package/dist/esm/components/RangeSlider/utils.d.ts +5 -0
  193. package/dist/esm/components/RangeSlider/utils.js +18 -0
  194. package/dist/esm/components/Tooltip/DefaultTooltipContent/index.js +2 -1
  195. package/dist/esm/components/Tooltip/DefaultTooltipContent/utils.d.ts +2 -2
  196. package/dist/esm/components/Tooltip/DefaultTooltipContent/utils.js +3 -2
  197. package/dist/esm/components/Tooltip/index.d.ts +3 -3
  198. package/dist/esm/constants/chart-types.d.ts +3 -1
  199. package/dist/esm/constants/chart-types.js +2 -1
  200. package/dist/esm/constants/defaults/brush.d.ts +2 -0
  201. package/dist/esm/constants/defaults/brush.js +15 -0
  202. package/dist/esm/constants/defaults/index.d.ts +1 -0
  203. package/dist/esm/constants/defaults/index.js +1 -0
  204. package/dist/esm/constants/defaults/series-options.d.ts +2 -1
  205. package/dist/esm/constants/defaults/series-options.js +11 -0
  206. package/dist/esm/constants/index.d.ts +1 -0
  207. package/dist/esm/constants/index.js +1 -0
  208. package/dist/esm/constants/zoom.d.ts +6 -0
  209. package/dist/esm/constants/zoom.js +5 -0
  210. package/dist/esm/hooks/index.d.ts +5 -0
  211. package/dist/esm/hooks/index.js +5 -0
  212. package/dist/esm/hooks/useAxis/index.d.ts +4 -3
  213. package/dist/esm/hooks/useAxis/index.js +2 -2
  214. package/dist/esm/hooks/useAxis/range-slider.d.ts +5 -0
  215. package/dist/esm/hooks/useAxis/range-slider.js +16 -0
  216. package/dist/esm/hooks/useAxis/types.d.ts +66 -0
  217. package/dist/esm/hooks/useAxis/types.js +1 -0
  218. package/dist/esm/hooks/{useChartOptions → useAxis}/utils.d.ts +1 -2
  219. package/dist/esm/hooks/useAxis/utils.js +9 -0
  220. package/dist/{cjs/hooks/useChartOptions → esm/hooks/useAxis}/x-axis.d.ts +2 -2
  221. package/dist/{cjs/hooks/useChartOptions → esm/hooks/useAxis}/x-axis.js +5 -3
  222. package/dist/esm/hooks/{useChartOptions → useAxis}/y-axis.d.ts +2 -2
  223. package/dist/esm/hooks/{useChartOptions → useAxis}/y-axis.js +3 -3
  224. package/dist/esm/hooks/useAxisScales/index.d.ts +3 -3
  225. package/dist/esm/hooks/useAxisScales/index.js +41 -15
  226. package/dist/esm/hooks/useBrush/index.js +87 -24
  227. package/dist/esm/hooks/useBrush/styles.css +1 -0
  228. package/dist/esm/hooks/useBrush/types.d.ts +8 -7
  229. package/dist/esm/hooks/useBrush/utils.d.ts +19 -0
  230. package/dist/esm/hooks/useBrush/utils.js +172 -0
  231. package/dist/esm/hooks/useChartDimensions/index.d.ts +4 -4
  232. package/dist/esm/hooks/useChartDimensions/index.js +14 -4
  233. package/dist/esm/hooks/useChartDimensions/utils.d.ts +4 -4
  234. package/dist/esm/hooks/useChartOptions/chart.js +1 -82
  235. package/dist/esm/hooks/useChartOptions/index.d.ts +9 -3
  236. package/dist/esm/hooks/useChartOptions/tooltip.js +1 -1
  237. package/dist/esm/hooks/useChartOptions/types.d.ts +4 -64
  238. package/dist/esm/hooks/useChartOptions/zoom.d.ts +11 -0
  239. package/dist/esm/hooks/useChartOptions/zoom.js +91 -0
  240. package/dist/esm/hooks/useCrosshair/index.d.ts +3 -3
  241. package/dist/esm/hooks/useNormalizedOriginalData/index.d.ts +1 -0
  242. package/dist/esm/hooks/useNormalizedOriginalData/index.js +1 -2
  243. package/dist/esm/hooks/useRangeSlider/index.d.ts +4 -0
  244. package/dist/esm/hooks/useRangeSlider/index.js +129 -0
  245. package/dist/esm/hooks/useRangeSlider/types.d.ts +42 -0
  246. package/dist/esm/hooks/useRangeSlider/types.js +1 -0
  247. package/dist/esm/hooks/useRangeSlider/utils.d.ts +16 -0
  248. package/dist/esm/hooks/useRangeSlider/utils.js +19 -0
  249. package/dist/esm/hooks/useSeries/prepare-area.js +17 -2
  250. package/dist/esm/hooks/useSeries/prepare-bar-x.js +21 -9
  251. package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +3 -2
  252. package/dist/esm/hooks/useSeries/prepare-bar-y.js +20 -7
  253. package/dist/esm/hooks/useSeries/prepare-funnel.d.ts +10 -0
  254. package/dist/esm/hooks/useSeries/prepare-funnel.js +50 -0
  255. package/dist/esm/hooks/useSeries/prepare-heatmap.js +13 -1
  256. package/dist/esm/hooks/useSeries/prepare-legend.js +5 -2
  257. package/dist/esm/hooks/useSeries/prepare-line.js +17 -2
  258. package/dist/esm/hooks/useSeries/prepare-pie.js +17 -3
  259. package/dist/esm/hooks/useSeries/prepare-scatter.js +18 -1
  260. package/dist/esm/hooks/useSeries/prepare-waterfall.js +18 -2
  261. package/dist/esm/hooks/useSeries/prepareSeries.js +9 -0
  262. package/dist/esm/hooks/useSeries/types.d.ts +22 -6
  263. package/dist/esm/hooks/useShapes/area/index.d.ts +3 -3
  264. package/dist/esm/hooks/useShapes/area/index.js +4 -2
  265. package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +3 -3
  266. package/dist/esm/hooks/useShapes/area/prepare-data.js +37 -22
  267. package/dist/esm/hooks/useShapes/area/types.d.ts +5 -2
  268. package/dist/esm/hooks/useShapes/bar-x/index.d.ts +3 -3
  269. package/dist/esm/hooks/useShapes/bar-x/index.js +2 -2
  270. package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +3 -3
  271. package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +26 -15
  272. package/dist/esm/hooks/useShapes/bar-y/index.d.ts +4 -4
  273. package/dist/esm/hooks/useShapes/bar-y/index.js +21 -24
  274. package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +3 -3
  275. package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +26 -8
  276. package/dist/esm/hooks/useShapes/bar-y/types.d.ts +2 -2
  277. package/dist/esm/hooks/useShapes/bar-y/utils.d.ts +3 -0
  278. package/dist/esm/hooks/useShapes/bar-y/utils.js +44 -0
  279. package/dist/esm/hooks/useShapes/funnel/index.d.ts +13 -0
  280. package/dist/esm/hooks/useShapes/funnel/index.js +95 -0
  281. package/dist/esm/hooks/useShapes/funnel/prepare-data.d.ts +9 -0
  282. package/dist/esm/hooks/useShapes/funnel/prepare-data.js +120 -0
  283. package/dist/esm/hooks/useShapes/funnel/types.d.ts +32 -0
  284. package/dist/esm/hooks/useShapes/funnel/types.js +1 -0
  285. package/dist/esm/hooks/useShapes/heatmap/index.d.ts +2 -2
  286. package/dist/esm/hooks/useShapes/heatmap/index.js +2 -2
  287. package/dist/esm/hooks/useShapes/heatmap/prepare-data.d.ts +3 -3
  288. package/dist/esm/hooks/useShapes/heatmap/prepare-data.js +7 -3
  289. package/dist/esm/hooks/useShapes/index.d.ts +15 -10
  290. package/dist/esm/hooks/useShapes/index.js +47 -25
  291. package/dist/esm/hooks/useShapes/line/index.d.ts +3 -3
  292. package/dist/esm/hooks/useShapes/line/index.js +3 -2
  293. package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +3 -3
  294. package/dist/esm/hooks/useShapes/line/prepare-data.js +58 -44
  295. package/dist/esm/hooks/useShapes/line/types.d.ts +7 -3
  296. package/dist/esm/hooks/useShapes/pie/index.d.ts +2 -2
  297. package/dist/esm/hooks/useShapes/pie/index.js +2 -2
  298. package/dist/esm/hooks/useShapes/pie/prepare-data.js +8 -4
  299. package/dist/esm/hooks/useShapes/radar/index.d.ts +2 -2
  300. package/dist/esm/hooks/useShapes/radar/index.js +2 -2
  301. package/dist/esm/hooks/useShapes/sankey/index.d.ts +2 -2
  302. package/dist/esm/hooks/useShapes/sankey/index.js +2 -2
  303. package/dist/esm/hooks/useShapes/scatter/index.d.ts +3 -2
  304. package/dist/esm/hooks/useShapes/scatter/index.js +4 -4
  305. package/dist/esm/hooks/useShapes/scatter/prepare-data.d.ts +3 -3
  306. package/dist/esm/hooks/useShapes/scatter/prepare-data.js +1 -1
  307. package/dist/esm/hooks/useShapes/styles.css +8 -0
  308. package/dist/esm/hooks/useShapes/treemap/index.d.ts +2 -2
  309. package/dist/esm/hooks/useShapes/treemap/index.js +2 -2
  310. package/dist/esm/hooks/useShapes/utils.d.ts +17 -9
  311. package/dist/esm/hooks/useShapes/utils.js +66 -18
  312. package/dist/esm/hooks/useShapes/waterfall/index.d.ts +3 -3
  313. package/dist/esm/hooks/useShapes/waterfall/index.js +2 -2
  314. package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +3 -3
  315. package/dist/esm/hooks/useShapes/waterfall/prepare-data.js +18 -8
  316. package/dist/esm/hooks/useTooltip/index.js +8 -4
  317. package/dist/esm/hooks/useZoom/index.d.ts +4 -3
  318. package/dist/esm/hooks/useZoom/index.js +2 -0
  319. package/dist/esm/hooks/useZoom/utils.d.ts +5 -4
  320. package/dist/esm/hooks/useZoom/utils.js +4 -3
  321. package/dist/esm/hooks/utils/bar-x.d.ts +2 -2
  322. package/dist/esm/hooks/utils/bar-y.d.ts +10 -3
  323. package/dist/esm/hooks/utils/bar-y.js +4 -0
  324. package/dist/esm/i18n/keysets/en.json +2 -2
  325. package/dist/esm/i18n/keysets/ru.json +2 -2
  326. package/dist/esm/types/chart/area.d.ts +18 -3
  327. package/dist/esm/types/chart/axis.d.ts +45 -0
  328. package/dist/esm/types/chart/bar-x.d.ts +17 -4
  329. package/dist/esm/types/chart/bar-y.d.ts +12 -3
  330. package/dist/esm/types/chart/base.d.ts +26 -25
  331. package/dist/esm/types/chart/brush.d.ts +22 -0
  332. package/dist/esm/types/chart/brush.js +1 -0
  333. package/dist/esm/types/chart/funnel.d.ts +46 -0
  334. package/dist/esm/types/chart/funnel.js +1 -0
  335. package/dist/esm/types/chart/heatmap.d.ts +12 -3
  336. package/dist/esm/types/chart/legend.d.ts +6 -0
  337. package/dist/esm/types/chart/line.d.ts +18 -3
  338. package/dist/esm/types/chart/pie.d.ts +12 -3
  339. package/dist/esm/types/chart/radar.d.ts +2 -2
  340. package/dist/esm/types/chart/sankey.d.ts +2 -2
  341. package/dist/esm/types/chart/scatter.d.ts +18 -4
  342. package/dist/esm/types/chart/series.d.ts +17 -2
  343. package/dist/esm/types/chart/tooltip.d.ts +10 -2
  344. package/dist/esm/types/chart/treemap.d.ts +2 -2
  345. package/dist/esm/types/chart/waterfall.d.ts +12 -3
  346. package/dist/esm/types/chart/zoom.d.ts +4 -6
  347. package/dist/esm/types/index.d.ts +2 -0
  348. package/dist/esm/types/index.js +2 -0
  349. package/dist/esm/types/misc.d.ts +6 -0
  350. package/dist/esm/utils/chart/axis.d.ts +5 -2
  351. package/dist/esm/utils/chart/axis.js +47 -1
  352. package/dist/esm/utils/chart/color.js +2 -1
  353. package/dist/esm/utils/chart/get-closest-data.js +30 -8
  354. package/dist/esm/utils/chart/index.js +3 -3
  355. package/dist/esm/utils/chart/series/sorting.js +20 -7
  356. package/dist/esm/utils/chart/zoom.d.ts +3 -3
  357. package/dist/esm/utils/chart/zoom.js +6 -4
  358. package/dist/esm/validation/index.js +6 -6
  359. package/package.json +1 -1
  360. package/dist/cjs/hooks/useChartOptions/utils.js +0 -49
  361. package/dist/esm/hooks/useChartOptions/utils.js +0 -49
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import type { ChartScale, PreparedAxis, PreparedSplit } from '../../hooks';
2
+ import type { ChartScale, PreparedSplit, PreparedXAxis } from '../../hooks';
3
3
  import './styles.css';
4
4
  type Props = {
5
- axis: PreparedAxis;
5
+ axis: PreparedXAxis;
6
6
  boundsOffsetLeft: number;
7
7
  boundsOffsetTop: number;
8
8
  height: number;
@@ -15,7 +15,7 @@ type Props = {
15
15
  plotAfterRef?: React.MutableRefObject<SVGGElement | null>;
16
16
  };
17
17
  export declare function getTitlePosition(args: {
18
- axis: PreparedAxis;
18
+ axis: PreparedXAxis;
19
19
  width: number;
20
20
  rowCount: number;
21
21
  }): {
@@ -1,24 +1,28 @@
1
1
  import React from 'react';
2
+ import { duration } from '@gravity-ui/date-utils';
2
3
  import { ArrowRotateLeft } from '@gravity-ui/icons';
3
4
  import { Button, ButtonIcon, useUniqId } from '@gravity-ui/uikit';
4
5
  import { useCrosshair } from '../../hooks';
6
+ import { getPreparedRangeSlider } from '../../hooks/useAxis/range-slider';
5
7
  import { getPreparedTooltip } from '../../hooks/useChartOptions/tooltip';
6
- import { EventType, block, getDispatcher } from '../../utils';
8
+ import { EventType, block, getDispatcher, isBandScale, isTimeScale } from '../../utils';
7
9
  import { AxisX } from '../AxisX/AxisX';
8
10
  import { AxisY } from '../AxisY/AxisY';
9
11
  import { prepareAxisData } from '../AxisY/prepare-axis-data';
10
12
  import { Legend } from '../Legend';
11
13
  import { PlotTitle } from '../PlotTitle';
14
+ import { RangeSlider } from '../RangeSlider';
12
15
  import { Title } from '../Title';
13
16
  import { Tooltip } from '../Tooltip';
14
17
  import { useChartInnerHandlers } from './useChartInnerHandlers';
15
18
  import { useChartInnerProps } from './useChartInnerProps';
16
19
  import { useChartInnerState } from './useChartInnerState';
17
- import { getResetZoomButtonStyle, useAsyncState } from './utils';
20
+ import { getResetZoomButtonStyle, useAsyncState, useDebouncedValue } from './utils';
18
21
  import './styles.css';
19
22
  const b = block('chart');
23
+ const DEBOUNCED_VALUE_DELAY = 10;
20
24
  export const ChartInner = (props) => {
21
- var _a, _b, _c, _d;
25
+ var _a, _b, _c, _d, _e;
22
26
  const { width, height, data } = props;
23
27
  const svgRef = React.useRef(null);
24
28
  const resetZoomButtonRef = React.useRef(null);
@@ -36,14 +40,30 @@ export const ChartInner = (props) => {
36
40
  xAxis: data.xAxis,
37
41
  });
38
42
  }, [data.series.data, data.tooltip, data.yAxis, data.xAxis]);
39
- const { tooltipPinned, togglePinTooltip, unpinTooltip, updateZoomState, zoomState } = useChartInnerState({
43
+ const preparedRangeSlider = React.useMemo(() => {
44
+ return getPreparedRangeSlider({ xAxis: data.xAxis });
45
+ }, [data.xAxis]);
46
+ const { initialized, setInitialized, tooltipPinned, togglePinTooltip, unpinTooltip, rangeSliderState, updateRangeSliderState, updateZoomState, zoomState, } = useChartInnerState({
40
47
  dispatcher,
41
48
  tooltip: preparedTooltip,
49
+ preparedRangeSlider,
42
50
  });
43
- const { boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, isOutsideBounds, legendConfig, legendItems, preparedSeries, preparedSplit, preparedLegend, preparedZoom, prevHeight, prevWidth, shapes, shapesData, svgXPos, title, xAxis, xScale, yAxis, yScale, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
51
+ const { allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, isOutsideBounds, legendConfig, legendItems, preparedChart, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, preparedZoom, prevHeight, prevWidth, shapes, shapesData, svgXPos, title, xAxis, xScale, yAxis, yScale, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
44
52
  dispatcher,
45
- htmlLayout, plotNode: plotRef.current, svgContainer: svgRef.current, updateZoomState,
53
+ htmlLayout, plotNode: plotRef.current, rangeSliderState, svgContainer: svgRef.current, updateZoomState,
46
54
  zoomState }));
55
+ const debouncedBoundsWidth = useDebouncedValue({
56
+ value: boundsWidth,
57
+ delay: DEBOUNCED_VALUE_DELAY,
58
+ });
59
+ const debouncedOffsetLeft = useDebouncedValue({
60
+ value: boundsOffsetLeft,
61
+ delay: DEBOUNCED_VALUE_DELAY,
62
+ });
63
+ const debouncedAllPreparedSeries = useDebouncedValue({
64
+ value: allPreparedSeries,
65
+ delay: DEBOUNCED_VALUE_DELAY,
66
+ });
47
67
  const { handleChartClick, handleMouseLeave, throttledHandleMouseMove, throttledHandleTouchMove } = useChartInnerHandlers({
48
68
  boundsHeight,
49
69
  boundsOffsetLeft,
@@ -116,31 +136,78 @@ export const ChartInner = (props) => {
116
136
  return items;
117
137
  }, [boundsHeight, boundsOffsetTop, boundsWidth, preparedSeries, preparedSplit, yAxis, yScale]);
118
138
  const yAxisDataItems = useAsyncState([], setYAxisDataItems);
139
+ React.useEffect(() => {
140
+ if (!initialized && xScale) {
141
+ const defaultRange = preparedRangeSlider.defaultRange;
142
+ if (isBandScale(xScale)) {
143
+ setInitialized(true);
144
+ return;
145
+ }
146
+ if (isTimeScale(xScale)) {
147
+ const domain = xScale.domain();
148
+ const minDomainMs = domain[0].valueOf();
149
+ const maxDomainMs = domain[1].valueOf();
150
+ let minRangeMs = minDomainMs;
151
+ try {
152
+ if (defaultRange === null || defaultRange === void 0 ? void 0 : defaultRange.size) {
153
+ const durationMs = duration(defaultRange.size).asMilliseconds();
154
+ const minDefaultRangeMs = maxDomainMs - durationMs;
155
+ if (minDefaultRangeMs < maxDomainMs) {
156
+ minRangeMs = minDefaultRangeMs;
157
+ }
158
+ }
159
+ }
160
+ catch (_a) { }
161
+ updateRangeSliderState({ min: minRangeMs, max: maxDomainMs });
162
+ setInitialized(true);
163
+ }
164
+ else {
165
+ const [minDomain, maxDomain] = xScale.domain();
166
+ let minRange = minDomain;
167
+ if (typeof (defaultRange === null || defaultRange === void 0 ? void 0 : defaultRange.size) === 'number') {
168
+ const minDefaultRange = maxDomain - defaultRange.size;
169
+ if (minDefaultRange < maxDomain) {
170
+ minRange = minDefaultRange;
171
+ }
172
+ }
173
+ updateRangeSliderState({ min: minRange, max: maxDomain });
174
+ setInitialized(true);
175
+ }
176
+ }
177
+ }, [
178
+ initialized,
179
+ preparedRangeSlider.defaultRange,
180
+ setInitialized,
181
+ updateRangeSliderState,
182
+ xScale,
183
+ ]);
184
+ const chartContent = (React.createElement(React.Fragment, null,
185
+ React.createElement("defs", null,
186
+ React.createElement("clipPath", { id: clipPathId },
187
+ React.createElement("rect", { x: 0, y: 0, width: boundsWidth, height: boundsHeight }))),
188
+ title && React.createElement(Title, Object.assign({}, title, { chartWidth: width })),
189
+ React.createElement("g", { transform: `translate(0, ${boundsOffsetTop})` }, preparedSplit.plots.map((plot, index) => {
190
+ return React.createElement(PlotTitle, { key: `plot-${index}`, title: plot.title });
191
+ })),
192
+ React.createElement("g", { width: boundsWidth, height: boundsHeight, transform: `translate(${[boundsOffsetLeft, boundsOffsetTop].join(',')})`, ref: plotRef },
193
+ xScale && xAxis && (React.createElement("g", { transform: `translate(0, ${boundsHeight})` },
194
+ React.createElement(AxisX, { axis: xAxis, boundsOffsetLeft: boundsOffsetLeft, boundsOffsetTop: boundsOffsetTop, height: boundsHeight, htmlLayout: htmlLayout, leftmostLimit: svgXPos, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, scale: xScale, split: preparedSplit, width: boundsWidth }))),
195
+ Boolean(yAxisDataItems.length) && (React.createElement(React.Fragment, null, yAxisDataItems.map((axisData, index) => {
196
+ if (!axisData) {
197
+ return null;
198
+ }
199
+ return (React.createElement(AxisY, { key: index, htmlLayout: htmlLayout, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, preparedAxisData: axisData }));
200
+ }))),
201
+ React.createElement("g", { ref: plotBeforeRef }),
202
+ shapes,
203
+ React.createElement("g", { ref: plotAfterRef })),
204
+ ((_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.rangeSlider) === null || _e === void 0 ? void 0 : _e.enabled) && (React.createElement(RangeSlider, { boundsOffsetLeft: debouncedOffsetLeft, boundsWidth: debouncedBoundsWidth, height: height, htmlLayout: htmlLayout, onUpdate: updateRangeSliderState, preparedChart: preparedChart, preparedLegend: preparedLegend, preparedSeries: debouncedAllPreparedSeries, preparedSeriesOptions: preparedSeriesOptions, preparedRangeSlider: xAxis.rangeSlider, rangeSliderState: rangeSliderState, width: width, xAxis: data.xAxis, yAxis: data.yAxis })),
205
+ (preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && legendConfig && (React.createElement(Legend, { chartSeries: preparedSeries, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip, htmlLayout: htmlLayout }))));
119
206
  return (React.createElement("div", { className: b() },
120
207
  React.createElement("svg", { ref: svgRef, width: width, height: height,
121
208
  // We use onPointerMove here because onMouseMove works incorrectly when the zoom setting is enabled:
122
209
  // when starting to select an area, the tooltip remains in the position where the selection began
123
- onPointerMove: throttledHandleMouseMove, onMouseLeave: handleMouseLeave, onTouchStart: throttledHandleTouchMove, onTouchMove: throttledHandleTouchMove, onClick: handleChartClick },
124
- React.createElement("defs", null,
125
- React.createElement("clipPath", { id: clipPathId },
126
- React.createElement("rect", { x: 0, y: 0, width: boundsWidth, height: boundsHeight }))),
127
- title && React.createElement(Title, Object.assign({}, title, { chartWidth: width })),
128
- React.createElement("g", { transform: `translate(0, ${boundsOffsetTop})` }, preparedSplit.plots.map((plot, index) => {
129
- return React.createElement(PlotTitle, { key: `plot-${index}`, title: plot.title });
130
- })),
131
- React.createElement("g", { width: boundsWidth, height: boundsHeight, transform: `translate(${[boundsOffsetLeft, boundsOffsetTop].join(',')})`, ref: plotRef },
132
- xScale && xAxis && (React.createElement("g", { transform: `translate(0, ${boundsHeight})` },
133
- React.createElement(AxisX, { axis: xAxis, boundsOffsetLeft: boundsOffsetLeft, boundsOffsetTop: boundsOffsetTop, height: boundsHeight, htmlLayout: htmlLayout, leftmostLimit: svgXPos, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, scale: xScale, split: preparedSplit, width: boundsWidth }))),
134
- Boolean(yAxisDataItems.length) && (React.createElement(React.Fragment, null, yAxisDataItems.map((axisData, index) => {
135
- if (!axisData) {
136
- return null;
137
- }
138
- return (React.createElement(AxisY, { key: index, htmlLayout: htmlLayout, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, preparedAxisData: axisData }));
139
- }))),
140
- React.createElement("g", { ref: plotBeforeRef }),
141
- shapes,
142
- React.createElement("g", { ref: plotAfterRef })),
143
- (preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && legendConfig && (React.createElement(Legend, { chartSeries: preparedSeries, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip, htmlLayout: htmlLayout }))),
210
+ onPointerMove: throttledHandleMouseMove, onMouseLeave: handleMouseLeave, onTouchStart: throttledHandleTouchMove, onTouchMove: throttledHandleTouchMove, onClick: handleChartClick }, initialized ? chartContent : null),
144
211
  React.createElement("div", { className: b('html-layer'), ref: setHtmlLayout, style: {
145
212
  '--g-html-layout-transform': `translate(${boundsOffsetLeft}px, ${boundsOffsetTop}px)`,
146
213
  } }),
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { Dispatch } from 'd3';
3
- import type { PreparedAxis, ShapeData } from '../../hooks';
3
+ import type { PreparedXAxis, PreparedYAxis, ShapeData } from '../../hooks';
4
4
  import type { useChartInnerState } from './useChartInnerState';
5
5
  type ChartInnerState = ReturnType<typeof useChartInnerState>;
6
6
  type Props = {
@@ -14,8 +14,8 @@ type Props = {
14
14
  togglePinTooltip: ChartInnerState['togglePinTooltip'];
15
15
  tooltipPinned: boolean;
16
16
  unpinTooltip: ChartInnerState['unpinTooltip'];
17
- xAxis: PreparedAxis | null;
18
- yAxis: PreparedAxis[];
17
+ xAxis: PreparedXAxis | null;
18
+ yAxis: PreparedYAxis[];
19
19
  tooltipThrottle: number;
20
20
  isOutsideBounds: (x: number, y: number) => boolean;
21
21
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { Dispatch } from 'd3';
3
- import type { ZoomState } from '../../hooks/useZoom/types';
3
+ import type { RangeSliderState, ZoomState } from '../../hooks';
4
4
  import type { ChartInnerProps } from './types';
5
5
  type Props = ChartInnerProps & {
6
6
  clipPathId: string;
@@ -10,9 +10,10 @@ type Props = ChartInnerProps & {
10
10
  svgContainer: SVGGElement | null;
11
11
  updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
12
12
  zoomState: Partial<ZoomState>;
13
+ rangeSliderState?: RangeSliderState;
13
14
  };
14
15
  export declare function useChartInnerProps(props: Props): {
15
- svgXPos: number | undefined;
16
+ allPreparedSeries: import("../../hooks").PreparedSeries[];
16
17
  boundsHeight: number;
17
18
  boundsOffsetLeft: number;
18
19
  boundsOffsetTop: number;
@@ -33,35 +34,55 @@ export declare function useChartInnerProps(props: Props): {
33
34
  maxWidth: number;
34
35
  } | undefined;
35
36
  legendItems: never[] | import("../../hooks").LegendItem[][];
37
+ preparedChart: import("../../hooks").PreparedChart;
36
38
  preparedLegend: import("../../hooks").PreparedLegend | null;
37
39
  preparedSeries: import("../../hooks").PreparedSeries[];
40
+ preparedSeriesOptions: import("../../constants").SeriesOptionsDefaults;
38
41
  preparedSplit: import("../../hooks").PreparedSplit;
39
- preparedZoom: Required<{
40
- type?: ("x" | "y" | "xy") | undefined;
41
- brush?: Required<{
42
- style?: Required<{
43
- fillOpacity?: number | undefined;
44
- } | undefined>;
45
- } | undefined>;
46
- resetButton?: Required<{
47
- align?: ("bottom-left" | "bottom-right" | "top-left" | "top-right") | undefined;
48
- offset?: Required<{
49
- x?: number | undefined;
50
- y?: number | undefined;
51
- } | undefined>;
52
- relativeTo?: ("chart-box" | "plot-box") | undefined;
53
- } | undefined>;
54
- }> | null;
42
+ preparedZoom: import("../../hooks").PreparedZoom | null;
55
43
  prevHeight: number | undefined;
56
44
  prevWidth: number | undefined;
57
45
  shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
58
46
  shapesData: import("../../hooks").ShapeData[];
47
+ svgXPos: number | undefined;
59
48
  title: (import("../..").ChartTitle & {
60
49
  height: number;
61
50
  }) | undefined;
62
- xAxis: import("../../hooks").PreparedAxis | null;
51
+ xAxis: import("../../hooks").PreparedXAxis | null;
63
52
  xScale: import("../../hooks").ChartScale | undefined;
64
- yAxis: import("../../hooks").PreparedAxis[];
53
+ yAxis: (Omit<import("../..").ChartAxis, "type" | "labels" | "plotLines" | "plotBands"> & {
54
+ type: import("../..").ChartAxisType;
55
+ labels: Omit<import("../..").ChartAxisLabels, "enabled" | "style" | "padding" | "autoRotation"> & Required<Pick<import("../..").ChartAxisLabels, "enabled" | "html" | "padding" | "margin" | "rotation">> & {
56
+ style: import("../..").BaseTextStyle;
57
+ rotation: number;
58
+ height: number;
59
+ width: number;
60
+ lineHeight: number;
61
+ maxWidth: number;
62
+ };
63
+ title: {
64
+ height: number;
65
+ width: number;
66
+ text: string;
67
+ margin: number;
68
+ style: import("../..").BaseTextStyle;
69
+ align: import("../..").ChartAxisTitleAlignment;
70
+ maxRowCount: number;
71
+ };
72
+ min?: number;
73
+ grid: {
74
+ enabled: boolean;
75
+ };
76
+ maxPadding: number;
77
+ ticks: {
78
+ pixelInterval?: number;
79
+ };
80
+ position: "left" | "right" | "top" | "bottom";
81
+ plotIndex: number;
82
+ plotLines: import("../../hooks").PreparedAxisPlotLine[];
83
+ plotBands: import("../../hooks").PreparedAxisPlotBand[];
84
+ crosshair: Required<import("../..").AxisCrosshair>;
85
+ })[];
65
86
  yScale: (import("../../hooks").ChartScale | undefined)[] | undefined;
66
87
  };
67
88
  export {};
@@ -1,14 +1,17 @@
1
1
  import React from 'react';
2
- import { useAxis, useAxisScales, useChartDimensions, useChartOptions, useNormalizedOriginalData, usePrevious, useSeries, useShapes, useSplit, } from '../../hooks';
2
+ import { SERIES_TYPE } from '../../constants';
3
+ import { useAxis, useAxisScales, useChartDimensions, useChartOptions, useNormalizedOriginalData, usePrevious, useSeries, useShapes, useSplit, useZoom, } from '../../hooks';
3
4
  import { getYAxisWidth } from '../../hooks/useChartDimensions/utils';
4
5
  import { getLegendComponents } from '../../hooks/useSeries/prepare-legend';
5
6
  import { getPreparedOptions } from '../../hooks/useSeries/prepare-options';
6
- import { useZoom } from '../../hooks/useZoom';
7
7
  import { getZoomedSeriesData } from '../../utils';
8
8
  import { hasAtLeastOneSeriesDataPerPlot } from './utils';
9
+ const CLIP_PATH_BY_SERIES_TYPE = {
10
+ [SERIES_TYPE.Scatter]: false,
11
+ };
9
12
  export function useChartInnerProps(props) {
10
13
  var _a;
11
- const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, svgContainer, width, updateZoomState, zoomState, } = props;
14
+ const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, rangeSliderState, svgContainer, width, updateZoomState, zoomState, } = props;
12
15
  const prevWidth = usePrevious(width);
13
16
  const prevHeight = usePrevious(height);
14
17
  const { normalizedSeriesData, normalizedXAxis, normalizedYAxis } = useNormalizedOriginalData({
@@ -16,16 +19,17 @@ export function useChartInnerProps(props) {
16
19
  xAxis: data.xAxis,
17
20
  yAxis: data.yAxis,
18
21
  });
19
- const { chart, title, colors } = useChartOptions({
22
+ const { chart, colors, title } = useChartOptions({
20
23
  chart: data.chart,
21
24
  colors: data.colors,
22
25
  seriesData: normalizedSeriesData,
23
26
  title: data.title,
27
+ xAxis: data.xAxis,
24
28
  });
25
29
  const preparedSeriesOptions = React.useMemo(() => {
26
30
  return getPreparedOptions(data.series.options);
27
31
  }, [data.series.options]);
28
- const { preparedSeries: basePreparedSeries, preparedLegend, handleLegendItemClick, } = useSeries({
32
+ const { preparedSeries: allPreparedSeries, preparedLegend, handleLegendItemClick, } = useSeries({
29
33
  colors,
30
34
  legend: data.legend,
31
35
  originalSeriesData: normalizedSeriesData,
@@ -34,12 +38,12 @@ export function useChartInnerProps(props) {
34
38
  });
35
39
  const { preparedSeries, preparedShapesSeries } = React.useMemo(() => {
36
40
  return getZoomedSeriesData({
37
- seriesData: basePreparedSeries,
41
+ seriesData: allPreparedSeries,
38
42
  xAxis: normalizedXAxis,
39
43
  yAxis: normalizedYAxis,
40
44
  zoomState,
41
45
  });
42
- }, [basePreparedSeries, normalizedXAxis, normalizedYAxis, zoomState]);
46
+ }, [allPreparedSeries, normalizedXAxis, normalizedYAxis, zoomState]);
43
47
  const { legendConfig, legendItems } = React.useMemo(() => {
44
48
  if (!preparedLegend) {
45
49
  return { legendConfig: undefined, legendItems: [] };
@@ -77,6 +81,7 @@ export function useChartInnerProps(props) {
77
81
  boundsHeight,
78
82
  hasZoomX: Boolean(zoomState.x),
79
83
  hasZoomY: Boolean(zoomState.y),
84
+ rangeSliderState,
80
85
  series: preparedSeries,
81
86
  seriesOptions: preparedSeriesOptions,
82
87
  split: preparedSplit,
@@ -89,6 +94,7 @@ export function useChartInnerProps(props) {
89
94
  const { shapes, shapesData } = useShapes({
90
95
  boundsWidth,
91
96
  boundsHeight,
97
+ clipPathBySeriesType: CLIP_PATH_BY_SERIES_TYPE,
92
98
  dispatcher,
93
99
  series: preparedShapesSeries,
94
100
  seriesOptions: preparedSeriesOptions,
@@ -125,7 +131,10 @@ export function useChartInnerProps(props) {
125
131
  yAxis,
126
132
  yScale,
127
133
  });
128
- const boundsOffsetTop = chart.margin.top;
134
+ const boundsOffsetTop = chart.margin.top +
135
+ ((preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && preparedLegend.position === 'top'
136
+ ? preparedLegend.height + preparedLegend.margin
137
+ : 0);
129
138
  // We need to calculate the width of each left axis because the first axis can be hidden
130
139
  const boundsOffsetLeft = chart.margin.left +
131
140
  yAxis.reduce((acc, axis) => {
@@ -140,7 +149,7 @@ export function useChartInnerProps(props) {
140
149
  }, 0);
141
150
  const { x } = (_a = svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) !== null && _a !== void 0 ? _a : {};
142
151
  return {
143
- svgXPos: x,
152
+ allPreparedSeries,
144
153
  boundsHeight,
145
154
  boundsOffsetLeft,
146
155
  boundsOffsetTop,
@@ -149,14 +158,17 @@ export function useChartInnerProps(props) {
149
158
  isOutsideBounds,
150
159
  legendConfig,
151
160
  legendItems,
161
+ preparedChart: chart,
152
162
  preparedLegend,
153
163
  preparedSeries,
164
+ preparedSeriesOptions,
154
165
  preparedSplit,
155
166
  preparedZoom: chart.zoom,
156
167
  prevHeight,
157
168
  prevWidth,
158
169
  shapes,
159
170
  shapesData,
171
+ svgXPos: x,
160
172
  title,
161
173
  xAxis,
162
174
  xScale,
@@ -1,14 +1,19 @@
1
1
  import React from 'react';
2
2
  import type { Dispatch } from 'd3';
3
- import type { PreparedTooltip, ZoomState } from '../../hooks';
3
+ import type { PreparedRangeSlider, PreparedTooltip, RangeSliderState, ZoomState } from '../../hooks';
4
4
  type Props = {
5
5
  dispatcher: Dispatch<object>;
6
+ preparedRangeSlider: PreparedRangeSlider;
6
7
  tooltip?: PreparedTooltip;
7
8
  };
8
9
  export declare function useChartInnerState(props: Props): {
10
+ initialized: boolean;
11
+ rangeSliderState: RangeSliderState | undefined;
12
+ setInitialized: React.Dispatch<React.SetStateAction<boolean>>;
9
13
  tooltipPinned: boolean;
10
14
  togglePinTooltip: ((value: boolean, event: React.MouseEvent) => void) | undefined;
11
15
  unpinTooltip: (() => void) | undefined;
16
+ updateRangeSliderState: (nextRangeSliderState?: RangeSliderState) => void;
12
17
  updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
13
18
  zoomState: Partial<ZoomState>;
14
19
  };
@@ -3,9 +3,11 @@ import isEqual from 'lodash/isEqual';
3
3
  import { EventType, isMacintosh } from '../../utils';
4
4
  export function useChartInnerState(props) {
5
5
  var _a, _b;
6
- const { dispatcher, tooltip } = props;
6
+ const { dispatcher, preparedRangeSlider, tooltip } = props;
7
7
  const [tooltipPinned, setTooltipPinned] = React.useState(false);
8
8
  const [zoomState, setZoomState] = React.useState({});
9
+ const [rangeSliderState, setRangeSliderState] = React.useState();
10
+ const [initialized, setInitialized] = React.useState(!preparedRangeSlider.enabled);
9
11
  const tooltipEnabled = tooltip === null || tooltip === void 0 ? void 0 : tooltip.enabled;
10
12
  const tooltipPinEnabled = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.pin) === null || _a === void 0 ? void 0 : _a.enabled;
11
13
  const modifierKey = (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.pin) === null || _b === void 0 ? void 0 : _b.modifierKey;
@@ -33,10 +35,24 @@ export function useChartInnerState(props) {
33
35
  setZoomState(nextZoomState);
34
36
  }
35
37
  }, [zoomState]);
38
+ const updateRangeSliderState = React.useCallback((nextRangeSliderState) => {
39
+ if (!isEqual(rangeSliderState, nextRangeSliderState)) {
40
+ setRangeSliderState(nextRangeSliderState
41
+ ? {
42
+ max: nextRangeSliderState.max,
43
+ min: nextRangeSliderState.min,
44
+ }
45
+ : undefined);
46
+ }
47
+ }, [rangeSliderState]);
36
48
  return {
49
+ initialized,
50
+ rangeSliderState,
51
+ setInitialized,
37
52
  tooltipPinned,
38
53
  togglePinTooltip: tooltipEnabled && tooltipPinEnabled ? togglePinTooltip : undefined,
39
54
  unpinTooltip: tooltipEnabled && tooltipPinEnabled ? unpinTooltip : undefined,
55
+ updateRangeSliderState,
40
56
  updateZoomState,
41
57
  zoomState,
42
58
  };
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import type { PreparedSeries } from '../../hooks';
3
- import type { PreparedAxis, PreparedZoom } from '../../hooks/useChartOptions/types';
2
+ import type { PreparedAxis, PreparedSeries, PreparedZoom } from '../../hooks';
4
3
  export declare function hasAtLeastOneSeriesDataPerPlot(seriesData: PreparedSeries[], yAxes?: PreparedAxis[]): boolean;
5
4
  export declare function useAsyncState<T>(value: T, setState: () => Promise<T>): T;
6
5
  export declare function getResetZoomButtonStyle(args: {
@@ -11,3 +10,7 @@ export declare function getResetZoomButtonStyle(args: {
11
10
  node: HTMLElement | null;
12
11
  titleHeight?: number;
13
12
  } & PreparedZoom['resetButton']): React.CSSProperties;
13
+ export declare function useDebouncedValue<T>(props: {
14
+ value: T;
15
+ delay?: number;
16
+ }): T;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import debounce from 'lodash/debounce';
2
3
  import isEqual from 'lodash/isEqual';
3
4
  export function hasAtLeastOneSeriesDataPerPlot(seriesData, yAxes = []) {
4
5
  const hasDataMap = new Map();
@@ -107,3 +108,15 @@ export function getResetZoomButtonStyle(args) {
107
108
  }
108
109
  return style;
109
110
  }
111
+ export function useDebouncedValue(props) {
112
+ const { value: propsValue, delay = 0 } = props;
113
+ const [value, setValue] = React.useState(propsValue);
114
+ React.useEffect(() => {
115
+ const debouncedSetValue = debounce(setValue, delay);
116
+ debouncedSetValue(propsValue);
117
+ return () => {
118
+ debouncedSetValue.cancel();
119
+ };
120
+ }, [propsValue, delay]);
121
+ return value;
122
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { RangeSliderProps } from '../../hooks';
3
+ import './styles.css';
4
+ declare function RangeSliderComponent(props: RangeSliderProps): React.JSX.Element;
5
+ export declare const RangeSlider: React.MemoExoticComponent<typeof RangeSliderComponent>;
6
+ export {};
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { useUniqId } from '@gravity-ui/uikit';
3
+ import { useBrush, useRangeSlider } from '../../hooks';
4
+ import { block } from '../../utils';
5
+ import { getFramedPath } from './utils';
6
+ import './styles.css';
7
+ const b = block('range-slider');
8
+ function RangeSliderComponent(props) {
9
+ const clipPathId = useUniqId();
10
+ const { brush, height, onBrushEnd, onOverlayClick, offsetLeft, offsetTop, preparedXAxis, preparedYAxis, selection, shapes, width, } = useRangeSlider(Object.assign(Object.assign({}, props), { clipPathId }));
11
+ const ref = React.useRef(null);
12
+ const areas = React.useMemo(() => {
13
+ if (!preparedXAxis || !(preparedYAxis === null || preparedYAxis === void 0 ? void 0 : preparedYAxis.length)) {
14
+ return [];
15
+ }
16
+ return [
17
+ {
18
+ extent: [
19
+ [0, 0],
20
+ [width, height],
21
+ ],
22
+ },
23
+ ];
24
+ }, [height, preparedXAxis, preparedYAxis, width]);
25
+ useBrush({
26
+ areas,
27
+ brushOptions: brush,
28
+ node: ref.current,
29
+ onBrushEnd,
30
+ selection,
31
+ type: 'x',
32
+ });
33
+ return (React.createElement("g", { className: b(), transform: `translate(${offsetLeft}, ${offsetTop})`, width: width, height: height, ref: ref },
34
+ React.createElement("defs", null,
35
+ React.createElement("clipPath", { id: clipPathId },
36
+ React.createElement("rect", { x: 0, y: 0, width: width, height: height }))),
37
+ React.createElement("path", { d: getFramedPath({ height, strokeWidth: 1, width }), fill: "var(--g-color-line-generic)" }),
38
+ React.createElement("g", { className: b('shapes') }, shapes),
39
+ React.createElement("rect", { height: height, className: b('clickable-overlay'), onClick: onOverlayClick, width: width, x: 0, y: 0 })));
40
+ }
41
+ export const RangeSlider = React.memo(RangeSliderComponent);
@@ -0,0 +1,6 @@
1
+ .gcharts-range-slider__shapes {
2
+ opacity: 0.5;
3
+ }
4
+ .gcharts-range-slider__clickable-overlay {
5
+ opacity: 0;
6
+ }
@@ -0,0 +1,5 @@
1
+ export declare function getFramedPath(args: {
2
+ height: number;
3
+ strokeWidth: number;
4
+ width: number;
5
+ }): string;
@@ -0,0 +1,18 @@
1
+ import { path } from 'd3';
2
+ export function getFramedPath(args) {
3
+ const { height, strokeWidth, width } = args;
4
+ const p = path();
5
+ // Outer rectangle
6
+ p.moveTo(0, 0);
7
+ p.lineTo(width, 0);
8
+ p.lineTo(width, height);
9
+ p.lineTo(0, height);
10
+ p.closePath();
11
+ // Inner rectangle (cutout)
12
+ p.moveTo(strokeWidth, strokeWidth);
13
+ p.lineTo(strokeWidth, height - strokeWidth);
14
+ p.lineTo(width - strokeWidth, height - strokeWidth);
15
+ p.lineTo(width - strokeWidth, strokeWidth);
16
+ p.closePath();
17
+ return p.toString();
18
+ }
@@ -151,7 +151,8 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
151
151
  }
152
152
  case 'pie':
153
153
  case 'heatmap':
154
- case 'treemap': {
154
+ case 'treemap':
155
+ case 'funnel': {
155
156
  const seriesData = data;
156
157
  const formattedValue = getFormattedValue({
157
158
  value: hoveredValues[i],
@@ -1,6 +1,6 @@
1
1
  import type { ChartSeriesData, ChartTooltip, ChartTooltipTotalsAggregationValue, ChartTooltipTotalsBuiltInAggregation, ChartXAxis, ChartYAxis, TooltipDataChunk, ValueFormat } from '../../../types';
2
2
  export type HoveredValue = string | number | null | undefined;
3
- export declare function getXRowData(data: ChartSeriesData, xAxis?: ChartXAxis | null): string | number | undefined;
3
+ export declare function getXRowData(data: ChartSeriesData, xAxis?: ChartXAxis | null): string | number | null | undefined;
4
4
  export declare function getDefaultValueFormat({ axis, closestPointsRange, }: {
5
5
  axis?: ChartXAxis | ChartYAxis | null;
6
6
  closestPointsRange?: number;
@@ -14,7 +14,7 @@ export declare const getMeasureValue: ({ data, xAxis, yAxis, headerFormat, }: {
14
14
  value: string | null;
15
15
  formattedValue?: undefined;
16
16
  } | {
17
- value: string | number | undefined;
17
+ value: string | number | null | undefined;
18
18
  formattedValue: string;
19
19
  } | null;
20
20
  export declare function getHoveredValues(args: {
@@ -39,7 +39,7 @@ export function getDefaultValueFormat({ axis, closestPointsRange, }) {
39
39
  }
40
40
  export const getMeasureValue = ({ data, xAxis, yAxis, headerFormat, }) => {
41
41
  var _a, _b, _c, _d, _e, _f;
42
- if (data.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'heatmap'].includes(item.series.type))) {
42
+ if (data.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'heatmap', 'funnel'].includes(item.series.type))) {
43
43
  return null;
44
44
  }
45
45
  if (data.some((item) => item.series.type === 'radar')) {
@@ -79,7 +79,8 @@ export function getHoveredValues(args) {
79
79
  case 'pie':
80
80
  case 'radar':
81
81
  case 'heatmap':
82
- case 'treemap': {
82
+ case 'treemap':
83
+ case 'funnel': {
83
84
  const seriesData = data;
84
85
  return seriesData.value;
85
86
  }