@mui/x-charts 9.3.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 (168) hide show
  1. package/BarChart/BarElement.d.mts +3 -2
  2. package/BarChart/BarElement.d.ts +3 -2
  3. package/BarChart/BarLabel/BarLabelItem.d.mts +3 -2
  4. package/BarChart/BarLabel/BarLabelItem.d.ts +3 -2
  5. package/BarChart/seriesConfig/bar/extremums.js +7 -2
  6. package/BarChart/seriesConfig/bar/extremums.mjs +7 -2
  7. package/CHANGELOG.md +196 -0
  8. package/ChartsContainer/ChartsContainer.js +21 -0
  9. package/ChartsContainer/ChartsContainer.mjs +21 -0
  10. package/ChartsLabel/ChartsLabelMark.js +1 -21
  11. package/ChartsLabel/ChartsLabelMark.mjs +0 -20
  12. package/ChartsLegend/chartsLegend.types.d.mts +3 -2
  13. package/ChartsLegend/chartsLegend.types.d.ts +3 -2
  14. package/ChartsLegend/piecewiseColorLegendClasses.js +8 -2
  15. package/ChartsLegend/piecewiseColorLegendClasses.mjs +8 -2
  16. package/ChartsOverlay/ChartsOverlay.d.mts +5 -4
  17. package/ChartsOverlay/ChartsOverlay.d.ts +5 -4
  18. package/ChartsReferenceLine/ChartsXReferenceLine.js +6 -1
  19. package/ChartsReferenceLine/ChartsXReferenceLine.mjs +6 -1
  20. package/ChartsReferenceLine/ChartsYReferenceLine.js +5 -0
  21. package/ChartsReferenceLine/ChartsYReferenceLine.mjs +5 -0
  22. package/ChartsTooltip/ChartTooltip.types.d.mts +3 -2
  23. package/ChartsTooltip/ChartTooltip.types.d.ts +3 -2
  24. package/ChartsTooltip/useAxesTooltip.js +2 -2
  25. package/ChartsTooltip/useAxesTooltip.mjs +2 -2
  26. package/ChartsTooltip/useItemTooltip.js +2 -2
  27. package/ChartsTooltip/useItemTooltip.mjs +2 -2
  28. package/ChartsXAxis/useAxisTicksProps.d.mts +84 -3
  29. package/ChartsXAxis/useAxisTicksProps.d.ts +84 -3
  30. package/ChartsYAxis/useAxisTicksProps.d.mts +84 -3
  31. package/ChartsYAxis/useAxisTicksProps.d.ts +84 -3
  32. package/LineChart/AreaElement.d.mts +3 -2
  33. package/LineChart/AreaElement.d.ts +3 -2
  34. package/LineChart/LineElement.d.mts +3 -2
  35. package/LineChart/LineElement.d.ts +3 -2
  36. package/LineChart/LineHighlightPlot.d.mts +3 -2
  37. package/LineChart/LineHighlightPlot.d.ts +3 -2
  38. package/LineChart/LineHighlightPlot.js +65 -45
  39. package/LineChart/LineHighlightPlot.mjs +65 -45
  40. package/LineChart/MarkPlot.d.mts +3 -2
  41. package/LineChart/MarkPlot.d.ts +3 -2
  42. package/LineChart/seriesConfig/curveEvaluation.js +28 -14
  43. package/LineChart/seriesConfig/curveEvaluation.mjs +27 -14
  44. package/LineChart/seriesConfig/extremums.js +5 -1
  45. package/LineChart/seriesConfig/extremums.mjs +5 -1
  46. package/LineChart/useMarkPlotData.js +3 -1
  47. package/LineChart/useMarkPlotData.mjs +3 -1
  48. package/PieChart/PieArcLabelPlot.d.mts +3 -2
  49. package/PieChart/PieArcLabelPlot.d.ts +3 -2
  50. package/PieChart/PieArcPlot.d.mts +3 -2
  51. package/PieChart/PieArcPlot.d.ts +3 -2
  52. package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +2 -2
  53. package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +2 -2
  54. package/ScatterChart/BatchScatter.d.mts +2 -8
  55. package/ScatterChart/BatchScatter.d.ts +2 -8
  56. package/ScatterChart/BatchScatter.js +17 -12
  57. package/ScatterChart/BatchScatter.mjs +17 -12
  58. package/ScatterChart/FocusedScatterMark.js +2 -2
  59. package/ScatterChart/FocusedScatterMark.mjs +2 -2
  60. package/ScatterChart/HighlightedScatterMark.js +3 -3
  61. package/ScatterChart/HighlightedScatterMark.mjs +3 -3
  62. package/ScatterChart/Scatter.d.mts +5 -0
  63. package/ScatterChart/Scatter.d.ts +5 -0
  64. package/ScatterChart/Scatter.js +7 -2
  65. package/ScatterChart/Scatter.mjs +7 -2
  66. package/ScatterChart/ScatterChart.d.mts +2 -1
  67. package/ScatterChart/ScatterChart.d.ts +2 -1
  68. package/ScatterChart/ScatterChart.js +21 -0
  69. package/ScatterChart/ScatterChart.mjs +21 -0
  70. package/ScatterChart/ScatterMarker.types.d.mts +3 -2
  71. package/ScatterChart/ScatterMarker.types.d.ts +3 -2
  72. package/ScatterChart/ScatterPlot.d.mts +3 -2
  73. package/ScatterChart/ScatterPlot.d.ts +3 -2
  74. package/ScatterChart/ScatterPlot.js +6 -1
  75. package/ScatterChart/ScatterPlot.mjs +6 -1
  76. package/ScatterChart/seriesConfig/extremums.js +6 -0
  77. package/ScatterChart/seriesConfig/extremums.mjs +6 -0
  78. package/ScatterChart/seriesConfig/getColor.js +1 -1
  79. package/ScatterChart/seriesConfig/getColor.mjs +1 -1
  80. package/ScatterChart/seriesConfig/getMarkerSize.d.mts +18 -0
  81. package/ScatterChart/seriesConfig/getMarkerSize.d.ts +18 -0
  82. package/ScatterChart/seriesConfig/getMarkerSize.js +43 -0
  83. package/ScatterChart/seriesConfig/getMarkerSize.mjs +37 -0
  84. package/ScatterChart/seriesConfig/seriesProcessor.js +23 -8
  85. package/ScatterChart/seriesConfig/seriesProcessor.mjs +23 -8
  86. package/ScatterChart/useScatterItemPosition.d.mts +4 -0
  87. package/ScatterChart/useScatterItemPosition.d.ts +4 -0
  88. package/ScatterChart/useScatterItemPosition.js +9 -0
  89. package/ScatterChart/useScatterItemPosition.mjs +8 -0
  90. package/Toolbar/Toolbar.types.d.mts +3 -2
  91. package/Toolbar/Toolbar.types.d.ts +3 -2
  92. package/index.js +1 -1
  93. package/index.mjs +1 -1
  94. package/internals/animation/animation.d.mts +1 -2
  95. package/internals/animation/animation.d.ts +1 -2
  96. package/internals/commonNextFocusItem.d.mts +10 -2
  97. package/internals/commonNextFocusItem.d.ts +10 -2
  98. package/internals/commonNextFocusItem.js +12 -4
  99. package/internals/commonNextFocusItem.mjs +12 -4
  100. package/internals/createCommonKeyboardFocusHandler.d.mts +1 -1
  101. package/internals/createCommonKeyboardFocusHandler.d.ts +1 -1
  102. package/internals/createCommonKeyboardFocusHandler.js +3 -3
  103. package/internals/createCommonKeyboardFocusHandler.mjs +3 -3
  104. package/internals/incompleteDatasetKeysError.d.mts +1 -0
  105. package/internals/incompleteDatasetKeysError.d.ts +1 -0
  106. package/internals/incompleteDatasetKeysError.js +11 -0
  107. package/internals/incompleteDatasetKeysError.mjs +4 -0
  108. package/internals/index.d.mts +2 -0
  109. package/internals/index.d.ts +2 -0
  110. package/internals/index.js +24 -0
  111. package/internals/index.mjs +2 -0
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.mjs +4 -3
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  115. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +3 -3
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.mts +10 -1
  117. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +10 -1
  118. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +18 -1
  119. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.mjs +16 -0
  120. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -3
  121. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -3
  122. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +24 -5
  123. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.mjs +24 -5
  124. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.mts +1 -1
  125. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +1 -1
  126. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +46 -2
  127. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.mjs +47 -2
  128. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +46 -11
  129. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +46 -11
  130. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +2 -1
  131. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +2 -1
  132. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +3 -2
  133. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.mjs +3 -2
  134. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.mts +4 -0
  135. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +4 -0
  136. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +3 -1
  137. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.mjs +1 -0
  138. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +5 -3
  139. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +7 -5
  140. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +17 -3
  141. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.mjs +17 -3
  142. package/internals/sizeScale.d.mts +6 -0
  143. package/internals/sizeScale.d.ts +6 -0
  144. package/internals/sizeScale.js +46 -0
  145. package/internals/sizeScale.mjs +38 -0
  146. package/models/axis.d.mts +18 -12
  147. package/models/axis.d.ts +18 -12
  148. package/models/chartsSlotsComponentsProps.d.mts +25 -0
  149. package/models/chartsSlotsComponentsProps.d.ts +25 -0
  150. package/models/chartsSlotsComponentsProps.js +5 -0
  151. package/models/chartsSlotsComponentsProps.mjs +1 -0
  152. package/models/index.d.mts +1 -0
  153. package/models/index.d.ts +1 -0
  154. package/models/index.js +11 -0
  155. package/models/index.mjs +1 -0
  156. package/models/seriesType/line.d.mts +5 -2
  157. package/models/seriesType/line.d.ts +5 -2
  158. package/models/seriesType/scatter.d.mts +34 -2
  159. package/models/seriesType/scatter.d.ts +34 -2
  160. package/models/sizeMapping.d.mts +64 -0
  161. package/models/sizeMapping.d.ts +64 -0
  162. package/models/sizeMapping.js +5 -0
  163. package/models/sizeMapping.mjs +1 -0
  164. package/models/slots/chartsBaseSlots.d.mts +6 -5
  165. package/models/slots/chartsBaseSlots.d.ts +6 -5
  166. package/models/z-axis.d.mts +10 -1
  167. package/models/z-axis.d.ts +10 -1
  168. package/package.json +6 -6
