@gravity-ui/charts 1.51.0 → 1.51.3

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 (251) hide show
  1. package/dist/cjs/components/AxisY/utils.js +16 -4
  2. package/dist/cjs/components/index.js +25 -17
  3. package/dist/cjs/core/series/plugin.d.ts +14 -0
  4. package/dist/cjs/core/series/plugin.js +1 -0
  5. package/dist/cjs/core/series/prepareSeries.d.ts +3 -10
  6. package/dist/cjs/core/series/prepareSeries.js +3 -126
  7. package/dist/cjs/core/series/seriesRegistry.d.ts +3 -0
  8. package/dist/cjs/core/series/seriesRegistry.js +12 -0
  9. package/dist/cjs/core/shapes/area/get-tooltip-data.d.ts +3 -0
  10. package/dist/cjs/core/shapes/area/get-tooltip-data.js +19 -0
  11. package/dist/cjs/core/shapes/area/types.d.ts +3 -3
  12. package/dist/cjs/core/shapes/bar-x/get-tooltip-data.d.ts +3 -0
  13. package/dist/cjs/core/shapes/bar-x/get-tooltip-data.js +20 -0
  14. package/dist/cjs/core/shapes/bar-x/types.d.ts +3 -3
  15. package/dist/cjs/core/shapes/bar-y/get-tooltip-data.d.ts +3 -0
  16. package/dist/cjs/core/shapes/bar-y/get-tooltip-data.js +32 -0
  17. package/dist/cjs/core/shapes/bar-y/prepare-data.js +6 -6
  18. package/dist/cjs/core/shapes/bar-y/types.d.ts +3 -3
  19. package/dist/cjs/core/shapes/funnel/get-tooltip-data.d.ts +3 -0
  20. package/dist/cjs/core/shapes/funnel/get-tooltip-data.js +21 -0
  21. package/dist/cjs/core/shapes/funnel/prepare-data.js +6 -4
  22. package/dist/cjs/core/shapes/funnel/types.d.ts +3 -3
  23. package/dist/cjs/core/shapes/heatmap/get-tooltip-data.d.ts +3 -0
  24. package/dist/cjs/core/shapes/heatmap/get-tooltip-data.js +21 -0
  25. package/dist/cjs/core/shapes/heatmap/prepare-data.js +1 -1
  26. package/dist/cjs/core/shapes/heatmap/types.d.ts +3 -3
  27. package/dist/cjs/core/shapes/line/get-tooltip-data.d.ts +3 -0
  28. package/dist/cjs/core/shapes/line/get-tooltip-data.js +18 -0
  29. package/dist/cjs/core/shapes/line/types.d.ts +3 -3
  30. package/dist/cjs/core/shapes/pie/get-tooltip-data.d.ts +3 -0
  31. package/dist/cjs/core/shapes/pie/get-tooltip-data.js +27 -0
  32. package/dist/cjs/core/shapes/pie/types.d.ts +3 -3
  33. package/dist/cjs/core/shapes/radar/get-tooltip-data.d.ts +3 -0
  34. package/dist/cjs/core/shapes/radar/get-tooltip-data.js +35 -0
  35. package/dist/cjs/core/shapes/radar/types.d.ts +3 -3
  36. package/dist/cjs/core/shapes/sankey/get-tooltip-data.d.ts +3 -0
  37. package/dist/cjs/core/shapes/sankey/get-tooltip-data.js +32 -0
  38. package/dist/cjs/core/shapes/sankey/prepare-data.js +2 -2
  39. package/dist/cjs/core/shapes/sankey/types.d.ts +3 -3
  40. package/dist/cjs/core/shapes/scatter/get-tooltip-data.d.ts +3 -0
  41. package/dist/cjs/core/shapes/scatter/get-tooltip-data.js +19 -0
  42. package/dist/cjs/core/shapes/scatter/types.d.ts +2 -2
  43. package/dist/cjs/core/shapes/treemap/get-tooltip-data.d.ts +3 -0
  44. package/dist/cjs/core/shapes/treemap/get-tooltip-data.js +18 -0
  45. package/dist/cjs/core/shapes/treemap/prepare-data.js +3 -3
  46. package/dist/cjs/core/shapes/treemap/types.d.ts +3 -3
  47. package/dist/cjs/core/shapes/types.d.ts +4 -0
  48. package/dist/cjs/core/shapes/types.js +1 -0
  49. package/dist/cjs/core/shapes/waterfall/get-tooltip-data.d.ts +3 -0
  50. package/dist/cjs/core/shapes/waterfall/get-tooltip-data.js +15 -0
  51. package/dist/cjs/core/shapes/waterfall/prepare-data.js +1 -1
  52. package/dist/cjs/core/shapes/waterfall/types.d.ts +3 -3
  53. package/dist/cjs/core/shapes/x-range/get-tooltip-data.d.ts +3 -0
  54. package/dist/cjs/core/shapes/x-range/get-tooltip-data.js +22 -0
  55. package/dist/cjs/core/shapes/x-range/types.d.ts +3 -3
  56. package/dist/cjs/core/types/chart/funnel.d.ts +9 -4
  57. package/dist/cjs/core/utils/axis/x-axis.js +16 -4
  58. package/dist/cjs/core/utils/get-closest-data.d.ts +2 -11
  59. package/dist/cjs/core/utils/get-closest-data.js +47 -326
  60. package/dist/cjs/core/utils/tooltip-helpers.d.ts +43 -0
  61. package/dist/cjs/core/utils/tooltip-helpers.js +72 -0
  62. package/dist/cjs/hooks/useShapes/bar-y/index.js +1 -1
  63. package/dist/cjs/hooks/useShapes/heatmap/index.js +1 -1
  64. package/dist/cjs/hooks/useShapes/sankey/index.js +1 -1
  65. package/dist/cjs/hooks/useShapes/treemap/index.js +1 -1
  66. package/dist/cjs/hooks/useShapes/waterfall/index.js +1 -1
  67. package/dist/cjs/index.d.ts +1 -0
  68. package/dist/cjs/index.js +1 -0
  69. package/dist/cjs/plugins/area/index.d.ts +3 -0
  70. package/dist/cjs/plugins/area/index.js +5 -0
  71. package/dist/cjs/{core/series/prepare-area.d.ts → plugins/area/prepare.d.ts} +2 -2
  72. package/dist/cjs/{core/series/prepare-area.js → plugins/area/prepare.js} +4 -4
  73. package/dist/cjs/plugins/bar-x/index.d.ts +3 -0
  74. package/dist/cjs/plugins/bar-x/index.js +5 -0
  75. package/dist/{esm/core/series/prepare-bar-x.d.ts → cjs/plugins/bar-x/prepare.d.ts} +1 -1
  76. package/dist/{esm/core/series/prepare-bar-x.js → cjs/plugins/bar-x/prepare.js} +4 -4
  77. package/dist/cjs/plugins/bar-y/index.d.ts +3 -0
  78. package/dist/cjs/plugins/bar-y/index.js +5 -0
  79. package/dist/cjs/{core/series/prepare-bar-y.d.ts → plugins/bar-y/prepare.d.ts} +2 -2
  80. package/dist/cjs/{core/series/prepare-bar-y.js → plugins/bar-y/prepare.js} +4 -4
  81. package/dist/cjs/plugins/funnel/index.d.ts +3 -0
  82. package/dist/cjs/plugins/funnel/index.js +5 -0
  83. package/dist/cjs/{core/series/prepare-funnel.d.ts → plugins/funnel/prepare.d.ts} +2 -2
  84. package/dist/{esm/core/series/prepare-funnel.js → cjs/plugins/funnel/prepare.js} +15 -9
  85. package/dist/cjs/plugins/heatmap/index.d.ts +3 -0
  86. package/dist/cjs/plugins/heatmap/index.js +10 -0
  87. package/dist/{esm/core/series/prepare-heatmap.d.ts → cjs/plugins/heatmap/prepare.d.ts} +1 -1
  88. package/dist/{esm/core/series/prepare-heatmap.js → cjs/plugins/heatmap/prepare.js} +4 -4
  89. package/dist/cjs/plugins/index.d.ts +1 -0
  90. package/dist/cjs/plugins/index.js +27 -0
  91. package/dist/cjs/plugins/line/index.d.ts +3 -0
  92. package/dist/cjs/plugins/line/index.js +5 -0
  93. package/dist/cjs/{core/series/prepare-line.d.ts → plugins/line/prepare.d.ts} +2 -2
  94. package/dist/cjs/{core/series/prepare-line.js → plugins/line/prepare.js} +3 -3
  95. package/dist/cjs/plugins/pie/index.d.ts +3 -0
  96. package/dist/cjs/plugins/pie/index.js +5 -0
  97. package/dist/cjs/{core/series/prepare-pie.d.ts → plugins/pie/prepare.d.ts} +2 -2
  98. package/dist/cjs/plugins/pie/prepare.js +84 -0
  99. package/dist/cjs/plugins/radar/index.d.ts +3 -0
  100. package/dist/cjs/plugins/radar/index.js +5 -0
  101. package/dist/cjs/{core/series/prepare-radar.d.ts → plugins/radar/prepare.d.ts} +2 -2
  102. package/dist/cjs/{core/series/prepare-radar.js → plugins/radar/prepare.js} +4 -4
  103. package/dist/cjs/plugins/sankey/index.d.ts +3 -0
  104. package/dist/cjs/plugins/sankey/index.js +5 -0
  105. package/dist/cjs/{core/series/prepare-sankey.d.ts → plugins/sankey/prepare.d.ts} +1 -1
  106. package/dist/cjs/{core/series/prepare-sankey.js → plugins/sankey/prepare.js} +3 -3
  107. package/dist/cjs/plugins/scatter/index.d.ts +3 -0
  108. package/dist/cjs/plugins/scatter/index.js +10 -0
  109. package/dist/cjs/{core/series/prepare-scatter.d.ts → plugins/scatter/prepare.d.ts} +1 -1
  110. package/dist/{esm/core/series/prepare-scatter.js → cjs/plugins/scatter/prepare.js} +4 -4
  111. package/dist/cjs/plugins/treemap/index.d.ts +3 -0
  112. package/dist/cjs/plugins/treemap/index.js +5 -0
  113. package/dist/{esm/core/series/prepare-treemap.d.ts → cjs/plugins/treemap/prepare.d.ts} +1 -1
  114. package/dist/cjs/{core/series/prepare-treemap.js → plugins/treemap/prepare.js} +4 -4
  115. package/dist/cjs/plugins/waterfall/index.d.ts +3 -0
  116. package/dist/cjs/plugins/waterfall/index.js +5 -0
  117. package/dist/cjs/{core/series/prepare-waterfall.d.ts → plugins/waterfall/prepare.d.ts} +1 -1
  118. package/dist/{esm/core/series/prepare-waterfall.js → cjs/plugins/waterfall/prepare.js} +4 -4
  119. package/dist/cjs/plugins/x-range/index.d.ts +3 -0
  120. package/dist/cjs/plugins/x-range/index.js +5 -0
  121. package/dist/cjs/{core/series/prepare-x-range.d.ts → plugins/x-range/prepare.d.ts} +1 -1
  122. package/dist/cjs/{core/series/prepare-x-range.js → plugins/x-range/prepare.js} +4 -4
  123. package/dist/cjs/setup-jsdom.d.ts +1 -0
  124. package/dist/cjs/setup-jsdom.js +30 -4
  125. package/dist/esm/components/AxisY/utils.js +16 -4
  126. package/dist/esm/components/index.js +25 -17
  127. package/dist/esm/core/series/plugin.d.ts +14 -0
  128. package/dist/esm/core/series/plugin.js +1 -0
  129. package/dist/esm/core/series/prepareSeries.d.ts +3 -10
  130. package/dist/esm/core/series/prepareSeries.js +3 -126
  131. package/dist/esm/core/series/seriesRegistry.d.ts +3 -0
  132. package/dist/esm/core/series/seriesRegistry.js +12 -0
  133. package/dist/esm/core/shapes/area/get-tooltip-data.d.ts +3 -0
  134. package/dist/esm/core/shapes/area/get-tooltip-data.js +19 -0
  135. package/dist/esm/core/shapes/area/types.d.ts +3 -3
  136. package/dist/esm/core/shapes/bar-x/get-tooltip-data.d.ts +3 -0
  137. package/dist/esm/core/shapes/bar-x/get-tooltip-data.js +20 -0
  138. package/dist/esm/core/shapes/bar-x/types.d.ts +3 -3
  139. package/dist/esm/core/shapes/bar-y/get-tooltip-data.d.ts +3 -0
  140. package/dist/esm/core/shapes/bar-y/get-tooltip-data.js +32 -0
  141. package/dist/esm/core/shapes/bar-y/prepare-data.js +6 -6
  142. package/dist/esm/core/shapes/bar-y/types.d.ts +3 -3
  143. package/dist/esm/core/shapes/funnel/get-tooltip-data.d.ts +3 -0
  144. package/dist/esm/core/shapes/funnel/get-tooltip-data.js +21 -0
  145. package/dist/esm/core/shapes/funnel/prepare-data.js +6 -4
  146. package/dist/esm/core/shapes/funnel/types.d.ts +3 -3
  147. package/dist/esm/core/shapes/heatmap/get-tooltip-data.d.ts +3 -0
  148. package/dist/esm/core/shapes/heatmap/get-tooltip-data.js +21 -0
  149. package/dist/esm/core/shapes/heatmap/prepare-data.js +1 -1
  150. package/dist/esm/core/shapes/heatmap/types.d.ts +3 -3
  151. package/dist/esm/core/shapes/line/get-tooltip-data.d.ts +3 -0
  152. package/dist/esm/core/shapes/line/get-tooltip-data.js +18 -0
  153. package/dist/esm/core/shapes/line/types.d.ts +3 -3
  154. package/dist/esm/core/shapes/pie/get-tooltip-data.d.ts +3 -0
  155. package/dist/esm/core/shapes/pie/get-tooltip-data.js +27 -0
  156. package/dist/esm/core/shapes/pie/types.d.ts +3 -3
  157. package/dist/esm/core/shapes/radar/get-tooltip-data.d.ts +3 -0
  158. package/dist/esm/core/shapes/radar/get-tooltip-data.js +35 -0
  159. package/dist/esm/core/shapes/radar/types.d.ts +3 -3
  160. package/dist/esm/core/shapes/sankey/get-tooltip-data.d.ts +3 -0
  161. package/dist/esm/core/shapes/sankey/get-tooltip-data.js +32 -0
  162. package/dist/esm/core/shapes/sankey/prepare-data.js +2 -2
  163. package/dist/esm/core/shapes/sankey/types.d.ts +3 -3
  164. package/dist/esm/core/shapes/scatter/get-tooltip-data.d.ts +3 -0
  165. package/dist/esm/core/shapes/scatter/get-tooltip-data.js +19 -0
  166. package/dist/esm/core/shapes/scatter/types.d.ts +2 -2
  167. package/dist/esm/core/shapes/treemap/get-tooltip-data.d.ts +3 -0
  168. package/dist/esm/core/shapes/treemap/get-tooltip-data.js +18 -0
  169. package/dist/esm/core/shapes/treemap/prepare-data.js +3 -3
  170. package/dist/esm/core/shapes/treemap/types.d.ts +3 -3
  171. package/dist/esm/core/shapes/types.d.ts +4 -0
  172. package/dist/esm/core/shapes/types.js +1 -0
  173. package/dist/esm/core/shapes/waterfall/get-tooltip-data.d.ts +3 -0
  174. package/dist/esm/core/shapes/waterfall/get-tooltip-data.js +15 -0
  175. package/dist/esm/core/shapes/waterfall/prepare-data.js +1 -1
  176. package/dist/esm/core/shapes/waterfall/types.d.ts +3 -3
  177. package/dist/esm/core/shapes/x-range/get-tooltip-data.d.ts +3 -0
  178. package/dist/esm/core/shapes/x-range/get-tooltip-data.js +22 -0
  179. package/dist/esm/core/shapes/x-range/types.d.ts +3 -3
  180. package/dist/esm/core/types/chart/funnel.d.ts +9 -4
  181. package/dist/esm/core/utils/axis/x-axis.js +16 -4
  182. package/dist/esm/core/utils/get-closest-data.d.ts +2 -11
  183. package/dist/esm/core/utils/get-closest-data.js +47 -326
  184. package/dist/esm/core/utils/tooltip-helpers.d.ts +43 -0
  185. package/dist/esm/core/utils/tooltip-helpers.js +72 -0
  186. package/dist/esm/hooks/useShapes/bar-y/index.js +1 -1
  187. package/dist/esm/hooks/useShapes/heatmap/index.js +1 -1
  188. package/dist/esm/hooks/useShapes/sankey/index.js +1 -1
  189. package/dist/esm/hooks/useShapes/treemap/index.js +1 -1
  190. package/dist/esm/hooks/useShapes/waterfall/index.js +1 -1
  191. package/dist/esm/index.d.ts +1 -0
  192. package/dist/esm/index.js +1 -0
  193. package/dist/esm/plugins/area/index.d.ts +3 -0
  194. package/dist/esm/plugins/area/index.js +5 -0
  195. package/dist/esm/{core/series/prepare-area.d.ts → plugins/area/prepare.d.ts} +2 -2
  196. package/dist/esm/{core/series/prepare-area.js → plugins/area/prepare.js} +4 -4
  197. package/dist/esm/plugins/bar-x/index.d.ts +3 -0
  198. package/dist/esm/plugins/bar-x/index.js +5 -0
  199. package/dist/{cjs/core/series/prepare-bar-x.d.ts → esm/plugins/bar-x/prepare.d.ts} +1 -1
  200. package/dist/{cjs/core/series/prepare-bar-x.js → esm/plugins/bar-x/prepare.js} +4 -4
  201. package/dist/esm/plugins/bar-y/index.d.ts +3 -0
  202. package/dist/esm/plugins/bar-y/index.js +5 -0
  203. package/dist/esm/{core/series/prepare-bar-y.d.ts → plugins/bar-y/prepare.d.ts} +5 -5
  204. package/dist/esm/{core/series/prepare-bar-y.js → plugins/bar-y/prepare.js} +4 -4
  205. package/dist/esm/plugins/funnel/index.d.ts +3 -0
  206. package/dist/esm/plugins/funnel/index.js +5 -0
  207. package/dist/esm/{core/series/prepare-funnel.d.ts → plugins/funnel/prepare.d.ts} +2 -2
  208. package/dist/{cjs/core/series/prepare-funnel.js → esm/plugins/funnel/prepare.js} +15 -9
  209. package/dist/esm/plugins/heatmap/index.d.ts +3 -0
  210. package/dist/esm/plugins/heatmap/index.js +10 -0
  211. package/dist/{cjs/core/series/prepare-heatmap.d.ts → esm/plugins/heatmap/prepare.d.ts} +1 -1
  212. package/dist/{cjs/core/series/prepare-heatmap.js → esm/plugins/heatmap/prepare.js} +4 -4
  213. package/dist/esm/plugins/index.d.ts +1 -0
  214. package/dist/esm/plugins/index.js +27 -0
  215. package/dist/esm/plugins/line/index.d.ts +3 -0
  216. package/dist/esm/plugins/line/index.js +5 -0
  217. package/dist/esm/{core/series/prepare-line.d.ts → plugins/line/prepare.d.ts} +2 -2
  218. package/dist/esm/{core/series/prepare-line.js → plugins/line/prepare.js} +3 -3
  219. package/dist/esm/plugins/pie/index.d.ts +3 -0
  220. package/dist/esm/plugins/pie/index.js +5 -0
  221. package/dist/esm/{core/series/prepare-pie.d.ts → plugins/pie/prepare.d.ts} +2 -2
  222. package/dist/esm/plugins/pie/prepare.js +84 -0
  223. package/dist/esm/plugins/radar/index.d.ts +3 -0
  224. package/dist/esm/plugins/radar/index.js +5 -0
  225. package/dist/esm/{core/series/prepare-radar.d.ts → plugins/radar/prepare.d.ts} +2 -2
  226. package/dist/esm/{core/series/prepare-radar.js → plugins/radar/prepare.js} +4 -4
  227. package/dist/esm/plugins/sankey/index.d.ts +3 -0
  228. package/dist/esm/plugins/sankey/index.js +5 -0
  229. package/dist/esm/{core/series/prepare-sankey.d.ts → plugins/sankey/prepare.d.ts} +1 -1
  230. package/dist/esm/{core/series/prepare-sankey.js → plugins/sankey/prepare.js} +3 -3
  231. package/dist/esm/plugins/scatter/index.d.ts +3 -0
  232. package/dist/esm/plugins/scatter/index.js +10 -0
  233. package/dist/esm/{core/series/prepare-scatter.d.ts → plugins/scatter/prepare.d.ts} +1 -1
  234. package/dist/{cjs/core/series/prepare-scatter.js → esm/plugins/scatter/prepare.js} +4 -4
  235. package/dist/esm/plugins/treemap/index.d.ts +3 -0
  236. package/dist/esm/plugins/treemap/index.js +5 -0
  237. package/dist/{cjs/core/series/prepare-treemap.d.ts → esm/plugins/treemap/prepare.d.ts} +1 -1
  238. package/dist/esm/{core/series/prepare-treemap.js → plugins/treemap/prepare.js} +4 -4
  239. package/dist/esm/plugins/waterfall/index.d.ts +3 -0
  240. package/dist/esm/plugins/waterfall/index.js +5 -0
  241. package/dist/esm/{core/series/prepare-waterfall.d.ts → plugins/waterfall/prepare.d.ts} +1 -1
  242. package/dist/{cjs/core/series/prepare-waterfall.js → esm/plugins/waterfall/prepare.js} +4 -4
  243. package/dist/esm/plugins/x-range/index.d.ts +3 -0
  244. package/dist/esm/plugins/x-range/index.js +5 -0
  245. package/dist/esm/{core/series/prepare-x-range.d.ts → plugins/x-range/prepare.d.ts} +1 -1
  246. package/dist/esm/{core/series/prepare-x-range.js → plugins/x-range/prepare.js} +4 -4
  247. package/dist/esm/setup-jsdom.d.ts +1 -0
  248. package/dist/esm/setup-jsdom.js +30 -4
  249. package/package.json +3 -2
  250. package/dist/cjs/core/series/prepare-pie.js +0 -83
  251. package/dist/esm/core/series/prepare-pie.js +0 -83
