@gravity-ui/charts 1.46.0 → 1.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (351) hide show
  1. package/dist/cjs/components/ChartInner/useChartInnerProps.js +1 -1
  2. package/dist/cjs/components/Legend/index.js +13 -14
  3. package/dist/cjs/components/Tooltip/index.js +22 -1
  4. package/dist/cjs/core/axes/x-axis.js +1 -1
  5. package/dist/cjs/core/axes/y-axis.js +1 -1
  6. package/dist/cjs/core/scales/utils.d.ts +1 -1
  7. package/dist/cjs/core/scales/utils.js +1 -1
  8. package/dist/cjs/core/scales/x-scale.js +2 -2
  9. package/dist/cjs/core/scales/y-scale.js +48 -4
  10. package/dist/cjs/core/series/prepare-area.js +1 -1
  11. package/dist/cjs/core/series/prepare-bar-x.js +1 -1
  12. package/dist/cjs/core/series/prepare-bar-y.js +1 -1
  13. package/dist/cjs/core/series/prepare-funnel.js +1 -1
  14. package/dist/cjs/core/series/prepare-heatmap.js +1 -1
  15. package/dist/cjs/core/series/prepare-legend.js +2 -2
  16. package/dist/cjs/core/series/prepare-line.js +1 -1
  17. package/dist/cjs/core/series/prepare-pie.js +1 -1
  18. package/dist/cjs/core/series/prepare-radar.js +1 -1
  19. package/dist/cjs/core/series/prepare-sankey.js +1 -1
  20. package/dist/cjs/core/series/prepare-scatter.js +1 -1
  21. package/dist/cjs/core/series/prepare-treemap.js +1 -1
  22. package/dist/cjs/core/series/prepare-waterfall.js +1 -1
  23. package/dist/cjs/core/series/prepare-x-range.js +1 -1
  24. package/dist/cjs/core/series/prepareSeries.d.ts +7 -1
  25. package/dist/cjs/core/series/prepareSeries.js +31 -0
  26. package/dist/cjs/core/series/types.d.ts +5 -0
  27. package/dist/cjs/core/series/utils.d.ts +4 -0
  28. package/dist/cjs/core/series/utils.js +9 -1
  29. package/dist/cjs/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
  30. package/dist/cjs/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
  31. package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
  32. package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.js +4 -4
  33. package/dist/cjs/core/shapes/area/renderer.d.ts +11 -0
  34. package/dist/cjs/core/shapes/area/renderer.js +181 -0
  35. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/area/types.d.ts +1 -3
  36. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.d.ts +4 -4
  37. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.js +6 -6
  38. package/dist/cjs/core/shapes/bar-x/renderer.d.ts +9 -0
  39. package/dist/cjs/core/shapes/bar-x/renderer.js +110 -0
  40. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/types.d.ts +1 -2
  41. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.d.ts +3 -3
  42. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.js +3 -3
  43. package/dist/cjs/core/shapes/bar-y/renderer.d.ts +6 -0
  44. package/dist/cjs/core/shapes/bar-y/renderer.js +80 -0
  45. package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
  46. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/utils.js +1 -1
  47. package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
  48. package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/prepare-data.js +1 -1
  49. package/dist/cjs/core/shapes/funnel/renderer.d.ts +6 -0
  50. package/dist/cjs/core/shapes/funnel/renderer.js +79 -0
  51. package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
  52. package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
  53. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/prepare-data.js +2 -2
  54. package/dist/cjs/core/shapes/heatmap/renderer.d.ts +6 -0
  55. package/dist/cjs/core/shapes/heatmap/renderer.js +55 -0
  56. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/types.d.ts +1 -1
  57. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/prepare-data.d.ts +4 -4
  58. package/dist/cjs/{hooks/useShapes → core/shapes}/line/prepare-data.js +3 -3
  59. package/dist/cjs/core/shapes/line/renderer.d.ts +11 -0
  60. package/dist/cjs/core/shapes/line/renderer.js +167 -0
  61. package/dist/cjs/{hooks/useShapes → core/shapes}/line/types.d.ts +2 -4
  62. package/dist/cjs/core/shapes/marker.d.ts +45 -0
  63. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/marker.js +2 -2
  64. package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
  65. package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
  66. package/dist/cjs/core/shapes/pie/renderer.d.ts +8 -0
  67. package/dist/cjs/core/shapes/pie/renderer.js +160 -0
  68. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/pie/types.d.ts +1 -1
  69. package/dist/cjs/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
  70. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/radar/prepare-data.js +2 -2
  71. package/dist/cjs/core/shapes/radar/renderer.d.ts +6 -0
  72. package/dist/cjs/core/shapes/radar/renderer.js +126 -0
  73. package/dist/cjs/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
  74. package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
  75. package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
  76. package/dist/cjs/core/shapes/sankey/renderer.d.ts +6 -0
  77. package/dist/cjs/core/shapes/sankey/renderer.js +50 -0
  78. package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/types.d.ts +1 -1
  79. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/scatter/prepare-data.d.ts +3 -3
  80. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/scatter/prepare-data.js +2 -2
  81. package/dist/cjs/core/shapes/scatter/renderer.d.ts +6 -0
  82. package/dist/cjs/core/shapes/scatter/renderer.js +52 -0
  83. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/scatter/types.d.ts +1 -1
  84. package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
  85. package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/prepare-data.js +3 -3
  86. package/dist/cjs/core/shapes/treemap/renderer.d.ts +6 -0
  87. package/dist/cjs/core/shapes/treemap/renderer.js +88 -0
  88. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/treemap/types.d.ts +1 -1
  89. package/dist/cjs/core/shapes/utils.d.ts +52 -0
  90. package/dist/cjs/core/shapes/utils.js +138 -0
  91. package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
  92. package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/prepare-data.js +4 -4
  93. package/dist/cjs/core/shapes/waterfall/renderer.d.ts +6 -0
  94. package/dist/cjs/core/shapes/waterfall/renderer.js +115 -0
  95. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/waterfall/types.d.ts +1 -1
  96. package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
  97. package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
  98. package/dist/cjs/core/shapes/x-range/renderer.d.ts +6 -0
  99. package/dist/cjs/core/shapes/x-range/renderer.js +94 -0
  100. package/dist/{esm/hooks/useShapes → cjs/core/shapes}/x-range/types.d.ts +1 -1
  101. package/dist/cjs/core/types/chart/area.d.ts +0 -1
  102. package/dist/cjs/core/types/chart/axis.d.ts +0 -1
  103. package/dist/cjs/core/types/chart/base.d.ts +1 -4
  104. package/dist/cjs/{hooks/utils/get-band-size.js → core/utils/band-size.js} +1 -1
  105. package/dist/{esm/hooks → cjs/core}/utils/bar-y.d.ts +3 -3
  106. package/dist/cjs/{hooks → core}/utils/bar-y.js +4 -4
  107. package/dist/cjs/core/utils/get-closest-data.d.ts +1 -1
  108. package/dist/cjs/core/utils/series/sorting.js +1 -1
  109. package/dist/cjs/core/utils/text.d.ts +0 -1
  110. package/dist/cjs/core/utils/text.js +0 -1
  111. package/dist/cjs/hooks/index.d.ts +1 -1
  112. package/dist/cjs/hooks/index.js +1 -1
  113. package/dist/cjs/hooks/useRangeSlider/types.d.ts +1 -1
  114. package/dist/cjs/hooks/useRangeSlider/utils.d.ts +1 -1
  115. package/dist/cjs/hooks/useShapes/area/index.d.ts +2 -2
  116. package/dist/cjs/hooks/useShapes/area/index.js +13 -185
  117. package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +4 -4
  118. package/dist/cjs/hooks/useShapes/bar-x/index.js +10 -119
  119. package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +3 -3
  120. package/dist/cjs/hooks/useShapes/bar-y/index.js +5 -84
  121. package/dist/cjs/hooks/useShapes/funnel/index.d.ts +4 -4
  122. package/dist/cjs/hooks/useShapes/funnel/index.js +4 -83
  123. package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +4 -4
  124. package/dist/cjs/hooks/useShapes/heatmap/index.js +4 -59
  125. package/dist/cjs/hooks/useShapes/index.d.ts +14 -15
  126. package/dist/cjs/hooks/useShapes/index.js +13 -13
  127. package/dist/cjs/hooks/useShapes/line/index.d.ts +2 -2
  128. package/dist/cjs/hooks/useShapes/line/index.js +14 -172
  129. package/dist/cjs/hooks/useShapes/pie/index.d.ts +3 -5
  130. package/dist/cjs/hooks/useShapes/pie/index.js +3 -158
  131. package/dist/cjs/hooks/useShapes/radar/index.d.ts +2 -2
  132. package/dist/cjs/hooks/useShapes/radar/index.js +2 -121
  133. package/dist/cjs/hooks/useShapes/sankey/index.d.ts +2 -2
  134. package/dist/cjs/hooks/useShapes/sankey/index.js +2 -51
  135. package/dist/cjs/hooks/useShapes/scatter/index.d.ts +3 -3
  136. package/dist/cjs/hooks/useShapes/scatter/index.js +3 -58
  137. package/dist/cjs/hooks/useShapes/treemap/index.d.ts +2 -2
  138. package/dist/cjs/hooks/useShapes/treemap/index.js +2 -88
  139. package/dist/cjs/hooks/useShapes/utils.d.ts +2 -52
  140. package/dist/cjs/hooks/useShapes/utils.js +3 -140
  141. package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +4 -4
  142. package/dist/cjs/hooks/useShapes/waterfall/index.js +6 -119
  143. package/dist/cjs/hooks/useShapes/x-range/index.d.ts +4 -4
  144. package/dist/cjs/hooks/useShapes/x-range/index.js +3 -98
  145. package/dist/cjs/setup-jsdom.js +7 -0
  146. package/dist/esm/components/ChartInner/useChartInnerProps.js +1 -1
  147. package/dist/esm/components/Legend/index.js +13 -14
  148. package/dist/esm/components/Tooltip/index.js +22 -1
  149. package/dist/esm/core/axes/x-axis.js +1 -1
  150. package/dist/esm/core/axes/y-axis.js +1 -1
  151. package/dist/esm/core/scales/utils.d.ts +1 -1
  152. package/dist/esm/core/scales/utils.js +1 -1
  153. package/dist/esm/core/scales/x-scale.js +2 -2
  154. package/dist/esm/core/scales/y-scale.js +48 -4
  155. package/dist/esm/core/series/prepare-area.js +1 -1
  156. package/dist/esm/core/series/prepare-bar-x.js +1 -1
  157. package/dist/esm/core/series/prepare-bar-y.js +1 -1
  158. package/dist/esm/core/series/prepare-funnel.js +1 -1
  159. package/dist/esm/core/series/prepare-heatmap.js +1 -1
  160. package/dist/esm/core/series/prepare-legend.js +2 -2
  161. package/dist/esm/core/series/prepare-line.js +1 -1
  162. package/dist/esm/core/series/prepare-pie.js +1 -1
  163. package/dist/esm/core/series/prepare-radar.js +1 -1
  164. package/dist/esm/core/series/prepare-sankey.js +1 -1
  165. package/dist/esm/core/series/prepare-scatter.js +1 -1
  166. package/dist/esm/core/series/prepare-treemap.js +1 -1
  167. package/dist/esm/core/series/prepare-waterfall.js +1 -1
  168. package/dist/esm/core/series/prepare-x-range.js +1 -1
  169. package/dist/esm/core/series/prepareSeries.d.ts +7 -1
  170. package/dist/esm/core/series/prepareSeries.js +31 -0
  171. package/dist/esm/core/series/types.d.ts +5 -0
  172. package/dist/esm/core/series/utils.d.ts +4 -0
  173. package/dist/esm/core/series/utils.js +9 -1
  174. package/dist/esm/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
  175. package/dist/esm/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
  176. package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
  177. package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.js +4 -4
  178. package/dist/esm/core/shapes/area/renderer.d.ts +11 -0
  179. package/dist/esm/core/shapes/area/renderer.js +181 -0
  180. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/area/types.d.ts +1 -3
  181. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.d.ts +4 -4
  182. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.js +6 -6
  183. package/dist/esm/core/shapes/bar-x/renderer.d.ts +9 -0
  184. package/dist/esm/core/shapes/bar-x/renderer.js +110 -0
  185. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/types.d.ts +1 -2
  186. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.d.ts +3 -3
  187. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.js +3 -3
  188. package/dist/esm/core/shapes/bar-y/renderer.d.ts +6 -0
  189. package/dist/esm/core/shapes/bar-y/renderer.js +80 -0
  190. package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
  191. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/utils.js +1 -1
  192. package/dist/esm/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
  193. package/dist/esm/{hooks/useShapes → core/shapes}/funnel/prepare-data.js +1 -1
  194. package/dist/esm/core/shapes/funnel/renderer.d.ts +6 -0
  195. package/dist/esm/core/shapes/funnel/renderer.js +79 -0
  196. package/dist/esm/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
  197. package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
  198. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/prepare-data.js +2 -2
  199. package/dist/esm/core/shapes/heatmap/renderer.d.ts +6 -0
  200. package/dist/esm/core/shapes/heatmap/renderer.js +55 -0
  201. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/types.d.ts +1 -1
  202. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/prepare-data.d.ts +4 -4
  203. package/dist/esm/{hooks/useShapes → core/shapes}/line/prepare-data.js +3 -3
  204. package/dist/esm/core/shapes/line/renderer.d.ts +11 -0
  205. package/dist/esm/core/shapes/line/renderer.js +167 -0
  206. package/dist/esm/{hooks/useShapes → core/shapes}/line/types.d.ts +2 -4
  207. package/dist/esm/core/shapes/marker.d.ts +45 -0
  208. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/marker.js +2 -2
  209. package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
  210. package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
  211. package/dist/esm/core/shapes/pie/renderer.d.ts +8 -0
  212. package/dist/esm/core/shapes/pie/renderer.js +160 -0
  213. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/pie/types.d.ts +1 -1
  214. package/dist/esm/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
  215. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/radar/prepare-data.js +2 -2
  216. package/dist/esm/core/shapes/radar/renderer.d.ts +6 -0
  217. package/dist/esm/core/shapes/radar/renderer.js +126 -0
  218. package/dist/esm/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
  219. package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
  220. package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
  221. package/dist/esm/core/shapes/sankey/renderer.d.ts +6 -0
  222. package/dist/esm/core/shapes/sankey/renderer.js +50 -0
  223. package/dist/esm/{hooks/useShapes → core/shapes}/sankey/types.d.ts +1 -1
  224. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/scatter/prepare-data.d.ts +3 -3
  225. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/scatter/prepare-data.js +2 -2
  226. package/dist/esm/core/shapes/scatter/renderer.d.ts +6 -0
  227. package/dist/esm/core/shapes/scatter/renderer.js +52 -0
  228. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/scatter/types.d.ts +1 -1
  229. package/dist/esm/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
  230. package/dist/esm/{hooks/useShapes → core/shapes}/treemap/prepare-data.js +3 -3
  231. package/dist/esm/core/shapes/treemap/renderer.d.ts +6 -0
  232. package/dist/esm/core/shapes/treemap/renderer.js +88 -0
  233. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/treemap/types.d.ts +1 -1
  234. package/dist/esm/core/shapes/utils.d.ts +52 -0
  235. package/dist/esm/core/shapes/utils.js +138 -0
  236. package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
  237. package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/prepare-data.js +4 -4
  238. package/dist/esm/core/shapes/waterfall/renderer.d.ts +6 -0
  239. package/dist/esm/core/shapes/waterfall/renderer.js +115 -0
  240. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/waterfall/types.d.ts +1 -1
  241. package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
  242. package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
  243. package/dist/esm/core/shapes/x-range/renderer.d.ts +6 -0
  244. package/dist/esm/core/shapes/x-range/renderer.js +94 -0
  245. package/dist/{cjs/hooks/useShapes → esm/core/shapes}/x-range/types.d.ts +1 -1
  246. package/dist/esm/core/types/chart/area.d.ts +0 -1
  247. package/dist/esm/core/types/chart/axis.d.ts +0 -1
  248. package/dist/esm/core/types/chart/base.d.ts +1 -4
  249. package/dist/esm/{hooks/utils/get-band-size.js → core/utils/band-size.js} +1 -1
  250. package/dist/{cjs/hooks → esm/core}/utils/bar-y.d.ts +3 -3
  251. package/dist/esm/{hooks → core}/utils/bar-y.js +4 -4
  252. package/dist/esm/core/utils/get-closest-data.d.ts +1 -1
  253. package/dist/esm/core/utils/series/sorting.js +1 -1
  254. package/dist/esm/core/utils/text.d.ts +0 -1
  255. package/dist/esm/core/utils/text.js +0 -1
  256. package/dist/esm/hooks/index.d.ts +1 -1
  257. package/dist/esm/hooks/index.js +1 -1
  258. package/dist/esm/hooks/useRangeSlider/types.d.ts +1 -1
  259. package/dist/esm/hooks/useRangeSlider/utils.d.ts +1 -1
  260. package/dist/esm/hooks/useShapes/area/index.d.ts +2 -2
  261. package/dist/esm/hooks/useShapes/area/index.js +13 -185
  262. package/dist/esm/hooks/useShapes/bar-x/index.d.ts +4 -4
  263. package/dist/esm/hooks/useShapes/bar-x/index.js +10 -119
  264. package/dist/esm/hooks/useShapes/bar-y/index.d.ts +3 -3
  265. package/dist/esm/hooks/useShapes/bar-y/index.js +5 -84
  266. package/dist/esm/hooks/useShapes/funnel/index.d.ts +4 -4
  267. package/dist/esm/hooks/useShapes/funnel/index.js +4 -83
  268. package/dist/esm/hooks/useShapes/heatmap/index.d.ts +4 -4
  269. package/dist/esm/hooks/useShapes/heatmap/index.js +4 -59
  270. package/dist/esm/hooks/useShapes/index.d.ts +14 -15
  271. package/dist/esm/hooks/useShapes/index.js +13 -13
  272. package/dist/esm/hooks/useShapes/line/index.d.ts +2 -2
  273. package/dist/esm/hooks/useShapes/line/index.js +14 -172
  274. package/dist/esm/hooks/useShapes/pie/index.d.ts +3 -5
  275. package/dist/esm/hooks/useShapes/pie/index.js +3 -158
  276. package/dist/esm/hooks/useShapes/radar/index.d.ts +2 -2
  277. package/dist/esm/hooks/useShapes/radar/index.js +2 -121
  278. package/dist/esm/hooks/useShapes/sankey/index.d.ts +2 -2
  279. package/dist/esm/hooks/useShapes/sankey/index.js +2 -51
  280. package/dist/esm/hooks/useShapes/scatter/index.d.ts +3 -3
  281. package/dist/esm/hooks/useShapes/scatter/index.js +3 -58
  282. package/dist/esm/hooks/useShapes/treemap/index.d.ts +2 -2
  283. package/dist/esm/hooks/useShapes/treemap/index.js +2 -88
  284. package/dist/esm/hooks/useShapes/utils.d.ts +2 -52
  285. package/dist/esm/hooks/useShapes/utils.js +3 -140
  286. package/dist/esm/hooks/useShapes/waterfall/index.d.ts +4 -4
  287. package/dist/esm/hooks/useShapes/waterfall/index.js +6 -119
  288. package/dist/esm/hooks/useShapes/x-range/index.d.ts +4 -4
  289. package/dist/esm/hooks/useShapes/x-range/index.js +3 -98
  290. package/dist/esm/setup-jsdom.js +7 -0
  291. package/package.json +5 -2
  292. package/dist/cjs/hooks/useSeries/index.d.ts +0 -12
  293. package/dist/cjs/hooks/useSeries/index.js +0 -40
  294. package/dist/cjs/hooks/useSeries/types.d.ts +0 -1
  295. package/dist/cjs/hooks/useSeries/types.js +0 -1
  296. package/dist/cjs/hooks/useSeries/utils.d.ts +0 -1
  297. package/dist/cjs/hooks/useSeries/utils.js +0 -1
  298. package/dist/cjs/hooks/useShapes/marker.d.ts +0 -15
  299. package/dist/cjs/hooks/utils/index.d.ts +0 -1
  300. package/dist/cjs/hooks/utils/index.js +0 -1
  301. package/dist/esm/hooks/useSeries/index.d.ts +0 -12
  302. package/dist/esm/hooks/useSeries/index.js +0 -40
  303. package/dist/esm/hooks/useSeries/types.d.ts +0 -1
  304. package/dist/esm/hooks/useSeries/types.js +0 -1
  305. package/dist/esm/hooks/useSeries/utils.d.ts +0 -1
  306. package/dist/esm/hooks/useSeries/utils.js +0 -1
  307. package/dist/esm/hooks/useShapes/marker.d.ts +0 -15
  308. package/dist/esm/hooks/utils/index.d.ts +0 -1
  309. package/dist/esm/hooks/utils/index.js +0 -1
  310. /package/dist/cjs/{hooks/useShapes → core/shapes}/area/types.js +0 -0
  311. /package/dist/cjs/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
  312. /package/dist/cjs/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
  313. /package/dist/cjs/{hooks/useShapes → core/shapes}/bar-x/types.js +0 -0
  314. /package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/types.js +0 -0
  315. /package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
  316. /package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/types.js +0 -0
  317. /package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/types.js +0 -0
  318. /package/dist/cjs/{hooks/useShapes → core/shapes}/line/types.js +0 -0
  319. /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/types.js +0 -0
  320. /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
  321. /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
  322. /package/dist/cjs/{hooks/useShapes → core/shapes}/radar/types.js +0 -0
  323. /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
  324. /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
  325. /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/types.js +0 -0
  326. /package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/types.js +0 -0
  327. /package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/types.js +0 -0
  328. /package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/types.js +0 -0
  329. /package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/types.js +0 -0
  330. /package/dist/cjs/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
  331. /package/dist/esm/{hooks/useShapes → core/shapes}/area/types.js +0 -0
  332. /package/dist/esm/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
  333. /package/dist/esm/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
  334. /package/dist/esm/{hooks/useShapes → core/shapes}/bar-x/types.js +0 -0
  335. /package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/types.js +0 -0
  336. /package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
  337. /package/dist/esm/{hooks/useShapes → core/shapes}/funnel/types.js +0 -0
  338. /package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/types.js +0 -0
  339. /package/dist/esm/{hooks/useShapes → core/shapes}/line/types.js +0 -0
  340. /package/dist/esm/{hooks/useShapes → core/shapes}/pie/types.js +0 -0
  341. /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
  342. /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
  343. /package/dist/esm/{hooks/useShapes → core/shapes}/radar/types.js +0 -0
  344. /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
  345. /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
  346. /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/types.js +0 -0
  347. /package/dist/esm/{hooks/useShapes → core/shapes}/scatter/types.js +0 -0
  348. /package/dist/esm/{hooks/useShapes → core/shapes}/treemap/types.js +0 -0
  349. /package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/types.js +0 -0
  350. /package/dist/esm/{hooks/useShapes → core/shapes}/x-range/types.js +0 -0
  351. /package/dist/esm/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { PieArcDatum } from 'd3-shape';
