@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,32 +1,6 @@
1
- import { getLabelsSize, getLeftPosition } from '../../../utils';
1
+ import { getLabelsSize, getTextSizeFn } from '../../../utils';
2
2
  import { getFormattedValue } from '../../../utils/chart/format';
3
3
  import { getXValue, getYValue } from '../utils';
4
- async function getLabelData(point, series, xMax) {
5
- const text = getFormattedValue(Object.assign({ value: point.data.label || point.data.y }, series.dataLabels));
6
- const style = series.dataLabels.style;
7
- const size = await getLabelsSize({ labels: [text], style });
8
- const labelData = {
9
- text,
10
- x: point.x,
11
- y: point.y - series.dataLabels.padding,
12
- style,
13
- size: { width: size.maxWidth, height: size.maxHeight },
14
- textAnchor: 'middle',
15
- series: series,
16
- active: true,
17
- };
18
- const left = getLeftPosition(labelData);
19
- if (left < 0) {
20
- labelData.x = labelData.x + Math.abs(left);
21
- }
22
- else {
23
- const right = left + labelData.size.width;
24
- if (right > xMax) {
25
- labelData.x = labelData.x - xMax - right;
26
- }
27
- }
28
- return labelData;
29
- }
30
4
  async function getHtmlLabel(point, series, xMax) {
31
5
  const content = String(point.data.label || point.data.y);
32
6
  const size = await getLabelsSize({ labels: [content], html: true });
@@ -53,33 +27,73 @@ export const prepareLineData = async (args) => {
53
27
  if (!seriesYScale) {
54
28
  continue;
55
29
  }
56
- const points = s.data.map((d) => ({
57
- x: getXValue({ point: d, points: s.data, xAxis, xScale }),
58
- y: yAxisTop +
59
- getYValue({ point: d, points: s.data, yAxis: seriesYAxis, yScale: seriesYScale }),
60
- active: true,
61
- data: d,
62
- series: s,
63
- }));
30
+ const points = s.data.map((d) => {
31
+ const yValue = getYValue({
32
+ point: d,
33
+ points: s.data,
34
+ yAxis: seriesYAxis,
35
+ yScale: seriesYScale,
36
+ });
37
+ return {
38
+ x: getXValue({ point: d, points: s.data, xAxis, xScale }),
39
+ y: yValue === null ? null : yAxisTop + yValue,
40
+ active: true,
41
+ data: d,
42
+ series: s,
43
+ };
44
+ });
64
45
  const htmlElements = [];
65
- let labels = [];
46
+ const labels = [];
66
47
  if (s.dataLabels.enabled) {
67
48
  if (s.dataLabels.html) {
68
- const list = await Promise.all(points.map((p) => getHtmlLabel(p, s, xMax)));
49
+ const list = await Promise.all(points.reduce((result, p) => {
50
+ if (p.y === null) {
51
+ return result;
52
+ }
53
+ result.push(getHtmlLabel(p, s, xMax));
54
+ return result;
55
+ }, []));
69
56
  htmlElements.push(...list);
70
57
  }
71
58
  else {
72
- labels = await Promise.all(points.map((p) => getLabelData(p, s, xMax)));
59
+ const getTextSize = getTextSizeFn({ style: s.dataLabels.style });
60
+ for (let index = 0; index < points.length; index++) {
61
+ const point = points[index];
62
+ if (point.y !== null && point.x !== null) {
63
+ const text = getFormattedValue(Object.assign({ value: point.data.label || point.data.y }, s.dataLabels));
64
+ const labelSize = await getTextSize(text);
65
+ const style = s.dataLabels.style;
66
+ const y = Math.max(yAxisTop, point.y - s.dataLabels.padding - labelSize.height);
67
+ const x = Math.min(xMax - labelSize.width, Math.max(0, point.x - labelSize.width / 2));
68
+ const labelData = {
69
+ text,
70
+ x,
71
+ y,
72
+ style,
73
+ size: labelSize,
74
+ textAnchor: 'start',
75
+ series: s,
76
+ active: true,
77
+ };
78
+ labels.push(labelData);
79
+ }
80
+ }
73
81
  }
74
82
  }
75
83
  let markers = [];
76
84
  if (s.marker.states.normal.enabled || s.marker.states.hover.enabled) {
77
- markers = points.map((p) => ({
78
- point: p,
79
- active: true,
80
- hovered: false,
81
- clipped: isOutsideBounds(p.x, p.y),
82
- }));
85
+ markers = points.reduce((result, p) => {
86
+ if (p.y === null || p.x === null) {
87
+ return result;
88
+ }
89
+ result.push({
90
+ point: p,
91
+ active: true,
92
+ hovered: false,
93
+ clipped: isOutsideBounds(p.x, p.y),
94
+ });
95
+ return result;
96
+ }, []);
83
97
  }
84
98
  const result = {
85
99
  points,
@@ -2,14 +2,18 @@ import type { DashStyle, LineCap } from '../../../constants';
2
2
  import type { HtmlItem, LabelData, LineSeriesData } from '../../../types';
3
3
  import type { PreparedLineSeries } from '../../useSeries/types';
4
4
  export type PointData = {
5
- x: number;
6
- y: number;
5
+ x: number | null;
6
+ y: number | null;
7
7
  data: LineSeriesData;
8
8
  series: PreparedLineSeries;
9
9
  color?: string;
10
10
  };
11
+ export type MarkerPointData = PointData & {
12
+ y: number;
13
+ x: number;
14
+ };
11
15
  export type MarkerData = {
12
- point: PointData;
16
+ point: MarkerPointData;
13
17
  active: boolean;
14
18
  hovered: boolean;
15
19
  clipped: boolean;
@@ -3,10 +3,10 @@ import type { Dispatch, PieArcDatum } from 'd3';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedPieData, SegmentData } from './types';
5
5
  type PreparePieSeriesArgs = {
6
- dispatcher: Dispatch<object>;
6
+ htmlLayout: HTMLElement | null;
7
7
  preparedData: PreparedPieData[];
8
8
  seriesOptions: PreparedSeriesOptions;
9
- htmlLayout: HTMLElement | null;
9
+ dispatcher?: Dispatch<object>;
10
10
  };
11
11
  export declare function getHaloVisibility(d: PieArcDatum<SegmentData>): "" | "hidden";
12
12
  export declare function PieSeriesShapes(args: PreparePieSeriesArgs): React.JSX.Element;
@@ -112,7 +112,7 @@ export function PieSeriesShapes(args) {
112
112
  const eventName = `hover-shape.pie`;
113
113
  const hoverOptions = get(seriesOptions, 'pie.states.hover');
114
114
  const inactiveOptions = get(seriesOptions, 'pie.states.inactive');
115
- dispatcher.on(eventName, (data) => {
115
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (data) => {
116
116
  var _a, _b;
117
117
  const selectedSeriesId = (_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id;
118
118
  const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
@@ -162,7 +162,7 @@ export function PieSeriesShapes(args) {
162
162
  });
163
163
  });
164
164
  return () => {
165
- dispatcher.on(eventName, null);
165
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
166
166
  };
167
167
  }, [dispatcher, preparedData, seriesOptions]);
168
168
  const htmlElements = preparedData.map((d) => d.htmlLabels).flat();
@@ -55,15 +55,18 @@ export function preparePieData(args) {
55
55
  },
56
56
  };
57
57
  const labelMaxHeight = (_a = max(Object.values(labels).map((l) => { var _a, _b; return (_b = (_a = l.size) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0; }))) !== null && _a !== void 0 ? _a : 0;
58
- const segments = items.map((item) => {
58
+ const segments = items.reduce((acc, item) => {
59
59
  var _a;
60
+ if (item.value === null) {
61
+ return acc;
62
+ }
60
63
  let maxSegmentRadius = maxRadius;
61
64
  if (dataLabels.enabled) {
62
65
  maxSegmentRadius -=
63
66
  dataLabels.distance + dataLabels.connectorPadding + labelMaxHeight;
64
67
  }
65
68
  const segmentRadius = (_a = calculateNumericProperty({ value: item.radius, base: maxSegmentRadius })) !== null && _a !== void 0 ? _a : maxSegmentRadius;
66
- return {
69
+ acc.push({
67
70
  value: item.value,
68
71
  color: item.color,
69
72
  opacity: item.opacity,
@@ -72,8 +75,9 @@ export function preparePieData(args) {
72
75
  active: true,
73
76
  pie: data,
74
77
  radius: segmentRadius,
75
- };
76
- });
78
+ });
79
+ return acc;
80
+ }, []);
77
81
  data.segments = pieGenerator(segments);
78
82
  return data;
79
83
  };
@@ -3,10 +3,10 @@ import type { Dispatch } from 'd3';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedRadarData } from './types';
5
5
  type PrepareRadarSeriesArgs = {
6
- dispatcher: Dispatch<object>;
6
+ htmlLayout: HTMLElement | null;
7
7
  series: PreparedRadarData[];
8
8
  seriesOptions: PreparedSeriesOptions;
9
- htmlLayout: HTMLElement | null;
9
+ dispatcher?: Dispatch<object>;
10
10
  };
11
11
  export declare function RadarSeriesShapes(args: PrepareRadarSeriesArgs): React.JSX.Element;
12
12
  export {};
@@ -81,7 +81,7 @@ export function RadarSeriesShapes(args) {
81
81
  const eventName = `hover-shape.radar`;
82
82
  const hoverOptions = get(seriesOptions, 'radar.states.hover');
83
83
  const inactiveOptions = get(seriesOptions, 'radar.states.inactive');
84
- dispatcher.on(eventName, (data) => {
84
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (data) => {
85
85
  const closest = data === null || data === void 0 ? void 0 : data.find((d) => d.closest);
86
86
  const selectedSeries = closest === null || closest === void 0 ? void 0 : closest.series;
87
87
  const selectedSeriesData = closest === null || closest === void 0 ? void 0 : closest.data;
@@ -126,7 +126,7 @@ export function RadarSeriesShapes(args) {
126
126
  });
127
127
  });
128
128
  return () => {
129
- dispatcher.on(eventName, null);
129
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
130
130
  };
131
131
  }, [dispatcher, preparedData, seriesOptions]);
132
132
  const htmlElements = preparedData.map((d) => d.htmlLabels).flat();
@@ -3,10 +3,10 @@ import type { Dispatch } from 'd3';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedSankeyData } from './types';
5
5
  type ShapeProps = {
6
- dispatcher: Dispatch<object>;
6
+ htmlLayout: HTMLElement | null;
7
7
  preparedData: PreparedSankeyData;
8
8
  seriesOptions: PreparedSeriesOptions;
9
- htmlLayout: HTMLElement | null;
9
+ dispatcher?: Dispatch<object>;
10
10
  };
