@gravity-ui/charts 1.46.0 → 1.47.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 (445) hide show
  1. package/dist/cjs/components/ChartInner/index.js +1 -0
  2. package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +1 -0
  3. package/dist/cjs/components/ChartInner/useChartInnerProps.js +13 -6
  4. package/dist/cjs/components/Legend/index.js +13 -14
  5. package/dist/cjs/components/Tooltip/index.js +22 -1
  6. package/dist/cjs/core/axes/x-axis.js +1 -1
  7. package/dist/cjs/core/axes/y-axis.js +1 -1
  8. package/dist/cjs/core/brush/index.d.ts +2 -0
  9. package/dist/cjs/core/brush/index.js +2 -0
  10. package/dist/cjs/{hooks/useBrush → core/brush}/types.d.ts +2 -2
  11. package/dist/cjs/{hooks/useBrush → core/brush}/utils.d.ts +1 -1
  12. package/dist/cjs/core/chart/index.d.ts +1 -0
  13. package/dist/cjs/core/chart/index.js +1 -0
  14. package/dist/cjs/core/chart/types.d.ts +8 -0
  15. package/dist/cjs/core/index.d.ts +3 -0
  16. package/dist/cjs/core/index.js +3 -0
  17. package/dist/cjs/core/layout/chart-dimensions.d.ts +1 -1
  18. package/dist/cjs/core/range-slider/index.d.ts +2 -0
  19. package/dist/cjs/core/range-slider/index.js +2 -0
  20. package/dist/cjs/core/range-slider/types.d.ts +4 -0
  21. package/dist/{esm/hooks/useRangeSlider → cjs/core/range-slider}/utils.d.ts +5 -5
  22. package/dist/{esm/hooks/useRangeSlider → cjs/core/range-slider}/utils.js +1 -1
  23. package/dist/cjs/core/scales/utils.d.ts +1 -1
  24. package/dist/cjs/core/scales/utils.js +1 -1
  25. package/dist/cjs/core/scales/x-scale.d.ts +2 -2
  26. package/dist/cjs/core/scales/x-scale.js +2 -2
  27. package/dist/cjs/core/scales/y-scale.js +69 -4
  28. package/dist/cjs/core/series/prepare-area.js +1 -1
  29. package/dist/cjs/core/series/prepare-bar-x.js +1 -1
  30. package/dist/cjs/core/series/prepare-bar-y.js +1 -1
  31. package/dist/cjs/core/series/prepare-funnel.js +1 -1
  32. package/dist/cjs/core/series/prepare-heatmap.js +1 -1
  33. package/dist/cjs/core/series/prepare-legend.d.ts +1 -1
  34. package/dist/cjs/core/series/prepare-legend.js +2 -2
  35. package/dist/cjs/core/series/prepare-line.js +1 -1
  36. package/dist/cjs/core/series/prepare-pie.js +1 -1
  37. package/dist/cjs/core/series/prepare-radar.js +1 -1
  38. package/dist/cjs/core/series/prepare-sankey.js +1 -1
  39. package/dist/cjs/core/series/prepare-scatter.js +1 -1
  40. package/dist/cjs/core/series/prepare-treemap.js +1 -1
  41. package/dist/cjs/core/series/prepare-waterfall.js +1 -1
  42. package/dist/cjs/core/series/prepare-x-range.js +1 -1
  43. package/dist/cjs/core/series/prepareSeries.d.ts +7 -1
  44. package/dist/cjs/core/series/prepareSeries.js +31 -0
  45. package/dist/cjs/core/series/types.d.ts +5 -0
  46. package/dist/cjs/core/series/utils.d.ts +4 -0
  47. package/dist/cjs/core/series/utils.js +9 -1
  48. package/dist/cjs/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
  49. package/dist/cjs/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
  50. package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
  51. package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.js +9 -4
  52. package/dist/cjs/core/shapes/area/renderer.d.ts +11 -0
  53. package/dist/cjs/core/shapes/area/renderer.js +175 -0
  54. package/dist/cjs/{hooks/useShapes → core/shapes}/area/types.d.ts +7 -8
  55. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.d.ts +4 -4
  56. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.js +6 -6
  57. package/dist/cjs/core/shapes/bar-x/renderer.d.ts +9 -0
  58. package/dist/cjs/core/shapes/bar-x/renderer.js +104 -0
  59. package/dist/cjs/{hooks/useShapes → core/shapes}/bar-x/types.d.ts +1 -2
  60. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.d.ts +3 -3
  61. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.js +3 -3
  62. package/dist/cjs/core/shapes/bar-y/renderer.d.ts +6 -0
  63. package/dist/cjs/core/shapes/bar-y/renderer.js +74 -0
  64. package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
  65. package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.js +1 -1
  66. package/dist/cjs/core/shapes/data-labels.d.ts +15 -0
  67. package/dist/cjs/core/shapes/data-labels.js +15 -0
  68. package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
  69. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/funnel/prepare-data.js +1 -1
  70. package/dist/cjs/core/shapes/funnel/renderer.d.ts +6 -0
  71. package/dist/cjs/core/shapes/funnel/renderer.js +74 -0
  72. package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
  73. package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
  74. package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.js +3 -2
  75. package/dist/cjs/core/shapes/heatmap/renderer.d.ts +6 -0
  76. package/dist/cjs/core/shapes/heatmap/renderer.js +50 -0
  77. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/types.d.ts +2 -1
  78. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/prepare-data.d.ts +4 -4
  79. package/dist/cjs/{hooks/useShapes → core/shapes}/line/prepare-data.js +12 -4
  80. package/dist/cjs/core/shapes/line/renderer.d.ts +11 -0
  81. package/dist/cjs/core/shapes/line/renderer.js +161 -0
  82. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/types.d.ts +7 -8
  83. package/dist/cjs/core/shapes/marker.d.ts +45 -0
  84. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/marker.js +2 -2
  85. package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
  86. package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
  87. package/dist/cjs/core/shapes/pie/renderer.d.ts +8 -0
  88. package/dist/cjs/core/shapes/pie/renderer.js +160 -0
  89. package/dist/cjs/{hooks/useShapes → core/shapes}/pie/types.d.ts +1 -1
  90. package/dist/cjs/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
  91. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/radar/prepare-data.js +2 -2
  92. package/dist/cjs/core/shapes/radar/renderer.d.ts +6 -0
  93. package/dist/cjs/core/shapes/radar/renderer.js +122 -0
  94. package/dist/cjs/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
  95. package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
  96. package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
  97. package/dist/cjs/core/shapes/sankey/renderer.d.ts +6 -0
  98. package/dist/cjs/core/shapes/sankey/renderer.js +44 -0
  99. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/sankey/types.d.ts +1 -1
  100. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/scatter/prepare-data.d.ts +3 -3
  101. package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/prepare-data.js +2 -2
  102. package/dist/cjs/core/shapes/scatter/renderer.d.ts +6 -0
  103. package/dist/cjs/core/shapes/scatter/renderer.js +52 -0
  104. package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/types.d.ts +1 -1
  105. package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
  106. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/treemap/prepare-data.js +3 -3
  107. package/dist/cjs/core/shapes/treemap/renderer.d.ts +6 -0
  108. package/dist/cjs/core/shapes/treemap/renderer.js +88 -0
  109. package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/types.d.ts +1 -1
  110. package/dist/cjs/core/shapes/utils.d.ts +76 -0
  111. package/dist/cjs/core/shapes/utils.js +186 -0
  112. package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
  113. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/waterfall/prepare-data.js +4 -4
  114. package/dist/cjs/core/shapes/waterfall/renderer.d.ts +6 -0
  115. package/dist/cjs/core/shapes/waterfall/renderer.js +109 -0
  116. package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/types.d.ts +1 -1
  117. package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
  118. package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
  119. package/dist/cjs/core/shapes/x-range/renderer.d.ts +6 -0
  120. package/dist/cjs/core/shapes/x-range/renderer.js +88 -0
  121. package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/types.d.ts +1 -1
  122. package/dist/cjs/core/types/chart/area.d.ts +0 -1
  123. package/dist/cjs/core/types/chart/axis.d.ts +0 -1
  124. package/dist/cjs/core/types/chart/base.d.ts +18 -7
  125. package/dist/cjs/core/types/chart/tooltip.d.ts +3 -3
  126. package/dist/cjs/core/types/formatter.d.ts +1 -40
  127. package/dist/{esm/hooks/utils/get-band-size.js → cjs/core/utils/band-size.js} +1 -1
  128. package/dist/cjs/{hooks → core}/utils/bar-y.d.ts +3 -3
  129. package/dist/{esm/hooks → cjs/core}/utils/bar-y.js +4 -4
  130. package/dist/cjs/core/utils/format.d.ts +2 -2
  131. package/dist/cjs/core/utils/get-closest-data.d.ts +1 -1
  132. package/dist/cjs/core/utils/get-closest-data.js +13 -8
  133. package/dist/cjs/core/utils/series/sorting.js +1 -1
  134. package/dist/cjs/core/utils/text.d.ts +0 -1
  135. package/dist/cjs/core/utils/text.js +0 -1
  136. package/dist/cjs/core/zoom/index.d.ts +2 -0
  137. package/dist/cjs/core/zoom/index.js +2 -0
  138. package/dist/{esm/hooks/useZoom → cjs/core/zoom}/utils.d.ts +3 -3
  139. package/dist/{esm/hooks/useZoom → cjs/core/zoom}/utils.js +1 -1
  140. package/dist/cjs/core/zoom/zoom.d.ts +3 -3
  141. package/dist/cjs/hooks/index.d.ts +3 -3
  142. package/dist/cjs/hooks/index.js +3 -3
  143. package/dist/cjs/hooks/types.d.ts +2 -8
  144. package/dist/cjs/hooks/useBrush/index.d.ts +1 -1
  145. package/dist/cjs/hooks/useBrush/index.js +1 -1
  146. package/dist/cjs/hooks/useRangeSlider/index.js +3 -3
  147. package/dist/cjs/hooks/useRangeSlider/types.d.ts +6 -8
  148. package/dist/cjs/hooks/useShapes/area/index.d.ts +2 -2
  149. package/dist/cjs/hooks/useShapes/area/index.js +13 -185
  150. package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +4 -4
  151. package/dist/cjs/hooks/useShapes/bar-x/index.js +10 -119
  152. package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +3 -3
  153. package/dist/cjs/hooks/useShapes/bar-y/index.js +5 -84
  154. package/dist/cjs/hooks/useShapes/funnel/index.d.ts +4 -4
  155. package/dist/cjs/hooks/useShapes/funnel/index.js +4 -83
  156. package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +4 -4
  157. package/dist/cjs/hooks/useShapes/heatmap/index.js +4 -59
  158. package/dist/cjs/hooks/useShapes/index.d.ts +15 -16
  159. package/dist/cjs/hooks/useShapes/index.js +13 -13
  160. package/dist/cjs/hooks/useShapes/line/index.d.ts +2 -2
  161. package/dist/cjs/hooks/useShapes/line/index.js +14 -172
  162. package/dist/cjs/hooks/useShapes/pie/index.d.ts +3 -5
  163. package/dist/cjs/hooks/useShapes/pie/index.js +3 -158
  164. package/dist/cjs/hooks/useShapes/radar/index.d.ts +2 -2
  165. package/dist/cjs/hooks/useShapes/radar/index.js +2 -121
  166. package/dist/cjs/hooks/useShapes/sankey/index.d.ts +2 -2
  167. package/dist/cjs/hooks/useShapes/sankey/index.js +2 -51
  168. package/dist/cjs/hooks/useShapes/scatter/index.d.ts +3 -3
  169. package/dist/cjs/hooks/useShapes/scatter/index.js +3 -58
  170. package/dist/cjs/hooks/useShapes/treemap/index.d.ts +2 -2
  171. package/dist/cjs/hooks/useShapes/treemap/index.js +2 -88
  172. package/dist/cjs/hooks/useShapes/utils.d.ts +3 -53
  173. package/dist/cjs/hooks/useShapes/utils.js +3 -140
  174. package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +4 -4
  175. package/dist/cjs/hooks/useShapes/waterfall/index.js +6 -119
  176. package/dist/cjs/hooks/useShapes/x-range/index.d.ts +4 -4
  177. package/dist/cjs/hooks/useShapes/x-range/index.js +3 -98
  178. package/dist/cjs/hooks/useZoom/index.d.ts +1 -1
  179. package/dist/cjs/hooks/useZoom/index.js +1 -1
  180. package/dist/cjs/index.d.ts +1 -0
  181. package/dist/cjs/index.js +1 -0
  182. package/dist/cjs/libs/format-number/index.js +82 -14
  183. package/dist/cjs/libs/format-number/presets.d.ts +40 -0
  184. package/dist/cjs/libs/format-number/presets.js +66 -0
  185. package/dist/cjs/libs/format-number/types.d.ts +82 -3
  186. package/dist/cjs/setup-jsdom.js +7 -0
  187. package/dist/esm/components/ChartInner/index.js +1 -0
  188. package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +1 -0
  189. package/dist/esm/components/ChartInner/useChartInnerProps.js +13 -6
  190. package/dist/esm/components/Legend/index.js +13 -14
  191. package/dist/esm/components/Tooltip/index.js +22 -1
  192. package/dist/esm/core/axes/x-axis.js +1 -1
  193. package/dist/esm/core/axes/y-axis.js +1 -1
  194. package/dist/esm/core/brush/index.d.ts +2 -0
  195. package/dist/esm/core/brush/index.js +2 -0
  196. package/dist/esm/{hooks/useBrush → core/brush}/types.d.ts +2 -2
  197. package/dist/esm/{hooks/useBrush → core/brush}/utils.d.ts +1 -1
  198. package/dist/esm/core/chart/index.d.ts +1 -0
  199. package/dist/esm/core/chart/index.js +1 -0
  200. package/dist/esm/core/chart/types.d.ts +8 -0
  201. package/dist/esm/core/index.d.ts +3 -0
  202. package/dist/esm/core/index.js +3 -0
  203. package/dist/esm/core/layout/chart-dimensions.d.ts +1 -1
  204. package/dist/esm/core/range-slider/index.d.ts +2 -0
  205. package/dist/esm/core/range-slider/index.js +2 -0
  206. package/dist/esm/core/range-slider/types.d.ts +4 -0
  207. package/dist/{cjs/hooks/useRangeSlider → esm/core/range-slider}/utils.d.ts +5 -5
  208. package/dist/{cjs/hooks/useRangeSlider → esm/core/range-slider}/utils.js +1 -1
  209. package/dist/esm/core/scales/utils.d.ts +1 -1
  210. package/dist/esm/core/scales/utils.js +1 -1
  211. package/dist/esm/core/scales/x-scale.d.ts +2 -2
  212. package/dist/esm/core/scales/x-scale.js +2 -2
  213. package/dist/esm/core/scales/y-scale.js +69 -4
  214. package/dist/esm/core/series/prepare-area.js +1 -1
  215. package/dist/esm/core/series/prepare-bar-x.js +1 -1
  216. package/dist/esm/core/series/prepare-bar-y.js +1 -1
  217. package/dist/esm/core/series/prepare-funnel.js +1 -1
  218. package/dist/esm/core/series/prepare-heatmap.js +1 -1
  219. package/dist/esm/core/series/prepare-legend.d.ts +1 -1
  220. package/dist/esm/core/series/prepare-legend.js +2 -2
  221. package/dist/esm/core/series/prepare-line.js +1 -1
  222. package/dist/esm/core/series/prepare-pie.js +1 -1
  223. package/dist/esm/core/series/prepare-radar.js +1 -1
  224. package/dist/esm/core/series/prepare-sankey.js +1 -1
  225. package/dist/esm/core/series/prepare-scatter.js +1 -1
  226. package/dist/esm/core/series/prepare-treemap.js +1 -1
  227. package/dist/esm/core/series/prepare-waterfall.js +1 -1
  228. package/dist/esm/core/series/prepare-x-range.js +1 -1
  229. package/dist/esm/core/series/prepareSeries.d.ts +7 -1
  230. package/dist/esm/core/series/prepareSeries.js +31 -0
  231. package/dist/esm/core/series/types.d.ts +5 -0
  232. package/dist/esm/core/series/utils.d.ts +4 -0
  233. package/dist/esm/core/series/utils.js +9 -1
  234. package/dist/esm/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
  235. package/dist/esm/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
  236. package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
  237. package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.js +9 -4
  238. package/dist/esm/core/shapes/area/renderer.d.ts +11 -0
  239. package/dist/esm/core/shapes/area/renderer.js +175 -0
  240. package/dist/esm/{hooks/useShapes → core/shapes}/area/types.d.ts +7 -8
  241. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.d.ts +4 -4
  242. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.js +6 -6
  243. package/dist/esm/core/shapes/bar-x/renderer.d.ts +9 -0
  244. package/dist/esm/core/shapes/bar-x/renderer.js +104 -0
  245. package/dist/esm/{hooks/useShapes → core/shapes}/bar-x/types.d.ts +1 -2
  246. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.d.ts +3 -3
  247. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.js +3 -3
  248. package/dist/esm/core/shapes/bar-y/renderer.d.ts +6 -0
  249. package/dist/esm/core/shapes/bar-y/renderer.js +74 -0
  250. package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
  251. package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.js +1 -1
  252. package/dist/esm/core/shapes/data-labels.d.ts +15 -0
  253. package/dist/esm/core/shapes/data-labels.js +15 -0
  254. package/dist/esm/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
  255. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/funnel/prepare-data.js +1 -1
  256. package/dist/esm/core/shapes/funnel/renderer.d.ts +6 -0
  257. package/dist/esm/core/shapes/funnel/renderer.js +74 -0
  258. package/dist/esm/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
  259. package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
  260. package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.js +3 -2
  261. package/dist/esm/core/shapes/heatmap/renderer.d.ts +6 -0
  262. package/dist/esm/core/shapes/heatmap/renderer.js +50 -0
  263. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/types.d.ts +2 -1
  264. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/prepare-data.d.ts +4 -4
  265. package/dist/esm/{hooks/useShapes → core/shapes}/line/prepare-data.js +12 -4
  266. package/dist/esm/core/shapes/line/renderer.d.ts +11 -0
  267. package/dist/esm/core/shapes/line/renderer.js +161 -0
  268. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/types.d.ts +7 -8
  269. package/dist/esm/core/shapes/marker.d.ts +45 -0
  270. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/marker.js +2 -2
  271. package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
  272. package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
  273. package/dist/esm/core/shapes/pie/renderer.d.ts +8 -0
  274. package/dist/esm/core/shapes/pie/renderer.js +160 -0
  275. package/dist/esm/{hooks/useShapes → core/shapes}/pie/types.d.ts +1 -1
  276. package/dist/esm/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
  277. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/radar/prepare-data.js +2 -2
  278. package/dist/esm/core/shapes/radar/renderer.d.ts +6 -0
  279. package/dist/esm/core/shapes/radar/renderer.js +122 -0
  280. package/dist/esm/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
  281. package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
  282. package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
  283. package/dist/esm/core/shapes/sankey/renderer.d.ts +6 -0
  284. package/dist/esm/core/shapes/sankey/renderer.js +44 -0
  285. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/sankey/types.d.ts +1 -1
  286. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/scatter/prepare-data.d.ts +3 -3
  287. package/dist/esm/{hooks/useShapes → core/shapes}/scatter/prepare-data.js +2 -2
  288. package/dist/esm/core/shapes/scatter/renderer.d.ts +6 -0
  289. package/dist/esm/core/shapes/scatter/renderer.js +52 -0
  290. package/dist/esm/{hooks/useShapes → core/shapes}/scatter/types.d.ts +1 -1
  291. package/dist/esm/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
  292. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/treemap/prepare-data.js +3 -3
  293. package/dist/esm/core/shapes/treemap/renderer.d.ts +6 -0
  294. package/dist/esm/core/shapes/treemap/renderer.js +88 -0
  295. package/dist/esm/{hooks/useShapes → core/shapes}/treemap/types.d.ts +1 -1
  296. package/dist/esm/core/shapes/treemap/types.js +1 -0
  297. package/dist/esm/core/shapes/utils.d.ts +76 -0
  298. package/dist/esm/core/shapes/utils.js +186 -0
  299. package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
  300. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/waterfall/prepare-data.js +4 -4
  301. package/dist/esm/core/shapes/waterfall/renderer.d.ts +6 -0
  302. package/dist/esm/core/shapes/waterfall/renderer.js +109 -0
  303. package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/types.d.ts +1 -1
  304. package/dist/esm/core/shapes/waterfall/types.js +1 -0
  305. package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
  306. package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
  307. package/dist/esm/core/shapes/x-range/renderer.d.ts +6 -0
  308. package/dist/esm/core/shapes/x-range/renderer.js +88 -0
  309. package/dist/esm/{hooks/useShapes → core/shapes}/x-range/types.d.ts +1 -1
  310. package/dist/esm/core/shapes/x-range/types.js +1 -0
  311. package/dist/esm/core/types/chart/area.d.ts +0 -1
  312. package/dist/esm/core/types/chart/axis.d.ts +0 -1
  313. package/dist/esm/core/types/chart/base.d.ts +18 -7
  314. package/dist/esm/core/types/chart/tooltip.d.ts +3 -3
  315. package/dist/esm/core/types/formatter.d.ts +1 -40
  316. package/dist/{cjs/hooks/utils/get-band-size.js → esm/core/utils/band-size.js} +1 -1
  317. package/dist/esm/{hooks → core}/utils/bar-y.d.ts +3 -3
  318. package/dist/{cjs/hooks → esm/core}/utils/bar-y.js +4 -4
  319. package/dist/esm/core/utils/format.d.ts +2 -2
  320. package/dist/esm/core/utils/get-closest-data.d.ts +1 -1
  321. package/dist/esm/core/utils/get-closest-data.js +13 -8
  322. package/dist/esm/core/utils/series/sorting.js +1 -1
  323. package/dist/esm/core/utils/text.d.ts +0 -1
  324. package/dist/esm/core/utils/text.js +0 -1
  325. package/dist/esm/core/zoom/index.d.ts +2 -0
  326. package/dist/esm/core/zoom/index.js +2 -0
  327. package/dist/esm/core/zoom/types.js +1 -0
  328. package/dist/{cjs/hooks/useZoom → esm/core/zoom}/utils.d.ts +3 -3
  329. package/dist/{cjs/hooks/useZoom → esm/core/zoom}/utils.js +1 -1
  330. package/dist/esm/core/zoom/zoom.d.ts +3 -3
  331. package/dist/esm/hooks/index.d.ts +3 -3
  332. package/dist/esm/hooks/index.js +3 -3
  333. package/dist/esm/hooks/types.d.ts +2 -8
  334. package/dist/esm/hooks/useBrush/index.d.ts +1 -1
  335. package/dist/esm/hooks/useBrush/index.js +1 -1
  336. package/dist/esm/hooks/useRangeSlider/index.js +3 -3
  337. package/dist/esm/hooks/useRangeSlider/types.d.ts +6 -8
  338. package/dist/esm/hooks/useShapes/area/index.d.ts +2 -2
  339. package/dist/esm/hooks/useShapes/area/index.js +13 -185
  340. package/dist/esm/hooks/useShapes/bar-x/index.d.ts +4 -4
  341. package/dist/esm/hooks/useShapes/bar-x/index.js +10 -119
  342. package/dist/esm/hooks/useShapes/bar-y/index.d.ts +3 -3
  343. package/dist/esm/hooks/useShapes/bar-y/index.js +5 -84
  344. package/dist/esm/hooks/useShapes/funnel/index.d.ts +4 -4
  345. package/dist/esm/hooks/useShapes/funnel/index.js +4 -83
  346. package/dist/esm/hooks/useShapes/heatmap/index.d.ts +4 -4
  347. package/dist/esm/hooks/useShapes/heatmap/index.js +4 -59
  348. package/dist/esm/hooks/useShapes/index.d.ts +15 -16
  349. package/dist/esm/hooks/useShapes/index.js +13 -13
  350. package/dist/esm/hooks/useShapes/line/index.d.ts +2 -2
  351. package/dist/esm/hooks/useShapes/line/index.js +14 -172
  352. package/dist/esm/hooks/useShapes/pie/index.d.ts +3 -5
  353. package/dist/esm/hooks/useShapes/pie/index.js +3 -158
  354. package/dist/esm/hooks/useShapes/radar/index.d.ts +2 -2
  355. package/dist/esm/hooks/useShapes/radar/index.js +2 -121
  356. package/dist/esm/hooks/useShapes/sankey/index.d.ts +2 -2
  357. package/dist/esm/hooks/useShapes/sankey/index.js +2 -51
  358. package/dist/esm/hooks/useShapes/scatter/index.d.ts +3 -3
  359. package/dist/esm/hooks/useShapes/scatter/index.js +3 -58
  360. package/dist/esm/hooks/useShapes/treemap/index.d.ts +2 -2
  361. package/dist/esm/hooks/useShapes/treemap/index.js +2 -88
  362. package/dist/esm/hooks/useShapes/utils.d.ts +3 -53
  363. package/dist/esm/hooks/useShapes/utils.js +3 -140
  364. package/dist/esm/hooks/useShapes/waterfall/index.d.ts +4 -4
  365. package/dist/esm/hooks/useShapes/waterfall/index.js +6 -119
  366. package/dist/esm/hooks/useShapes/x-range/index.d.ts +4 -4
  367. package/dist/esm/hooks/useShapes/x-range/index.js +3 -98
  368. package/dist/esm/hooks/useZoom/index.d.ts +1 -1
  369. package/dist/esm/hooks/useZoom/index.js +1 -1
  370. package/dist/esm/index.d.ts +1 -0
  371. package/dist/esm/index.js +1 -0
  372. package/dist/esm/libs/format-number/index.js +82 -14
  373. package/dist/esm/libs/format-number/presets.d.ts +40 -0
  374. package/dist/esm/libs/format-number/presets.js +66 -0
  375. package/dist/esm/libs/format-number/types.d.ts +82 -3
  376. package/dist/esm/setup-jsdom.js +7 -0
  377. package/package.json +5 -2
  378. package/dist/cjs/hooks/useSeries/index.d.ts +0 -12
  379. package/dist/cjs/hooks/useSeries/index.js +0 -40
  380. package/dist/cjs/hooks/useSeries/types.d.ts +0 -1
  381. package/dist/cjs/hooks/useSeries/types.js +0 -1
  382. package/dist/cjs/hooks/useSeries/utils.d.ts +0 -1
  383. package/dist/cjs/hooks/useSeries/utils.js +0 -1
  384. package/dist/cjs/hooks/useShapes/marker.d.ts +0 -15
  385. package/dist/cjs/hooks/utils/index.d.ts +0 -1
  386. package/dist/cjs/hooks/utils/index.js +0 -1
  387. package/dist/esm/hooks/useSeries/index.d.ts +0 -12
  388. package/dist/esm/hooks/useSeries/index.js +0 -40
  389. package/dist/esm/hooks/useSeries/types.d.ts +0 -1
  390. package/dist/esm/hooks/useSeries/types.js +0 -1
  391. package/dist/esm/hooks/useSeries/utils.d.ts +0 -1
  392. package/dist/esm/hooks/useSeries/utils.js +0 -1
  393. package/dist/esm/hooks/useShapes/marker.d.ts +0 -15
  394. package/dist/esm/hooks/utils/index.d.ts +0 -1
  395. package/dist/esm/hooks/utils/index.js +0 -1
  396. /package/dist/cjs/{hooks/useBrush → core/brush}/types.js +0 -0
  397. /package/dist/cjs/{hooks/useBrush → core/brush}/utils.js +0 -0
  398. /package/dist/cjs/{hooks/useShapes/area → core/chart}/types.js +0 -0
  399. /package/dist/cjs/{hooks/useShapes/bar-x → core/range-slider}/types.js +0 -0
  400. /package/dist/cjs/{hooks/useShapes/bar-y → core/shapes/area}/types.js +0 -0
  401. /package/dist/cjs/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
  402. /package/dist/cjs/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
  403. /package/dist/cjs/{hooks/useShapes/funnel → core/shapes/bar-x}/types.js +0 -0
  404. /package/dist/cjs/{hooks/useShapes/heatmap → core/shapes/bar-y}/types.js +0 -0
  405. /package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
  406. /package/dist/cjs/{hooks/useShapes/line → core/shapes/funnel}/types.js +0 -0
  407. /package/dist/cjs/{hooks/useShapes/pie → core/shapes/heatmap}/types.js +0 -0
  408. /package/dist/cjs/{hooks/useShapes/radar → core/shapes/line}/types.js +0 -0
  409. /package/dist/cjs/{hooks/useShapes/sankey → core/shapes/pie}/types.js +0 -0
  410. /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
  411. /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
  412. /package/dist/cjs/{hooks/useShapes/scatter → core/shapes/radar}/types.js +0 -0
  413. /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
  414. /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
  415. /package/dist/cjs/{hooks/useShapes/treemap → core/shapes/sankey}/types.js +0 -0
  416. /package/dist/cjs/{hooks/useShapes/waterfall → core/shapes/scatter}/types.js +0 -0
  417. /package/dist/cjs/{hooks/useShapes/x-range → core/shapes/treemap}/types.js +0 -0
  418. /package/dist/cjs/{hooks/useZoom → core/shapes/waterfall}/types.js +0 -0
  419. /package/dist/{esm/hooks/useBrush → cjs/core/shapes/x-range}/types.js +0 -0
  420. /package/dist/cjs/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
  421. /package/dist/cjs/{hooks/useZoom → core/zoom}/types.d.ts +0 -0
  422. /package/dist/{esm/hooks/useShapes/area → cjs/core/zoom}/types.js +0 -0
  423. /package/dist/esm/{hooks/useShapes/bar-x → core/brush}/types.js +0 -0
  424. /package/dist/esm/{hooks/useBrush → core/brush}/utils.js +0 -0
  425. /package/dist/esm/{hooks/useShapes/bar-y → core/chart}/types.js +0 -0
  426. /package/dist/esm/{hooks/useShapes/funnel → core/range-slider}/types.js +0 -0
  427. /package/dist/esm/{hooks/useShapes/heatmap → core/shapes/area}/types.js +0 -0
  428. /package/dist/esm/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
  429. /package/dist/esm/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
  430. /package/dist/esm/{hooks/useShapes/line → core/shapes/bar-x}/types.js +0 -0
  431. /package/dist/esm/{hooks/useShapes/pie → core/shapes/bar-y}/types.js +0 -0
  432. /package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
  433. /package/dist/esm/{hooks/useShapes/radar → core/shapes/funnel}/types.js +0 -0
  434. /package/dist/esm/{hooks/useShapes/sankey → core/shapes/heatmap}/types.js +0 -0
  435. /package/dist/esm/{hooks/useShapes/scatter → core/shapes/line}/types.js +0 -0
  436. /package/dist/esm/{hooks/useShapes/treemap → core/shapes/pie}/types.js +0 -0
  437. /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
  438. /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
  439. /package/dist/esm/{hooks/useShapes/waterfall → core/shapes/radar}/types.js +0 -0
  440. /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
  441. /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
  442. /package/dist/esm/{hooks/useShapes/x-range → core/shapes/sankey}/types.js +0 -0
  443. /package/dist/esm/{hooks/useZoom → core/shapes/scatter}/types.js +0 -0
  444. /package/dist/esm/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
  445. /package/dist/esm/{hooks/useZoom → core/zoom}/types.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { HtmlItem, LabelData, TooltipDataChunkBarY } from '../../../types';