@@ -1,6 +1,7 @@
1
- import type { HtmlItem, LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
1
+ import type { LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
2
2
  import type { DashStyle, LineCap, LineJoin } from '../../constants';
3
3
  import type { AnnotationAnchor, PreparedAnnotation, PreparedLineSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type PointData = {
5
6
  annotation?: PreparedAnnotation;
6
7
  color?: string;
@@ -29,9 +30,8 @@ export type PreparedLineData = {
29
30
  hovered: boolean;
30
31
  active: boolean;
31
32
  svgLabels: LabelData[];
32
- htmlLabels: HtmlItem[];
33
33
  color: string;
34
34
  dashStyle: DashStyle;
35
35
  linecap: LineCap;
36
36
  linejoin: LineJoin;
37
- } & Required<LineSeriesLineBaseStyle>;
37
+ } & Required<LineSeriesLineBaseStyle> & SeriesShapeData;
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedPieData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedPieData>): GetTooltipDataResult;
@@ -0,0 +1,27 @@
1
+ import { getRadius } from '../../utils/tooltip-helpers';
2
+ export function getTooltipData(args) {
3
+ const { data, position } = args;
4
+ const [pointerX, pointerY] = position;
5
+ const points = data.flatMap((d) => d.segments);
6
+ const closestPoint = points.find((p) => {
7
+ const { center } = p.data.pie;
8
+ const x = pointerX - center[0];
9
+ const y = pointerY - center[1];
10
+ let angle = Math.atan2(y, x) + 0.5 * Math.PI;
11
+ angle = angle < 0 ? Math.PI * 2 + angle : angle;
12
+ const polarRadius = getRadius({ center, pointer: [pointerX, pointerY] });
13
+ return angle >= p.startAngle && angle <= p.endAngle && polarRadius < p.data.radius;
14
+ });
15
+ if (!closestPoint) {
16
+ return { chunks: [] };
17
+ }
18
+ return {
19
+ chunks: [
20
+ {
21
+ data: closestPoint.data.series.data,
22
+ series: closestPoint.data.series,
23
+ closest: true,
24
+ },
25
+ ],
26
+ };
27
+ }
@@ -1,6 +1,7 @@
1
1
  import type { PieArcDatum } from 'd3-shape';
2
- import type { ConnectorCurve, HtmlItem, LabelData } from '../../../types';
2
+ import type { ConnectorCurve, LabelData } from '../../../types';
3
3
  import type { PreparedPieSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type SegmentData = {
5
6
  value: number;
6
7
  color: string;
@@ -37,5 +38,4 @@ export type PreparedPieData = {
37
38
  opacity: number;
38
39
  size: number;
39
40
  };
40
- htmlLabels: HtmlItem[];
41
- };
41
+ } & SeriesShapeData;
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedRadarData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedRadarData>): GetTooltipDataResult;
@@ -0,0 +1,35 @@
1
+ import { Delaunay } from 'd3-delaunay';
2
+ import { getRadius, isInsidePath } from '../../utils/tooltip-helpers';
3
+ export function getTooltipData(args) {
4
+ const { data, position, boundsWidth, boundsHeight } = args;
5
+ const [pointerX, pointerY] = position;
6
+ const [radarData] = data;
7
+ if (!radarData) {
8
+ return { chunks: [] };
9
+ }
10
+ const radius = getRadius({ center: radarData.center, pointer: [pointerX, pointerY] });
11
+ if (radius > radarData.radius) {
12
+ return { chunks: [] };
13
+ }
14
+ const radarShapes = radarData.shapes.filter((shape) => isInsidePath({
15
+ path: shape.path,
16
+ point: [pointerX, pointerY],
17
+ width: boundsWidth,
18
+ height: boundsHeight,
19
+ strokeWidth: shape.borderWidth,
20
+ }));
21
+ const points = radarShapes.flatMap((shape) => shape.points);
22
+ const delaunay = Delaunay.from(points, (d) => d.position[0], (d) => d.position[1]);
23
+ const closestPoint = points[delaunay.find(pointerX, pointerY)];
24
+ if (!closestPoint) {
25
+ return { chunks: [] };
26
+ }
27
+ return {
28
+ chunks: radarData.shapes.map((shape) => ({
29
+ data: shape.points[closestPoint.index].data,
30
+ series: shape.series,
31
+ category: shape.series.categories[closestPoint.index],
32
+ closest: shape.series === closestPoint.series,
33
+ })),
34
+ };
35
+ }
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, RadarSeriesData } from '../../../types';
1
+ import type { LabelData, RadarSeriesData } from '../../../types';
2
2
  import type { PreparedRadarSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type RadarLabelData = LabelData & {
4
5
  maxWidth: number;
5
6
  };
@@ -54,6 +55,5 @@ export type PreparedRadarData = {
54
55
  grid: RadarGridData[];
55
56
  center: [number, number];
56
57
  radius: number;
57
- htmlLabels: HtmlItem[];
58
58
  cursor: string | null;
59
- };
59
+ } & SeriesShapeData;
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedSankeyData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedSankeyData>): GetTooltipDataResult;
@@ -0,0 +1,32 @@
1
+ import { isInsidePath } from '../../utils/tooltip-helpers';
2
+ export function getTooltipData(args) {
3
+ const { data, position, boundsWidth, boundsHeight } = args;
4
+ const [pointerX, pointerY] = position;
5
+ const [sankeyData] = data;
6
+ if (!sankeyData) {
7
+ return { chunks: [] };
8
+ }
9
+ const closestLink = sankeyData.links.find((d) => {
10
+ var _a;
11
+ return isInsidePath({
12
+ path: (_a = d.path) !== null && _a !== void 0 ? _a : '',
13
+ strokeWidth: d.strokeWidth,
14
+ point: [pointerX, pointerY],
15
+ width: boundsWidth,
16
+ height: boundsHeight,
17
+ });
18
+ });
19
+ if (!closestLink) {
20
+ return { chunks: [] };
21
+ }
22
+ return {
23
+ chunks: [
24
+ {
25
+ data: closestLink.source,
26
+ target: closestLink.target,
27
+ series: sankeyData.series,
28
+ closest: true,
29
+ },
30
+ ],
31
+ };
32
+ }
@@ -2,7 +2,7 @@ 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;
5
- const htmlElements = [];
5
+ const htmlLabels = [];
6
6
  const sankeyGenerator = sankey()
