@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
@@ -17,6 +17,7 @@ var _useScatterSeries = require("../hooks/useScatterSeries");
17
17
  var _hooks = require("../hooks");
18
18
  var _useZAxis = require("../hooks/useZAxis");
19
19
  var _seriesConfig = require("./seriesConfig");
20
+ var _getMarkerSize = _interopRequireDefault(require("./seriesConfig/getMarkerSize"));
20
21
  var _BatchScatter = require("./BatchScatter");
21
22
  var _scatterClasses = require("./scatterClasses");
22
23
  var _jsxRuntime = require("react/jsx-runtime");
@@ -79,14 +80,17 @@ function ScatterPlot(props) {
79
80
  id,
80
81
  xAxisId,
81
82
  yAxisId,
83
+ colorAxisId,
82
84
  zAxisId,
85
+ sizeAxisId,
83
86
  color,
84
87
  hidden
85
88
  } = series[seriesId];
86
89
  if (hidden) {
87
90
  return null;
88
91
  }
89
- const colorGetter = _seriesConfig.scatterSeriesConfig.colorProcessor(series[seriesId], xAxis[xAxisId ?? defaultXAxisId], yAxis[yAxisId ?? defaultYAxisId], zAxis[zAxisId ?? defaultZAxisId]);
92
+ const colorGetter = _seriesConfig.scatterSeriesConfig.colorProcessor(series[seriesId], xAxis[xAxisId ?? defaultXAxisId], yAxis[yAxisId ?? defaultYAxisId], zAxis[colorAxisId ?? zAxisId ?? defaultZAxisId]);
93
+ const sizeGetter = (0, _getMarkerSize.default)(series[seriesId], zAxis[sizeAxisId ?? defaultZAxisId]);
90
94
  const xScale = xAxis[xAxisId ?? defaultXAxisId].scale;
91
95
  const yScale = yAxis[yAxisId ?? defaultYAxisId].scale;