2
- import type { PreparedBarYSeries } from '../../useSeries/types';
2
+ import type { PreparedBarYSeries } from '../../series/types';
3
3
  export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
4
4
  x: number;
5
5
  y: number;
@@ -1,4 +1,4 @@
1
- import { getRectBorderPath, getRectPath } from '../utils';
1
+ import { getRectBorderPath, getRectPath } from '../../shapes/utils';
2
2
  export function getAdjustedRectPath(d) {
3
3
  const borderRadius = d.isLastStackItem
4
4
  ? Math.min(d.height, d.width / 2, d.series.borderRadius)
@@ -0,0 +1,15 @@
1
+ import type { Selection } from 'd3-selection';
2
+ import type { BaseTextStyle } from '../types/chart/base';
3
+ type RenderableLabelData = {
4
+ text: string;
5
+ x: number;
6
+ y: number;
7
+ textAnchor: 'start' | 'end' | 'middle';
8
+ style: BaseTextStyle;
9
+ };
10
+ export declare function renderDataLabels<T extends RenderableLabelData>(args: {
11
+ container: Selection<SVGGElement, unknown, null, undefined>;
12
+ data: T[];
13
+ className: string;
14
+ }): Selection<SVGTextElement, T, SVGGElement, unknown>;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ export function renderDataLabels(args) {
2
+ const { container, data, className } = args;
3
+ return container
4
+ .selectAll('text')
5
+ .data(data)
6
+ .join('text')
7
+ .html((d) => d.text)
8
+ .attr('class', className)
9
+ .attr('x', (d) => d.x)
10
+ .attr('y', (d) => d.y)
11
+ .attr('text-anchor', (d) => d.textAnchor)
12
+ .style('font-size', (d) => d.style.fontSize)
13
+ .style('font-weight', (d) => d.style.fontWeight || null)
14
+ .style('fill', (d) => d.style.fontColor || null);
15
+ }
@@ -1,4 +1,4 @@
1
- import type { PreparedFunnelSeries } from '../../useSeries/types';
1
+ import type { PreparedFunnelSeries } from '../../series/types';
2
2
  import type { PreparedFunnelData } from './types';
3
3
  type Args = {
4
4
  series: PreparedFunnelSeries[];
@@ -1,5 +1,5 @@
1
1
  import { path } from 'd3-path';
2
- import { calculateNumericProperty, getFormattedValue, getTextSizeFn } from '../../../core/utils';
2
+ import { calculateNumericProperty, getFormattedValue, getTextSizeFn } from '../../utils';
3
3
  function getLineConnectorPaths(args) {
4
4
  const { points } = args;
5
5
  const leftPath = path();
@@ -0,0 +1,6 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedFunnelData } from './types';
4
+ export declare function renderFunnel(elements: {
5
+ plot: SVGGElement;
6
+ }, preparedData: PreparedFunnelData, seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,74 @@
1
+ import { color } from 'd3-color';
2
+ import { select } from 'd3-selection';
3
+ import { block } from '../../../utils';
4
+ import { getLineDashArray } from '../../utils';
5
+ import { renderDataLabels } from '../data-labels';
6
+ const b = block('funnel');
7
+ export function renderFunnel(elements, preparedData, seriesOptions, dispatcher) {
8
+ var _a, _b;
9
+ const svgElement = select(elements.plot);
10
+ const hoverOptions = (_b = (_a = seriesOptions.funnel) === null || _a === void 0 ? void 0 : _a.states) === null || _b === void 0 ? void 0 : _b.hover;
11
+ svgElement.selectAll('*').remove();
12
+ // funnel levels
13
+ const cellsSelection = svgElement
14
+ .selectAll('rect')
15
+ .data(preparedData.items)
16
+ .join('rect')
17
+ .attr('x', (d) => d.x)
18
+ .attr('y', (d) => d.y)
19
+ .attr('height', (d) => d.height)
20
+ .attr('width', (d) => d.width)
21
+ .attr('fill', (d) => d.color)
22
+ .attr('stroke', (d) => d.borderColor)
23
+ .attr('stroke-width', (d) => d.borderWidth);
24
+ // connectors
25
+ const connectorAreaClassName = b('connector-area');
26
+ svgElement
27
+ .selectAll(`.${connectorAreaClassName}`)
28
+ .data(preparedData.connectors)
29
+ .join('path')
30
+ .attr('d', (d) => d.areaPath.toString())
31
+ .attr('class', connectorAreaClassName)
32
+ .attr('fill', (d) => d.areaColor)
33
+ .attr('opacity', (d) => d.areaOpacity);
34
+ const connectorLineClassName = b('connector-line');
35
+ const connectorLines = svgElement
36
+ .selectAll(`.${connectorLineClassName}`)
37
+ .data(preparedData.connectors)
38
+ .join('g')
39
+ .attr('class', connectorLineClassName)
40
+ .attr('stroke', (d) => d.lineColor)
41
+ .attr('stroke-width', (d) => d.lineWidth)
42
+ .attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.lineWidth))
43
+ .attr('fill', 'none')
44
+ .attr('opacity', (d) => d.lineOpacity);
45
+ connectorLines.append('path').attr('d', (d) => d.linePath[0].toString());
46
+ connectorLines.append('path').attr('d', (d) => d.linePath[1].toString());
47
+ // dataLabels
48
+ renderDataLabels({
49
+ container: svgElement,
50
+ data: preparedData.svgLabels,
51
+ className: b('label'),
52
+ });
53
+ function handleShapeHover(data) {
54
+ const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
55
+ if (hoverEnabled) {
56
+ const hovered = data === null || data === void 0 ? void 0 : data.reduce((acc, d) => {
57
+ acc.add(d.data);
58
+ return acc;
59
+ }, new Set());
60
+ cellsSelection.attr('fill', (d) => {
61
+ var _a;
62
+ const fillColor = d.color;
63
+ if (hovered === null || hovered === void 0 ? void 0 : hovered.has(d.data)) {
64
+ return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) || fillColor);
65
+ }
66
+ return fillColor;
67
+ });
68
+ }
69
+ }
70
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.funnel', handleShapeHover);
71
+ return () => {
72
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.funnel', null);
73
+ };
74
+ }
@@ -1,7 +1,7 @@
1
1
  import type { Path } from 'd3-path';
