@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
@@ -3,6 +3,7 @@ import { type SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
3
  import { type AnimatedAreaProps } from "./AnimatedArea.js";
4
4
  import { type SeriesId } from "../models/seriesType/common.js";
5
5
  import { type LineClasses } from "./lineClasses.js";
6
+ import type { AreaPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
6
7
  export interface AreaElementOwnerState {
7
8
  seriesId: SeriesId;
8
9
  color: string;
@@ -16,10 +17,10 @@ export interface AreaElementSlots {
16
17
  * The component that renders the area.
17
18
  * @default AnimatedArea
18
19
  */
19
- area?: React.JSXElementConstructor<AnimatedAreaProps>;
20
+ area?: React.JSXElementConstructor<AnimatedAreaProps & AreaPropsOverrides>;
20
21
  }
21
22
  export interface AreaElementSlotProps {
22
- area?: SlotComponentPropsFromProps<AnimatedAreaProps, {}, AreaElementOwnerState>;
23
+ area?: SlotComponentPropsFromProps<AnimatedAreaProps, AreaPropsOverrides, AreaElementOwnerState>;
23
24
  }
24
25
  export interface AreaElementProps extends Omit<AreaElementOwnerState, 'isFaded' | 'isHighlighted'>, Pick<AnimatedAreaProps, 'skipAnimation'>, Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color'> {
25
26
  d: string;
@@ -3,6 +3,7 @@ import { type SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
3
  import { type AnimatedLineProps } from "./AnimatedLine.mjs";
4
4
  import { type SeriesId } from "../models/seriesType/common.mjs";
5
5
  import { type LineClasses } from "./lineClasses.mjs";
6
+ import type { LinePropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
6
7
  export interface LineElementOwnerState {
7
8
  seriesId: SeriesId;
8
9
  color: string;
@@ -18,10 +19,10 @@ export interface LineElementSlots {
18
19
  * The component that renders the line.
19
20
  * @default LineElementPath
20
21
  */
21
- line?: React.JSXElementConstructor<AnimatedLineProps>;
22
+ line?: React.JSXElementConstructor<AnimatedLineProps & LinePropsOverrides>;
22
23
  }
23
24
  export interface LineElementSlotProps {
24
- line?: SlotComponentPropsFromProps<AnimatedLineProps, {}, LineElementOwnerState>;
25
+ line?: SlotComponentPropsFromProps<AnimatedLineProps, LinePropsOverrides, LineElementOwnerState>;
25
26
  }
26
27
  export interface LineElementProps extends Omit<LineElementOwnerState, 'isFaded' | 'isHighlighted'>, Pick<AnimatedLineProps, 'skipAnimation'>, Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color'> {
27
28
  d: string;
@@ -3,6 +3,7 @@ import { type SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
3
  import { type AnimatedLineProps } from "./AnimatedLine.js";
4
4
  import { type SeriesId } from "../models/seriesType/common.js";
5
5
  import { type LineClasses } from "./lineClasses.js";
6
+ import type { LinePropsOverrides } from "../models/chartsSlotsComponentsProps.js";
6
7
  export interface LineElementOwnerState {
7
8
  seriesId: SeriesId;
8
9
  color: string;
@@ -18,10 +19,10 @@ export interface LineElementSlots {
18
19
  * The component that renders the line.
19
20
  * @default LineElementPath
20
21
  */
21
- line?: React.JSXElementConstructor<AnimatedLineProps>;
22
+ line?: React.JSXElementConstructor<AnimatedLineProps & LinePropsOverrides>;
22
23
  }
23
24
  export interface LineElementSlotProps {
24
- line?: SlotComponentPropsFromProps<AnimatedLineProps, {}, LineElementOwnerState>;
25
+ line?: SlotComponentPropsFromProps<AnimatedLineProps, LinePropsOverrides, LineElementOwnerState>;
25
26
  }
26
27
  export interface LineElementProps extends Omit<LineElementOwnerState, 'isFaded' | 'isHighlighted'>, Pick<AnimatedLineProps, 'skipAnimation'>, Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color'> {
27
28
  d: string;
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
3
  import { type LineHighlightElementProps } from "./LineHighlightElement.mjs";
4
+ import type { LineHighlightPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
4
5
  export interface LineHighlightPlotSlots {
5
- lineHighlight?: React.JSXElementConstructor<LineHighlightElementProps>;
6
+ lineHighlight?: React.JSXElementConstructor<LineHighlightElementProps & LineHighlightPropsOverrides>;
6
7
  }
7
8
  export interface LineHighlightPlotSlotProps {
8
- lineHighlight?: SlotComponentPropsFromProps<LineHighlightElementProps, {}, {}>;
9
+ lineHighlight?: SlotComponentPropsFromProps<LineHighlightElementProps, LineHighlightPropsOverrides, {}>;
9
10
  }
10
11
  export interface LineHighlightPlotProps extends React.SVGAttributes<SVGSVGElement> {
11
12
  /**
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
3
  import { type LineHighlightElementProps } from "./LineHighlightElement.js";
4
+ import type { LineHighlightPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
4
5
  export interface LineHighlightPlotSlots {
5
- lineHighlight?: React.JSXElementConstructor<LineHighlightElementProps>;
6
+ lineHighlight?: React.JSXElementConstructor<LineHighlightElementProps & LineHighlightPropsOverrides>;
6
7
  }
7
8
  export interface LineHighlightPlotSlotProps {
8
- lineHighlight?: SlotComponentPropsFromProps<LineHighlightElementProps, {}, {}>;
9
+ lineHighlight?: SlotComponentPropsFromProps<LineHighlightElementProps, LineHighlightPropsOverrides, {}>;
9
10
  }
10
11
  export interface LineHighlightPlotProps extends React.SVGAttributes<SVGSVGElement> {
11
12
  /**
@@ -53,9 +53,6 @@ function LineHighlightPlot(props) {
53
53
  } = (0, _ChartsProvider.useChartsContext)();
54
54
  const store = (0, _useStore.useStore)();
55
55
  const highlightedIndexes = store.use(_useChartCartesianAxis.selectorChartsHighlightXAxisIndex);
56
- if (highlightedIndexes.length === 0) {
57
- return null;
58
- }
59
56
  if (seriesData === undefined) {
60
57
  return null;
61
58
  }
@@ -65,54 +62,77 @@ function LineHighlightPlot(props) {
65
62
  } = seriesData;
66
63
  const defaultXAxisId = xAxisIds[0];
67
64
  const defaultYAxisId = yAxisIds[0];
65
+ const hasStartEndMark = stackingGroups.some(({
66
+ ids
67
+ }) => ids.some(seriesId => series[seriesId].showMark === 'start' || series[seriesId].showMark === 'end'));
68
+ if (highlightedIndexes.length === 0 && !hasStartEndMark) {
69
+ return null;
70
+ }
71
+ const getHighlightedIndex = new Map();
72
+ highlightedIndexes.forEach(({
73
+ axisId,
74
+ dataIndex
75
+ }) => {
76
+ getHighlightedIndex.set(axisId, dataIndex);
77
+ });
68
78
  const Element = slots?.lineHighlight ?? _LineHighlightElement.LineHighlightElement;
69
79
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
70
- children: highlightedIndexes.flatMap(({
71
- dataIndex: highlightedIndex,
72
- axisId: highlightedAxisId
73
- }) => stackingGroups.flatMap(({
80
+ children: stackingGroups.flatMap(({
74
81
  ids: groupIds
75
- }) => {
76
- return groupIds.flatMap(seriesId => {
77
- const {
78
- xAxisId = defaultXAxisId,
79
- yAxisId = defaultYAxisId,
80
- visibleStackedData,
81
- data,
82
- disableHighlight,
83
- shape = 'circle',
84
- hidden
85
- } = series[seriesId];
86
- if (hidden || disableHighlight || data[highlightedIndex] == null) {
87
- return null;
88
- }
89
- if (highlightedAxisId !== xAxisId) {
90
- return null;
91
- }
92
- const xScale = (0, _getValueToPositionMapper.getValueToPositionMapper)(xAxis[xAxisId].scale);
93
- const yScale = yAxis[yAxisId].scale;
94
- const xData = xAxis[xAxisId].data;
95
- if (xData === undefined) {
96
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.' : (0, _formatErrorMessage2.default)(10, xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`));
97
- }
98
- const x = xScale(xData[highlightedIndex]);
99
- const y = yScale(visibleStackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
100
-
101
- if (!instance.isPointInside(x, y)) {
102
- return null;
103
- }
104
- const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
105
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, (0, _extends2.default)({
106
- seriesId: seriesId,
107
- color: colorGetter(highlightedIndex),
108
- x: x,
109
- y: y,
110
- shape: shape
111
- }, slotProps?.lineHighlight), `${seriesId}`);
112
- });
82
+ }) => groupIds.flatMap(seriesId => {
83
+ const {
84
+ xAxisId = defaultXAxisId,
85
+ yAxisId = defaultYAxisId,
86
+ visibleStackedData,
87
+ data,
88
+ disableHighlight,
89
+ showMark,
90
+ shape = 'circle',
91
+ hidden
92
+ } = series[seriesId];
93
+ if (hidden) {
94
+ return null;
95
+ }
96
+ const axisIndex = disableHighlight ? undefined : getHighlightedIndex.get(xAxisId);
97
+ const showMarkIndex = showMark === 'start' || showMark === 'end' ? getStartEndMarkIndex(data, showMark) : undefined;
98
+ const highlightedIndex = axisIndex ?? showMarkIndex;
99
+ if (highlightedIndex === undefined || data[highlightedIndex] == null) {
100
+ return null;
101
+ }
102
+ const xScale = (0, _getValueToPositionMapper.getValueToPositionMapper)(xAxis[xAxisId].scale);
103
+ const yScale = yAxis[yAxisId].scale;
104
+ const xData = xAxis[xAxisId].data;
105
+ if (xData === undefined) {
106
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.' : (0, _formatErrorMessage2.default)(10, xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`));
107
+ }
108
+ const x = xScale(xData[highlightedIndex]);
109
+ const y = yScale(visibleStackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
110
+ if (!instance.isPointInside(x, y)) {
111
+ return null;
112
+ }
113
+ const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
114
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, (0, _extends2.default)({
115
+ seriesId: seriesId,
116
+ color: colorGetter(highlightedIndex),
117
+ x: x,
118
+ y: y,
119
+ shape: shape
120
+ }, slotProps?.lineHighlight), `${seriesId}`);
113
121
  }))
114
122
  }));
115
123
  }
124
+
125
+ /**
126
+ * Returns the index of the first (`'start'`) or last (`'end'`) non-null item, or `-1` if none.
127
+ */
128
+ function getStartEndMarkIndex(data, type) {
129
+ if (type === 'start') {
130
+ const index = data.findIndex(value => value != null);
131
+ return index < 0 ? undefined : index;
132
+ }
133
+ const index = data.findLastIndex(value => value != null);
134
+ return index < 0 ? undefined : index;
135
+ }
116
136
  process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
117
137
  // ----------------------------- Warning --------------------------------
118
138
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -46,9 +46,6 @@ function LineHighlightPlot(props) {
46
46
  } = useChartsContext();
47
47
  const store = useStore();
48
48
  const highlightedIndexes = store.use(selectorChartsHighlightXAxisIndex);
49
- if (highlightedIndexes.length === 0) {
50
- return null;
51
- }
52
49
  if (seriesData === undefined) {
53
50
  return null;
54
51
  }
@@ -58,54 +55,77 @@ function LineHighlightPlot(props) {
58
55
  } = seriesData;
59
56
  const defaultXAxisId = xAxisIds[0];
60
57
  const defaultYAxisId = yAxisIds[0];
58
+ const hasStartEndMark = stackingGroups.some(({
59
+ ids
60
+ }) => ids.some(seriesId => series[seriesId].showMark === 'start' || series[seriesId].showMark === 'end'));
61
+ if (highlightedIndexes.length === 0 && !hasStartEndMark) {
62
+ return null;
63
+ }
64
+ const getHighlightedIndex = new Map();
65
+ highlightedIndexes.forEach(({
66
+ axisId,
67
+ dataIndex
68
+ }) => {
69
+ getHighlightedIndex.set(axisId, dataIndex);
70
+ });
61
71
  const Element = slots?.lineHighlight ?? LineHighlightElement;
62
72
  return /*#__PURE__*/_jsx("g", _extends({}, other, {
63
- children: highlightedIndexes.flatMap(({
64
- dataIndex: highlightedIndex,
65
- axisId: highlightedAxisId
66
- }) => stackingGroups.flatMap(({
73
+ children: stackingGroups.flatMap(({
67
74
  ids: groupIds
68
- }) => {
69
- return groupIds.flatMap(seriesId => {
70
- const {
71
- xAxisId = defaultXAxisId,
72
- yAxisId = defaultYAxisId,
73
- visibleStackedData,
74
- data,
75
- disableHighlight,
76
- shape = 'circle',
77
- hidden
78
- } = series[seriesId];
79
- if (hidden || disableHighlight || data[highlightedIndex] == null) {
80
- return null;
81
- }
82
- if (highlightedAxisId !== xAxisId) {
83
- return null;
84
- }
85
- const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
86
- const yScale = yAxis[yAxisId].scale;
87
- const xData = xAxis[xAxisId].data;
88
- if (xData === undefined) {
89
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.' : _formatErrorMessage(10, xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`));
90
- }
91
- const x = xScale(xData[highlightedIndex]);
92
- const y = yScale(visibleStackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
93
-
94
- if (!instance.isPointInside(x, y)) {
95
- return null;
96
- }
97
- const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
98
- return /*#__PURE__*/_jsx(Element, _extends({
99
- seriesId: seriesId,
100
- color: colorGetter(highlightedIndex),
101
- x: x,
102
- y: y,
103
- shape: shape
104
- }, slotProps?.lineHighlight), `${seriesId}`);
105
- });
75
+ }) => groupIds.flatMap(seriesId => {
76
+ const {
77
+ xAxisId = defaultXAxisId,
78
+ yAxisId = defaultYAxisId,
79
+ visibleStackedData,
80
+ data,
81
+ disableHighlight,
82
+ showMark,
83
+ shape = 'circle',
84
+ hidden
85
+ } = series[seriesId];
86
+ if (hidden) {
87
+ return null;
88
+ }
89
+ const axisIndex = disableHighlight ? undefined : getHighlightedIndex.get(xAxisId);
90
+ const showMarkIndex = showMark === 'start' || showMark === 'end' ? getStartEndMarkIndex(data, showMark) : undefined;
91
+ const highlightedIndex = axisIndex ?? showMarkIndex;
92
+ if (highlightedIndex === undefined || data[highlightedIndex] == null) {
93
+ return null;
94
+ }
95
+ const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
96
+ const yScale = yAxis[yAxisId].scale;
97
+ const xData = xAxis[xAxisId].data;
98
+ if (xData === undefined) {
99
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.' : _formatErrorMessage(10, xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`));
100
+ }
101
+ const x = xScale(xData[highlightedIndex]);
102
+ const y = yScale(visibleStackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
103
+ if (!instance.isPointInside(x, y)) {
104
+ return null;
105
+ }
106
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
107
+ return /*#__PURE__*/_jsx(Element, _extends({
108
+ seriesId: seriesId,
109
+ color: colorGetter(highlightedIndex),
110
+ x: x,
111
+ y: y,
112
+ shape: shape
113
+ }, slotProps?.lineHighlight), `${seriesId}`);
106
114
  }))
107
115
  }));
108
116
  }
117
+
118
+ /**
119
+ * Returns the index of the first (`'start'`) or last (`'end'`) non-null item, or `-1` if none.
120
+ */
121
+ function getStartEndMarkIndex(data, type) {
122
+ if (type === 'start') {
123
+ const index = data.findIndex(value => value != null);
124
+ return index < 0 ? undefined : index;
125
+ }
126
+ const index = data.findLastIndex(value => value != null);
127
+ return index < 0 ? undefined : index;
128
+ }
109
129
  process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
110
130
  // ----------------------------- Warning --------------------------------
111
131
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type LineItemIdentifier } from "../models/seriesType/line.mjs";
3
3
  import { type MarkElementProps } from "./MarkElement.mjs";
4
+ import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
4
5
  export interface MarkPlotSlots {
5
- mark?: React.JSXElementConstructor<MarkElementProps>;
6
+ mark?: React.JSXElementConstructor<MarkElementProps & MarkPropsOverrides>;
6
7
  }
7
8
  export interface MarkPlotSlotProps {
8
- mark?: Partial<MarkElementProps>;
9
+ mark?: Partial<MarkElementProps> & MarkPropsOverrides;
9
10
  }
10
11
  export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<MarkElementProps, 'skipAnimation'> {
11
12
  /**
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type LineItemIdentifier } from "../models/seriesType/line.js";
3
3
  import { type MarkElementProps } from "./MarkElement.js";
4
+ import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
4
5
  export interface MarkPlotSlots {
5
- mark?: React.JSXElementConstructor<MarkElementProps>;
6
+ mark?: React.JSXElementConstructor<MarkElementProps & MarkPropsOverrides>;
6
7
  }
7
8
  export interface MarkPlotSlotProps {
8
- mark?: Partial<MarkElementProps>;
9
+ mark?: Partial<MarkElementProps> & MarkPropsOverrides;
9
10
  }
10
11
  export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<MarkElementProps, 'skipAnimation'> {
11
12
  /**
@@ -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.evaluateCurveAtAngle = evaluateCurveAtAngle;
7
8
  exports.evaluateCurveY = evaluateCurveY;
9
+ var _bezierEasing = _interopRequireDefault(require("bezier-easing"));
10
+ var _warning = require("@mui/x-internals/warning");
8
11
  var _epsilon = require("../../utils/epsilon");
9
12
  var _getCurve = require("../../internals/getCurve");
10
13
  var _clampAngle = require("../../internals/clampAngle");
@@ -75,22 +78,34 @@ function cubicBezierCoeffs(p0, p1, p2, p3) {
75
78
  }
76
79
 
77
80
  /**
78
- * Find parameter t such that the segment's x(t) ≈ targetX
81
+ * Evaluate y on a segment at the given x.
82
+ *
83
+ * Line segments are interpolated linearly. Bezier segments are normalized so
84
+ * their endpoints become (0, 0) and (1, 1), passed to `bezier-easing`, and
85
+ * the result is mapped back to pixel space.
86
+ *
87
+ * Warns once if a curve produces control points outside the segment's x
88
+ * range.
79
89
  */
80
- function findTForX(segment, targetX) {
90
+ function evaluateSegmentYAtX(segment, targetX) {
91
+ const dx = segment.x1 - segment.x0;
92
+ if (dx === 0) {
93
+ return segment.y0;
94
+ }
95
+ const dy = segment.y1 - segment.y0;
81
96
  if (!isBezierSegment(segment)) {
82
- // Linear segment.
83
- const dx = segment.x1 - segment.x0;
84
- return dx === 0 ? 0 : (targetX - segment.x0) / dx;
97
+ return segment.y0 + dy * (targetX - segment.x0) / dx;
85
98
  }
86
- const xBezierCoeffs = cubicBezierCoeffs(segment.x0, segment.cpx1, segment.cpx2, segment.x1);
87
- const polyToSolve = [...xBezierCoeffs];
88
- polyToSolve[3] -= targetX;
89
- const roots = (0, _cubiqSolver.cubicRoots)(polyToSolve);
90
- if (roots.length > 0) {
91
- return roots[0];
99
+ const nx1 = (segment.cpx1 - segment.x0) / dx;
100
+ const nx2 = (segment.cpx2 - segment.x0) / dx;
101
+ if (process.env.NODE_ENV !== 'production' && (nx1 < 0 || nx1 > 1 || nx2 < 0 || nx2 > 1)) {
102
+ (0, _warning.warnOnce)(`MUI X Charts: a curve segment has control points outside its x range. ` + `Please report the curve type and data at https://github.com/mui/mui-x/issues ` + `so we can support it natively.`);
92
103
  }
93
- return -1;
104
+ const ny1 = dy === 0 ? 0 : (segment.cpy1 - segment.y0) / dy;
105
+ const ny2 = dy === 0 ? 0 : (segment.cpy2 - segment.y0) / dy;
106
+ const ease = (0, _bezierEasing.default)(nx1, ny1, nx2, ny2);
107
+ const nt = (targetX - segment.x0) / dx;
108
+ return segment.y0 + dy * ease(nt);
94
109
  }
95
110
 
96
111
  /**
@@ -189,8 +204,7 @@ function evaluateCurveY(points, targetX, curveType) {
189
204
  const xMin = Math.min(segment.x0, segment.x1);
190
205
  const xMax = Math.max(segment.x0, segment.x1);
191
206
  if (targetX >= xMin && targetX <= xMax) {
192
- const t = findTForX(segment, targetX);
193
- return evaluateSegmentY(segment, t);
207
+ return evaluateSegmentYAtX(segment, targetX);
194
208
  }
195
209
  }
196
210
  return null;
@@ -1,3 +1,5 @@
1
+ import BezierEasing from 'bezier-easing';
2
+ import { warnOnce } from '@mui/x-internals/warning';
1
3
  import { EPSILON } from "../../utils/epsilon.mjs";
2
4
  import { getCurveFactory } from "../../internals/getCurve.mjs";
3
5
  import { clampAngleRad } from "../../internals/clampAngle.mjs";
@@ -69,22 +71,34 @@ function cubicBezierCoeffs(p0, p1, p2, p3) {
69
71
  }
70
72
 
71
73
  /**
72
- * Find parameter t such that the segment's x(t) ≈ targetX
74
+ * Evaluate y on a segment at the given x.
75
+ *
76
+ * Line segments are interpolated linearly. Bezier segments are normalized so
77
+ * their endpoints become (0, 0) and (1, 1), passed to `bezier-easing`, and
78
+ * the result is mapped back to pixel space.
79
+ *
80
+ * Warns once if a curve produces control points outside the segment's x
81
+ * range.
73
82
  */
74
- function findTForX(segment, targetX) {
83
+ function evaluateSegmentYAtX(segment, targetX) {
84
+ const dx = segment.x1 - segment.x0;
85
+ if (dx === 0) {
86
+ return segment.y0;
87
+ }
88
+ const dy = segment.y1 - segment.y0;
75
89
  if (!isBezierSegment(segment)) {
76
- // Linear segment.
77
- const dx = segment.x1 - segment.x0;
78
- return dx === 0 ? 0 : (targetX - segment.x0) / dx;
90
+ return segment.y0 + dy * (targetX - segment.x0) / dx;
79
91
  }
80
- const xBezierCoeffs = cubicBezierCoeffs(segment.x0, segment.cpx1, segment.cpx2, segment.x1);
81
- const polyToSolve = [...xBezierCoeffs];
82
- polyToSolve[3] -= targetX;
83
- const roots = cubicRoots(polyToSolve);
84
- if (roots.length > 0) {
85
- return roots[0];
92
+ const nx1 = (segment.cpx1 - segment.x0) / dx;
93
+ const nx2 = (segment.cpx2 - segment.x0) / dx;
94
+ if (process.env.NODE_ENV !== 'production' && (nx1 < 0 || nx1 > 1 || nx2 < 0 || nx2 > 1)) {
95
+ warnOnce(`MUI X Charts: a curve segment has control points outside its x range. ` + `Please report the curve type and data at https://github.com/mui/mui-x/issues ` + `so we can support it natively.`);
86
96
  }
87
- return -1;
97
+ const ny1 = dy === 0 ? 0 : (segment.cpy1 - segment.y0) / dy;
98
+ const ny2 = dy === 0 ? 0 : (segment.cpy2 - segment.y0) / dy;
99
+ const ease = BezierEasing(nx1, ny1, nx2, ny2);
100
+ const nt = (targetX - segment.x0) / dx;
101
+ return segment.y0 + dy * ease(nt);
88
102
  }
89
103
 
90
104
  /**
@@ -183,8 +197,7 @@ export function evaluateCurveY(points, targetX, curveType) {
183
197
  const xMin = Math.min(segment.x0, segment.x1);
184
198
  const xMax = Math.max(segment.x0, segment.x1);
185
199
  if (targetX >= xMin && targetX <= xMax) {
186
- const t = findTForX(segment, targetX);
187
- return evaluateSegmentY(segment, t);
200
+ return evaluateSegmentYAtX(segment, targetX);
188
201
  }
189
202
  }
190
203
  return null;
@@ -38,12 +38,16 @@ const getExtremumY = params => {
38
38
  getFilters
39
39
  } = params;
40
40
  return Object.keys(series).filter(seriesId => {
41
+ if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
42
+ return false;
43
+ }
41
44
  const yAxisId = series[seriesId].yAxisId;
42
45
  return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
43
46
  }).reduce((acc, seriesId) => {
44
47
  const {
45
48
  area,
46
49
  stackedData,
50
+ visibleStackedData,
47
51
  data
48
52
  } = series[seriesId];
49
53
  const isArea = area !== undefined;
@@ -56,7 +60,7 @@ const getExtremumY = params => {
56
60
 
57
61
  // Since this series is not used to display an area, we do not consider the base (the d[0]).
58
62
  const getValues = isArea && axis.scaleType !== 'log' && typeof series[seriesId].baseline !== 'string' ? d => d : d => [d[1], d[1]];
59
- const seriesExtremums = getSeriesExtremums(getValues, data, stackedData, filter);
63
+ const seriesExtremums = getSeriesExtremums(getValues, data, axis.domainSeries === 'visible' ? visibleStackedData : stackedData, filter);
60
64
  const [seriesMin, seriesMax] = seriesExtremums;
61
65
  return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
62
66
  }, [Infinity, -Infinity]);
@@ -31,12 +31,16 @@ export const getExtremumY = params => {
31
31
  getFilters
32
32
  } = params;
33
33
  return Object.keys(series).filter(seriesId => {
34
+ if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
35
+ return false;
36
+ }
34
37
  const yAxisId = series[seriesId].yAxisId;
35
38
  return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
36
39
  }).reduce((acc, seriesId) => {
37
40
  const {
38
41
  area,
39
42
  stackedData,
43
+ visibleStackedData,
40
44
  data
41
45
  } = series[seriesId];
42
46
  const isArea = area !== undefined;
@@ -49,7 +53,7 @@ export const getExtremumY = params => {
49
53
 
50
54
  // Since this series is not used to display an area, we do not consider the base (the d[0]).
51
55
  const getValues = isArea && axis.scaleType !== 'log' && typeof series[seriesId].baseline !== 'string' ? d => d : d => [d[1], d[1]];
52
- const seriesExtremums = getSeriesExtremums(getValues, data, stackedData, filter);
56
+ const seriesExtremums = getSeriesExtremums(getValues, data, axis.domainSeries === 'visible' ? visibleStackedData : stackedData, filter);
53
57
  const [seriesMin, seriesMax] = seriesExtremums;
54
58
  return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
55
59
  }, [Infinity, -Infinity]);
@@ -42,7 +42,9 @@ function useMarkPlotData(xAxes, yAxes) {
42
42
  shape = 'circle',
43
43
  hidden
44
44
  } = series[seriesId];
45
- if (!showMark) {
45
+
46
+ // `'start'` and `'end'` marks are rendered by the `LineHighlightPlot` using the highlight element.
47
+ if (!showMark || showMark === 'start' || showMark === 'end') {
46
48
  continue;
47
49
  }
48
50
  if (!(xAxisId in xAxes) || !(yAxisId in yAxes)) {
@@ -34,7 +34,9 @@ export function useMarkPlotData(xAxes, yAxes) {
34
34
  shape = 'circle',
35
35
  hidden
36
36
  } = series[seriesId];
37
- if (!showMark) {
37
+
38
+ // `'start'` and `'end'` marks are rendered by the `LineHighlightPlot` using the highlight element.
39
+ if (!showMark || showMark === 'start' || showMark === 'end') {
38
40
  continue;
39
41
  }
40
42
  if (!(xAxisId in xAxes) || !(yAxisId in yAxes)) {
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type ComputedPieRadius, type DefaultizedPieSeriesType } from "../models/seriesType/pie.mjs";
3
3
  import { type PieArcLabelProps } from "./PieArcLabel.mjs";
4
+ import type { PieArcLabelPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
4
5
  export interface PieArcLabelPlotSlots {
5
- pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps>;
6
+ pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps & PieArcLabelPropsOverrides>;
6
7
  }
7
8
  export interface PieArcLabelPlotSlotProps {
8
- pieArcLabel?: Partial<PieArcLabelProps>;
9
+ pieArcLabel?: Partial<PieArcLabelProps> & PieArcLabelPropsOverrides;
9
10
  }
10
11
  export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle'>, ComputedPieRadius {
11
12
  /**
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type ComputedPieRadius, type DefaultizedPieSeriesType } from "../models/seriesType/pie.js";
3
3
  import { type PieArcLabelProps } from "./PieArcLabel.js";
4
+ import type { PieArcLabelPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
4
5
  export interface PieArcLabelPlotSlots {
5
- pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps>;
6
+ pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps & PieArcLabelPropsOverrides>;
6
7
  }
7
8
  export interface PieArcLabelPlotSlotProps {
8
- pieArcLabel?: Partial<PieArcLabelProps>;
9
+ pieArcLabel?: Partial<PieArcLabelProps> & PieArcLabelPropsOverrides;
9
10
  }
10
11
  export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle'>, ComputedPieRadius {
11
12
  /**