@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,18 +1,11 @@
1
1
  import React from 'react';
2
- import { color } from 'd3-color';
3
- import { select } from 'd3-selection';
4
- import { area as areaGenerator, line as lineGenerator } from 'd3-shape';
5
- import get from 'lodash/get';
2
+ import { renderArea } from '../../../core/shapes/area/renderer';
6
3
  import { filterOverlappingLabels } from '../../../core/utils';
7
4
  import { block } from '../../../utils';
8
5
  import { HtmlLayer } from '../HtmlLayer';
9
- import { renderAnnotations } from '../annotation';
10
- import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
11
- import { setActiveState } from '../utils';
12
6
  const b = block('area');
13
7
  export const AreaSeriesShapes = (args) => {
14
8
  const { boundsHeight, boundsWidth, dispatcher, preparedData, seriesOptions, htmlLayout, clipPathId, } = args;
15
- const hoveredDataRef = React.useRef(null);
16
9
  const plotRef = React.useRef(null);
17
10
  const markersRef = React.useRef(null);
18
11
  const hoverMarkersRef = React.useRef(null);
@@ -21,185 +14,20 @@ export const AreaSeriesShapes = (args) => {
21
14
  return preparedData.some((d) => d === null || d === void 0 ? void 0 : d.series.dataLabels.allowOverlap);
22
15
  }, [preparedData]);