2
2
  import type { ConnectorCurve, HtmlItem, LabelData } from '../../../types';
3
- import type { PreparedPieSeries } from '../../useSeries/types';
3
+ import type { PreparedPieSeries } from '../../series/types';
4
4
  export type SegmentData = {
5
5
  value: number;
6
6
  color: string;
@@ -1,4 +1,4 @@
1
- import type { PreparedRadarSeries } from '../../useSeries/types';
1
+ import type { PreparedRadarSeries } from '../../series/types';
2
2
  import type { PreparedRadarData } from './types';
3
3
  type Args = {
4
4
  series: PreparedRadarSeries[];
@@ -1,8 +1,8 @@
1
1
  import { range } from 'd3-array';
2
2
  import { scaleLinear } from 'd3-scale';
3
3
  import { curveLinearClosed, line } from 'd3-shape';
4
- import { getLabelsSize, getTextSizeFn } from '../../../core/utils';
5
- import { getFormattedValue } from '../../../core/utils/format';
4
+ import { getLabelsSize, getTextSizeFn } from '../../utils';
5
+ import { getFormattedValue } from '../../utils/format';
6
6
  export async function prepareRadarData(args) {
7
7
  const { series: preparedSeries, boundsWidth, boundsHeight } = args;
8
8
  const maxRadius = Math.min(boundsWidth, boundsHeight) / 2;
@@ -0,0 +1,6 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedRadarData } from './types';
4
+ export declare function renderRadar(elements: {
5
+ plot: SVGGElement;
6
+ }, preparedData: PreparedRadarData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,126 @@
1
+ import { color } from 'd3-color';
2
+ import { select } from 'd3-selection';
3
+ import { line } from 'd3-shape';
4
+ import get from 'lodash/get';
5
+ import { block } from '../../../utils';
6
+ import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../../shapes/marker';
7
+ import { setActiveState } from '../../shapes/utils';
8
+ const b = block('radar');
9
+ export function renderRadar(elements, preparedData, seriesOptions, dispatcher) {
10
+ const svgElement = select(elements.plot);
11
+ svgElement.selectAll('*').remove();
12
+ const areaSelector = `.${b('area')}`;
13
+ const radarSelection = svgElement
14
+ .selectAll('radar')
15
+ .data(preparedData)
16
+ .join('g')
17
+ .attr('id', (radarData) => radarData.id)
18
+ .attr('class', b('item'))
19
+ .attr('cursor', (radarData) => radarData.cursor);
20
+ // render axes
21
+ radarSelection
22
+ .selectAll(`.${b('axis')}`)
23
+ .data((radarData) => radarData.axes)
24
+ .join('line')
25
+ .attr('class', b('axis'))
26
+ .attr('x1', (d) => d.radar.center[0])
27
+ .attr('y1', (d) => d.radar.center[1])
28
+ .attr('x2', (d) => d.point[0])
29
+ .attr('y2', (d) => d.point[1])
30
+ .attr('stroke', (d) => d.strokeColor)
31
+ .attr('stroke-width', (d) => d.strokeWidth);
32
+ // render grid lines
33
+ radarSelection
34
+ .selectAll(`.${b('grid')}`)
35
+ .data((radarData) => radarData.grid)
36
+ .join('path')
37
+ .attr('class', b('grid'))
38
+ .attr('d', (d) => `${line()(d.path)} Z`)
39
+ .attr('fill', 'none')
40
+ .attr('stroke', (d) => d.strokeColor)
41
+ .attr('stroke-width', (d) => d.strokeWidth);
42
+ // render radar area
43
+ const shapesSelection = radarSelection
44
+ .selectAll(areaSelector)
45
+ .data((radarData) => radarData.shapes)
46
+ .join('g')
47
+ .attr('class', b('area'));
48
+ shapesSelection
49
+ .append('path')
50
+ .attr('d', (d) => d.path)
51
+ .attr('fill', (d) => d.color)
52
+ .attr('fill-opacity', (d) => d.fillOpacity)
53
+ .attr('stroke', (d) => d.borderColor)
54
+ .attr('stroke-width', (d) => d.borderWidth);
55
+ // render markers
56
+ const markerSelection = shapesSelection
57
+ .selectAll('marker')
58
+ .data((radarData) => radarData.points)
59
+ .join('g')
60
+ .call(renderMarker);
61
+ // Render labels
62
+ radarSelection
63
+ .selectAll('text')
64
+ .data((radarData) => radarData.labels)
65
+ .join('text')
66
+ .html((d) => d.text)
67
+ .attr('class', b('label'))
68
+ .attr('x', (d) => d.x)
69
+ .attr('y', (d) => d.y)
70
+ .attr('text-anchor', (d) => d.textAnchor)
71
+ .style('font-size', (d) => d.style.fontSize)
72
+ .style('font-weight', (d) => d.style.fontWeight || null)
73
+ .style('fill', (d) => d.style.fontColor || null);
74
+ // Handle hover events
75
+ const eventName = `hover-shape.radar`;
76
+ const hoverOptions = get(seriesOptions, 'radar.states.hover');
77
+ const inactiveOptions = get(seriesOptions, 'radar.states.inactive');
78
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (data) => {
79
+ const closest = data === null || data === void 0 ? void 0 : data.find((d) => d.closest);
80
+ const selectedSeries = closest === null || closest === void 0 ? void 0 : closest.series;
81
+ const selectedSeriesData = closest === null || closest === void 0 ? void 0 : closest.data;
82
+ const selectedSeriesId = selectedSeries === null || selectedSeries === void 0 ? void 0 : selectedSeries.id;
83
+ const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
84
+ const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
85
+ shapesSelection.datum((d, i, elements) => {
86
+ var _a;
87
+ const hovered = Boolean(hoverEnabled && ((_a = d.series) === null || _a === void 0 ? void 0 : _a.id) === selectedSeriesId);
88
+ if (d.hovered !== hovered) {
89
+ d.hovered = hovered;
90
+ select(elements[i]).attr('fill', () => {
91
+ var _a;
92
+ const initialColor = d.color;
93
+ if (d.hovered) {
94
+ return (((_a = color(initialColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
95
+ initialColor);
96
+ }
97
+ return initialColor;
98
+ });
99
+ if (hovered) {
100
+ select(elements[i]).raise();
101
+ }
102
+ }
103
+ setActiveState({
104
+ element: elements[i],
105
+ state: inactiveOptions,
106
+ active: Boolean(!inactiveEnabled || !selectedSeriesId || selectedSeriesId === d.series.id),
107
+ datum: d,
108
+ });
109
+ markerSelection.datum((markerData, index, markers) => {
110
+ const hoveredState = Boolean(hoverEnabled && markerData.data === selectedSeriesData);
111
+ if (markerData.hovered !== hoveredState) {
112
+ markerData.hovered = hoveredState;
113
+ const elementSelection = select(markers[index]);
114
+ elementSelection.attr('visibility', getMarkerVisibility(markerData));
115
+ selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
116
+ selectMarkerSymbol(elementSelection).call(setMarker, hoveredState ? 'hover' : 'normal');
117
+ }
118
+ return markerData;
119
+ });
120
+ return d;
121
+ });
122
+ });
123
+ return () => {
124
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
125
+ };
126
+ }
@@ -1,5 +1,5 @@
1
1
  import type { HtmlItem, LabelData, RadarSeriesData } from '../../../types';
2
- import type { PreparedRadarSeries } from '../../useSeries/types';
2
+ import type { PreparedRadarSeries } from '../../series/types';
3
3
  export type RadarLabelData = LabelData & {
4
4
  maxWidth: number;
5
5
  };
@@ -1,4 +1,4 @@
1
- import type { PreparedSankeySeries } from '../../useSeries/types';
1
+ import type { PreparedSankeySeries } from '../../series/types';
2
2
  import type { PreparedSankeyData } from './types';
3
3
  export declare function prepareSankeyData(args: {
4
4
  series: PreparedSankeySeries;
@@ -1,4 +1,4 @@
1
- import { getFormattedValue } from '../../../core/utils/format';
1
+ import { getFormattedValue } from '../../utils/format';
2
2
  import { sankey, sankeyLinkHorizontal } from './sankey-layout';
3
3
  export function prepareSankeyData(args) {
4
4
  const { series, width, height } = args;
@@ -0,0 +1,6 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedSankeyData } from './types';
4
+ export declare function renderSankey(elements: {
5
+ plot: SVGGElement;
6
+ }, preparedData: PreparedSankeyData, _seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,50 @@
1
+ import { select } from 'd3-selection';
2
+ import { block } from '../../../utils';
3
+ const b = block('sankey');
4
+ export function renderSankey(elements, preparedData, _seriesOptions, dispatcher) {
5
+ const svgElement = select(elements.plot);
6
+ svgElement.selectAll('*').remove();
7
+ // nodes
8
+ svgElement
9
+ .append('g')
10
+ .selectAll()
11
+ .data(preparedData.nodes)
12
+ .join('rect')
13
+ .attr('x', (d) => d.x0)
14
+ .attr('y', (d) => d.y0)
15
+ .attr('height', (d) => d.y1 - d.y0)
16
+ .attr('width', (d) => d.x1 - d.x0)
17
+ .attr('fill', (d) => d.color);
18
+ // links
19
+ svgElement
20
+ .append('g')
21
+ .attr('fill', 'none')
22
+ .selectAll()
23
+ .data(preparedData.links)
24
+ .join('g')
25
+ .append('path')
26
+ .attr('stroke-opacity', (d) => d.opacity)
27
+ .attr('d', (d) => d.path)
28
+ .attr('stroke', (d) => d.color)
29
+ .attr('stroke-width', (d) => d.strokeWidth);
30
+ // dataLabels
31
+ svgElement
32
+ .append('g')
33
+ .selectAll()
34
+ .data(preparedData.labels)
35
+ .join('text')
36
+ .html((d) => d.text)
37
+ .attr('class', b('label'))
38
+ .attr('x', (d) => d.x)
39
+ .attr('y', (d) => d.y)
40
+ .attr('dy', '0.35em')
41
+ .attr('text-anchor', (d) => d.textAnchor)
42
+ .attr('fill', (d) => { var _a; return (_a = d.style.fontColor) !== null && _a !== void 0 ? _a : null; });
43
+ const eventName = `hover-shape.sankey`;
44
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (_data) => {
45
+ // no-op hover handler
46
+ });
47
+ return () => {
48
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
49
+ };
50
+ }
@@ -1,5 +1,5 @@
1
1
  import type { BaseTextStyle, HtmlItem, SankeySeriesData } from '../../../types';
2
- import type { PreparedSankeySeries } from '../../useSeries/types';
2
+ import type { PreparedSankeySeries } from '../../series/types';
3
3
  export type SankeyDataLabel = {
4
4
  text: string;
5
5
  x: number;
@@ -1,6 +1,6 @@
1
- import type { ChartScale } from '../../../core/scales/types';
2
- import type { PreparedXAxis, PreparedYAxis } from '../../useAxis/types';
3
- import type { PreparedScatterSeries } from '../../useSeries/types';
1
+ import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
2
+ import type { ChartScale } from '../../scales/types';
3
+ import type { PreparedScatterSeries } from '../../series/types';
4
4
  import type { PreparedScatterData } from './types';
5
5
  export declare function prepareScatterData(args: {
6
6
  series: PreparedScatterSeries[];
@@ -1,6 +1,6 @@
1
1
  import get from 'lodash/get';
2
- import { getDataCategoryValue } from '../../../core/utils';
3
- import { getXValue, getYValue } from '../utils';
2
+ import { getXValue, getYValue } from '../../shapes/utils';
3
+ import { getDataCategoryValue } from '../../utils';
4
4
  function getFilteredLinearScatterData(data) {
5
5
  return data.filter((d) => typeof d.x === 'number' && typeof d.y === 'number');
6
6
  }
@@ -0,0 +1,6 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedScatterData } from './types';
4
+ export declare function renderScatter(elements: {
5
+ plot: SVGGElement;
6
+ }, preparedData: PreparedScatterData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,52 @@
1
+ import { select } from 'd3-selection';
2
+ import get from 'lodash/get';
3
+ import { getMarkerHaloVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../../shapes/marker';
4
+ import { setActiveState, shapeKey } from '../../shapes/utils';
5
+ export function renderScatter(elements, preparedData, seriesOptions, dispatcher) {
6
+ const svgElement = select(elements.plot);
7
+ const hoverOptions = get(seriesOptions, 'scatter.states.hover');
8
+ const inactiveOptions = get(seriesOptions, 'scatter.states.inactive');
9
+ svgElement.selectAll('*').remove();
10
+ const selection = svgElement
11
+ .selectAll('path')
12
+ .data(preparedData, shapeKey)
13
+ .join('g')
14
+ .call(renderMarker)
15
+ .attr('opacity', (d) => d.point.opacity)
16
+ .attr('cursor', (d) => d.point.series.cursor);
17
+ const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
18
+ const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
19
+ function handleShapeHover(data) {
20
+ var _a;
21
+ const selected = data === null || data === void 0 ? void 0 : data.find((d) => d.series.type === 'scatter');
22
+ const selectedDataItem = selected === null || selected === void 0 ? void 0 : selected.data;
23
+ const selectedSeriesId = (_a = selected === null || selected === void 0 ? void 0 : selected.series) === null || _a === void 0 ? void 0 : _a.id;
24
+ selection.datum((d, index, list) => {
25
+ const elementSelection = select(list[index]);
26
+ const hovered = Boolean(hoverEnabled && d.point.data === selectedDataItem);
27
+ if (d.hovered !== hovered) {
28
+ d.hovered = hovered;
29
+ elementSelection.attr('z-index', hovered ? 999 : null);
30
+ selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
31
+ selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
32
+ }
33
+ if (hovered) {
34
+ elementSelection.raise();
35
+ }
36
+ if (d.point.series.marker.states.normal.enabled) {
37
+ const isActive = Boolean(!inactiveEnabled || !selectedSeriesId || selectedSeriesId === d.point.series.id);
38
+ setActiveState({
39
+ element: list[index],
40
+ state: inactiveOptions,
41
+ active: isActive,
42
+ datum: d,
43
+ });
44
+ }
45
+ return d;
46
+ });
47
+ }
48
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', handleShapeHover);
49
+ return () => {
50
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', null);
51
+ };
52
+ }
@@ -1,5 +1,5 @@
1
1
  import type { HtmlItem, ScatterSeriesData } from '../../../types';
2
- import type { PreparedScatterSeries } from '../../useSeries/types';
2
+ import type { PreparedScatterSeries } from '../../series/types';
3
3
  type PointData = {
4
4
  x: number;
5
5
  y: number;
@@ -1,4 +1,4 @@
1
- import type { PreparedTreemapSeries } from '../../useSeries/types';
1
+ import type { PreparedTreemapSeries } from '../../series/types';
2
2
  import type { PreparedTreemapData } from './types';
3
3
  export declare function prepareTreemapData(args: {
4
4
  series: PreparedTreemapSeries;
@@ -1,8 +1,8 @@
1
1
  import { ascending, descending, sort } from 'd3-array';
2
2
  import { stratify, treemap, treemapBinary, treemapDice, treemapSlice, treemapSliceDice, treemapSquarify, } from 'd3-hierarchy';
3
- import { LayoutAlgorithm } from '../../../core/constants';
4
- import { getLabelsSize, getTextSizeFn, getTextWithElipsis } from '../../../core/utils';
5
- import { getFormattedValue } from '../../../core/utils/format';
3
+ import { LayoutAlgorithm } from '../../constants';
4
+ import { getLabelsSize, getTextSizeFn, getTextWithElipsis } from '../../utils';
5
+ import { getFormattedValue } from '../../utils/format';
6
6
  const DEFAULT_PADDING = 1;
7
7
  async function getLabels(args) {
8
8
  var _a;
@@ -0,0 +1,6 @@
1
+ import type { Dispatch } from 'd3-dispatch';
2
+ import type { PreparedSeriesOptions } from '../../series/types';
3
+ import type { PreparedTreemapData } from './types';
4
+ export declare function renderTreemap(elements: {
5
+ plot: SVGGElement;
6
+ }, preparedData: PreparedTreemapData, seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
@@ -0,0 +1,88 @@
1
+ import { color } from 'd3-color';
2
+ import { select } from 'd3-selection';
3
+ import get from 'lodash/get';
4
+ import { block } from '../../../utils';
5
+ const b = block('treemap');
6
+ export function renderTreemap(elements, preparedData, seriesOptions, dispatcher) {
7
+ const svgElement = select(elements.plot);
8
+ svgElement.selectAll('*').remove();
9
+ const { labelData, leaves, series } = preparedData;
10
+ const leaf = svgElement
11
+ .selectAll('g')
12
+ .data(leaves)
13
+ .join('g')
14
+ .attr('transform', (d) => `translate(${d.x0},${d.y0})`)
15
+ .attr('cursor', series.cursor);
16
+ const rectSelection = leaf
17
+ .append('rect')
18
+ .attr('id', (d) => d.id || d.name)
19
+ .attr('fill', (d) => {
20
+ var _a;
21
+ if (d.data.color) {
22
+ return d.data.color;
23
+ }
24
+ const levelOptions = (_a = series.levels) === null || _a === void 0 ? void 0 : _a.find((l) => l.index === d.depth);
25
+ return (levelOptions === null || levelOptions === void 0 ? void 0 : levelOptions.color) || series.color;
26
+ })
27
+ .attr('width', (d) => d.x1 - d.x0)
28
+ .attr('height', (d) => d.y1 - d.y0);
29
+ const labelSelection = svgElement
30
+ .selectAll('tspan')
31
+ .data(labelData)
32
+ .join('text')
33
+ .html((d) => d.text)
34
+ .attr('class', b('label'))
35
+ .attr('x', (d) => d.x)
36
+ .attr('y', (d) => d.y)
37
+ .style('font-size', () => series.dataLabels.style.fontSize)
38
+ .style('font-weight', () => { var _a; return ((_a = series.dataLabels.style) === null || _a === void 0 ? void 0 : _a.fontWeight) || null; })
39
+ .style('fill', () => { var _a; return ((_a = series.dataLabels.style) === null || _a === void 0 ? void 0 : _a.fontColor) || null; });
40
+ const eventName = `hover-shape.treemap`;
41
+ const hoverOptions = get(seriesOptions, 'treemap.states.hover');
42
+ const inactiveOptions = get(seriesOptions, 'treemap.states.inactive');
43
+ function handleShapeHover(data) {
44
+ var _a;
45
+ const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
46
+ const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
47
+ const hoveredData = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.data;
48
+ rectSelection.datum((d, index, list) => {
49
+ const currentRect = select(list[index]);
50
+ const hovered = Boolean(hoverEnabled && hoveredData === d.data);
51
+ const inactive = Boolean(inactiveEnabled && hoveredData && !hovered);
52
+ currentRect
53
+ .attr('fill', (currentD) => {
54
+ var _a, _b;
55
+ const levelOptions = (_a = series.levels) === null || _a === void 0 ? void 0 : _a.find((l) => l.index === currentD.depth);
56
+ const initialColor = (levelOptions === null || levelOptions === void 0 ? void 0 : levelOptions.color) || d.data.color || series.color;
57
+ if (hovered) {
58
+ return (((_b = color(initialColor)) === null || _b === void 0 ? void 0 : _b.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
59
+ initialColor);
60
+ }
61
+ return initialColor;
62
+ })
63
+ .attr('opacity', () => {
64
+ if (inactive) {
65
+ return (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
66
+ }
67
+ return null;
68
+ });
69
+ return d;
70
+ });
71
+ labelSelection.datum((d, index, list) => {
72
+ const currentLabel = select(list[index]);
73
+ const hovered = Boolean(hoverEnabled && hoveredData === d.nodeData);
74
+ const inactive = Boolean(inactiveEnabled && hoveredData && !hovered);
75
+ currentLabel.attr('opacity', () => {
76
+ if (inactive) {
77
+ return (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
78
+ }
79
+ return null;
80
+ });
81
+ return d;
82
+ });
83
+ }
84
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, handleShapeHover);
85
+ return () => {
86
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
87
+ };
88
+ }
@@ -1,6 +1,6 @@
1
1
  import type { HierarchyRectangularNode } from 'd3-hierarchy';
2
2
  import type { HtmlItem, TreemapSeriesData } from '../../../types';
3
- import type { PreparedTreemapSeries } from '../../useSeries/types';
3
+ import type { PreparedTreemapSeries } from '../../series/types';
4
4
  export type TreemapLabelData = {
5
5
  text: string;
6
6
  x: number;
@@ -0,0 +1,52 @@
1
+ import type { BaseType } from 'd3-selection';
2
+ import type { PreparedXAxis, PreparedYAxis } from '../axes/types';
3
+ import type { ChartScale } from '../scales/types';
4
+ import type { BasicInactiveState } from '../types';
5
+ export declare function getXValue(args: {
6
+ point: {
7
+ x?: number | string | null;
8
+ };
9
+ points?: {
10
+ x?: number | string | null;
11
+ }[];
12
+ xAxis: PreparedXAxis;
13
+ xScale: ChartScale;
14
+ }): number | null;
15
+ export declare function getYValue(args: {
16
+ point: {
17
+ y?: number | string | null;
18
+ };
19
+ points?: {
20
+ y?: number | string | null;
21
+ }[];
22
+ yAxis: PreparedYAxis;
23
+ yScale: ChartScale;
24
+ }): number | null;
25
+ export declare function shapeKey(d: unknown): string | number;
26
+ export declare function setActiveState<T extends {
27
+ active?: boolean;
28
+ }>(args: {
29
+ element: BaseType;
30
+ datum: T;
31
+ state: BasicInactiveState | undefined;
32
+ active: boolean;
33
+ }): T;
34
+ export declare function getRectPath(args: {
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ borderRadius?: number | number[];
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;
49
+ export declare function getClipPathIdByBounds(args: {
50
+ clipPathId: string;
51
+ bounds?: 'horizontal';
52
+ }): string;