@mui/x-charts 9.2.0 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/BarChart/BarChart.js +10 -10
  2. package/BarChart/BarChart.mjs +10 -10
  3. package/BarChart/BarElement.d.mts +3 -2
  4. package/BarChart/BarElement.d.ts +3 -2
  5. package/BarChart/BarLabel/BarLabelItem.d.mts +3 -2
  6. package/BarChart/BarLabel/BarLabelItem.d.ts +3 -2
  7. package/BarChart/seriesConfig/bar/extremums.js +7 -2
  8. package/BarChart/seriesConfig/bar/extremums.mjs +7 -2
  9. package/BarChart/seriesConfig/bar/getColor.js +7 -53
  10. package/BarChart/seriesConfig/bar/getColor.mjs +7 -53
  11. package/BarChart/seriesConfig/bar/seriesProcessor.js +3 -1
  12. package/BarChart/seriesConfig/bar/seriesProcessor.mjs +3 -1
  13. package/BarChart/seriesConfig/bar/tooltip.js +4 -27
  14. package/BarChart/seriesConfig/bar/tooltip.mjs +4 -27
  15. package/CHANGELOG.md +314 -0
  16. package/ChartsContainer/ChartsContainer.js +30 -9
  17. package/ChartsContainer/ChartsContainer.mjs +30 -9
  18. package/ChartsLabel/ChartsLabelMark.js +1 -23
  19. package/ChartsLabel/ChartsLabelMark.mjs +0 -22
  20. package/ChartsLabel/labelMarkClasses.d.mts +0 -1
  21. package/ChartsLabel/labelMarkClasses.d.ts +0 -1
  22. package/ChartsLabel/labelMarkClasses.js +1 -2
  23. package/ChartsLabel/labelMarkClasses.mjs +2 -2
  24. package/ChartsLayerContainer/ChartsLayerContainer.js +36 -30
  25. package/ChartsLayerContainer/ChartsLayerContainer.mjs +36 -30
  26. package/ChartsLegend/chartsLegend.types.d.mts +3 -2
  27. package/ChartsLegend/chartsLegend.types.d.ts +3 -2
  28. package/ChartsLegend/piecewiseColorLegendClasses.js +8 -2
  29. package/ChartsLegend/piecewiseColorLegendClasses.mjs +8 -2
  30. package/ChartsOverlay/ChartsOverlay.d.mts +5 -4
  31. package/ChartsOverlay/ChartsOverlay.d.ts +5 -4
  32. package/ChartsReferenceLine/ChartsXReferenceLine.js +6 -1
  33. package/ChartsReferenceLine/ChartsXReferenceLine.mjs +6 -1
  34. package/ChartsReferenceLine/ChartsYReferenceLine.js +5 -0
  35. package/ChartsReferenceLine/ChartsYReferenceLine.mjs +5 -0
  36. package/ChartsTooltip/ChartTooltip.types.d.mts +3 -2
  37. package/ChartsTooltip/ChartTooltip.types.d.ts +3 -2
  38. package/ChartsTooltip/useAxesTooltip.js +2 -2
  39. package/ChartsTooltip/useAxesTooltip.mjs +2 -2
  40. package/ChartsTooltip/useItemTooltip.js +2 -2
  41. package/ChartsTooltip/useItemTooltip.mjs +2 -2
  42. package/ChartsXAxis/ChartsXAxis.js +3 -1
  43. package/ChartsXAxis/ChartsXAxis.mjs +3 -1
  44. package/ChartsXAxis/useAxisTicksProps.d.mts +84 -3
  45. package/ChartsXAxis/useAxisTicksProps.d.ts +84 -3
  46. package/ChartsYAxis/ChartsYAxis.js +3 -1
  47. package/ChartsYAxis/ChartsYAxis.mjs +3 -1
  48. package/ChartsYAxis/useAxisTicksProps.d.mts +84 -3
  49. package/ChartsYAxis/useAxisTicksProps.d.ts +84 -3
  50. package/LineChart/AreaElement.d.mts +3 -2
  51. package/LineChart/AreaElement.d.ts +3 -2
  52. package/LineChart/LineChart.js +6 -6
  53. package/LineChart/LineChart.mjs +6 -6
  54. package/LineChart/LineElement.d.mts +3 -2
  55. package/LineChart/LineElement.d.ts +3 -2
  56. package/LineChart/LineHighlightPlot.d.mts +3 -2
  57. package/LineChart/LineHighlightPlot.d.ts +3 -2
  58. package/LineChart/LineHighlightPlot.js +65 -45
  59. package/LineChart/LineHighlightPlot.mjs +65 -45
  60. package/LineChart/MarkPlot.d.mts +3 -2
  61. package/LineChart/MarkPlot.d.ts +3 -2
  62. package/LineChart/seriesConfig/curveEvaluation.js +40 -15
  63. package/LineChart/seriesConfig/curveEvaluation.mjs +39 -15
  64. package/LineChart/seriesConfig/extremums.js +5 -1
  65. package/LineChart/seriesConfig/extremums.mjs +5 -1
  66. package/LineChart/seriesConfig/getColor.js +7 -54
  67. package/LineChart/seriesConfig/getColor.mjs +7 -54
  68. package/LineChart/seriesConfig/seriesProcessor.d.mts +2 -4
  69. package/LineChart/seriesConfig/seriesProcessor.d.ts +2 -4
  70. package/LineChart/seriesConfig/seriesProcessor.js +2 -139
  71. package/LineChart/seriesConfig/seriesProcessor.mjs +2 -138
  72. package/LineChart/seriesConfig/tooltip.js +4 -25
  73. package/LineChart/seriesConfig/tooltip.mjs +4 -25
  74. package/LineChart/useMarkPlotData.js +3 -1
  75. package/LineChart/useMarkPlotData.mjs +3 -1
  76. package/PieChart/PieArcLabelPlot.d.mts +3 -2
  77. package/PieChart/PieArcLabelPlot.d.ts +3 -2
  78. package/PieChart/PieArcPlot.d.mts +3 -2
  79. package/PieChart/PieArcPlot.d.ts +3 -2
  80. package/PieChart/PieChart.js +6 -6
  81. package/PieChart/PieChart.mjs +6 -6
  82. package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +2 -2
  83. package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +2 -2
  84. package/RadarChart/RadarAxis/useRadarAxis.js +1 -1
  85. package/RadarChart/RadarAxis/useRadarAxis.mjs +1 -1
  86. package/RadarChart/RadarChart.js +8 -8
  87. package/RadarChart/RadarChart.mjs +8 -8
  88. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
  89. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
  90. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +1 -0
  91. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +1 -0
  92. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -0
  93. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.mjs +1 -0
  94. package/ScatterChart/BatchScatter.d.mts +2 -8
  95. package/ScatterChart/BatchScatter.d.ts +2 -8
  96. package/ScatterChart/BatchScatter.js +17 -12
  97. package/ScatterChart/BatchScatter.mjs +17 -12
  98. package/ScatterChart/FocusedScatterMark.js +2 -2
  99. package/ScatterChart/FocusedScatterMark.mjs +2 -2
  100. package/ScatterChart/HighlightedScatterMark.js +3 -3
  101. package/ScatterChart/HighlightedScatterMark.mjs +3 -3
  102. package/ScatterChart/Scatter.d.mts +5 -0
  103. package/ScatterChart/Scatter.d.ts +5 -0
  104. package/ScatterChart/Scatter.js +7 -2
  105. package/ScatterChart/Scatter.mjs +7 -2
  106. package/ScatterChart/ScatterChart.d.mts +2 -1
  107. package/ScatterChart/ScatterChart.d.ts +2 -1
  108. package/ScatterChart/ScatterChart.js +32 -11
  109. package/ScatterChart/ScatterChart.mjs +32 -11
  110. package/ScatterChart/ScatterMarker.types.d.mts +3 -2
  111. package/ScatterChart/ScatterMarker.types.d.ts +3 -2
  112. package/ScatterChart/ScatterPlot.d.mts +3 -2
  113. package/ScatterChart/ScatterPlot.d.ts +3 -2
  114. package/ScatterChart/ScatterPlot.js +6 -1
  115. package/ScatterChart/ScatterPlot.mjs +6 -1
  116. package/ScatterChart/seriesConfig/extremums.js +6 -0
  117. package/ScatterChart/seriesConfig/extremums.mjs +6 -0
  118. package/ScatterChart/seriesConfig/getColor.js +1 -1
  119. package/ScatterChart/seriesConfig/getColor.mjs +1 -1
  120. package/ScatterChart/seriesConfig/getMarkerSize.d.mts +18 -0
  121. package/ScatterChart/seriesConfig/getMarkerSize.d.ts +18 -0
  122. package/ScatterChart/seriesConfig/getMarkerSize.js +43 -0
  123. package/ScatterChart/seriesConfig/getMarkerSize.mjs +37 -0
  124. package/ScatterChart/seriesConfig/seriesProcessor.js +23 -8
  125. package/ScatterChart/seriesConfig/seriesProcessor.mjs +23 -8
  126. package/ScatterChart/seriesConfig/tooltip.js +2 -24
  127. package/ScatterChart/seriesConfig/tooltip.mjs +2 -24
  128. package/ScatterChart/useScatterItemPosition.d.mts +4 -0
  129. package/ScatterChart/useScatterItemPosition.d.ts +4 -0
  130. package/ScatterChart/useScatterItemPosition.js +9 -0
  131. package/ScatterChart/useScatterItemPosition.mjs +8 -0
  132. package/SparkLineChart/SparkLineChart.js +27 -27
  133. package/SparkLineChart/SparkLineChart.mjs +27 -27
  134. package/Toolbar/Toolbar.types.d.mts +3 -2
  135. package/Toolbar/Toolbar.types.d.ts +3 -2
  136. package/index.js +1 -1
  137. package/index.mjs +1 -1
  138. package/internals/animation/animation.d.mts +1 -2
  139. package/internals/animation/animation.d.ts +1 -2
  140. package/internals/commonNextFocusItem.d.mts +10 -2
  141. package/internals/commonNextFocusItem.d.ts +10 -2
  142. package/internals/commonNextFocusItem.js +12 -4
  143. package/internals/commonNextFocusItem.mjs +12 -4
  144. package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +1 -1
  145. package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +1 -1
  146. package/internals/createCommonKeyboardFocusHandler.d.mts +1 -1
  147. package/internals/createCommonKeyboardFocusHandler.d.ts +1 -1
  148. package/internals/createCommonKeyboardFocusHandler.js +3 -3
  149. package/internals/createCommonKeyboardFocusHandler.mjs +3 -3
  150. package/internals/getLineLikeTooltip.d.mts +9 -0
  151. package/internals/getLineLikeTooltip.d.ts +9 -0
  152. package/internals/getLineLikeTooltip.js +38 -0
  153. package/internals/getLineLikeTooltip.mjs +31 -0
  154. package/internals/incompleteDatasetKeysError.d.mts +1 -0
  155. package/internals/incompleteDatasetKeysError.d.ts +1 -0
  156. package/internals/incompleteDatasetKeysError.js +11 -0
  157. package/internals/incompleteDatasetKeysError.mjs +4 -0
  158. package/internals/index.d.mts +5 -0
  159. package/internals/index.d.ts +5 -0
  160. package/internals/index.js +48 -0
  161. package/internals/index.mjs +5 -0
  162. package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.mts +4 -2
  163. package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.ts +4 -2
  164. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  165. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.mjs +4 -3
  166. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  167. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +3 -3
  168. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.mts +10 -1
  169. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +10 -1
  170. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +18 -1
  171. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.mjs +16 -0
  172. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -3
  173. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -3
  174. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +24 -5
  175. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.mjs +24 -5
  176. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.mts +1 -1
  177. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +1 -1
  178. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +46 -2
  179. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.mjs +47 -2
  180. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +46 -11
  181. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +46 -11
  182. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +2 -1
  183. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +2 -1
  184. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +6 -2
  185. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.mjs +6 -2
  186. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.mts +4 -0
  187. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +4 -0
  188. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +3 -1
  189. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.mjs +1 -0
  190. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +5 -3
  191. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +7 -5
  192. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +17 -3
  193. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.mjs +17 -3
  194. package/internals/processLineLikeSeries.d.mts +6 -0
  195. package/internals/processLineLikeSeries.d.ts +6 -0
  196. package/internals/processLineLikeSeries.js +145 -0
  197. package/internals/processLineLikeSeries.mjs +138 -0
  198. package/internals/resolveColorProcessor.d.mts +11 -0
  199. package/internals/resolveColorProcessor.d.ts +11 -0
  200. package/internals/resolveColorProcessor.js +62 -0
  201. package/internals/resolveColorProcessor.mjs +56 -0
  202. package/internals/sizeScale.d.mts +6 -0
  203. package/internals/sizeScale.d.ts +6 -0
  204. package/internals/sizeScale.js +46 -0
  205. package/internals/sizeScale.mjs +38 -0
  206. package/models/axis.d.mts +18 -12
  207. package/models/axis.d.ts +18 -12
  208. package/models/chartsSlotsComponentsProps.d.mts +25 -0
  209. package/models/chartsSlotsComponentsProps.d.ts +25 -0
  210. package/models/chartsSlotsComponentsProps.js +5 -0
  211. package/models/chartsSlotsComponentsProps.mjs +1 -0
  212. package/models/index.d.mts +1 -0
  213. package/models/index.d.ts +1 -0
  214. package/models/index.js +11 -0
  215. package/models/index.mjs +1 -0
  216. package/models/seriesType/line.d.mts +5 -2
  217. package/models/seriesType/line.d.ts +5 -2
  218. package/models/seriesType/scatter.d.mts +34 -2
  219. package/models/seriesType/scatter.d.ts +34 -2
  220. package/models/sizeMapping.d.mts +64 -0
  221. package/models/sizeMapping.d.ts +64 -0
  222. package/models/sizeMapping.js +5 -0
  223. package/models/sizeMapping.mjs +1 -0
  224. package/models/slots/chartsBaseSlots.d.mts +6 -5
  225. package/models/slots/chartsBaseSlots.d.ts +6 -5
  226. package/models/z-axis.d.mts +10 -1
  227. package/models/z-axis.d.ts +10 -1
  228. package/package.json +6 -6