7
7
  .nodeId((d) => d.name)
8
8
  .nodeSort((a, b) => { var _a, _b; return ((_a = a.index) !== null && _a !== void 0 ? _a : 0) - ((_b = b.index) !== null && _b !== void 0 ? _b : 0); })
@@ -70,5 +70,5 @@ export function prepareSankeyData(args) {
70
70
  });
71
71
  dataLabels.push(...labels);
72
72
  }
73
- return { series, nodes: sankeyNodes, links: sankeyLinks, htmlElements, labels: dataLabels };
73
+ return { series, nodes: sankeyNodes, links: sankeyLinks, htmlLabels, labels: dataLabels };
74
74
  }
@@ -1,5 +1,6 @@
1
- import type { BaseTextStyle, HtmlItem, SankeySeriesData } from '../../../types';
1
+ import type { BaseTextStyle, SankeySeriesData } from '../../../types';
2
2
  import type { PreparedSankeySeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type SankeyDataLabel = {
4
5
  text: string;
5
6
  x: number;
@@ -26,8 +27,7 @@ export type SankeyLink = {
26
27
  };
27
28
  export type PreparedSankeyData = {
28
29
  series: PreparedSankeySeries;
29
- htmlElements: HtmlItem[];
30
30
  nodes: SankeyNode[];
31
31
  links: SankeyLink[];
32
32
  labels: SankeyDataLabel[];
33
- };
33
+ } & SeriesShapeData;
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedScatterData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedScatterData>): GetTooltipDataResult;
@@ -0,0 +1,19 @@
1
+ import { Delaunay } from 'd3-delaunay';
2
+ export function getTooltipData(args) {
3
+ const { data, position } = args;
4
+ const [pointerX, pointerY] = position;
5
+ const delaunay = Delaunay.from(data, (d) => d.point.x, (d) => d.point.y);
6
+ const closestPoint = data[delaunay.find(pointerX, pointerY)];
7
+ if (!closestPoint) {
8
+ return { chunks: [] };
9
+ }
10
+ return {
11
+ chunks: [
12
+ {
13
+ data: closestPoint.point.data,
14
+ series: closestPoint.point.series,
15
+ closest: true,
16
+ },
17
+ ],
18
+ };
19
+ }
@@ -1,5 +1,6 @@
1
1
  import type { HtmlItem, LabelData, ScatterSeriesData } from '../../../types';