2
- import type { DashStyle } from 'src/core/constants';
3
2
  import type { FunnelSeriesData, LabelData } from '../../../types';
4
- import type { PreparedFunnelSeries } from '../../useSeries/types';
3
+ import type { DashStyle } from '../../constants';
4
+ import type { PreparedFunnelSeries } from '../../series/types';
5
5
  export type FunnelItemData = {
6
6
  x: number;
7
7
  y: number;
@@ -1,6 +1,6 @@
1
- import type { ChartScale } from '../../../core/scales/types';
2
- import type { PreparedXAxis, PreparedYAxis } from '../../../hooks/useAxis/types';
3
- import type { PreparedHeatmapSeries } from '../../useSeries/types';
1
+ import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
2
+ import type { ChartScale } from '../../scales/types';
3
+ import type { PreparedHeatmapSeries } from '../../series/types';
4
4
  import type { PreparedHeatmapData } from './types';
5
5
  type PrepareHeatmapDataArgs = {
6
6
  series: PreparedHeatmapSeries;
@@ -1,5 +1,5 @@
1
- import { getDomainDataXBySeries, getDomainDataYBySeries, getFormattedValue, getLabelsSize, getTextSizeFn, getTextWithElipsis, isBandScale, } from '../../../core/utils';
2
- import { getBandSize } from '../../../hooks/utils/get-band-size';
1
+ import { getDomainDataXBySeries, getDomainDataYBySeries, getFormattedValue, getLabelsSize, getTextSizeFn, getTextWithElipsis, isBandScale, } from '../../utils';
2
+ import { getBandSize } from '../../utils/band-size';
3
3
  export async function prepareHeatmapData({ series, xAxis, xScale, yAxis, yScale, }) {
4
4
  var _a, _b, _c, _d, _e;
5
5
  const yDomainData = getDomainDataYBySeries([series]);
@@ -84,6 +84,7 @@ export async function prepareHeatmapData({ series, xAxis, xScale, yAxis, yScale,
84
84
  x: item.x + item.width / 2 - size.width / 2,
85
85
  y: item.y + item.height / 2 - size.height / 2 + size.hangingOffset,
86
86
  text,
87
+ textAnchor: 'start',
87
88
  style: series.dataLabels.style,
88
89
  });
89
90
  }
@@ -0,0 +1,6 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedHeatmapData } from './types';
4
+ export declare function renderHeatmap(elements: {
5
+ plot: SVGGElement;
6
+ }, preparedData: PreparedHeatmapData, seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,50 @@
1
+ import { color } from 'd3-color';
2
+ import { select } from 'd3-selection';
3
+ import { block } from '../../../utils';
4
+ import { renderDataLabels } from '../data-labels';
5
+ const b = block('heatmap');
6
+ export function renderHeatmap(elements, preparedData, seriesOptions, dispatcher) {
7
+ var _a, _b;
8
+ const svgElement = select(elements.plot);
9
+ const hoverOptions = (_b = (_a = seriesOptions.heatmap) === null || _a === void 0 ? void 0 : _a.states) === null || _b === void 0 ? void 0 : _b.hover;
10
+ svgElement.selectAll('*').remove();
11
+ // heatmap cells
12
+ const cellsSelection = svgElement
13
+ .selectAll('rect')
14
+ .data(preparedData.items)
15
+ .join('rect')
16
+ .attr('x', (d) => d.x)
17
+ .attr('y', (d) => d.y)
18
+ .attr('height', (d) => d.height)
19
+ .attr('width', (d) => d.width)
20
+ .attr('fill', (d) => d.color)
21
+ .attr('stroke', (d) => d.borderColor)
22
+ .attr('stroke-width', (d) => d.borderWidth);
23
+ // dataLabels
24
+ renderDataLabels({
25
+ container: svgElement,
26
+ data: preparedData.labels,
27
+ className: b('label'),
28
+ });
29
+ function handleShapeHover(data) {
30
+ const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
31
+ if (hoverEnabled) {
32
+ const hovered = data === null || data === void 0 ? void 0 : data.reduce((acc, d) => {
33
+ acc.add(d.data);
34
+ return acc;
35
+ }, new Set());
36
+ cellsSelection.attr('fill', (d) => {
37
+ var _a;
38
+ const fillColor = d.color;
39
+ if (hovered === null || hovered === void 0 ? void 0 : hovered.has(d.data)) {
40
+ return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) || fillColor);
41
+ }
42
+ return fillColor;
43
+ });
44
+ }
45
+ }
46
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.heatmap', handleShapeHover);
47
+ return () => {
48
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.heatmap', null);
49
+ };
50
+ }
@@ -1,5 +1,5 @@
1
1
  import type { BaseTextStyle, HeatmapSeriesData, HtmlItem } from '../../../types';