@@ -24,6 +24,8 @@ var _domain = require("./domain");
24
24
  var _Flatbush = require("../../../Flatbush");
25
25
  var _useChartSeriesConfig = require("../../corePlugins/useChartSeriesConfig");
26
26
  var _useChartAxisExtrema = require("./useChartAxisExtrema.selectors");
27
+ var _useChartZAxis = require("../useChartZAxis");
28
+ var _getMarkerSize = _interopRequireDefault(require("../../../../ScatterChart/seriesConfig/getMarkerSize"));
27
29
  const createZoomMap = zoom => {
28
30
  const zoomItemMap = new Map();
29
31
  zoom.forEach(zoomItem => {
@@ -257,29 +259,46 @@ const selectorChartDefaultYAxisId = exports.selectorChartDefaultYAxisId = (0, _s
257
259
  const EMPTY_MAP = new Map();
258
260
  const selectorChartSeriesEmptyFlatbushMap = () => EMPTY_MAP;
259
261
  exports.selectorChartSeriesEmptyFlatbushMap = selectorChartSeriesEmptyFlatbushMap;
260
- const selectorChartSeriesFlatbushMap = exports.selectorChartSeriesFlatbushMap = (0, _store.createSelectorMemoized)(_useChartSeries.selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId, function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId) {
262
+ const selectorChartSeriesFlatbushMap = exports.selectorChartSeriesFlatbushMap = (0, _store.createSelectorMemoized)(_useChartSeries.selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId, _useChartZAxis.selectorChartZAxis, _useChartDimensions.selectorChartDrawingArea, function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId, zAxisState) {
261
263
  // FIXME: Do we want to support non-scatter series here?
262
264
  const validSeries = allSeries.scatter;
263
265
  const flatbushMap = new Map();
264
266
  if (!validSeries) {
265
267
  return flatbushMap;
266
268
  }
269
+ const zAxes = zAxisState?.axis ?? {};
270
+ const zAxisIds = zAxisState?.axisIds ?? [];
267
271
  validSeries.seriesOrder.forEach(seriesId => {
272
+ const series = validSeries.series[seriesId];
268
273
  const {
269
274
  data,
270
275
  xAxisId = defaultXAxisId,
271
276
  yAxisId = defaultYAxisId
272
- } = validSeries.series[seriesId];
277
+ } = series;
278
+ if (data.length === 0) {
279
+ return;
280
+ }
273
281
  const flatbush = new _Flatbush.Flatbush(data.length);
282
+ const sizeAxis = zAxes[series.sizeAxisId ?? zAxisIds[0]];
283
+ const isFixedSize = !sizeAxis || !sizeAxis.sizeScale;
284
+ const getItemRadius = isFixedSize ? series.markerSize ?? 0 : (0, _getMarkerSize.default)(series, sizeAxis);
285
+ let maxItemRadius = isFixedSize ? getItemRadius : 0;
274
286
  const originalXScale = xAxesScaleMap[xAxisId];
275
287
  const originalYScale = yAxesScaleMap[yAxisId];
276
- for (const datum of data) {
288
+ for (let i = 0; i < data.length; i += 1) {
289
+ if (!isFixedSize) {
290
+ maxItemRadius = Math.max(maxItemRadius, getItemRadius(i));
291
+ }
277
292
  // Add the points using a [0, 1] range so that we don't need to recreate the Flatbush structure when zooming.
278
293
  // This doesn't happen in practice, though, because currently the scales depend on the drawing area.
279
- flatbush.add(originalXScale(datum.x), originalYScale(datum.y));
294
+ flatbush.add(originalXScale(data[i].x), originalYScale(data[i].y));
280
295
  }
281
296
  flatbush.finish();
282
- flatbushMap.set(seriesId, flatbush);
297
+ flatbushMap.set(seriesId, {
298
+ flatbush,
299
+ getItemRadius,
300
+ maxItemRadius
301
+ });
283
302
  });
284
303
  return flatbushMap;
285
304
  });
@@ -17,6 +17,8 @@ import { calculateFinalDomain, computeAxisDomainsMap } from "./domain.mjs";
17
17
  import { Flatbush } from "../../../Flatbush.mjs";
18
18
  import { selectorChartSeriesConfig } from "../../corePlugins/useChartSeriesConfig/index.mjs";
19
19
  import { selectorChartXAxisExtrema, selectorChartYAxisExtrema } from "./useChartAxisExtrema.selectors.mjs";
20
+ import { selectorChartZAxis } from "../useChartZAxis/index.mjs";
21
+ import getMarkerSize from "../../../../ScatterChart/seriesConfig/getMarkerSize.mjs";
20
22
  export const createZoomMap = zoom => {
21
23
  const zoomItemMap = new Map();
22
24
  zoom.forEach(zoomItem => {
@@ -248,29 +250,46 @@ export const selectorChartDefaultXAxisId = createSelector(selectorChartRawXAxis,
248
250
  export const selectorChartDefaultYAxisId = createSelector(selectorChartRawYAxis, yAxes => yAxes[0].id);
249
251
  const EMPTY_MAP = new Map();
250
252
  export const selectorChartSeriesEmptyFlatbushMap = () => EMPTY_MAP;
251
- export const selectorChartSeriesFlatbushMap = createSelectorMemoized(selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId, function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId) {
253
+ export const selectorChartSeriesFlatbushMap = createSelectorMemoized(selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId, selectorChartZAxis, selectorChartDrawingArea, function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId, zAxisState) {
252
254
  // FIXME: Do we want to support non-scatter series here?
253
255
  const validSeries = allSeries.scatter;
254
256
  const flatbushMap = new Map();
255
257
  if (!validSeries) {
256
258
  return flatbushMap;
257
259
  }
260
+ const zAxes = zAxisState?.axis ?? {};
261
+ const zAxisIds = zAxisState?.axisIds ?? [];
258
262
  validSeries.seriesOrder.forEach(seriesId => {
263
+ const series = validSeries.series[seriesId];
259
264
  const {
260
265
  data,
261
266
  xAxisId = defaultXAxisId,
262
267
  yAxisId = defaultYAxisId
263
- } = validSeries.series[seriesId];
268
+ } = series;
269
+ if (data.length === 0) {
270
+ return;
271
+ }
264
272
  const flatbush = new Flatbush(data.length);
273
+ const sizeAxis = zAxes[series.sizeAxisId ?? zAxisIds[0]];
274
+ const isFixedSize = !sizeAxis || !sizeAxis.sizeScale;
275
+ const getItemRadius = isFixedSize ? series.markerSize ?? 0 : getMarkerSize(series, sizeAxis);
276
+ let maxItemRadius = isFixedSize ? getItemRadius : 0;
265
277
  const originalXScale = xAxesScaleMap[xAxisId];
266
278
  const originalYScale = yAxesScaleMap[yAxisId];
267
- for (const datum of data) {
279
+ for (let i = 0; i < data.length; i += 1) {
280
+ if (!isFixedSize) {
281
+ maxItemRadius = Math.max(maxItemRadius, getItemRadius(i));
282
+ }
268
283
  // Add the points using a [0, 1] range so that we don't need to recreate the Flatbush structure when zooming.
269
284
  // This doesn't happen in practice, though, because currently the scales depend on the drawing area.
270
- flatbush.add(originalXScale(datum.x), originalYScale(datum.y));
285
+ flatbush.add(originalXScale(data[i].x), originalYScale(data[i].y));
271
286
  }
272
287
  flatbush.finish();
273
- flatbushMap.set(seriesId, flatbush);
288
+ flatbushMap.set(seriesId, {
289
+ flatbush,
290
+ getItemRadius,
291
+ maxItemRadius
292
+ });
274
293
  });
275
294
  return flatbushMap;
276
295
  });
@@ -1,4 +1,4 @@
1
1
  import { type ScatterValueType } from "../../../../models/seriesType/scatter.mjs";
2
2
  import { type Flatbush } from "../../../Flatbush.mjs";
3
3
  import { type D3Scale } from "../../../../models/axis.mjs";
4
- export declare function findClosestPoints(flatbush: Flatbush, seriesData: readonly ScatterValueType[], xScale: D3Scale, yScale: D3Scale, xZoomStart: number, xZoomEnd: number, yZoomStart: number, yZoomEnd: number, svgPointX: number, svgPointY: number, maxRadius?: number, maxResults?: number): number[];
4
+ export declare function findClosestPoints(flatbush: Flatbush, seriesData: readonly ScatterValueType[], xScale: D3Scale, yScale: D3Scale, xZoomStart: number, xZoomEnd: number, yZoomStart: number, yZoomEnd: number, svgPointX: number, svgPointY: number, maxRadius?: number, maxResults?: number, getItemRadius?: number | ((dataIndex: number) => number)): number[];
@@ -1,4 +1,4 @@
1
1
  import { type ScatterValueType } from "../../../../models/seriesType/scatter.js";
2
2
  import { type Flatbush } from "../../../Flatbush.js";
3
3
  import { type D3Scale } from "../../../../models/axis.js";
4
- export declare function findClosestPoints(flatbush: Flatbush, seriesData: readonly ScatterValueType[], xScale: D3Scale, yScale: D3Scale, xZoomStart: number, xZoomEnd: number, yZoomStart: number, yZoomEnd: number, svgPointX: number, svgPointY: number, maxRadius?: number, maxResults?: number): number[];
4
+ export declare function findClosestPoints(flatbush: Flatbush, seriesData: readonly ScatterValueType[], xScale: D3Scale, yScale: D3Scale, xZoomStart: number, xZoomEnd: number, yZoomStart: number, yZoomEnd: number, svgPointX: number, svgPointY: number, maxRadius?: number, maxResults?: number, getItemRadius?: number | ((dataIndex: number) => number)): number[];
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.findClosestPoints = findClosestPoints;
7
7
  var _scaleGuards = require("../../../scaleGuards");
8
- function findClosestPoints(flatbush, seriesData, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPointX, svgPointY, maxRadius = Infinity, maxResults = 1) {
8
+ // Arbitrary large number to be sure we don't pull the entire dataset from flatbush when radius is not fixed.
9
+ const LARGE_NUMBER = 50;
10
+ function findClosestPoints(flatbush, seriesData, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPointX, svgPointY, maxRadius = Infinity, maxResults = 1, getItemRadius = 0) {
9
11
  const originalXScale = xScale.copy();
10
12
  const originalYScale = yScale.copy();
11
13
  originalXScale.range([0, 1]);
@@ -28,7 +30,49 @@ function findClosestPoints(flatbush, seriesData, xScale, yScale, xZoomStart, xZo
28
30
  }
29
31
  const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex]?.x));
30
32
  const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex]?.y));
31
- return flatbush.neighbors(pointX, pointY, maxResults, maxRadius != null ? maxRadius * maxRadius : Infinity, excludeIfOutsideDrawingArea, sqDistFn);
33
+ if (pointX === undefined || pointY === undefined) {
34
+ return [];
35
+ }
36
+ const withFixRadius = typeof getItemRadius === 'number';
37
+ const maxRadiusSq = Number.isFinite(maxRadius) ? maxRadius * maxRadius : Infinity;
38
+
39
+ // Pull every candidate whose lower-bound (box) distance is within the hit threshold.
40
+ // Any unpulled point j has box-dist > maxRadius, hence center-dist ≥ box-dist > maxRadius,
41
+ // so it cannot be a hit. We re-rank by true edge distance below.
42
+ const candidates = flatbush.neighbors(pointX, pointY, withFixRadius ? maxResults : LARGE_NUMBER, maxRadiusSq, excludeIfOutsideDrawingArea, sqDistFn);
43
+ if (withFixRadius) {
44
+ // If radius is constant, we can skip the expensive edge-distance calculation and return candidates in box-distance order.
45
+ return candidates;
46
+ }
47
+
48
+ // Re-rank by true (signed) edge distance. Negative values mean the cursor is inside
49
+ // the marker — those win over any outside marker, with deeper containment ranked first.
50
+ let ranked = [];
51
+ for (const i of candidates) {
52
+ const cx = originalXScale(seriesData[i].x);
53
+ const cy = originalYScale(seriesData[i].y);
54
+ const centerDistSq = sqDistFn(cx - pointX, cy - pointY);
55
+ // Preserve the existing hit-area semantics: hit means center distance ≤ maxRadius.
56
+ if (centerDistSq > maxRadiusSq) {
57
+ continue;
58
+ }
59
+ const edge = Math.sqrt(centerDistSq) - getItemRadius(i);
60
+ ranked.push({
61
+ index: i,
62
+ edge,
63
+ centerDistSq
64
+ });
65
+ }
66
+ ranked.sort((a, b) => a.edge - b.edge);
67
+
68
+ // The pointer is inside multiple marks, we sort them by distance to the center. Priority is
69
+ // 1. marks that are under the pointer (negative edge distance) sorted by distance to the center
70
+ // 2. marks that are outside the pointer (positive edge distance) by distance to the edge
71
+ const splitIndex = ranked.findLastIndex(d => d.edge < 0);
72
+ if (splitIndex !== -1) {
73
+ ranked = [...ranked.slice(0, splitIndex + 1).sort((a, b) => a.centerDistSq - b.centerDistSq), ...ranked.slice(splitIndex + 1)];
74
+ }
75
+ return ranked.slice(0, Math.min(ranked.length, maxResults)).map(d => d.index);
32
76
  }
33
77
  function invertScale(scale, value, getDataPoint) {
34
78
  if ((0, _scaleGuards.isOrdinalScale)(scale)) {
@@ -1,5 +1,8 @@
1
1
  import { isOrdinalScale } from "../../../scaleGuards.mjs";
2
- export function findClosestPoints(flatbush, seriesData, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPointX, svgPointY, maxRadius = Infinity, maxResults = 1) {
2
+
3
+ // Arbitrary large number to be sure we don't pull the entire dataset from flatbush when radius is not fixed.
4
+ const LARGE_NUMBER = 50;
5
+ export function findClosestPoints(flatbush, seriesData, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPointX, svgPointY, maxRadius = Infinity, maxResults = 1, getItemRadius = 0) {
3
6
  const originalXScale = xScale.copy();
4
7
  const originalYScale = yScale.copy();
5
8
  originalXScale.range([0, 1]);
@@ -22,7 +25,49 @@ export function findClosestPoints(flatbush, seriesData, xScale, yScale, xZoomSta
22
25
  }
23
26
  const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex]?.x));
24
27
  const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex]?.y));
25
- return flatbush.neighbors(pointX, pointY, maxResults, maxRadius != null ? maxRadius * maxRadius : Infinity, excludeIfOutsideDrawingArea, sqDistFn);
28
+ if (pointX === undefined || pointY === undefined) {
29
+ return [];
30
+ }
31
+ const withFixRadius = typeof getItemRadius === 'number';
32
+ const maxRadiusSq = Number.isFinite(maxRadius) ? maxRadius * maxRadius : Infinity;
33
+
34
+ // Pull every candidate whose lower-bound (box) distance is within the hit threshold.
35
+ // Any unpulled point j has box-dist > maxRadius, hence center-dist ≥ box-dist > maxRadius,
36
+ // so it cannot be a hit. We re-rank by true edge distance below.
37
+ const candidates = flatbush.neighbors(pointX, pointY, withFixRadius ? maxResults : LARGE_NUMBER, maxRadiusSq, excludeIfOutsideDrawingArea, sqDistFn);
38
+ if (withFixRadius) {
39
+ // If radius is constant, we can skip the expensive edge-distance calculation and return candidates in box-distance order.
40
+ return candidates;
41
+ }
42
+
43
+ // Re-rank by true (signed) edge distance. Negative values mean the cursor is inside
44
+ // the marker — those win over any outside marker, with deeper containment ranked first.
45
+ let ranked = [];
46
+ for (const i of candidates) {
47
+ const cx = originalXScale(seriesData[i].x);
48
+ const cy = originalYScale(seriesData[i].y);
49
+ const centerDistSq = sqDistFn(cx - pointX, cy - pointY);
50
+ // Preserve the existing hit-area semantics: hit means center distance ≤ maxRadius.
51
+ if (centerDistSq > maxRadiusSq) {
52
+ continue;
53
+ }
54
+ const edge = Math.sqrt(centerDistSq) - getItemRadius(i);
55
+ ranked.push({
56
+ index: i,
57
+ edge,
58
+ centerDistSq
59
+ });
60
+ }
61
+ ranked.sort((a, b) => a.edge - b.edge);
62
+
63
+ // The pointer is inside multiple marks, we sort them by distance to the center. Priority is
64
+ // 1. marks that are under the pointer (negative edge distance) sorted by distance to the center
65
+ // 2. marks that are outside the pointer (positive edge distance) by distance to the edge
66
+ const splitIndex = ranked.findLastIndex(d => d.edge < 0);
67
+ if (splitIndex !== -1) {
68
+ ranked = [...ranked.slice(0, splitIndex + 1).sort((a, b) => a.centerDistSq - b.centerDistSq), ...ranked.slice(splitIndex + 1)];
69
+ }
70
+ return ranked.slice(0, Math.min(ranked.length, maxResults)).map(d => d.index);
26
71
  }