2
2
  import type { PreparedScatterSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  type PointData = {
4
5
  x: number;
5
6
  y: number;
@@ -19,6 +20,5 @@ export type PreparedScatterData = MarkerData;
19
20
  export type PreparedScatterShapeData = {
20
21
  markers: PreparedScatterData[];
21
22
  svgLabels: LabelData[];
22
- htmlLabels: HtmlItem[];
23
- };
23
+ } & SeriesShapeData;
24
24
  export {};
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedTreemapData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedTreemapData>): GetTooltipDataResult;
@@ -0,0 +1,18 @@
1
+ export function getTooltipData(args) {
2
+ var _a;
3
+ const { data, position } = args;
4
+ const [pointerX, pointerY] = position;
5
+ const closestPoint = (_a = data[0]) === null || _a === void 0 ? void 0 : _a.leaves.find((l) => pointerX >= l.x0 && pointerX <= l.x1 && pointerY >= l.y0 && pointerY <= l.y1);
6
+ if (!closestPoint) {
7
+ return { chunks: [] };
8
+ }
9
+ return {
10
+ chunks: [
11
+ {
12
+ data: closestPoint.data,
13
+ series: data[0].series,
14
+ closest: true,
15
+ },
16
+ ],
17
+ };
18
+ }
@@ -148,17 +148,17 @@ export async function prepareTreemapData(args) {
148
148
  })(hierarchy);