23
16
  React.useEffect(() => {
24
- if (!plotRef.current || !markersRef.current) {
17
+ if (!plotRef.current ||
18
+ !markersRef.current ||
19
+ !hoverMarkersRef.current ||
20
+ !annotationsRef.current) {
25
21
  return () => { };
26
22
  }
27
- const plotSvgElement = select(plotRef.current);
28
- const markersSvgElement = select(markersRef.current);
29
- const hoverMarkersSvgElement = select(hoverMarkersRef.current);
30
- const hoverOptions = get(seriesOptions, 'area.states.hover');
31
- const inactiveOptions = get(seriesOptions, 'area.states.inactive');
32
- const line = lineGenerator()
33
- .x((d) => d.x)
34
- .defined((d) => d.y !== null)
35
- .y((d) => d.y);
36
- plotSvgElement.selectAll('*').remove();
37
- markersSvgElement.selectAll('*').remove();
38
- const shapeSelection = plotSvgElement
39
- .selectAll('shape')
40
- .data(preparedData)
41
- .join('g')
42
- .attr('class', b('series'))
43
- .attr('cursor', (d) => d.series.cursor);
44
- shapeSelection
45
- .append('path')
46
- .attr('class', b('line'))
47
- .attr('d', (d) => line(d.points))
48
- .attr('fill', 'none')
49
- .attr('stroke', (d) => d.color)
50
- .attr('stroke-width', (d) => d.width)
51
- .attr('stroke-linejoin', 'round')
52
- .attr('stroke-linecap', 'round');
53
- const area = areaGenerator()
54
- .defined((d) => d.y !== null)
55
- .x((d) => d.x)
56
- .y0((d) => d.y0)
57
- .y1((d) => d.y);
58
- shapeSelection
59
- .append('path')
60
- .attr('class', b('region'))
61
- .attr('d', (d) => area(d.points))
62
- .attr('fill', (d) => d.color)
63
- .attr('opacity', (d) => d.opacity);
64
- let dataLabels = preparedData.reduce((acc, d) => {
65
- return acc.concat(d.svgLabels);
66
- }, []);
67
- if (!allowOverlapDataLabels) {
68
- dataLabels = filterOverlappingLabels(dataLabels);
69
- }
70
- const labelsSelection = plotSvgElement
71
- .selectAll('text')
72
- .data(dataLabels)
73
- .join('text')
74
- .html((d) => d.text)
75
- .attr('class', b('label'))
76
- .attr('x', (d) => d.x)
77
- .attr('y', (d) => d.y)
78
- .attr('text-anchor', (d) => d.textAnchor)
79
- .style('font-size', (d) => d.style.fontSize)
80
- .style('font-weight', (d) => d.style.fontWeight || null)
81
- .style('fill', (d) => d.style.fontColor || null);
82
- const markers = preparedData.reduce((acc, d) => acc.concat(d.markers), []);
83
- const markerSelection = markersSvgElement
84
- .selectAll('marker')
85
- .data(markers)
86
- .join('g')
87
- .call(renderMarker);
88
- if (annotationsRef.current) {
89
- const anchors = preparedData.flatMap((d) => d.annotations);
90
- renderAnnotations({
91
- anchors,
92
- container: select(annotationsRef.current),
93
- plotHeight: boundsHeight,
94
- plotWidth: boundsWidth,
95
- });
96
- }
97
- const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
98
- const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
99
- function handleShapeHover(data) {
100
- hoveredDataRef.current = data;
101
- const selected = (data === null || data === void 0 ? void 0 : data.filter((d) => d.series.type === 'area')) || [];
102
- const selectedDataItems = selected.map((d) => d.data);
103
- const selectedSeriesIds = selected.map((d) => { var _a; return (_a = d.series) === null || _a === void 0 ? void 0 : _a.id; });
104
- shapeSelection.datum((d, index, list) => {
105
- var _a;
106
- const elementSelection = select(list[index]);
107
- const hovered = Boolean(hoverEnabled && selectedSeriesIds.includes(d.id));
108
- if (d.hovered !== hovered) {
109
- d.hovered = hovered;
110
- let strokeColor = d.color || '';
111
- if (d.hovered) {
112
- strokeColor =
113
- ((_a = color(strokeColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
114
- strokeColor;
115
- }
116
- elementSelection.selectAll(`.${b('line')}`).attr('stroke', strokeColor);
117
- elementSelection.selectAll(`.${b('region')}`).attr('fill', strokeColor);
118
- }
119
- return setActiveState({
120
- element: list[index],
121
- state: inactiveOptions,
122
- active: Boolean(!inactiveEnabled ||
123
- !selectedSeriesIds.length ||
124
- selectedSeriesIds.includes(d.id)),
125
- datum: d,
126
- });
127
- });
128
- labelsSelection.datum((d, index, list) => {
129
- return setActiveState({
130
- element: list[index],
131
- state: inactiveOptions,
132
- active: Boolean(!inactiveEnabled ||
133
- !selectedSeriesIds.length ||
134
- selectedSeriesIds.includes(d.series.id)),
135
- datum: d,
136
- });
137
- });
138
- markerSelection.datum((d, index, list) => {
139
- const elementSelection = select(list[index]);
140
- const hovered = Boolean(hoverEnabled && selectedDataItems.includes(d.point.data));
141
- if (d.hovered !== hovered) {
142
- d.hovered = hovered;
143
- elementSelection.attr('visibility', getMarkerVisibility(d));
144
- selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
145
- selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
146
- }
147
- if (d.point.series.marker.states.normal.enabled) {
148
- const isActive = Boolean(!inactiveEnabled ||
149
- !selectedSeriesIds.length ||
150
- selectedSeriesIds.includes(d.point.series.id));
151
- setActiveState({
152
- element: list[index],
153
- state: inactiveOptions,
154
- active: isActive,
155
- datum: d,
156
- });
157
- }
158
- return d;
159
- });
160
- hoverMarkersSvgElement.selectAll('*').remove();
161
- if (hoverEnabled && selected.length > 0) {
162
- const hoverOnlyMarkers = [];
163
- for (const chunk of selected) {
164
- const seriesData = preparedData.find((pd) => pd.id === chunk.series.id);
165
- if (!seriesData) {
166
- continue;
167
- }
168
- const { series } = seriesData;
169
- if (series.marker.states.normal.enabled ||
170
- !series.marker.states.hover.enabled) {
171
- continue;
172
- }
173
- const point = seriesData.points.find((p) => p.data === chunk.data);
174
- if (!point || point.y === null) {
175
- continue;
176
- }
177
- hoverOnlyMarkers.push({
178
- point: point,
179
- active: true,
180
- hovered: true,
181
- clipped: false,
182
- });
183
- }
184
- if (hoverOnlyMarkers.length > 0) {
185
- hoverMarkersSvgElement
186
- .selectAll('g')
187
- .data(hoverOnlyMarkers)
188
- .join('g')
189
- .call(renderMarker)
190
- .each((_d, i, nodes) => {
191
- selectMarkerSymbol(select(nodes[i])).call(setMarker, 'hover');
192
- });
193
- }
194
- }
195
- }
196
- if (hoveredDataRef.current !== null) {
197
- handleShapeHover(hoveredDataRef.current);
198
- }
199
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.area', handleShapeHover);
200
- return () => {
201
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.area', null);
202
- };
23
+ return renderArea({
24
+ plot: plotRef.current,
25
+ markers: markersRef.current,
26
+ hoverMarkers: hoverMarkersRef.current,
27
+ annotations: annotationsRef.current,
28
+ boundsWidth,
29
+ boundsHeight,
30
+ }, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher);
203
31
  }, [
204
32
  allowOverlapDataLabels,
205
33
  boundsHeight,
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { Dispatch } from 'd3-dispatch';
3
- import type { PreparedSeriesOptions } from '../../useSeries/types';
4
- import type { PreparedBarXData } from './types';
5
- export { prepareBarXData } from './prepare-data';
6
- export * from './types';
3
+ import type { PreparedSeriesOptions } from '../../../core/series/types';
4
+ import type { PreparedBarXData } from '../../../core/shapes/bar-x/types';
5
+ export { prepareBarXData } from '../../../core/shapes/bar-x/prepare-data';
6
+ export * from '../../../core/shapes/bar-x/types';
7
7
  type Args = {
8
8
  boundsHeight: number;
9
9
  boundsWidth: number;
@@ -1,137 +1,28 @@
1
1
  import React from 'react';
2
- import { color } from 'd3-color';
3
- import { select } from 'd3-selection';
4
- import get from 'lodash/get';
2
+ import { renderBarX } from '../../../core/shapes/bar-x/renderer';
5
3
  import { filterOverlappingLabels } from '../../../core/utils';
6
4
  import { block } from '../../../utils';
7
5
  import { HtmlLayer } from '../HtmlLayer';
8
- import { renderAnnotations } from '../annotation';
9
- import { getRectPath } from '../utils';
10
- export { prepareBarXData } from './prepare-data';
11
- export * from './types';
6
+ export { prepareBarXData } from '../../../core/shapes/bar-x/prepare-data';
7
+ export * from '../../../core/shapes/bar-x/types';
12
8
  const b = block('bar-x');
13
9
  export const BarXSeriesShapes = (args) => {
14
10
  const { boundsHeight, boundsWidth, dispatcher, preparedData, seriesOptions, htmlLayout, clipPathId, } = args;
15
- const hoveredDataRef = React.useRef(null);
16
11
  const ref = React.useRef(null);
17
12
  const annotationsRef = React.useRef(null);
18
13
  const allowOverlapDataLabels = React.useMemo(() => {
19
14
  return preparedData.some((d) => d === null || d === void 0 ? void 0 : d.series.dataLabels.allowOverlap);
20
15
  }, [preparedData]);
21
16
  React.useEffect(() => {
22
- if (!ref.current) {
17
+ if (!ref.current || !annotationsRef.current) {
23
18
  return () => { };
24
19
  }
25
- const svgElement = select(ref.current);
26
- const hoverOptions = get(seriesOptions, 'bar-x.states.hover');
27
- const inactiveOptions = get(seriesOptions, 'bar-x.states.inactive');
28
- svgElement.selectAll('*').remove();
29
- const rectSelection = svgElement
30
- .selectAll('allRects')
31
- .data(preparedData)
32
- .join('path')
33
- .attr('d', (d) => {
34
- const borderRadius = d.isLastStackItem
35
- ? Math.min(d.height, d.width / 2, d.series.borderRadius)
36
- : 0;
37
- const p = getRectPath({
38
- x: d.x,
39
- y: d.y,
40
- width: d.width,
41
- height: d.height,
42
- borderRadius: [borderRadius, borderRadius, 0, 0],
43
- });
44
- return p.toString();
45
- })
46
- .attr('class', b('segment'))
47
- .attr('x', (d) => d.x)
48
- .attr('y', (d) => d.y)
49
- .attr('height', (d) => d.height)
50
- .attr('width', (d) => d.width)
51
- .attr('fill', (d) => d.data.color || d.series.color)
52
- .attr('opacity', (d) => d.opacity)
53
- .attr('cursor', (d) => d.series.cursor);
54
- let dataLabels = preparedData.map((d) => d.svgLabels).flat();
55
- if (!allowOverlapDataLabels) {
56
- dataLabels = filterOverlappingLabels(dataLabels);
57
- }
58
- const labelSelection = svgElement
59
- .selectAll('text')
60
- .data(dataLabels)
61
- .join('text')
62
- .html((d) => d.text)
63
- .attr('class', b('label'))
64
- .attr('x', (d) => d.x)
65
- .attr('y', (d) => d.y)
66
- .attr('text-anchor', (d) => d.textAnchor)
67
- .style('font-size', (d) => d.style.fontSize)
68
- .style('font-weight', (d) => d.style.fontWeight || null)
69
- .style('fill', (d) => d.style.fontColor || null);
70
- if (annotationsRef.current) {
71
- const anchors = [];
72
- for (const d of preparedData) {
73
- if (d.annotation) {
74
- anchors.push({
75
- annotation: d.annotation,
76
- x: d.x + d.width / 2,
77
- y: d.y,
78
- });
79
- }
80
- }
81
- renderAnnotations({
82
- anchors,
83
- container: select(annotationsRef.current),
84
- plotHeight: boundsHeight,
85
- plotWidth: boundsWidth,
86
- });
87
- }
88
- function handleShapeHover(data) {
89
- hoveredDataRef.current = data;
90
- const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
91
- const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
92
- if (!data) {
93
- if (hoverEnabled) {
94
- rectSelection.attr('fill', (d) => d.data.color || d.series.color);
95
- }
96
- if (inactiveEnabled) {
97
- rectSelection.attr('opacity', null);
98
- labelSelection.attr('opacity', null);
99
- }
100
- return;
101
- }
102
- if (hoverEnabled) {
103
- const hoveredValues = data.map((d) => d.data.x);
104
- rectSelection.attr('fill', (d) => {
105
- var _a;
106
- const fillColor = d.data.color || d.series.color;
107
- if (hoveredValues.includes(d.data.x)) {
108
- return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
109
- fillColor);
110
- }
111
- return fillColor;
112
- });
113
- }
114
- if (inactiveEnabled) {
115
- const hoveredSeries = data.map((d) => d.series.id);
116
- rectSelection.attr('opacity', (d) => {
117
- return hoveredSeries.includes(d.series.id)
118
- ? null
119
- : (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
120
- });
121
- labelSelection.attr('opacity', (d) => {
122
- return hoveredSeries.includes(d.series.id)
123
- ? null
124
- : (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
125
- });
126
- }
127
- }
128
- if (hoveredDataRef.current !== null) {
129
- handleShapeHover(hoveredDataRef.current);
130
- }
131
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-x', handleShapeHover);
132
- return () => {
133
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-x', null);
134
- };
20
+ return renderBarX({
21
+ plot: ref.current,
22
+ annotations: annotationsRef.current,
23
+ boundsWidth,
24
+ boundsHeight,
25
+ }, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher);
135
26
  }, [
136
27
  allowOverlapDataLabels,
137
28
  boundsHeight,
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { Dispatch } from 'd3-dispatch';
3
- import type { PreparedSeriesOptions } from '../../useSeries/types';
4
- import type { BarYShapesArgs } from './types';
5
- export { prepareBarYData } from './prepare-data';
3
+ import type { PreparedSeriesOptions } from '../../../core/series/types';
4
+ import type { BarYShapesArgs } from '../../../core/shapes/bar-y/types';
5
+ export { prepareBarYData } from '../../../core/shapes/bar-y/prepare-data';
6
6
  type Args = {
7
7
  clipPathId: string;
8
8
  htmlLayout: HTMLElement | null;
@@ -1,97 +1,18 @@
1
1
  import React from 'react';
2
- import { color } from 'd3-color';
3
- import { select } from 'd3-selection';
4
- import get from 'lodash/get';
2
+ import { renderBarY } from '../../../core/shapes/bar-y/renderer';
5
3
  import { block } from '../../../utils';
6
4
  import { HtmlLayer } from '../HtmlLayer';
7
- import { getAdjustedRectBorderPath, getAdjustedRectPath } from './utils';
8
- export { prepareBarYData } from './prepare-data';
5
+ export { prepareBarYData } from '../../../core/shapes/bar-y/prepare-data';
9
6
  const b = block('bar-y');
10
7
  export function BarYSeriesShapes(args) {
11
- const { dispatcher, preparedData: { shapes: preparedData, labels: dataLabels, htmlElements }, seriesOptions, htmlLayout, clipPathId, } = args;
12
- const hoveredDataRef = React.useRef(null);
8
+ const { dispatcher, preparedData: { htmlElements }, seriesOptions, htmlLayout, clipPathId, } = args;
13
9
  const ref = React.useRef(null);
14
10
  React.useEffect(() => {
15
11
  if (!ref.current) {
16
12
  return () => { };
17
13
  }
18
- const svgElement = select(ref.current);
19
- svgElement.selectAll('*').remove();
20
- const segmentSelection = svgElement
21
- .selectAll(`path.${b('segment')}`)
22
- .data(preparedData)
23
- .join('path')
24
- .attr('d', (d) => getAdjustedRectPath(d))
25
- .attr('class', b('segment'))
26
- .attr('x', (d) => d.x)
27
- .attr('y', (d) => d.y)
28
- .attr('height', (d) => d.height)
29
- .attr('width', (d) => d.width)
30
- .attr('fill', (d) => d.color)
31
- .attr('opacity', (d) => d.data.opacity || null)
32
- .attr('cursor', (d) => d.series.cursor);
33
- const borderSelection = svgElement
34
- .selectAll(`path.${b('segment-border')}`)
35
- .data(preparedData.filter((d) => d.borderWidth > 0))
36
- .join('path')
37
- .attr('d', (d) => getAdjustedRectBorderPath(d))
38
- .attr('class', b('segment-border'))
39
- .attr('fill', (d) => d.borderColor)
40
- .attr('fill-rule', 'evenodd')
41
- .attr('opacity', (d) => d.data.opacity || null)
42
- .attr('pointer-events', 'none');
43
- const labelSelection = svgElement
44
- .selectAll('text')
45
- .data(dataLabels)
46
- .join('text')
47
- .html((d) => d.text)
48
- .attr('class', b('label'))
49
- .attr('x', (d) => d.x)
50
- .attr('y', (d) => d.y)
51
- .attr('text-anchor', (d) => d.textAnchor)
52
- .style('font-size', (d) => d.style.fontSize)
53
- .style('font-weight', (d) => d.style.fontWeight || null)
54
- .style('fill', (d) => d.style.fontColor || null);
55
- const hoverOptions = get(seriesOptions, 'bar-y.states.hover');
56
- const inactiveOptions = get(seriesOptions, 'bar-y.states.inactive');
57
- function handleShapeHover(data) {
58
- hoveredDataRef.current = data;
59
- if (hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled) {
60
- const hovered = data === null || data === void 0 ? void 0 : data.reduce((acc, d) => {
61
- acc.add(d.data.y);
62
- return acc;
63
- }, new Set());
64
- segmentSelection.attr('fill', (d) => {
65
- var _a;
66
- const fillColor = d.color;
67
- if (hovered === null || hovered === void 0 ? void 0 : hovered.has(d.data.y)) {
68
- return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) ||
69
- fillColor);
70
- }
71
- return fillColor;
72
- });
73
- }
74
- if (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled) {
75
- const hoveredSeries = data === null || data === void 0 ? void 0 : data.map((d) => d.series.id);
76
- const newOpacity = (d) => {
77
- if ((hoveredSeries === null || hoveredSeries === void 0 ? void 0 : hoveredSeries.length) && !hoveredSeries.includes(d.series.id)) {
78
- return inactiveOptions.opacity || null;
79
- }
80
- return null;
81
- };
82
- segmentSelection.attr('opacity', newOpacity);
83
- borderSelection.attr('opacity', newOpacity);
84
- labelSelection.attr('opacity', newOpacity);
85
- }
86
- }
87
- if (hoveredDataRef.current !== null) {
88
- handleShapeHover(hoveredDataRef.current);
89
- }
90
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-y', handleShapeHover);
91
- return () => {
92
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-y', null);
93
- };
94
- }, [dataLabels, dispatcher, preparedData, seriesOptions]);
14
+ return renderBarY({ plot: ref.current }, args.preparedData, seriesOptions, dispatcher);
15
+ }, [args.preparedData, dispatcher, seriesOptions]);
95
16
  return (React.createElement(React.Fragment, null,
96
17
  React.createElement("g", { ref: ref, className: b(), clipPath: `url(#${clipPathId})` }),
97
18
  React.createElement(HtmlLayer, { preparedData: { htmlElements }, htmlLayout: htmlLayout })));
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { Dispatch } from 'd3-dispatch';
3
- import type { PreparedSeriesOptions } from '../../useSeries/types';
4
- import type { PreparedFunnelData } from './types';
5
- export { prepareFunnelData } from './prepare-data';
6
- export * from './types';
3
+ import type { PreparedSeriesOptions } from '../../../core/series/types';
4
+ import type { PreparedFunnelData } from '../../../core/shapes/funnel/types';
5
+ export { prepareFunnelData } from '../../../core/shapes/funnel/prepare-data';
6
+ export * from '../../../core/shapes/funnel/types';
7
7
  type Args = {
8
8
  dispatcher?: Dispatch<object>;
9
9
  preparedData: PreparedFunnelData;
@@ -1,96 +1,17 @@
1
1
  import React from 'react';
2
- import { color } from 'd3-color';
3
- import { select } from 'd3-selection';
4
- import { getLineDashArray } from '../../../core/utils';
2
+ import { renderFunnel } from '../../../core/shapes/funnel/renderer';
5
3
  import { block } from '../../../utils';
6
- export { prepareFunnelData } from './prepare-data';
7
- export * from './types';
4
+ export { prepareFunnelData } from '../../../core/shapes/funnel/prepare-data';
5
+ export * from '../../../core/shapes/funnel/types';
8
6
  const b = block('funnel');
9
7
  export const FunnelSeriesShapes = (args) => {
10
8
  const { dispatcher, preparedData, seriesOptions } = args;
11
- const hoveredDataRef = React.useRef(null);
12
9
  const ref = React.useRef(null);
13
10
  React.useEffect(() => {
14
- var _a, _b;
15
11
  if (!ref.current) {
16
12
  return () => { };
17
13
  }
18
- const svgElement = select(ref.current);
19
- const hoverOptions = (_b = (_a = seriesOptions.funnel) === null || _a === void 0 ? void 0 : _a.states) === null || _b === void 0 ? void 0 : _b.hover;
20
- svgElement.selectAll('*').remove();
21
- // funnel levels
22
- const cellsSelection = svgElement
23
- .selectAll('rect')
24
- .data(preparedData.items)
25
- .join('rect')
26
- .attr('x', (d) => d.x)
27
- .attr('y', (d) => d.y)
28
- .attr('height', (d) => d.height)
29
- .attr('width', (d) => d.width)
30
- .attr('fill', (d) => d.color)
31
- .attr('stroke', (d) => d.borderColor)
32
- .attr('stroke-width', (d) => d.borderWidth);
33
- // connectors
34
- const connectorAreaClassName = b('connector-area');
35
- svgElement
36
- .selectAll(`.${connectorAreaClassName}`)
37
- .data(preparedData.connectors)
38
- .join('path')
39
- .attr('d', (d) => d.areaPath.toString())
40
- .attr('class', connectorAreaClassName)
41
- .attr('fill', (d) => d.areaColor)
42
- .attr('opacity', (d) => d.areaOpacity);
43
- const connectorLineClassName = b('connector-line');
44
- const connectorLines = svgElement
45
- .selectAll(`.${connectorLineClassName}`)
46
- .data(preparedData.connectors)
47
- .join('g')
48
- .attr('class', connectorLineClassName)
49
- .attr('stroke', (d) => d.lineColor)
50
- .attr('stroke-width', (d) => d.lineWidth)
51
- .attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.lineWidth))
52
- .attr('fill', 'none')
53
- .attr('opacity', (d) => d.lineOpacity);
54
- connectorLines.append('path').attr('d', (d) => d.linePath[0].toString());
55
- connectorLines.append('path').attr('d', (d) => d.linePath[1].toString());
56
- // dataLabels
57
- svgElement
58
- .selectAll('text')
59
- .data(preparedData.svgLabels)
60
- .join('text')
61
- .html((d) => d.text)
62
- .attr('class', b('label'))
63
- .attr('x', (d) => d.x)
64
- .attr('y', (d) => d.y)
65
- .style('font-size', (d) => d.style.fontSize)
66
- .style('font-weight', (d) => d.style.fontWeight || null)
67
- .style('fill', (d) => d.style.fontColor || null);
68
- function handleShapeHover(data) {
69
- hoveredDataRef.current = data;
70
- const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
71
- if (hoverEnabled) {
72
- const hovered = data === null || data === void 0 ? void 0 : data.reduce((acc, d) => {
73
- acc.add(d.data);
74
- return acc;
75
- }, new Set());
76
- cellsSelection.attr('fill', (d) => {
77
- var _a;
78
- const fillColor = d.color;
79
- if (hovered === null || hovered === void 0 ? void 0 : hovered.has(d.data)) {
80
- return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) ||
81
- fillColor);
82
- }
83
- return fillColor;
84
- });
85
- }
86
- }
87
- if (hoveredDataRef.current !== null) {
88
- handleShapeHover(hoveredDataRef.current);
89
- }
90
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.funnel', handleShapeHover);
91
- return () => {
92
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.funnel', null);
93
- };
14
+ return renderFunnel({ plot: ref.current }, preparedData, seriesOptions, dispatcher);
94
15
  }, [dispatcher, preparedData, seriesOptions]);
95
16
  return (React.createElement(React.Fragment, null,
96
17
  React.createElement("g", { ref: ref, className: b() })));
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { Dispatch } from 'd3-dispatch';
3
- import type { PreparedSeriesOptions } from '../../useSeries/types';
4
- import type { PreparedHeatmapData } from './types';
5
- export { prepareHeatmapData } from './prepare-data';
6
- export * from './types';
3
+ import type { PreparedSeriesOptions } from '../../../core/series/types';
4
+ import type { PreparedHeatmapData } from '../../../core/shapes/heatmap/types';
5
+ export { prepareHeatmapData } from '../../../core/shapes/heatmap/prepare-data';
6
+ export * from '../../../core/shapes/heatmap/types';
7
7
  type Args = {
8
8
  htmlLayout: HTMLElement | null;
9
9
  preparedData: PreparedHeatmapData;