27
72
  function invertScale(scale, value, getDataPoint) {
28
73
  if (isOrdinalScale(scale)) {
@@ -15,6 +15,29 @@ var _getChartPoint = require("../../../getChartPoint");
15
15
  var _useChartCartesianAxis = require("../useChartCartesianAxis");
16
16
  var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
17
17
  var _findClosestPoints = require("./findClosestPoints");
18
+ /**
19
+ * Return `true` if the candidate point is closer to the pointer than the current closest point.
20
+ * By priority we prefer:
21
+ * 1. points that are under the pointer (negative edge distance) sorted by distance to the center.
22
+ * 2. points that are outside the pointer (positive edge distance) by distance to the edge.
23
+ */
24
+ function isCloser(candidatePoint, currentClosestPoint) {
25
+ if (currentClosestPoint === undefined) {
26
+ return true;
27
+ }
28
+ if (candidatePoint.edgeDistance <= 0) {
29
+ if (currentClosestPoint.edgeDistance > 0) {
30
+ return true;
31
+ }
32
+ const candidateDistance = candidatePoint.edgeDistance + candidatePoint.radius;
33
+ const currentDistance = currentClosestPoint.edgeDistance + currentClosestPoint.radius;
34
+ return candidateDistance < currentDistance;
35
+ }
36
+ if (currentClosestPoint.edgeDistance <= 0) {
37
+ return false;
38
+ }
39
+ return candidatePoint.edgeDistance < currentClosestPoint.edgeDistance;
40
+ }
18
41
  const useChartClosestPoint = ({
19
42
  params,
20
43
  store,
@@ -65,35 +88,47 @@ const useChartClosestPoint = ({
65
88
  let closestPoint = undefined;
66
89
  for (const seriesId of seriesOrder ?? []) {
67
90
  const aSeries = (series ?? {})[seriesId];
68
- const flatbush = flatbushMap.get(seriesId);
69
- if (!flatbush) {
91
+ const entry = flatbushMap.get(seriesId);
92
+ if (!entry || aSeries.hidden) {
70
93
  continue;
71
94
  }
95
+ const {
96
+ flatbush,
97
+ getItemRadius,
98
+ maxItemRadius
99
+ } = entry;
72
100
  const xAxisId = aSeries.xAxisId ?? defaultXAxisId;
73
101
  const yAxisId = aSeries.yAxisId ?? defaultYAxisId;
74
102
  const xAxisZoom = (0, _useChartCartesianAxis.selectorChartAxisZoomData)(store.state, xAxisId);
75
103
  const yAxisZoom = (0, _useChartCartesianAxis.selectorChartAxisZoomData)(store.state, yAxisId);
76
- const maxRadius = resolvedHitAreaRadius === 'item' ? aSeries.markerSize : resolvedHitAreaRadius;
104
+ const maxRadius = resolvedHitAreaRadius === 'item' ? maxItemRadius : resolvedHitAreaRadius;
77
105
  const xZoomStart = (xAxisZoom?.start ?? 0) / 100;
78
106
  const xZoomEnd = (xAxisZoom?.end ?? 100) / 100;
79
107
  const yZoomStart = (yAxisZoom?.start ?? 0) / 100;
80
108
  const yZoomEnd = (yAxisZoom?.end ?? 100) / 100;
81
109
  const xScale = xAxis[xAxisId].scale;
82
110
  const yScale = yAxis[yAxisId].scale;
83
- const closestPointIndex = (0, _findClosestPoints.findClosestPoints)(flatbush, aSeries.data, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPoint.x, svgPoint.y, maxRadius)[0];
111
+ const closestPointIndex = (0, _findClosestPoints.findClosestPoints)(flatbush, aSeries.data, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPoint.x, svgPoint.y, maxRadius, 1, getItemRadius)[0];
84
112
  if (closestPointIndex === undefined) {
85
113
  continue;
86
114
  }
87
115
  const point = aSeries.data[closestPointIndex];
88
116
  const scaledX = xScale(point.x);
89
117
  const scaledY = yScale(point.y);
90
- const distSq = (scaledX - svgPoint.x) ** 2 + (scaledY - svgPoint.y) ** 2;
91
- if (closestPoint === undefined || distSq < closestPoint.distanceSq) {
92
- closestPoint = {
93
- dataIndex: closestPointIndex,
94
- seriesId,
95
- distanceSq: distSq
96
- };
118
+ const centerDist = Math.hypot(scaledX - svgPoint.x, scaledY - svgPoint.y);
119
+ const closestPointRadius = typeof getItemRadius === 'number' ? getItemRadius : getItemRadius(closestPointIndex);
120
+ const edgeDistance = centerDist - closestPointRadius;
121
+ if (resolvedHitAreaRadius === 'item' && edgeDistance > 0) {
122
+ continue;
123
+ }
124
+ const newPoint = {
125
+ dataIndex: closestPointIndex,
126
+ seriesId,
127
+ edgeDistance,
128
+ radius: closestPointRadius
129
+ };
130
+ if (isCloser(newPoint, closestPoint)) {
131
+ closestPoint = newPoint;
97
132
  }
98
133
  }
99
134
  if (closestPoint === undefined) {
@@ -8,6 +8,29 @@ import { getChartPoint } from "../../../getChartPoint.mjs";
8
8
  import { selectorChartAxisZoomData, selectorChartSeriesEmptyFlatbushMap, selectorChartSeriesFlatbushMap, selectorChartXAxis, selectorChartYAxis, selectorChartZoomIsInteracting } from "../useChartCartesianAxis/index.mjs";
9
9
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.mjs";
10
10
  import { findClosestPoints } from "./findClosestPoints.mjs";
11
+ /**
12
+ * Return `true` if the candidate point is closer to the pointer than the current closest point.
13
+ * By priority we prefer:
14
+ * 1. points that are under the pointer (negative edge distance) sorted by distance to the center.
15
+ * 2. points that are outside the pointer (positive edge distance) by distance to the edge.
16
+ */
17
+ function isCloser(candidatePoint, currentClosestPoint) {
18
+ if (currentClosestPoint === undefined) {
19
+ return true;
20
+ }
21
+ if (candidatePoint.edgeDistance <= 0) {
22
+ if (currentClosestPoint.edgeDistance > 0) {
23
+ return true;
24
+ }
25
+ const candidateDistance = candidatePoint.edgeDistance + candidatePoint.radius;
26
+ const currentDistance = currentClosestPoint.edgeDistance + currentClosestPoint.radius;
27
+ return candidateDistance < currentDistance;
28
+ }
29
+ if (currentClosestPoint.edgeDistance <= 0) {
30
+ return false;
31
+ }
32
+ return candidatePoint.edgeDistance < currentClosestPoint.edgeDistance;
33
+ }
11
34
  export const useChartClosestPoint = ({
12
35
  params,
13
36
  store,
@@ -58,35 +81,47 @@ export const useChartClosestPoint = ({
58
81
  let closestPoint = undefined;
59
82
  for (const seriesId of seriesOrder ?? []) {
60
83
  const aSeries = (series ?? {})[seriesId];
61
- const flatbush = flatbushMap.get(seriesId);
62
- if (!flatbush) {
84
+ const entry = flatbushMap.get(seriesId);
85
+ if (!entry || aSeries.hidden) {
63
86
  continue;
64
87
  }
88
+ const {
89
+ flatbush,
90
+ getItemRadius,
91
+ maxItemRadius
92
+ } = entry;
65
93
  const xAxisId = aSeries.xAxisId ?? defaultXAxisId;
66
94
  const yAxisId = aSeries.yAxisId ?? defaultYAxisId;
67
95
  const xAxisZoom = selectorChartAxisZoomData(store.state, xAxisId);
68
96
  const yAxisZoom = selectorChartAxisZoomData(store.state, yAxisId);
69
- const maxRadius = resolvedHitAreaRadius === 'item' ? aSeries.markerSize : resolvedHitAreaRadius;
97
+ const maxRadius = resolvedHitAreaRadius === 'item' ? maxItemRadius : resolvedHitAreaRadius;
70
98
  const xZoomStart = (xAxisZoom?.start ?? 0) / 100;
71
99
  const xZoomEnd = (xAxisZoom?.end ?? 100) / 100;
72
100
  const yZoomStart = (yAxisZoom?.start ?? 0) / 100;
73
101
  const yZoomEnd = (yAxisZoom?.end ?? 100) / 100;
74
102
  const xScale = xAxis[xAxisId].scale;
75
103
  const yScale = yAxis[yAxisId].scale;
76
- const closestPointIndex = findClosestPoints(flatbush, aSeries.data, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPoint.x, svgPoint.y, maxRadius)[0];
104
+ const closestPointIndex = findClosestPoints(flatbush, aSeries.data, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPoint.x, svgPoint.y, maxRadius, 1, getItemRadius)[0];
77
105
  if (closestPointIndex === undefined) {
78
106
  continue;
79
107
  }
80
108
  const point = aSeries.data[closestPointIndex];
81
109
  const scaledX = xScale(point.x);
82
110
  const scaledY = yScale(point.y);
83
- const distSq = (scaledX - svgPoint.x) ** 2 + (scaledY - svgPoint.y) ** 2;
84
- if (closestPoint === undefined || distSq < closestPoint.distanceSq) {
85
- closestPoint = {
86
- dataIndex: closestPointIndex,
87
- seriesId,
88
- distanceSq: distSq
89
- };
111
+ const centerDist = Math.hypot(scaledX - svgPoint.x, scaledY - svgPoint.y);
112
+ const closestPointRadius = typeof getItemRadius === 'number' ? getItemRadius : getItemRadius(closestPointIndex);
113
+ const edgeDistance = centerDist - closestPointRadius;
114
+ if (resolvedHitAreaRadius === 'item' && edgeDistance > 0) {
115
+ continue;
116
+ }
117
+ const newPoint = {
118
+ dataIndex: closestPointIndex,
119
+ seriesId,
120
+ edgeDistance,
121
+ radius: closestPointRadius
122
+ };
123
+ if (isCloser(newPoint, closestPoint)) {
124
+ closestPoint = newPoint;
90
125
  }
91
126
  }
92
127
  if (closestPoint === undefined) {
@@ -6,6 +6,7 @@ import { type UseChartCartesianAxisSignature } from "../useChartCartesianAxis/in
6
6
  import { type UseChartHighlightSignature } from "../useChartHighlight/index.mjs";
7
7
  import { type UseChartInteractionSignature } from "../useChartInteraction/index.mjs";
8
8
  import { type UseChartTooltipSignature } from "../useChartTooltip/index.mjs";
9
+ import { type UseChartZAxisSignature } from "../useChartZAxis/index.mjs";
9
10
  export interface UseChartVoronoiInstance {
10
11
  /**
11
12
  * Enable the voronoi computation.
@@ -51,5 +52,5 @@ export type UseChartClosestPointSignature<SeriesType extends ChartSeriesType = C
51
52
  params: UseChartVoronoiParameters;
52
53
  defaultizedParams: UseChartVoronoiDefaultizedParameters;
53
54
  dependencies: [UseChartSeriesSignature, UseChartCartesianAxisSignature];
54
- optionalDependencies: [UseChartInteractionSignature, UseChartHighlightSignature<SeriesType>, UseChartTooltipSignature];
55
+ optionalDependencies: [UseChartInteractionSignature, UseChartHighlightSignature<SeriesType>, UseChartTooltipSignature, UseChartZAxisSignature];
55
56
  }>;
@@ -6,6 +6,7 @@ import { type UseChartCartesianAxisSignature } from "../useChartCartesianAxis/in
6
6
  import { type UseChartHighlightSignature } from "../useChartHighlight/index.js";
7
7
  import { type UseChartInteractionSignature } from "../useChartInteraction/index.js";
8
8
  import { type UseChartTooltipSignature } from "../useChartTooltip/index.js";
9
+ import { type UseChartZAxisSignature } from "../useChartZAxis/index.js";
9
10
  export interface UseChartVoronoiInstance {
10
11
  /**
11
12
  * Enable the voronoi computation.
@@ -51,5 +52,5 @@ export type UseChartClosestPointSignature<SeriesType extends ChartSeriesType = C
51
52
  params: UseChartVoronoiParameters;
52
53
  defaultizedParams: UseChartVoronoiDefaultizedParameters;
53
54
  dependencies: [UseChartSeriesSignature, UseChartCartesianAxisSignature];
54
- optionalDependencies: [UseChartInteractionSignature, UseChartHighlightSignature<SeriesType>, UseChartTooltipSignature];
55
+ optionalDependencies: [UseChartInteractionSignature, UseChartHighlightSignature<SeriesType>, UseChartTooltipSignature, UseChartZAxisSignature];
55
56
  }>;
@@ -12,6 +12,7 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
12
12
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
13
13
  var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
14
14
  var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries");
15
+ var _cleanIdentifier = require("../../corePlugins/useChartSeriesConfig/utils/cleanIdentifier");
15
16
  const useChartHighlight = ({
16
17
  store,
17
18
  params,
@@ -25,6 +26,9 @@ const useChartHighlight = ({
25
26
  defaultValue: null
26
27
  });
27
28
  (0, _useEnhancedEffect.default)(() => {
29
+ if (params.highlightedItem === undefined) {
30
+ return;
31
+ }
28
32
  if (store.state.highlight.item !== params.highlightedItem) {
29
33
  if (params.highlightedItem === null) {
30
34
  store.set('highlight', (0, _extends2.default)({}, store.state.highlight, {
@@ -83,9 +87,9 @@ const useChartHighlight = ({
83
87
  exports.useChartHighlight = useChartHighlight;
84
88
  useChartHighlight.getInitialState = (params, currentState) => ({
85
89
  highlight: {
86
- item: params.highlightedItem == null ? params.highlightedItem : (0, _useChartSeries.createIdentifierWithType)(currentState)(
90
+ item: params.highlightedItem == null ? params.highlightedItem : (0, _cleanIdentifier.cleanIdentifier)(currentState.seriesConfig.config, (0, _useChartSeries.createIdentifierWithType)(currentState)(
87
91
  // Need some as because the generic SeriesType can't be propagated to plugins methods.
88
- params.highlightedItem),
92
+ params.highlightedItem)),
89
93
  lastUpdate: 'pointer',
90
94
  isControlled: params.highlightedItem !== undefined
91
95
  }
@@ -5,6 +5,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
7
7
  import { createIdentifierWithType } from "../../corePlugins/useChartSeries/useChartSeries.mjs";
8
+ import { cleanIdentifier } from "../../corePlugins/useChartSeriesConfig/utils/cleanIdentifier.mjs";
8
9
  export const useChartHighlight = ({
9
10
  store,
10
11
  params,
@@ -18,6 +19,9 @@ export const useChartHighlight = ({
18
19
  defaultValue: null
19
20
  });
20
21
  useEnhancedEffect(() => {
22
+ if (params.highlightedItem === undefined) {
23
+ return;
24
+ }
21
25
  if (store.state.highlight.item !== params.highlightedItem) {
22
26
  if (params.highlightedItem === null) {
23
27
  store.set('highlight', _extends({}, store.state.highlight, {
@@ -75,9 +79,9 @@ export const useChartHighlight = ({
75
79
  };
76
80
  useChartHighlight.getInitialState = (params, currentState) => ({
77
81
  highlight: {
78
- item: params.highlightedItem == null ? params.highlightedItem : createIdentifierWithType(currentState)(
82
+ item: params.highlightedItem == null ? params.highlightedItem : cleanIdentifier(currentState.seriesConfig.config, createIdentifierWithType(currentState)(
79
83
  // Need some as because the generic SeriesType can't be propagated to plugins methods.
80
- params.highlightedItem),
84
+ params.highlightedItem)),
81
85
  lastUpdate: 'pointer',
82
86
  isControlled: params.highlightedItem !== undefined
83
87
  }
@@ -2,6 +2,10 @@ export declare const generateSvg2rotation: (center: {
2
2
  cx: number;
3
3
  cy: number;
4
4
  }) => (x: number, y: number) => number;
5
+ export declare const generateSvg2radius: (center: {
6
+ cx: number;
7
+ cy: number;
8
+ }) => (x: number, y: number) => number;
5
9
  export declare const generateSvg2polar: (center: {
6
10
  cx: number;
7
11
  cy: number;
@@ -2,6 +2,10 @@ export declare const generateSvg2rotation: (center: {
2
2
  cx: number;
3
3
  cy: number;
4
4
  }) => (x: number, y: number) => number;
5
+ export declare const generateSvg2radius: (center: {
6
+ cx: number;
7
+ cy: number;
8
+ }) => (x: number, y: number) => number;
5
9
  export declare const generateSvg2polar: (center: {
6
10
  cx: number;
7
11
  cy: number;
@@ -3,9 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.generateSvg2rotation = exports.generateSvg2polar = exports.generatePolar2svg = void 0;
6
+ exports.generateSvg2rotation = exports.generateSvg2radius = exports.generateSvg2polar = exports.generatePolar2svg = void 0;
7
7
  const generateSvg2rotation = center => (x, y) => Math.atan2(x - center.cx, center.cy - y);
8
8
  exports.generateSvg2rotation = generateSvg2rotation;
9
+ const generateSvg2radius = center => (x, y) => Math.sqrt((x - center.cx) ** 2 + (center.cy - y) ** 2);
10
+ exports.generateSvg2radius = generateSvg2radius;
9
11
  const generateSvg2polar = center => (x, y) => {
10
12
  const angle = Math.atan2(x - center.cx, center.cy - y);
11
13
  return [Math.sqrt((x - center.cx) ** 2 + (center.cy - y) ** 2), angle];
@@ -1,4 +1,5 @@
1
1
  export const generateSvg2rotation = center => (x, y) => Math.atan2(x - center.cx, center.cy - y);
2
+ export const generateSvg2radius = center => (x, y) => Math.sqrt((x - center.cx) ** 2 + (center.cy - y) ** 2);
2
3
  export const generateSvg2polar = center => (x, y) => {
3
4
  const angle = Math.atan2(x - center.cx, center.cy - y);
4
5
  return [Math.sqrt((x - center.cx) ** 2 + (center.cy - y) ** 2), angle];
@@ -19,6 +19,7 @@ var _coordinateTransformation = require("./coordinateTransformation");
19
19
  var _getAxisIndex = require("./getAxisIndex");
20
20
  var _useChartSeries = require("../../corePlugins/useChartSeries");
21
21
  var _checkHasInteractionPlugin = require("../useChartInteraction/checkHasInteractionPlugin");
22
+ var _isPolar = require("../../../isPolar");
22
23
  const useChartPolarAxis = ({
23
24
  params,
24
25
  store,
@@ -178,9 +179,10 @@ const useChartPolarAxis = ({
178
179
  const svgPoint = (0, _getChartPoint.getChartPoint)(element, event.detail.srcEvent);
179
180
  const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
180
181
  const rotationIndex = (0, _getAxisIndex.getRotationAxisIndex)(rotationAxisWithScale[usedRotationAxisId], rotation);
182
+ const radius = (0, _coordinateTransformation.generateSvg2radius)(center)(svgPoint.x, svgPoint.y);
183
+ const radiusIndex = (0, _getAxisIndex.getRadiusAxisIndex)(radiusAxisWithScale[usedRadiusAxisId], radius);
181
184
  isRotationAxis = rotationIndex !== -1;
182
- dataIndex = isRotationAxis ? rotationIndex : null; // radius index is not yet implemented.
183
-
185
+ dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
184
186
  const USED_AXIS_ID = isRotationAxis ? usedRotationAxisId : usedRadiusAxisId;
185
187
  if (dataIndex == null || dataIndex === -1) {
186
188
  return;
@@ -189,7 +191,7 @@ const useChartPolarAxis = ({
189
191
  // The .data exist because otherwise the dataIndex would be null or -1.
190
192
  const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
191
193
  const seriesValues = {};
192
- Object.keys(processedSeries).filter(seriesType => seriesType === 'radar').forEach(seriesType => {
194
+ Object.keys(processedSeries).filter(_isPolar.isPolarSeriesType).forEach(seriesType => {
193
195
  processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
194
196
  const seriesItem = processedSeries[seriesType].series[seriesId];
195
197
  seriesValues[seriesId] = seriesItem.data[dataIndex];