149
149
  const leaves = root.leaves();
150
150
  let labelData = [];
151
- const htmlElements = [];
151
+ const htmlLabels = [];
152
152
  if ((_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.enabled) {
153
153
  const { html, style: dataLabelsStyle } = series.dataLabels;
154
154
  const labels = await getLabels({ data: leaves, options: series.dataLabels });
155
155
  if (html) {
156
156
  const htmlItems = labels.map((l) => (Object.assign({ style: Object.assign(Object.assign({}, dataLabelsStyle), { maxWidth: l.size.width, maxHeight: l.size.height, overflow: 'hidden' }) }, l)));
157
- htmlElements.push(...htmlItems);
157
+ htmlLabels.push(...htmlItems);
158
158
  }
159
159
  else {
160
160
  labelData = labels;
161
161
  }
162
162
  }
163
- return { labelData, leaves, series, htmlElements };
163
+ return { labelData, leaves, series, htmlLabels };
164
164
  }
@@ -1,6 +1,7 @@
1
1
  import type { HierarchyRectangularNode } from 'd3-hierarchy';
2
- import type { HtmlItem, TreemapSeriesData } from '../../../types';
2
+ import type { TreemapSeriesData } from '../../../types';
3
3
  import type { PreparedTreemapSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type TreemapLabelData = {
5
6
  text: string;
6
7
  x: number;
@@ -11,5 +12,4 @@ export type PreparedTreemapData = {
11
12
  labelData: TreemapLabelData[];
12
13
  leaves: HierarchyRectangularNode<TreemapSeriesData<any>>[];
13
14
  series: PreparedTreemapSeries;
14
- htmlElements: HtmlItem[];
15
- };
15
+ } & SeriesShapeData;
@@ -0,0 +1,4 @@
1
+ import type { HtmlItem } from '../../types';
2
+ export interface SeriesShapeData {
3
+ htmlLabels: HtmlItem[];
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedWaterfallData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedWaterfallData>): GetTooltipDataResult;
@@ -0,0 +1,15 @@
1
+ import { getClosestPointsByXValue } from '../../utils/tooltip-helpers';
2
+ export function getTooltipData(args) {
3
+ const { data, position } = args;
4
+ const [pointerX, pointerY] = position;
5
+ const points = data.map((d) => ({
6
+ data: d.data,
7
+ series: d.series,
8
+ x: d.x + d.width / 2,
9
+ y0: d.y,
10
+ y1: d.y + d.height,
11
+ subTotal: d.subTotal,
12
+ }));
13
+ const chunks = getClosestPointsByXValue(pointerX, pointerY, points);
14
+ return { chunks };
15
+ }
@@ -144,7 +144,7 @@ export const prepareWaterfallData = async (args) => {
144
144
  data: item.data,
145
145
  series: item.series,
146
146
  subTotal: totalValue,
147
- htmlElements: [],
147
+ htmlLabels: [],
148
148
  };
149
149
  preparedData.label = await getLabelData(preparedData, plotHeight);
150
150
  result.push(preparedData);
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, WaterfallSeriesData } from '../../../types';
1
+ import type { LabelData, WaterfallSeriesData } from '../../../types';
2
2
  import type { PreparedWaterfallSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedWaterfallData = {
4
5
  x: number;
5
6
  y: number;
@@ -10,5 +11,4 @@ export type PreparedWaterfallData = {
10
11
  data: WaterfallSeriesData;
11
12
  label?: LabelData;
12
13
  subTotal: number;
13
- htmlElements: HtmlItem[];
14
- };
14
+ } & SeriesShapeData;
@@ -0,0 +1,3 @@
1
+ import type { GetTooltipDataArgs, GetTooltipDataResult } from '../../utils/tooltip-helpers';
2
+ import type { PreparedXRangeData } from './types';
3
+ export declare function getTooltipData(args: GetTooltipDataArgs<PreparedXRangeData>): GetTooltipDataResult;
@@ -0,0 +1,22 @@
1
+ import { sort } from 'd3-array';
2
+ export function getTooltipData(args) {
3
+ const { data, position } = args;
4
+ const [pointerX, pointerY] = position;
5
+ const pointsInRange = data.filter((d) => pointerX >= d.x &&
6
+ pointerX <= d.x + d.width &&
7
+ pointerY >= d.y &&
8
+ pointerY <= d.y + d.height);
9
+ if (pointsInRange.length === 0) {
10
+ return { chunks: [] };
11
+ }
12
+ const closestByX = pointsInRange.length === 1
13
+ ? pointsInRange[0]
14
+ : sort(pointsInRange, (d) => Math.abs(d.x + d.width / 2 - pointerX))[0];
15
+ return {
16
+ chunks: pointsInRange.map((d) => ({
17
+ data: d.data,
18
+ series: d.series,
19
+ closest: d === closestByX,
20
+ })),
21
+ };
22
+ }
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkXRange } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkXRange } from '../../../types';
2
2
  import type { PreparedXRangeSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
4
5
  x: number;
5
6
  y: number;
@@ -8,5 +9,4 @@ export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
8
9
  color: string;
9
10
  series: PreparedXRangeSeries;
10
11
  svgLabels: LabelData[];
11
- htmlLabels: HtmlItem[];
12
- };
12
+ } & SeriesShapeData;
@@ -34,18 +34,23 @@ export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataL
34
34
  * width alone, exaggerating differences between large and small values. Use only for