11
11
  export declare const SankeySeriesShape: (props: ShapeProps) => React.JSX.Element;
12
12
  export {};
@@ -56,9 +56,9 @@ export const SankeySeriesShape = (props) => {
56
56
  if (hoveredDataRef.current !== null) {
57
57
  handleShapeHover(hoveredDataRef.current);
58
58
  }
59
- dispatcher.on(eventName, handleShapeHover);
59
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, handleShapeHover);
60
60
  return () => {
61
- dispatcher.on(eventName, null);
61
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
62
62
  };
63
63
  }, [dispatcher, preparedData, seriesOptions]);
64
64
  return (React.createElement(React.Fragment, null,
@@ -4,9 +4,10 @@ import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedScatterData } from './types';
5
5
  export { prepareScatterData } from './prepare-data';
6
6
  type ScatterSeriesShapeProps = {
7
- dispatcher: Dispatch<object>;
7
+ htmlLayout: HTMLElement | null;
8
8
  preparedData: PreparedScatterData[];
9
9
  seriesOptions: PreparedSeriesOptions;
10
- htmlLayout: HTMLElement | null;
10
+ clipPathId?: string;
11
+ dispatcher?: Dispatch<object>;
11
12
  };
12
13
  export declare function ScatterSeriesShape(props: ScatterSeriesShapeProps): React.JSX.Element;
@@ -8,7 +8,7 @@ import { setActiveState, shapeKey } from '../utils';
8
8
  export { prepareScatterData } from './prepare-data';
9
9
  const b = block('scatter');
10
10
  export function ScatterSeriesShape(props) {
11
- const { dispatcher, preparedData, seriesOptions, htmlLayout } = props;
11
+ const { clipPathId, dispatcher, preparedData, seriesOptions, htmlLayout } = props;
12
12
  const hoveredDataRef = React.useRef(null);
13
13
  const ref = React.useRef(null);
14
14
  React.useEffect(() => {
@@ -63,12 +63,12 @@ export function ScatterSeriesShape(props) {
63
63
  if (hoveredDataRef.current !== null) {
64
64
  handleShapeHover(hoveredDataRef.current);
65
65
  }
66
- dispatcher.on('hover-shape.scatter', handleShapeHover);
66
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', handleShapeHover);
67
67
  return () => {
68
- dispatcher.on('hover-shape.scatter', null);
68
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', null);
69
69
  };
70
70
  }, [dispatcher, preparedData, seriesOptions]);
71
71
  return (React.createElement(React.Fragment, null,
72
- React.createElement("g", { ref: ref, className: b() }),
72
+ React.createElement("g", { ref: ref, className: b(), clipPath: clipPathId ? `url(#${clipPathId})` : undefined }),
73
73
  React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
74
74
  }
@@ -1,12 +1,12 @@
1
+ import type { PreparedXAxis, PreparedYAxis } from '../../useAxis/types';
1
2
  import type { ChartScale } from '../../useAxisScales';
2
- import type { PreparedAxis } from '../../useChartOptions/types';
3
3
  import type { PreparedScatterSeries } from '../../useSeries/types';
4
4
  import type { PreparedScatterData } from './types';
5
5
  export declare function prepareScatterData(args: {
6
6
  series: PreparedScatterSeries[];
7
- xAxis: PreparedAxis;
7
+ xAxis: PreparedXAxis;
8
8
  xScale: ChartScale;
9
- yAxis: PreparedAxis[];
9
+ yAxis: PreparedYAxis[];
10
10
  yScale: (ChartScale | undefined)[];
11
11
  isOutsideBounds: (x: number, y: number) => boolean;
12
12
  }): PreparedScatterData[];
@@ -54,7 +54,7 @@ export function prepareScatterData(args) {
54
54
  var _a;
55
55
  const x = getXValue({ point: d, xAxis, xScale });
56
56
  const y = getYValue({ point: d, yAxis: seriesYAxis, yScale: seriesYScale });
57
- if (typeof x === 'undefined' || typeof y === 'undefined') {
57
+ if (typeof x === 'undefined' || typeof y === 'undefined' || x === null || y === null) {
58
58
  return;
59
59
  }
60
60
  acc.push({
@@ -1,3 +1,7 @@
1
+ .gcharts-line__label {
2
+ dominant-baseline: text-before-edge;
3
+ }
4
+
1
5
  .gcharts-scatter__point {
2
6
  stroke-width: 1px;
3
7
  }
@@ -40,4 +44,8 @@
40
44
 
41
45
  .gcharts-heatmap__label {
42
46
  dominant-baseline: text-before-edge;
47
+ }
48
+
49
+ .gcharts-funnel__label {
50
+ dominant-baseline: text-before-edge;
43
51
  }
@@ -3,10 +3,10 @@ import type { Dispatch } from 'd3';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedTreemapData } from './types';
5
5
  type ShapeProps = {
6
- dispatcher: Dispatch<object>;
6
+ htmlLayout: HTMLElement | null;
7
7
  preparedData: PreparedTreemapData;
8
8
  seriesOptions: PreparedSeriesOptions;
9
- htmlLayout: HTMLElement | null;
9
+ dispatcher?: Dispatch<object>;
10
10
  };
11
11
  export declare const TreemapSeriesShape: (props: ShapeProps) => React.JSX.Element;
12
12
  export {};
@@ -92,9 +92,9 @@ export const TreemapSeriesShape = (props) => {
92
92
  if (hoveredDataRef.current !== null) {
93
93
  handleShapeHover(hoveredDataRef.current);
94
94
  }
95
- dispatcher.on(eventName, handleShapeHover);
95
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, handleShapeHover);
96
96
  return () => {
97
- dispatcher.on(eventName, null);
97
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
98
98
  };
99
99
  }, [dispatcher, preparedData, seriesOptions]);
100
100
  return (React.createElement(React.Fragment, null,
@@ -1,27 +1,27 @@
1
1
  import type { BaseType } from 'd3';
2
2
  import type { BasicInactiveState } from '../../types';
3
+ import type { PreparedXAxis, PreparedYAxis } from '../useAxis/types';
3
4
  import type { ChartScale } from '../useAxisScales';
4
- import type { PreparedAxis } from '../useChartOptions/types';
5
5
  export declare function getXValue(args: {
6
6
  point: {
7
- x?: number | string;
7
+ x?: number | string | null;
8
8
  };
9
9
  points?: {
10
- x?: number | string;
10
+ x?: number | string | null;
11
11
  }[];
12
- xAxis: PreparedAxis;
12
+ xAxis: PreparedXAxis;
13
13
  xScale: ChartScale;
14
- }): number;
14
+ }): number | null;
15
15
  export declare function getYValue(args: {
16
16
  point: {
17
- y?: number | string;
17
+ y?: number | string | null;
18
18
  };
19
19
  points?: {
20
- y?: number | string;
20
+ y?: number | string | null;
21
21
  }[];
22
- yAxis: PreparedAxis;
22
+ yAxis: PreparedYAxis;
23
23
  yScale: ChartScale;
24
- }): number;
24
+ }): number | null;
25
25
  export declare function shapeKey(d: unknown): string | -1;
26
26
  export declare function setActiveState<T extends {
27
27
  active?: boolean;
@@ -38,3 +38,11 @@ export declare function getRectPath(args: {
38
38
  height: number;
39
39
  borderRadius?: number | number[];
40
40
  }): import("d3-path").Path;
41
+ export declare function getRectBorderPath(args: {
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ borderWidth: number;
47
+ borderRadius?: number | number[];
48
+ }): string;
@@ -14,16 +14,18 @@ export function getXValue(args) {
14
14
  const [xMinDomain, xMaxDomain] = xLinearScale.domain();
15
15
  if (Number(xMinDomain) === Number(xMaxDomain) &&
16
16
  (points === null || points === void 0 ? void 0 : points.length) === ONE_POINT_DOMAIN_DATA_CAPACITY) {
17
- const x1 = points[0].x;
18
- const xTarget = points[1].x;
19
- const x3 = points[2].x;
20
- const xMin = Math.min(x1, xTarget, x3);
21
- const xMax = Math.max(x1, xTarget, x3);
22
- xLinearScale = xLinearScale
23
- .copy()
24
- .domain([xMin + (xTarget - xMin) / 2, xMax - (xMax - xTarget) / 2]);
17
+ const x1 = Number(points[0].x);
18
+ const xTarget = Number(points[1].x);
19
+ const x3 = Number(points[2].x);
20
+ if (!Number.isNaN(x1) && !Number.isNaN(xTarget) && !Number.isNaN(x3)) {
21
+ const xMin = Math.min(x1, xTarget, x3);
22
+ const xMax = Math.max(x1, xTarget, x3);
23
+ xLinearScale = xLinearScale
24
+ .copy()
25
+ .domain([xMin + (xTarget - xMin) / 2, xMax - (xMax - xTarget) / 2]);
26
+ }
25
27
  }
26
- return xLinearScale(point.x);
28
+ return point.x === null ? null : xLinearScale(point.x);
27
29
  }
28
30
  export function getYValue(args) {
29
31
  const { point, points, yAxis, yScale } = args;
@@ -37,16 +39,18 @@ export function getYValue(args) {
37
39
  const [yMinDomain, yMaxDomain] = yLinearScale.domain();
38
40
  if (Number(yMinDomain) === Number(yMaxDomain) &&
39
41
  (points === null || points === void 0 ? void 0 : points.length) === ONE_POINT_DOMAIN_DATA_CAPACITY) {
40
- const y1 = points[0].y;
41
- const yTarget = points[1].y;
42
- const y2 = points[2].y;
43
- const yMin = Math.min(y1, yTarget, y2);
44
- const yMax = Math.max(y1, yTarget, y2);
45
- yLinearScale = yLinearScale
46
- .copy()
47
- .domain([yMin + (yTarget - yMin) / 2, yMax - (yMax - yTarget) / 2]);
42
+ const y1 = Number(points[0].y);
43
+ const yTarget = Number(points[1].y);
44
+ const y2 = Number(points[2].y);
45
+ if (!Number.isNaN(y1) && !Number.isNaN(yTarget) && !Number.isNaN(y2)) {
46
+ const yMin = Math.min(y1, yTarget, y2);
47
+ const yMax = Math.max(y1, yTarget, y2);
48
+ yLinearScale = yLinearScale
49
+ .copy()
50
+ .domain([yMin + (yTarget - yMin) / 2, yMax - (yMax - yTarget) / 2]);
51
+ }
48
52
  }
49
- return yLinearScale(point.y);
53
+ return point.y === null ? null : yLinearScale(point.y);
50
54
  }
51
55
  export function shapeKey(d) {
52
56
  return d.id || -1;
@@ -83,3 +87,47 @@ export function getRectPath(args) {
83
87
  p.closePath();
84
88
  return p;
85
89
  }
90
+ export function getRectBorderPath(args) {
91
+ const { x, y, width, height, borderWidth, borderRadius = 0 } = args;
92
+ if (!borderWidth) {
93
+ return '';
94
+ }
95
+ const halfWidth = borderWidth / 2;
96
+ const expandedWidth = width + borderWidth;
97
+ const expandedHeight = height + borderWidth;
98
+ const innerWidth = width - borderWidth;
99
+ const innerHeight = height - borderWidth;
100
+ const borderRadiuses = typeof borderRadius === 'number' ? new Array(4).fill(borderRadius) : borderRadius;
101
+ const [borderRadiusTopLeft = 0, borderRadiusTopRight = 0, borderRadiusBottomRight = 0, borderRadiusBottomLeft = 0,] = borderRadiuses !== null && borderRadiuses !== void 0 ? borderRadiuses : [];
102
+ const adjustOuterRadius = (radius) => (radius ? radius + halfWidth : 0);
103
+ const outerBorderRadius = [
104
+ adjustOuterRadius(borderRadiusTopLeft),
105
+ adjustOuterRadius(borderRadiusTopRight),
106
+ adjustOuterRadius(borderRadiusBottomRight),
107
+ adjustOuterRadius(borderRadiusBottomLeft),
108
+ ];
109
+ const outerPath = getRectPath({
110
+ x: x - halfWidth,
111
+ y: y - halfWidth,
112
+ width: expandedWidth,
113
+ height: expandedHeight,
114
+ borderRadius: outerBorderRadius,
115
+ }).toString();
116
+ if (innerWidth <= 0 || innerHeight <= 0) {
117
+ return outerPath;
118
+ }
119
+ const innerBorderRadius = [
120
+ Math.max(borderRadiusTopLeft - halfWidth, 0),
121
+ Math.max(borderRadiusTopRight - halfWidth, 0),
122
+ Math.max(borderRadiusBottomRight - halfWidth, 0),
123
+ Math.max(borderRadiusBottomLeft - halfWidth, 0),
124
+ ];
125
+ const innerPath = getRectPath({
126
+ x: x + halfWidth,
127
+ y: y + halfWidth,
128
+ width: innerWidth,
129
+ height: innerHeight,
130
+ borderRadius: innerBorderRadius,
131
+ }).toString();
132
+ return `${outerPath} ${innerPath}`;
133
+ }
@@ -5,10 +5,10 @@ import type { PreparedWaterfallData } from './types';
5
5
  export { prepareWaterfallData } from './prepare-data';
6
6
  export * from './types';
7
7
  type Args = {
8
- dispatcher: Dispatch<object>;
8
+ clipPathId: string;
9
+ htmlLayout: HTMLElement | null;
9
10
  preparedData: PreparedWaterfallData[];
10
11
  seriesOptions: PreparedSeriesOptions;
11
- htmlLayout: HTMLElement | null;
12
- clipPathId: string;
12
+ dispatcher?: Dispatch<object>;
13
13
  };
14
14
  export declare const WaterfallSeriesShapes: (args: Args) => React.JSX.Element;
@@ -121,9 +121,9 @@ export const WaterfallSeriesShapes = (args) => {
121
121
  if (hoveredDataRef.current !== null) {
122
122
  handleShapeHover(hoveredDataRef.current);
123
123
  }
124
- dispatcher.on('hover-shape.waterfall', handleShapeHover);
124
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.waterfall', handleShapeHover);
125
125
  return () => {
126
- dispatcher.on('hover-shape.waterfall', null);
126
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.waterfall', null);
127
127
  };
128
128
  }, [connectorSelector, dispatcher, preparedData, seriesOptions]);
129
129
  return (React.createElement(React.Fragment, null,
@@ -1,12 +1,12 @@
1
+ import type { PreparedXAxis, PreparedYAxis } from '../../useAxis/types';
1
2
  import type { ChartScale } from '../../useAxisScales';
2
- import type { PreparedAxis } from '../../useChartOptions/types';
3
3
  import type { PreparedSeriesOptions, PreparedWaterfallSeries } from '../../useSeries/types';
4
4
  import type { PreparedWaterfallData } from './types';
5
5
  export declare const prepareWaterfallData: (args: {
6
6
  series: PreparedWaterfallSeries[];
7
7
  seriesOptions: PreparedSeriesOptions;
8
- xAxis: PreparedAxis;
8
+ xAxis: PreparedXAxis;
9
9
  xScale: ChartScale;
10
- yAxis: PreparedAxis[];
10
+ yAxis: PreparedYAxis[];
11
11
  yScale: (ChartScale | undefined)[];
12
12
  }) => Promise<PreparedWaterfallData[]>;
@@ -53,6 +53,7 @@ function getBandWidth(args) {
53
53
  return bandWidth;
54
54
  }
55
55
  export const prepareWaterfallData = async (args) => {
56
+ var _a;
56
57
  const { series, seriesOptions, xAxis, xScale, yAxis: [yAxis], yScale: [yScale], } = args;
57
58
  const yLinearScale = yScale;
58
59
  if (!yLinearScale) {
@@ -73,11 +74,11 @@ export const prepareWaterfallData = async (args) => {
73
74
  });
74
75
  const rectGap = Math.max(bandWidth * barPadding, MIN_BAR_GAP);
75
76
  const rectWidth = Math.max(MIN_BAR_WIDTH, Math.min(bandWidth - rectGap, barMaxWidth));
76
- const yZero = getYValue({
77
+ const yZero = (_a = getYValue({
77
78
  point: { y: 0 },
78
79
  yScale: yLinearScale,
79
80
  yAxis,
80
- });
81
+ })) !== null && _a !== void 0 ? _a : 0;
81
82
  let totalValue = 0;
82
83
  const result = [];
83
84
  for (let i = 0; i < data.length; i++) {
@@ -90,14 +91,20 @@ export const prepareWaterfallData = async (args) => {
90
91
  }
91
92
  const prevPoint = result[result.length - 1];
92
93
  const xCenter = getXValue({ point: item.data, xAxis, xScale });
94
+ if (xCenter === null) {
95
+ continue;
96
+ }
93
97
  const x = xCenter - rectWidth / 2;
94
98
  const yValue = Number(item.data.total ? totalValue : item.data.y);
95
- const height = yZero -
96
- getYValue({
97
- point: { y: Math.abs(yValue) },
98
- yScale: yLinearScale,
99
- yAxis,
100
- });
99
+ const calculatedYValue = getYValue({
100
+ point: { y: Math.abs(yValue) },
101
+ yScale: yLinearScale,
102
+ yAxis,
103
+ });
104
+ if (calculatedYValue === null) {
105
+ continue;
106
+ }
107
+ const height = yZero - calculatedYValue;
101
108
  let y;
102
109
  if (!prevPoint || item.data.total) {
103
110
  y = getYValue({
@@ -122,6 +129,9 @@ export const prepareWaterfallData = async (args) => {
122
129
  else {
123
130
  y = prevPoint.y - height;
124
131
  }
132
+ if (y === null) {
133
+ continue;
134
+ }
125
135
  const preparedData = {
126
136
  x,
127
137
  y,