@@ -2,7 +2,7 @@ import type { ChartSeriesType } from "../models/seriesType/config.mjs";
2
2
  /**
3
3
  * Create a keyboard focus handler for common use cases where focused item are defined by the series is and data index.
4
4
  */
5
- export declare function createCommonKeyboardFocusHandler<SeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, TInputSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = SeriesType>(outSeriesTypes: Set<SeriesType>, allowCycles?: boolean): (event: KeyboardEvent) => ((currentItem: import("../index.mjs").FocusedItemIdentifier<TInputSeriesType> | null, state: {
5
+ export declare function createCommonKeyboardFocusHandler<SeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, TInputSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = SeriesType>(outSeriesTypes: Set<SeriesType>, allowCycles?: boolean, useCurrentSeriesMaxLength?: boolean): (event: KeyboardEvent) => ((currentItem: import("../index.mjs").FocusedItemIdentifier<TInputSeriesType> | null, state: {
6
6
  series: {
7
7
  defaultizedSeries: import("./plugins/corePlugins/useChartSeries/useChartSeries.types.mjs").DefaultizedSeriesGroups<TInputSeriesType>;
8
8
  idToType: import("./index.mjs").SeriesIdToType;
@@ -2,7 +2,7 @@ import type { ChartSeriesType } from "../models/seriesType/config.js";
2
2
  /**
3
3
  * Create a keyboard focus handler for common use cases where focused item are defined by the series is and data index.
4
4
  */
5
- export declare function createCommonKeyboardFocusHandler<SeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, TInputSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = SeriesType>(outSeriesTypes: Set<SeriesType>, allowCycles?: boolean): (event: KeyboardEvent) => ((currentItem: import("../index.js").FocusedItemIdentifier<TInputSeriesType> | null, state: {
5
+ export declare function createCommonKeyboardFocusHandler<SeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, TInputSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = SeriesType>(outSeriesTypes: Set<SeriesType>, allowCycles?: boolean, useCurrentSeriesMaxLength?: boolean): (event: KeyboardEvent) => ((currentItem: import("../index.js").FocusedItemIdentifier<TInputSeriesType> | null, state: {
6
6
  series: {
7
7
  defaultizedSeries: import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").DefaultizedSeriesGroups<TInputSeriesType>;
8
8
  idToType: import("./index.js").SeriesIdToType;
@@ -8,13 +8,13 @@ var _commonNextFocusItem = require("./commonNextFocusItem");
8
8
  /**
9
9
  * Create a keyboard focus handler for common use cases where focused item are defined by the series is and data index.
10
10
  */
11
- function createCommonKeyboardFocusHandler(outSeriesTypes, allowCycles) {
11
+ function createCommonKeyboardFocusHandler(outSeriesTypes, allowCycles, useCurrentSeriesMaxLength) {
12
12
  const keyboardFocusHandler = event => {
13
13
  switch (event.key) {
14
14
  case 'ArrowRight':
15
- return (0, _commonNextFocusItem.createGetNextIndexFocusedItem)(outSeriesTypes, allowCycles);
15
+ return (0, _commonNextFocusItem.createGetNextIndexFocusedItem)(outSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
16
16
  case 'ArrowLeft':
17
- return (0, _commonNextFocusItem.createGetPreviousIndexFocusedItem)(outSeriesTypes, allowCycles);
17
+ return (0, _commonNextFocusItem.createGetPreviousIndexFocusedItem)(outSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
18
18
  case 'ArrowDown':
19
19
  return (0, _commonNextFocusItem.createGetPreviousSeriesFocusedItem)(outSeriesTypes);
20
20
  case 'ArrowUp':
@@ -3,13 +3,13 @@ import { createGetNextIndexFocusedItem, createGetPreviousIndexFocusedItem, creat
3
3
  /**
4
4
  * Create a keyboard focus handler for common use cases where focused item are defined by the series is and data index.
5
5
  */
6
- export function createCommonKeyboardFocusHandler(outSeriesTypes, allowCycles) {
6
+ export function createCommonKeyboardFocusHandler(outSeriesTypes, allowCycles, useCurrentSeriesMaxLength) {
7
7
  const keyboardFocusHandler = event => {
8
8
  switch (event.key) {
9
9
  case 'ArrowRight':
10
- return createGetNextIndexFocusedItem(outSeriesTypes, allowCycles);
10
+ return createGetNextIndexFocusedItem(outSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
11
11
  case 'ArrowLeft':
12
- return createGetPreviousIndexFocusedItem(outSeriesTypes, allowCycles);
12
+ return createGetPreviousIndexFocusedItem(outSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
13
13
  case 'ArrowDown':
14
14
  return createGetPreviousSeriesFocusedItem(outSeriesTypes);
15
15
  case 'ArrowUp':
@@ -0,0 +1 @@
1
+ export declare function incompleteDatasetKeysError(seriesType: string, seriesId: string, missingKeys: string[]): void;
@@ -0,0 +1 @@
1
+ export declare function incompleteDatasetKeysError(seriesType: string, seriesId: string, missingKeys: string[]): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.incompleteDatasetKeysError = incompleteDatasetKeysError;
8
+ var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
9
+ function incompleteDatasetKeysError(seriesType, seriesId, missingKeys) {
10
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${seriesType} series with id="${seriesId}" has incomplete datasetKeys.` + `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.` : (0, _formatErrorMessage2.default)(279, seriesType, seriesId, missingKeys.map(key => `"${key}"`).join(', ')));
11
+ }
@@ -0,0 +1,4 @@
1
+ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
+ export function incompleteDatasetKeysError(seriesType, seriesId, missingKeys) {
3
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${seriesType} series with id="${seriesId}" has incomplete datasetKeys.` + `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.` : _formatErrorMessage(279, seriesType, seriesId, missingKeys.map(key => `"${key}"`).join(', ')));
4
+ }
@@ -65,6 +65,8 @@ export * from "./consumeSlots.mjs";
65
65
  export * from "./consumeThemeProps.mjs";
66
66
  export * from "./defaultizeMargin.mjs";
67
67
  export * from "./colorScale.mjs";
68
+ export * from "./sizeScale.mjs";
69
+ export * from "./incompleteDatasetKeysError.mjs";
68
70
  export * from "./ticks.mjs";
69
71
  export * from "./dateHelpers.mjs";
70
72
  export * from "./invertScale.mjs";
@@ -65,6 +65,8 @@ export * from "./consumeSlots.js";
65
65
  export * from "./consumeThemeProps.js";
66
66
  export * from "./defaultizeMargin.js";
67
67
  export * from "./colorScale.js";
68
+ export * from "./sizeScale.js";
69
+ export * from "./incompleteDatasetKeysError.js";
68
70
  export * from "./ticks.js";
69
71
  export * from "./dateHelpers.js";
70
72
  export * from "./invertScale.js";
@@ -832,6 +832,30 @@ Object.keys(_colorScale).forEach(function (key) {
832
832
  }
833
833
  });
834
834
  });
835
+ var _sizeScale = require("./sizeScale");
836
+ Object.keys(_sizeScale).forEach(function (key) {
837
+ if (key === "default" || key === "__esModule") return;
838
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
839
+ if (key in exports && exports[key] === _sizeScale[key]) return;
840
+ Object.defineProperty(exports, key, {
841
+ enumerable: true,
842
+ get: function () {
843
+ return _sizeScale[key];
844
+ }
845
+ });
846
+ });
847
+ var _incompleteDatasetKeysError = require("./incompleteDatasetKeysError");
848
+ Object.keys(_incompleteDatasetKeysError).forEach(function (key) {
849
+ if (key === "default" || key === "__esModule") return;
850
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
851
+ if (key in exports && exports[key] === _incompleteDatasetKeysError[key]) return;
852
+ Object.defineProperty(exports, key, {
853
+ enumerable: true,
854
+ get: function () {
855
+ return _incompleteDatasetKeysError[key];
856
+ }
857
+ });
858
+ });
835
859
  var _ticks = require("./ticks");
836
860
  Object.keys(_ticks).forEach(function (key) {
837
861
  if (key === "default" || key === "__esModule") return;
@@ -73,6 +73,8 @@ export * from "./consumeSlots.mjs";
73
73
  export * from "./consumeThemeProps.mjs";
74
74
  export * from "./defaultizeMargin.mjs";
75
75
  export * from "./colorScale.mjs";
76
+ export * from "./sizeScale.mjs";
77
+ export * from "./incompleteDatasetKeysError.mjs";
76
78
  export * from "./ticks.mjs";
77
79
  export * from "./dateHelpers.mjs";
78
80
  export * from "./invertScale.mjs";
@@ -10,9 +10,10 @@ const createZoomLookup = axisDirection => (axes = []) => axes.reduce((acc, v) =>
10
10
  const {
11
11
  zoom,
12
12
  id: axisId,
13
- reverse
13
+ reverse,
14
+ scaleType
14
15
  } = v;
15
- const defaultizedZoom = (0, _defaultizeZoom.defaultizeZoom)(zoom, axisId, axisDirection, reverse);
16
+ const defaultizedZoom = (0, _defaultizeZoom.defaultizeZoom)(zoom, axisId, axisDirection, (0, _defaultizeZoom.getEffectiveZoomReverse)(axisDirection, scaleType, reverse));
16
17
  if (defaultizedZoom) {
17
18
  acc[axisId] = defaultizedZoom;
18
19
  }
@@ -1,12 +1,13 @@
1
- import { defaultizeZoom } from "./defaultizeZoom.mjs";
1
+ import { defaultizeZoom, getEffectiveZoomReverse } from "./defaultizeZoom.mjs";
2
2
  export const createZoomLookup = axisDirection => (axes = []) => axes.reduce((acc, v) => {
3
3
  // @ts-ignore
4
4
  const {
5
5
  zoom,
6
6
  id: axisId,
7
- reverse
7
+ reverse,
8
+ scaleType
8
9
  } = v;
9
- const defaultizedZoom = defaultizeZoom(zoom, axisId, axisDirection, reverse);
10
+ const defaultizedZoom = defaultizeZoom(zoom, axisId, axisDirection, getEffectiveZoomReverse(axisDirection, scaleType, reverse));
10
11
  if (defaultizedZoom) {
11
12
  acc[axisId] = defaultizedZoom;
12
13
  }
@@ -35,7 +35,7 @@ function defaultizeXAxis(inAxes, dataset, axesGap) {
35
35
  id,
36
36
  position,
37
37
  height,
38
- zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x', axisConfig.reverse)
38
+ zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x', (0, _defaultizeZoom.getEffectiveZoomReverse)('x', axisConfig.scaleType, axisConfig.reverse))
39
39
  });
40
40
 
41
41
  // Increment the offset for the next axis
@@ -87,7 +87,7 @@ function defaultizeYAxis(inAxes, dataset, axesGap) {
87
87
  id,
88
88
  position,
89
89
  width,
90
- zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y', axisConfig.reverse)
90
+ zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y', (0, _defaultizeZoom.getEffectiveZoomReverse)('y', axisConfig.scaleType, axisConfig.reverse))
91
91
  });
92
92
 
93
93
  // Increment the offset for the next axis
@@ -1,6 +1,6 @@
1
1
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- import { defaultizeZoom } from "./defaultizeZoom.mjs";
3
+ import { defaultizeZoom, getEffectiveZoomReverse } from "./defaultizeZoom.mjs";
4
4
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY, DEFAULT_AXIS_SIZE_HEIGHT, DEFAULT_AXIS_SIZE_WIDTH, AXIS_LABEL_DEFAULT_HEIGHT } from "../../../../constants/index.mjs";
5
5
  export function defaultizeXAxis(inAxes, dataset, axesGap) {
6
6
  const offsets = {
@@ -27,7 +27,7 @@ export function defaultizeXAxis(inAxes, dataset, axesGap) {
27
27
  id,
28
28
  position,
29
29
  height,
30
- zoom: defaultizeZoom(axisConfig.zoom, id, 'x', axisConfig.reverse)
30
+ zoom: defaultizeZoom(axisConfig.zoom, id, 'x', getEffectiveZoomReverse('x', axisConfig.scaleType, axisConfig.reverse))
31
31
  });
32
32
 
33
33
  // Increment the offset for the next axis
@@ -79,7 +79,7 @@ export function defaultizeYAxis(inAxes, dataset, axesGap) {
79
79
  id,
80
80
  position,
81
81
  width,
82
- zoom: defaultizeZoom(axisConfig.zoom, id, 'y', axisConfig.reverse)
82
+ zoom: defaultizeZoom(axisConfig.zoom, id, 'y', getEffectiveZoomReverse('y', axisConfig.scaleType, axisConfig.reverse))
83
83
  });
84
84
 
85
85
  // Increment the offset for the next axis
@@ -1,6 +1,15 @@
1
- import { type AxisId } from "../../../../models/axis.mjs";
1
+ import { type AxisId, type ScaleName } from "../../../../models/axis.mjs";
2
2
  import { type DefaultizedZoomOptions } from "./useChartCartesianAxis.types.mjs";
3
3
  import { type ZoomOptions } from "./zoom.types.mjs";
4
+ /**
5
+ * Ordinal Y axes (band/point) render with `domain[0]` at the top of the chart
6
+ * (see the `range.reverse()` applied in `selectorChartYScales`), which is the
7
+ * opposite of the cartesian convention assumed by the zoom/pan math.
8
+ *
9
+ * Returns the `reverse` flag the zoom handlers should use so that pan/wheel
10
+ * gestures follow the visual direction of the axis.
11
+ */
12
+ export declare const getEffectiveZoomReverse: (axisDirection: "x" | "y", scaleType: ScaleName | undefined, reverse: boolean | undefined) => boolean;
4
13
  export declare const defaultZoomOptions: {
5
14
  minStart: number;
6
15
  maxEnd: number;
@@ -1,6 +1,15 @@
1
- import { type AxisId } from "../../../../models/axis.js";
1
+ import { type AxisId, type ScaleName } from "../../../../models/axis.js";
2
2
  import { type DefaultizedZoomOptions } from "./useChartCartesianAxis.types.js";
3
3
  import { type ZoomOptions } from "./zoom.types.js";
4
+ /**
5
+ * Ordinal Y axes (band/point) render with `domain[0]` at the top of the chart
6
+ * (see the `range.reverse()` applied in `selectorChartYScales`), which is the
7
+ * opposite of the cartesian convention assumed by the zoom/pan math.
8
+ *
9
+ * Returns the `reverse` flag the zoom handlers should use so that pan/wheel
10
+ * gestures follow the visual direction of the axis.
11
+ */
12
+ export declare const getEffectiveZoomReverse: (axisDirection: "x" | "y", scaleType: ScaleName | undefined, reverse: boolean | undefined) => boolean;
4
13
  export declare const defaultZoomOptions: {
5
14
  minStart: number;
6
15
  maxEnd: number;
@@ -4,9 +4,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.defaultizeZoom = exports.defaultZoomOptions = void 0;
7
+ exports.getEffectiveZoomReverse = exports.defaultizeZoom = exports.defaultZoomOptions = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _constants = require("../../../constants");
10
+ /**
11
+ * Ordinal Y axes (band/point) render with `domain[0]` at the top of the chart
12
+ * (see the `range.reverse()` applied in `selectorChartYScales`), which is the
13
+ * opposite of the cartesian convention assumed by the zoom/pan math.
14
+ *
15
+ * Returns the `reverse` flag the zoom handlers should use so that pan/wheel
16
+ * gestures follow the visual direction of the axis.
17
+ */
18
+ const getEffectiveZoomReverse = (axisDirection, scaleType, reverse) => {
19
+ const resolvedReverse = reverse ?? false;
20
+ const isOrdinal = scaleType === 'band' || scaleType === 'point';
21
+ if (axisDirection === 'y' && isOrdinal) {
22
+ return !resolvedReverse;
23
+ }
24
+ return resolvedReverse;
25
+ };
26
+ exports.getEffectiveZoomReverse = getEffectiveZoomReverse;
10
27
  const defaultZoomOptions = exports.defaultZoomOptions = {
11
28
  minStart: 0,
12
29
  maxEnd: 100,
@@ -1,5 +1,21 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE, DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP, DEFAULT_ZOOM_SLIDER_SIZE } from "../../../constants.mjs";
3
+ /**
4
+ * Ordinal Y axes (band/point) render with `domain[0]` at the top of the chart
5
+ * (see the `range.reverse()` applied in `selectorChartYScales`), which is the
6
+ * opposite of the cartesian convention assumed by the zoom/pan math.
7
+ *
8
+ * Returns the `reverse` flag the zoom handlers should use so that pan/wheel
9
+ * gestures follow the visual direction of the axis.
10
+ */
11
+ export const getEffectiveZoomReverse = (axisDirection, scaleType, reverse) => {
12
+ const resolvedReverse = reverse ?? false;
13
+ const isOrdinal = scaleType === 'band' || scaleType === 'point';
14
+ if (axisDirection === 'y' && isOrdinal) {
15
+ return !resolvedReverse;
16
+ }
17
+ return resolvedReverse;
18
+ };
3
19
  export const defaultZoomOptions = {
4
20
  minStart: 0,
5
21
  maxEnd: 100,
@@ -164,6 +164,7 @@ export declare const selectorChartRawAxis: (args_0: import("../../corePlugins/us
164
164
  min: NumberValue;
165
165
  max: NumberValue;
166
166
  });
167
+ domainSeries?: "all" | "visible";
167
168
  ignoreTooltip?: boolean;
168
169
  } & Omit<Partial<import("../../../index.mjs").ChartsYAxisProps>, "axisId"> & Partial<Omit<{
169
170
  scaleType: "linear";
@@ -223,7 +224,14 @@ export declare const selectorChartDefaultXAxisId: (args_0: import("../../corePlu
223
224
  export declare const selectorChartDefaultYAxisId: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.mjs").UseChartCartesianAxisState> & {
224
225
  cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
225
226
  }) => AxisId;
226
- export declare const selectorChartSeriesEmptyFlatbushMap: () => Map<string, Flatbush>;
227
- export declare const selectorChartSeriesFlatbushMap: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<{}> & {
227
+ export type ScatterFlatbushEntry = {
228
+ flatbush: Flatbush;
229
+ /** Per-point marker radius, in pixels. */
230
+ getItemRadius: number | ((dataIndex: number) => number);
231
+ /** Largest radius across all points in this series, in pixels. */
232
+ maxItemRadius: number;
233
+ };
234
+ export declare const selectorChartSeriesEmptyFlatbushMap: () => Map<string, ScatterFlatbushEntry>;
235
+ export declare const selectorChartSeriesFlatbushMap: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & import("../useChartZAxis/index.mjs").UseChartZAxisState & Partial<{}> & {
228
236
  cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
229
- }) => Map<string, Flatbush>;
237
+ }) => Map<string, ScatterFlatbushEntry>;
@@ -164,6 +164,7 @@ export declare const selectorChartRawAxis: (args_0: import("../../corePlugins/us
164
164
  min: NumberValue;
165
165
  max: NumberValue;
166
166
  });
167
+ domainSeries?: "all" | "visible";
167
168
  ignoreTooltip?: boolean;
168
169
  } & Omit<Partial<import("../../../index.js").ChartsYAxisProps>, "axisId"> & Partial<Omit<{
169
170
  scaleType: "linear";
@@ -223,7 +224,14 @@ export declare const selectorChartDefaultXAxisId: (args_0: import("../../corePlu
223
224
  export declare const selectorChartDefaultYAxisId: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
224
225
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
225
226
  }) => AxisId;
226
- export declare const selectorChartSeriesEmptyFlatbushMap: () => Map<string, Flatbush>;
227
- export declare const selectorChartSeriesFlatbushMap: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<{}> & {
227
+ export type ScatterFlatbushEntry = {
228
+ flatbush: Flatbush;
229
+ /** Per-point marker radius, in pixels. */
230
+ getItemRadius: number | ((dataIndex: number) => number);
231
+ /** Largest radius across all points in this series, in pixels. */
232
+ maxItemRadius: number;
233
+ };
234
+ export declare const selectorChartSeriesEmptyFlatbushMap: () => Map<string, ScatterFlatbushEntry>;
235
+ export declare const selectorChartSeriesFlatbushMap: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & import("../useChartZAxis/index.js").UseChartZAxisState & Partial<{}> & {
228
236
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
229
- }) => Map<string, Flatbush>;
237
+ }) => Map<string, ScatterFlatbushEntry>;
@@ -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)) {