35
35
  * decorative purposes or when visual familiarity with the funnel metaphor is more
36
36
  * important than analytical precision.
37
- *
38
37
  * @default 'rectangle'
39
38
  */
40
39
  shape?: 'rectangle' | 'trapezoid';
41
40
  /** Lines or areas connecting the funnel segments. */
42
41
  connectors?: {
43
42
  enabled?: boolean;
44
- /** The height of the connector area relative to the funnel segment. */
43
+ /**
44
+ * The height of the connector area between funnel segments.
45
+ * Accepts a pixel number, a pixel string (e.g. `'10px'`), or a percentage string
46
+ * (e.g. `'25%'`) relative to the segment band height.
47
+ *
48
+ * Defaults to `0` for `'trapezoid'` and `'25%'` for `'rectangle'`.
49
+ */
45
50
  height?: string | number;
46
51
  /** Option for line stroke style */
47
52
  lineDashStyle?: DashStyle;
48
- /** Opacity for the connector line. */
53
+ /** Opacity for the connector line. Defaults to `0` for `'trapezoid'`, `1` for `'rectangle'`. */
49
54
  lineOpacity?: number;
50
55
  /** Connector line color. */
51
56
  lineColor?: string;
@@ -53,7 +58,7 @@ export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataL
53
58
  lineWidth?: number;
54
59
  /** Connector area color. */
55
60
  areaColor?: string;
56
- /** Opacity for the connector area. */
61
+ /** Opacity for the connector area fill. Defaults to `0` for `'trapezoid'`, `0.25` for `'rectangle'`. */
57
62
  areaOpacity?: number;
58
63
  };