2
- import type { PreparedHeatmapSeries } from '../../useSeries/types';
2
+ import type { PreparedHeatmapSeries } from '../../series/types';
3
3
  export type HeatmapItem = {
4
4
  x: number;
5
5
  y: number;
@@ -14,6 +14,7 @@ export type HeatmapLabel = {
14
14
  x: number;
15
15
  y: number;
16
16
  text: string;
17
+ textAnchor: 'start' | 'end' | 'middle';
17
18
  style: BaseTextStyle;
18
19
  };
19
20
  export type PreparedHeatmapData = {
@@ -1,8 +1,8 @@
1
- import type { PreparedSplit } from '../../../core/layout/split-types';
2
- import type { ChartScale } from '../../../core/scales/types';
3
1
  import type { ShapeDataWithLabels } from '../../../types';
4
- import type { PreparedXAxis, PreparedYAxis } from '../../useAxis/types';
5
- import type { PreparedLineSeries, PreparedSeriesOptions } from '../../useSeries/types';
2
+ import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
3
+ import type { PreparedSplit } from '../../layout/split-types';
4
+ import type { ChartScale } from '../../scales/types';
5
+ import type { PreparedLineSeries, PreparedSeriesOptions } from '../../series/types';
6
6
  import type { PreparedLineData } from './types';
7
7
  export declare const prepareLineData: (args: {
8
8
  series: PreparedLineSeries[];
@@ -1,7 +1,7 @@
1
- import { prepareAnnotation } from '../../../core/series/prepare-annotation';
2
- import { filterOverlappingLabels, getLabelsSize, getTextSizeFn } from '../../../core/utils';
3
- import { getFormattedValue } from '../../../core/utils/format';
4
- import { getXValue, getYValue } from '../utils';
1
+ import { prepareAnnotation } from '../../series/prepare-annotation';
2
+ import { filterOverlappingLabels, getLabelsSize, getTextSizeFn } from '../../utils';
3
+ import { getFormattedValue } from '../../utils/format';
4
+ import { getXValue, getYValue, markHiddenPointsOutOfYRange } from '../utils';
5
5
  async function getHtmlLabel(point, series, xMax) {
6
6
  var _a;
7
7
  const content = String((_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y);
@@ -129,6 +129,14 @@ export const prepareLineData = async (args) => {
129
129
  }
130
130
  return result;
131
131
  }, []);
132
+ markHiddenPointsOutOfYRange({
133
+ points,
134
+ yScale: seriesYScale,
135
+ yAxisTop,
136
+ axisMin: seriesYAxis.min,
137
+ axisMax: seriesYAxis.max,
138
+ getDataY: (p) => p.data.y,
139
+ });
132
140
  const result = {
133
141
  annotations,
134
142
  points,
@@ -0,0 +1,11 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedLineData } from './types';
4
+ export declare function renderLine(elements: {
5
+ plot: SVGGElement;
6
+ markers: SVGGElement;
7
+ hoverMarkers: SVGGElement;
8
+ annotations: SVGGElement;
9
+ boundsWidth: number;
10
+ boundsHeight: number;
11
+ }, preparedData: PreparedLineData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,161 @@
1
+ import { color } from 'd3-color';
2
+ import { select } from 'd3-selection';
3
+ import { line as lineGenerator } from 'd3-shape';
4
+ import get from 'lodash/get';
5
+ import { block } from '../../../utils';
6
+ import { getLineDashArray } from '../../utils';
7
+ import { renderAnnotations } from '../annotation';
8
+ import { renderDataLabels } from '../data-labels';
9
+ import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
10
+ import { setActiveState } from '../utils';
11
+ const b = block('line');
12
+ export function renderLine(elements, preparedData, seriesOptions, dispatcher) {
13
+ var _a, _b;
14
+ const plotSvgElement = select(elements.plot);
15
+ const markersSvgElement = select(elements.markers);
16
+ const hoverMarkersSvgElement = select(elements.hoverMarkers);
17
+ const annotationsSvgElement = select(elements.annotations);
18
+ const hoverOptions = get(seriesOptions, 'line.states.hover');
19
+ const inactiveOptions = get(seriesOptions, 'line.states.inactive');
20
+ const line = lineGenerator()
21
+ .defined((d) => d.y !== null && d.x !== null && !d.hiddenInLine)
22
+ .x((d) => d.x)
23
+ .y((d) => d.y);
24
+ plotSvgElement.selectAll('*').remove();
25
+ markersSvgElement.selectAll('*').remove();
26
+ const lineSelection = plotSvgElement
27
+ .selectAll('path')
28
+ .data(preparedData)
29
+ .join('path')
30
+ .attr('d', (d) => line(d.points))
31
+ .attr('fill', 'none')
32
+ .attr('stroke', (d) => d.color)
33
+ .attr('stroke-width', (d) => d.lineWidth)
34
+ .attr('stroke-linejoin', (d) => d.linejoin)
35
+ .attr('stroke-linecap', (d) => d.linecap)
36
+ .attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.lineWidth))
37
+ .attr('opacity', (d) => d.opacity)
38
+ .attr('cursor', (d) => d.series.cursor);
39
+ const dataLabels = preparedData.reduce((acc, d) => {
40
+ return acc.concat(d.svgLabels);
41
+ }, []);
42
+ const labelsSelection = renderDataLabels({
43
+ container: plotSvgElement,
44
+ data: dataLabels,
45
+ className: b('label'),
46
+ });
47
+ const markers = preparedData.reduce((acc, d) => acc.concat(d.markers), []);
48
+ const markerSelection = markersSvgElement
49
+ .selectAll('marker')
50
+ .data(markers)
51
+ .join('g')
52
+ .call(renderMarker);
53
+ renderAnnotations({
54
+ anchors: preparedData.flatMap((d) => d.annotations),
55
+ container: annotationsSvgElement,
56
+ plotHeight: elements.boundsHeight,
57
+ plotWidth: elements.boundsWidth,
58
+ });
59
+ const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
60
+ const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
61
+ function handleShapeHover(data) {
62
+ const selected = (data === null || data === void 0 ? void 0 : data.filter((d) => d.series.type === 'line')) || [];
63
+ const selectedDataItems = selected.map((d) => d.data);
64
+ const selectedSeriesIds = selected.map((d) => { var _a; return (_a = d.series) === null || _a === void 0 ? void 0 : _a.id; });
65
+ lineSelection.datum((d, index, list) => {
66
+ const elementSelection = select(list[index]);
67
+ const hovered = Boolean(hoverEnabled && selectedSeriesIds.includes(d.id));
68
+ if (d.hovered !== hovered) {
69
+ d.hovered = hovered;
70
+ elementSelection.attr('stroke', (dSelection) => {
71
+ var _a;
72
+ const initialColor = dSelection.color || '';
73
+ if (dSelection.hovered) {
74
+ return (((_a = color(initialColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
75
+ initialColor);
76
+ }
77
+ return initialColor;
78
+ });
79
+ }
80
+ return setActiveState({
81
+ element: list[index],
82
+ state: inactiveOptions,
83
+ active: Boolean(!inactiveEnabled ||
84
+ !selectedSeriesIds.length ||
85
+ selectedSeriesIds.includes(d.id)),
86
+ datum: d,
87
+ });
88
+ });
89
+ labelsSelection.datum((d, index, list) => {
90
+ return setActiveState({
91
+ element: list[index],
92
+ state: inactiveOptions,
93
+ active: Boolean(!inactiveEnabled ||
94
+ !selectedSeriesIds.length ||
95
+ selectedSeriesIds.includes(d.series.id)),
96
+ datum: d,
97
+ });
98
+ });
99
+ markerSelection.datum((d, index, list) => {
100
+ const elementSelection = select(list[index]);
101
+ const hovered = Boolean(hoverEnabled && selectedDataItems.includes(d.point.data));
102
+ if (d.hovered !== hovered) {
103
+ d.hovered = hovered;
104
+ elementSelection.attr('visibility', getMarkerVisibility(d));
105
+ selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
106
+ selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
107
+ }
108
+ if (d.point.series.marker.states.normal.enabled) {
109
+ const isActive = Boolean(!inactiveEnabled ||
110
+ !selectedSeriesIds.length ||
111
+ selectedSeriesIds.includes(d.point.series.id));
112
+ setActiveState({
113
+ element: list[index],
114
+ state: inactiveOptions,
115
+ active: isActive,
116
+ datum: d,
117
+ });
118
+ }
119
+ return d;
120
+ });
121
+ hoverMarkersSvgElement.selectAll('*').remove();
122
+ if (hoverEnabled && selected.length > 0) {
123
+ const hoverOnlyMarkers = [];
124
+ for (const chunk of selected) {
125
+ const seriesData = preparedData.find((pd) => pd.id === chunk.series.id);
126
+ if (!seriesData) {
127
+ continue;
128
+ }
129
+ const { series } = seriesData;
130
+ if (series.marker.states.normal.enabled || !series.marker.states.hover.enabled) {
131
+ continue;
132
+ }
133
+ const point = seriesData.points.find((p) => p.data === chunk.data);
134
+ if (!point || point.x === null || point.y === null) {
135
+ continue;
136
+ }
137
+ hoverOnlyMarkers.push({
138
+ point: point,
139
+ active: true,
140
+ hovered: true,
141
+ clipped: false,
142
+ });
143
+ }
144
+ if (hoverOnlyMarkers.length > 0) {
145
+ hoverMarkersSvgElement
146
+ .selectAll('g')
147
+ .data(hoverOnlyMarkers)
148
+ .join('g')
149
+ .call(renderMarker)
150
+ .each((_d, i, nodes) => {
151
+ selectMarkerSymbol(select(nodes[i])).call(setMarker, 'hover');
152
+ });
153
+ }
154
+ }
155
+ }
156
+ const eventName = `hover-shape.line-${(_b = (_a = preparedData[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 'unknown'}`;
157
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, handleShapeHover);
158
+ return () => {
159
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
160
+ };
161
+ }
@@ -1,15 +1,14 @@
1
- import type { DashStyle, LineCap, LineJoin } from '../../../core/constants';
2
- import type { PreparedAnnotation } from '../../../core/series/types';
3
1
  import type { HtmlItem, LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
4
- import type { PreparedLineSeries } from '../../useSeries/types';
5
- import type { AnnotationAnchor } from '../annotation';
2
+ import type { DashStyle, LineCap, LineJoin } from '../../constants';
3
+ import type { AnnotationAnchor, PreparedAnnotation, PreparedLineSeries } from '../../series/types';
6
4
  export type PointData = {
7
- x: number | null;
8
- y: number | null;
9
- data: LineSeriesData;
10
- series: PreparedLineSeries;
11
5
  annotation?: PreparedAnnotation;
12
6
  color?: string;
7
+ data: LineSeriesData;
8
+ hiddenInLine?: boolean;
9
+ series: PreparedLineSeries;
10
+ x: number | null;
11
+ y: number | null;
13
12
  };
14
13
  export type MarkerPointData = PointData & {
15
14
  y: number;
@@ -0,0 +1,45 @@
1
+ import type { BaseType, Selection } from 'd3-selection';
2
+ import { SymbolType } from '../constants';
3
+ export interface BaseMarkerData {
4
+ point: {
5
+ x: number;
6
+ y: number;
7
+ color?: string;
8
+ data: unknown;
9
+ series: {
10
+ color: string;
11
+ marker: {
12
+ states: {
13
+ normal: {
14
+ symbol: `${SymbolType}`;
15
+ enabled: boolean;
16
+ radius: number;
17
+ borderWidth: number;
18
+ borderColor: string;
19
+ };
20
+ hover: {
21
+ enabled: boolean;
22
+ radius: number;
23
+ borderWidth: number;
24
+ borderColor: string;
25
+ halo: {
26
+ enabled: boolean;
27
+ size: number;
28
+ opacity: number;
29
+ };
30
+ };
31
+ };
32
+ };
33
+ };
34
+ };
35
+ active: boolean;
36
+ hovered: boolean;
37
+ clipped?: boolean;
38
+ }
39
+ export declare function renderMarker<T extends BaseMarkerData>(selection: Selection<BaseType, T, BaseType, unknown>): Selection<BaseType, T, BaseType, unknown>;
40
+ export declare function getMarkerVisibility(d: BaseMarkerData): "" | "hidden";
41
+ export declare function getMarkerHaloVisibility(d: BaseMarkerData): "" | "hidden";
42
+ export declare function setMarker<T extends BaseType, D extends BaseMarkerData>(selection: Selection<T, D, BaseType | null, unknown>, state: 'normal' | 'hover'): void;
43
+ export declare function getMarkerSymbol(type: `${SymbolType}` | undefined, radius: number): string | null;
44
+ export declare function selectMarkerHalo<T>(parentSelection: Selection<BaseType, T, null, undefined>): Selection<BaseType, T, null, undefined>;
45
+ export declare function selectMarkerSymbol<T>(parentSelection: Selection<BaseType, T, null, undefined>): Selection<BaseType, T, null, undefined>;
@@ -1,8 +1,8 @@
1
1
  import { symbol } from 'd3-shape';
2
2
  import get from 'lodash/get';
3
- import { SymbolType } from '../../core/constants';
4
- import { getSymbol } from '../../core/utils';
5
3
  import { block } from '../../utils';
4
+ import { SymbolType } from '../constants';
5
+ import { getSymbol } from '../utils';
6
6
  const b = block('marker');
7
7
  const haloClassName = b('halo');
8
8
  const symbolClassName = b('symbol');
@@ -1,4 +1,4 @@
1
- import type { PreparedPieSeries } from '../../useSeries/types';
1
+ import type { PreparedPieSeries } from '../../series/types';
2
2
  import type { PreparedPieData } from './types';
3
3
  type Args = {
4
4
  series: PreparedPieSeries[];
@@ -1,9 +1,9 @@
1
1
  import { group, max } from 'd3-array';
2
2
  import { arc, line as lineGenerator } from 'd3-shape';
3
3
  import merge from 'lodash/merge';
4
- import { DEFAULT_DATALABELS_STYLE } from '../../../core/constants';
5
- import { calculateNumericProperty, getLabelsSize, getLeftPosition, getTextSizeFn, isLabelsOverlapping, } from '../../../core/utils';
6
- import { getFormattedValue } from '../../../core/utils/format';
4
+ import { DEFAULT_DATALABELS_STYLE } from '../../constants';
5
+ import { calculateNumericProperty, getLabelsSize, getLeftPosition, getTextSizeFn, isLabelsOverlapping, } from '../../utils';
6
+ import { getFormattedValue } from '../../utils/format';
7
7
  import { getCurveFactory, getInscribedAngle, pieGenerator } from './utils';
8
8
  const FULL_CIRCLE = Math.PI * 2;
9
9
  const getCenter = (boundsWidth, boundsHeight, center) => {
@@ -0,0 +1,8 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PieArcDatum } from 'd3-shape';
3
+ import type { PreparedSeriesOptions } from '../../series/types';
4
+ import type { PreparedPieData, SegmentData } from './types';
5
+ export declare function getHaloVisibility(d: PieArcDatum<SegmentData>): "" | "hidden";
6
+ export declare function renderPie(elements: {
7
+ plot: SVGGElement;
8
+ }, preparedData: PreparedPieData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;