92
96
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScatterItems, (0, _extends2.default)({
@@ -94,6 +98,7 @@ function ScatterPlot(props) {
94
98
  yScale: yScale,
95
99
  color: color,
96
100
  colorGetter: colorGetter,
101
+ sizeGetter: sizeGetter,
97
102
  series: series[seriesId],
98
103
  onItemClick: onItemClick,
99
104
  slots: slots,
@@ -10,6 +10,7 @@ import { useScatterSeriesContext } from "../hooks/useScatterSeries.mjs";
10
10
  import { useXAxes, useYAxes } from "../hooks/index.mjs";
11
11
  import { useZAxes } from "../hooks/useZAxis.mjs";
12
12
  import { scatterSeriesConfig } from "./seriesConfig/index.mjs";
13
+ import getMarkerSize from "./seriesConfig/getMarkerSize.mjs";
13
14
  import { BatchScatter } from "./BatchScatter.mjs";
14
15
  import { useUtilityClasses } from "./scatterClasses.mjs";
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -72,14 +73,17 @@ function ScatterPlot(props) {
72
73
  id,
73
74
  xAxisId,
74
75
  yAxisId,
76
+ colorAxisId,
75
77
  zAxisId,
78
+ sizeAxisId,
76
79
  color,
77
80
  hidden
78
81
  } = series[seriesId];
79
82
  if (hidden) {
80
83
  return null;
81
84
  }
82
- const colorGetter = scatterSeriesConfig.colorProcessor(series[seriesId], xAxis[xAxisId ?? defaultXAxisId], yAxis[yAxisId ?? defaultYAxisId], zAxis[zAxisId ?? defaultZAxisId]);
85
+ const colorGetter = scatterSeriesConfig.colorProcessor(series[seriesId], xAxis[xAxisId ?? defaultXAxisId], yAxis[yAxisId ?? defaultYAxisId], zAxis[colorAxisId ?? zAxisId ?? defaultZAxisId]);
86
+ const sizeGetter = getMarkerSize(series[seriesId], zAxis[sizeAxisId ?? defaultZAxisId]);
83
87
  const xScale = xAxis[xAxisId ?? defaultXAxisId].scale;
84
88
  const yScale = yAxis[yAxisId ?? defaultYAxisId].scale;
85
89
  return /*#__PURE__*/_jsx(ScatterItems, _extends({
@@ -87,6 +91,7 @@ function ScatterPlot(props) {
87
91
  yScale: yScale,
88
92
  color: color,
89
93
  colorGetter: colorGetter,
94
+ sizeGetter: sizeGetter,
90
95
  series: series[seriesId],
91
96
  onItemClick: onItemClick,
92
97
  slots: slots,
@@ -17,6 +17,9 @@ const getExtremumX = params => {
17
17
  if (!Object.hasOwn(series, seriesId)) {
18
18
  continue;
19
19
  }
20
+ if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
21
+ continue;
22
+ }
20
23
  const axisId = series[seriesId].xAxisId;
21
24
  if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
22
25
  continue;
@@ -59,6 +62,9 @@ const getExtremumY = params => {
59
62
  if (!Object.hasOwn(series, seriesId)) {
60
63
  continue;
61
64
  }
65
+ if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
66
+ continue;
67
+ }
62
68
  const axisId = series[seriesId].yAxisId;
63
69
  if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
64
70
  continue;
@@ -11,6 +11,9 @@ export const getExtremumX = params => {
11
11
  if (!Object.hasOwn(series, seriesId)) {
12
12
  continue;
13
13
  }
14
+ if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
15
+ continue;
16
+ }
14
17
  const axisId = series[seriesId].xAxisId;
15
18
  if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
16
19
  continue;
@@ -52,6 +55,9 @@ export const getExtremumY = params => {
52
55
  if (!Object.hasOwn(series, seriesId)) {
53
56
  continue;
54
57
  }
58
+ if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
59
+ continue;
60
+ }
55
61
  const axisId = series[seriesId].yAxisId;
56
62
  if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
57
63
  continue;
@@ -25,7 +25,7 @@ const getColor = (series, xAxis, yAxis, zAxis) => {
25
25
  const color = value === null ? getSeriesColor({
26
26
  value,
27
27
  dataIndex
28
- }) : zColorScale(value.z);
28
+ }) : zColorScale(value.colorValue ?? value.z);
29
29
  if (color === null) {
30
30
  return getSeriesColor({
31
31
  value,
@@ -19,7 +19,7 @@ const getColor = (series, xAxis, yAxis, zAxis) => {
19
19
  const color = value === null ? getSeriesColor({
20
20
  value,
21
21
  dataIndex
22
- }) : zColorScale(value.z);
22
+ }) : zColorScale(value.colorValue ?? value.z);
23
23
  if (color === null) {
24
24
  return getSeriesColor({
25
25
  value,
@@ -0,0 +1,18 @@
1
+ import { type DefaultizedScatterSeriesType } from "../../models/seriesType/scatter.mjs";
2
+ import { type ZAxisDefaultized } from "../../models/z-axis.mjs";
3
+ /**
4
+ * Returns the marker size of a scatter item given its data index.
5
+ * @param {number} dataIndex The index of the scatter item.
6
+ * @returns {number} The marker size in pixels.
7
+ */
8
+ export type ScatterSizeGetter = (dataIndex: number) => number;
9
+ /**
10
+ * Builds a getter returning the marker size of each scatter item.
11
+ *
12
+ * When the size axis defines a `sizeMap`, the size is computed by mapping a value
13
+ * through the resulting `sizeScale`. The mapped value is taken from the size axis
14
+ * `data` when available, otherwise from the `sizeValue` of the scatter point.
15
+ * It falls back to the series `markerSize` when no size can be computed.
16
+ */
17
+ declare const getMarkerSize: (series: DefaultizedScatterSeriesType, sizeZAxis?: ZAxisDefaultized) => ScatterSizeGetter;
18
+ export default getMarkerSize;
@@ -0,0 +1,18 @@
1
+ import { type DefaultizedScatterSeriesType } from "../../models/seriesType/scatter.js";
2
+ import { type ZAxisDefaultized } from "../../models/z-axis.js";
3
+ /**
4
+ * Returns the marker size of a scatter item given its data index.
5
+ * @param {number} dataIndex The index of the scatter item.
6
+ * @returns {number} The marker size in pixels.
7
+ */
8
+ export type ScatterSizeGetter = (dataIndex: number) => number;
9
+ /**
10
+ * Builds a getter returning the marker size of each scatter item.
11
+ *
12
+ * When the size axis defines a `sizeMap`, the size is computed by mapping a value
13
+ * through the resulting `sizeScale`. The mapped value is taken from the size axis
14
+ * `data` when available, otherwise from the `sizeValue` of the scatter point.
15
+ * It falls back to the series `markerSize` when no size can be computed.
16
+ */
17
+ declare const getMarkerSize: (series: DefaultizedScatterSeriesType, sizeZAxis?: ZAxisDefaultized) => ScatterSizeGetter;
18
+ export default getMarkerSize;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * Returns the marker size of a scatter item given its data index.
9
+ * @param {number} dataIndex The index of the scatter item.
10
+ * @returns {number} The marker size in pixels.
11
+ */
12
+
13
+ /**
14
+ * Builds a getter returning the marker size of each scatter item.
15
+ *
16
+ * When the size axis defines a `sizeMap`, the size is computed by mapping a value
17
+ * through the resulting `sizeScale`. The mapped value is taken from the size axis
18
+ * `data` when available, otherwise from the `sizeValue` of the scatter point.
19
+ * It falls back to the series `markerSize` when no size can be computed.
20
+ */
21
+ const getMarkerSize = (series, sizeZAxis) => {
22
+ const sizeScale = sizeZAxis?.sizeScale;
23
+ if (!sizeScale) {
24
+ return () => series.markerSize;
25
+ }
26
+ return dataIndex => {
27
+ if (sizeZAxis?.data?.[dataIndex] !== undefined) {
28
+ const size = sizeScale(sizeZAxis.data[dataIndex]);
29
+ if (size != null && !Number.isNaN(size)) {
30
+ return size;
31
+ }
32
+ }
33
+ const value = series.data[dataIndex];
34
+ if (value != null) {
35
+ const size = sizeScale(value.sizeValue);
36
+ if (size != null && !Number.isNaN(size)) {
37
+ return size;
38
+ }
39
+ }
40
+ return series.markerSize;
41
+ };
42
+ };
43
+ var _default = exports.default = getMarkerSize;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Returns the marker size of a scatter item given its data index.
3
+ * @param {number} dataIndex The index of the scatter item.
4
+ * @returns {number} The marker size in pixels.
5
+ */
6
+
7
+ /**
8
+ * Builds a getter returning the marker size of each scatter item.
9
+ *
10
+ * When the size axis defines a `sizeMap`, the size is computed by mapping a value
11
+ * through the resulting `sizeScale`. The mapped value is taken from the size axis
12
+ * `data` when available, otherwise from the `sizeValue` of the scatter point.
13
+ * It falls back to the series `markerSize` when no size can be computed.
14
+ */
15
+ const getMarkerSize = (series, sizeZAxis) => {
16
+ const sizeScale = sizeZAxis?.sizeScale;
17
+ if (!sizeScale) {
18
+ return () => series.markerSize;
19
+ }
20
+ return dataIndex => {
21
+ if (sizeZAxis?.data?.[dataIndex] !== undefined) {
22
+ const size = sizeScale(sizeZAxis.data[dataIndex]);
23
+ if (size != null && !Number.isNaN(size)) {
24
+ return size;
25
+ }
26
+ }
27
+ const value = series.data[dataIndex];
28
+ if (value != null) {
29
+ const size = sizeScale(value.sizeValue);
30
+ if (size != null && !Number.isNaN(size)) {
31
+ return size;
32
+ }
33
+ }
34
+ return series.markerSize;
35
+ };
36
+ };
37
+ export default getMarkerSize;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
9
+ var _incompleteDatasetKeysError = require("../../internals/incompleteDatasetKeysError");
10
10
  const seriesProcessor = ({
11
11
  series,
12
12
  seriesOrder
@@ -15,18 +15,33 @@ const seriesProcessor = ({
15
15
  const datasetKeys = seriesData?.datasetKeys;
16
16
  const missingKeys = ['x', 'y'].filter(key => typeof datasetKeys?.[key] !== 'string');
17
17
  if (seriesData?.datasetKeys && missingKeys.length > 0) {
18
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: Scatter series with id="${seriesId}" has incomplete datasetKeys. ` + `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing. ` + 'Scatter plots require both "x" and "y" keys to map dataset values to coordinates. ' + 'Add the missing datasetKeys to the series configuration.' : (0, _formatErrorMessage2.default)(29, seriesId, missingKeys.map(key => `"${key}"`).join(', ')));
18
+ (0, _incompleteDatasetKeysError.incompleteDatasetKeysError)('Scatter', seriesId, missingKeys);
19
19
  }
20
20
  let data;
21
21
  if (seriesData.valueGetter) {
22
22
  data = dataset?.map(seriesData.valueGetter) ?? [];
23
23
  } else if (datasetKeys) {
24
- data = dataset?.map(d => ({
25
- x: d[datasetKeys.x] ?? null,
26
- y: d[datasetKeys.y] ?? null,
27
- z: datasetKeys.z && d[datasetKeys.z],
28
- id: datasetKeys.id && d[datasetKeys.id]
29
- })) ?? [];
24
+ data = dataset?.map(d => {
25
+ const x = d[datasetKeys.x];
26
+ const y = d[datasetKeys.y];
27
+ const rep = {
28
+ x,
29
+ y
30
+ };
31
+ if (datasetKeys.colorValue !== undefined) {
32
+ rep.colorValue = d[datasetKeys.colorValue];
33
+ }
34
+ if (datasetKeys.sizeValue !== undefined) {
35
+ rep.sizeValue = d[datasetKeys.sizeValue];
36
+ }
37
+ if (datasetKeys.z !== undefined) {
38
+ rep.z = d[datasetKeys.z];
39
+ }
40
+ if (datasetKeys.id !== undefined) {
41
+ rep.id = d[datasetKeys.id];
42
+ }
43
+ return rep;
44
+ }) ?? [];
30
45
  } else {
31
46
  data = seriesData.data ?? [];
32
47
  }
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
+ import { incompleteDatasetKeysError } from "../../internals/incompleteDatasetKeysError.mjs";
3
3
  const seriesProcessor = ({
4
4
  series,
5
5
  seriesOrder
@@ -8,18 +8,33 @@ const seriesProcessor = ({
8
8
  const datasetKeys = seriesData?.datasetKeys;
9
9
  const missingKeys = ['x', 'y'].filter(key => typeof datasetKeys?.[key] !== 'string');
10
10
  if (seriesData?.datasetKeys && missingKeys.length > 0) {
11
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: Scatter series with id="${seriesId}" has incomplete datasetKeys. ` + `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing. ` + 'Scatter plots require both "x" and "y" keys to map dataset values to coordinates. ' + 'Add the missing datasetKeys to the series configuration.' : _formatErrorMessage(29, seriesId, missingKeys.map(key => `"${key}"`).join(', ')));
11
+ incompleteDatasetKeysError('Scatter', seriesId, missingKeys);
12
12
  }
13
13
  let data;
14
14
  if (seriesData.valueGetter) {
15
15
  data = dataset?.map(seriesData.valueGetter) ?? [];
16
16
  } else if (datasetKeys) {
17
- data = dataset?.map(d => ({
18
- x: d[datasetKeys.x] ?? null,
19
- y: d[datasetKeys.y] ?? null,
20
- z: datasetKeys.z && d[datasetKeys.z],
21
- id: datasetKeys.id && d[datasetKeys.id]
22
- })) ?? [];
17
+ data = dataset?.map(d => {
18
+ const x = d[datasetKeys.x];
19
+ const y = d[datasetKeys.y];
20
+ const rep = {
21
+ x,
22
+ y
23
+ };
24
+ if (datasetKeys.colorValue !== undefined) {
25
+ rep.colorValue = d[datasetKeys.colorValue];
26
+ }
27
+ if (datasetKeys.sizeValue !== undefined) {
28
+ rep.sizeValue = d[datasetKeys.sizeValue];
29
+ }
30
+ if (datasetKeys.z !== undefined) {
31
+ rep.z = d[datasetKeys.z];
32
+ }
33
+ if (datasetKeys.id !== undefined) {
34
+ rep.id = d[datasetKeys.id];
35
+ }
36
+ return rep;
37
+ }) ?? [];
23
38
  } else {
24
39
  data = seriesData.data ?? [];
25
40
  }
@@ -2,6 +2,10 @@ import { type DefaultizedScatterSeriesType, type ScatterItemIdentifier, type Sca
2
2
  export interface ResolvedScatterItem {
3
3
  cx: number;
4
4
  cy: number;
5
+ /**
6
+ * The resolved marker size of the scatter point, accounting for any size axis.
7
+ */
8
+ markerSize: number;
5
9
  series: DefaultizedScatterSeriesType;
6
10
  scatterPoint: ScatterValueType;
7
11
  }
@@ -2,6 +2,10 @@ import { type DefaultizedScatterSeriesType, type ScatterItemIdentifier, type Sca
2
2
  export interface ResolvedScatterItem {
3
3
  cx: number;
4
4
  cy: number;
5
+ /**
6
+ * The resolved marker size of the scatter point, accounting for any size axis.
7
+ */
8
+ markerSize: number;
5
9
  series: DefaultizedScatterSeriesType;
6
10
  scatterPoint: ScatterValueType;
7
11
  }
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.useScatterItemPosition = useScatterItemPosition;
7
8
  var _hooks = require("../hooks");
9
+ var _useZAxis = require("../hooks/useZAxis");
10
+ var _getMarkerSize = _interopRequireDefault(require("./seriesConfig/getMarkerSize"));
8
11
  /**
9
12
  * Resolves a scatter item identifier to its on-screen position and the owning
10
13
  * series. Shared by `FocusedScatterMark`, `HighlightedScatterMark`, and other
@@ -23,6 +26,10 @@ function useScatterItemPosition(item) {
23
26
  yAxis,
24
27
  yAxisIds
25
28
  } = (0, _hooks.useYAxes)();
29
+ const {
30
+ zAxis,
31
+ zAxisIds
32
+ } = (0, _useZAxis.useZAxes)();
26
33
  if (!item || !scatterSeries) {
27
34
  return null;
28
35
  }
@@ -38,9 +45,11 @@ function useScatterItemPosition(item) {
38
45
  const yAxisId = series.yAxisId ?? yAxisIds[0];
39
46
  const cx = (0, _hooks.getValueToPositionMapper)(xAxis[xAxisId].scale)(scatterPoint.x);
40
47
  const cy = (0, _hooks.getValueToPositionMapper)(yAxis[yAxisId].scale)(scatterPoint.y);
48
+ const markerSize = (0, _getMarkerSize.default)(series, zAxis[series.sizeAxisId ?? zAxisIds[0]])(item.dataIndex);
41
49
  return {
42
50
  cx,
43
51
  cy,
52
+ markerSize,
44
53
  series,
45
54
  scatterPoint
46
55
  };
@@ -1,4 +1,6 @@
1
1
  import { getValueToPositionMapper, useScatterSeriesContext, useXAxes, useYAxes } from "../hooks/index.mjs";
2
+ import { useZAxes } from "../hooks/useZAxis.mjs";
3
+ import getMarkerSize from "./seriesConfig/getMarkerSize.mjs";
2
4
  /**
3
5
  * Resolves a scatter item identifier to its on-screen position and the owning
4
6
  * series. Shared by `FocusedScatterMark`, `HighlightedScatterMark`, and other
@@ -17,6 +19,10 @@ export function useScatterItemPosition(item) {
17
19
  yAxis,
18
20
  yAxisIds
19
21
  } = useYAxes();
22
+ const {
23
+ zAxis,
24
+ zAxisIds
25
+ } = useZAxes();
20
26
  if (!item || !scatterSeries) {
21
27
  return null;
22
28
  }
@@ -32,9 +38,11 @@ export function useScatterItemPosition(item) {
32
38
  const yAxisId = series.yAxisId ?? yAxisIds[0];
33
39
  const cx = getValueToPositionMapper(xAxis[xAxisId].scale)(scatterPoint.x);
34
40
  const cy = getValueToPositionMapper(yAxis[yAxisId].scale)(scatterPoint.y);
41
+ const markerSize = getMarkerSize(series, zAxis[series.sizeAxisId ?? zAxisIds[0]])(item.dataIndex);
35
42
  return {
36
43
  cx,
37
44
  cy,
45
+ markerSize,
38
46
  series,
39
47
  scatterPoint
40
48
  };
@@ -1,15 +1,16 @@
1
1
  import type * as React from 'react';
2
+ import type { ToolbarPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
2
3
  export interface ChartsToolbarProps {}
3
4
  export interface ChartsToolbarSlots {
4
5
  /**
5
6
  * Custom component for the toolbar.
6
7
  * @default ChartsToolbar
7
8
  */
8
- toolbar?: React.ElementType<ChartsToolbarProps>;
9
+ toolbar?: React.ElementType<ChartsToolbarProps & ToolbarPropsOverrides>;
9
10
  }
10
11
  export interface ChartsToolbarSlotProps {
11
12
  /**
12
13
  * Props for the toolbar component.
13
14
  */
14
- toolbar?: Partial<ChartsToolbarProps>;
15
+ toolbar?: Partial<ChartsToolbarProps> & ToolbarPropsOverrides;
15
16
  }
@@ -1,15 +1,16 @@
1
1
  import type * as React from 'react';
2
+ import type { ToolbarPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
2
3
  export interface ChartsToolbarProps {}
3
4
  export interface ChartsToolbarSlots {
4
5
  /**
5
6
  * Custom component for the toolbar.
6
7
  * @default ChartsToolbar
7
8
  */
8
- toolbar?: React.ElementType<ChartsToolbarProps>;
9
+ toolbar?: React.ElementType<ChartsToolbarProps & ToolbarPropsOverrides>;
9
10
  }
10
11
  export interface ChartsToolbarSlotProps {
11
12
  /**
12
13
  * Props for the toolbar component.
13
14
  */
14
- toolbar?: Partial<ChartsToolbarProps>;
15
+ toolbar?: Partial<ChartsToolbarProps> & ToolbarPropsOverrides;
15
16
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v9.3.0
2
+ * @mui/x-charts v9.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v9.3.0
2
+ * @mui/x-charts v9.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,4 +1,3 @@
1
- import BezierEasing from 'bezier-easing';
2
1
  export declare const ANIMATION_DURATION_MS = 300;
3
2
  export declare const ANIMATION_TIMING_FUNCTION = "cubic-bezier(0.66, 0, 0.34, 1)";
4
- export declare const ANIMATION_TIMING_FUNCTION_JS: BezierEasing.EasingFunction;
3
+ export declare const ANIMATION_TIMING_FUNCTION_JS: import("bezier-easing").EasingFunction;
@@ -1,4 +1,3 @@
1
- import BezierEasing from 'bezier-easing';
2
1
  export declare const ANIMATION_DURATION_MS = 300;
3
2
  export declare const ANIMATION_TIMING_FUNCTION = "cubic-bezier(0.66, 0, 0.34, 1)";
4
- export declare const ANIMATION_TIMING_FUNCTION_JS: BezierEasing.EasingFunction;
3
+ export declare const ANIMATION_TIMING_FUNCTION_JS: import("bezier-easing").EasingFunction;
@@ -16,7 +16,11 @@ compatibleSeriesTypes: Set<OutSeriesType>,
16
16
  /**
17
17
  * If true, allows cycling from the last item to the first one.
18
18
  */
19
- allowCycles?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
19
+ allowCycles?: boolean,
20
+ /**
21
+ * If true, series max index is defined by the current series length and not all series.
22
+ */
23
+ useCurrentSeriesMaxLength?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
20
24
  export declare function createGetPreviousIndexFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = InSeriesType>(
21
25
  /**
22
26
  * The set of series types compatible with this navigation action.
@@ -25,7 +29,11 @@ compatibleSeriesTypes: Set<OutSeriesType>,
25
29
  /**
26
30
  * If true, allows cycling from the last item to the first one.
27
31
  */
28
- allowCycles?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
32
+ allowCycles?: boolean,
33
+ /**
34
+ * If true, series max index is defined by the current series length and not all series.
35
+ */
36
+ useCurrentSeriesMaxLength?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
29
37
  export declare function createGetNextSeriesFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = InSeriesType>(
30
38
  /**
31
39
  * The set of series types compatible with this navigation action.
@@ -16,7 +16,11 @@ compatibleSeriesTypes: Set<OutSeriesType>,
16
16
  /**
17
17
  * If true, allows cycling from the last item to the first one.
18
18
  */
19
- allowCycles?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
19
+ allowCycles?: boolean,
20
+ /**
21
+ * If true, series max index is defined by the current series length and not all series.
22
+ */
23
+ useCurrentSeriesMaxLength?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
20
24
  export declare function createGetPreviousIndexFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = InSeriesType>(
21
25
  /**
22
26
  * The set of series types compatible with this navigation action.
@@ -25,7 +29,11 @@ compatibleSeriesTypes: Set<OutSeriesType>,
25
29
  /**
26
30
  * If true, allows cycling from the last item to the first one.
27
31
  */
28
- allowCycles?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
32
+ allowCycles?: boolean,
33
+ /**
34
+ * If true, series max index is defined by the current series length and not all series.
35
+ */
36
+ useCurrentSeriesMaxLength?: boolean): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: StateParameters<InSeriesType>) => ReturnedItem<OutSeriesType>;
29
37
  export declare function createGetNextSeriesFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey' | 'heatmap'> = InSeriesType>(
30
38
  /**
31
39
  * The set of series types compatible with this navigation action.
@@ -25,7 +25,11 @@ compatibleSeriesTypes,
25
25
  /**
26
26
  * If true, allows cycling from the last item to the first one.
27
27
  */
28
- allowCycles = false) {
28
+ allowCycles = false,
29
+ /**
30
+ * If true, series max index is defined by the current series length and not all series.
31
+ */
32
+ useCurrentSeriesMaxLength = false) {
29
33
  return function getNextIndexFocusedItem(currentItem, state) {
30
34
  const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
31
35
  let seriesId = currentItem?.seriesId;
@@ -38,7 +42,7 @@ allowCycles = false) {
38
42
  type = nextSeries.type;
39
43
  seriesId = nextSeries.seriesId;
40
44
  }
41
- const maxLength = (0, _getMaxSeriesLength.getMaxSeriesLength)(processedSeries, compatibleSeriesTypes);
45
+ const maxLength = useCurrentSeriesMaxLength ? processedSeries[type]?.series[seriesId]?.data.length ?? 0 : (0, _getMaxSeriesLength.getMaxSeriesLength)(processedSeries, compatibleSeriesTypes);
42
46
  let dataIndex = currentItem?.dataIndex == null ? 0 : currentItem.dataIndex + 1;
43
47
  if (allowCycles) {
44
48
  dataIndex = dataIndex % maxLength;
@@ -72,7 +76,11 @@ compatibleSeriesTypes,
72
76
  /**
73
77
  * If true, allows cycling from the last item to the first one.
74
78
  */
75
- allowCycles = false) {
79
+ allowCycles = false,
80
+ /**
81
+ * If true, series max index is defined by the current series length and not all series.
82
+ */
83
+ useCurrentSeriesMaxLength = false) {
76
84
  return function getPreviousIndexFocusedItem(currentItem, state) {
77
85
  const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
78
86
  let seriesId = currentItem?.seriesId;
@@ -85,7 +93,7 @@ allowCycles = false) {
85
93
  type = previousSeries.type;
86
94
  seriesId = previousSeries.seriesId;
87
95
  }
88
- const maxLength = (0, _getMaxSeriesLength.getMaxSeriesLength)(processedSeries, compatibleSeriesTypes);
96
+ const maxLength = useCurrentSeriesMaxLength ? processedSeries[type]?.series[seriesId]?.data.length ?? 0 : (0, _getMaxSeriesLength.getMaxSeriesLength)(processedSeries, compatibleSeriesTypes);
89
97
  let dataIndex = currentItem?.dataIndex == null ? maxLength - 1 : currentItem.dataIndex - 1;
90
98
  if (allowCycles) {
91
99
  dataIndex = (maxLength + dataIndex) % maxLength;
@@ -16,7 +16,11 @@ compatibleSeriesTypes,
16
16
  /**
17
17
  * If true, allows cycling from the last item to the first one.
18
18
  */
19
- allowCycles = false) {
19
+ allowCycles = false,
20
+ /**
21
+ * If true, series max index is defined by the current series length and not all series.
22
+ */
23
+ useCurrentSeriesMaxLength = false) {
20
24
  return function getNextIndexFocusedItem(currentItem, state) {
21
25
  const processedSeries = selectorChartSeriesProcessed(state);
22
26
  let seriesId = currentItem?.seriesId;
@@ -29,7 +33,7 @@ allowCycles = false) {
29
33
  type = nextSeries.type;
30
34
  seriesId = nextSeries.seriesId;
31
35
  }
32
- const maxLength = getMaxSeriesLength(processedSeries, compatibleSeriesTypes);
36
+ const maxLength = useCurrentSeriesMaxLength ? processedSeries[type]?.series[seriesId]?.data.length ?? 0 : getMaxSeriesLength(processedSeries, compatibleSeriesTypes);
33
37
  let dataIndex = currentItem?.dataIndex == null ? 0 : currentItem.dataIndex + 1;
34
38
  if (allowCycles) {
35
39
  dataIndex = dataIndex % maxLength;
@@ -63,7 +67,11 @@ compatibleSeriesTypes,
63
67
  /**
64
68
  * If true, allows cycling from the last item to the first one.
65
69
  */
66
- allowCycles = false) {
70
+ allowCycles = false,
71
+ /**
72
+ * If true, series max index is defined by the current series length and not all series.
73
+ */
74
+ useCurrentSeriesMaxLength = false) {
67
75
  return function getPreviousIndexFocusedItem(currentItem, state) {
68
76
  const processedSeries = selectorChartSeriesProcessed(state);
69
77
  let seriesId = currentItem?.seriesId;
@@ -76,7 +84,7 @@ allowCycles = false) {
76
84
  type = previousSeries.type;
77
85
  seriesId = previousSeries.seriesId;
78
86
  }
79
- const maxLength = getMaxSeriesLength(processedSeries, compatibleSeriesTypes);
87
+ const maxLength = useCurrentSeriesMaxLength ? processedSeries[type]?.series[seriesId]?.data.length ?? 0 : getMaxSeriesLength(processedSeries, compatibleSeriesTypes);
80
88
  let dataIndex = currentItem?.dataIndex == null ? maxLength - 1 : currentItem.dataIndex - 1;
81
89
  if (allowCycles) {
82
90
  dataIndex = (maxLength + dataIndex) % maxLength;