59
64
  dataLabels?: Omit<BaseDataLabels, 'allowOverlap'> & {
@@ -55,8 +55,13 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
55
55
  let result = originalTickValues;
56
56
  let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
57
57
  let ticksCount = result.length - 1;
58
+ let lastMultiTickResult = result;
59
+ const triedCounts = new Set();
58
60
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
59
61
  ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
62
+ if (triedCounts.has(ticksCount))
63
+ break;
64
+ triedCounts.add(ticksCount);
60
65
  const newScaleTicks = getScaleTicks({ scale, ticksCount, dateTimeLabelFormats });
61
66
  result = newScaleTicks.map((t) => ({
62
67
  x: scale(t),
@@ -64,16 +69,23 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
64
69
  }));
65
70
  availableSpaceForLabel =
66
71
  getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
72
+ if (result.length > 1) {
73
+ lastMultiTickResult = result;
74
+ }
67
75
  }
68
76
  // when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
69
- // just thin out the originally proposed result
70
- if (!result.length) {
71
- result = originalTickValues;
77
+ // just thin out the last result that had multiple ticks
78
+ // For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
79
+ // so a sub-decade range legitimately yields 1 tick despite having room for more.
80
+ // For linear scales, 1 tick is a valid result meaning the chart is simply too small.
81
+ const isLogScale = axis.type === 'logarithmic';
82
+ if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
83
+ result = lastMultiTickResult;
72
84
  availableSpaceForLabel =
73
85
  getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
74
86
  let delta = 2;
75
87
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
76
- result = thinOut(result, delta);
88
+ result = thinOut(lastMultiTickResult, delta);
77
89
  if (result.length > 1) {
78
90
  delta += 1;
79
91
  availableSpaceForLabel =
@@ -1,19 +1,10 @@
1
1
  import type { ShapeData } from '../../hooks/useShapes';
2
- import type { ChartSeries, ChartSeriesData, TooltipDataChunk } from '../../types';
2
+ import type { TooltipDataChunk } from '../../types';
3
3
  type GetClosestPointsArgs = {
4
4
  position: [number, number];
5
5
  shapesData: ShapeData[];
6
6
  boundsHeight: number;
7
7
  boundsWidth: number;
8
8
  };
9
- export type ShapePoint = {
10
- x: number;
11
- y0: number;
12
- y1: number;
13
- data: ChartSeriesData;
14
- series: ChartSeries;
15
- subTotal?: number;
16
- sourceX?: number;
17
- };
9
+ export type { ShapePoint } from './tooltip-helpers';
18
10
  export declare function getClosestPoints(args: GetClosestPointsArgs): TooltipDataChunk[];
19
- export {};