@mui/x-charts 8.0.0-alpha.10 → 8.0.0-alpha.11

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 (108) hide show
  1. package/BarChart/BarChart.d.ts +1 -2
  2. package/BarChart/BarChart.js +2 -4
  3. package/BarChart/BarChart.plugins.d.ts +12 -0
  4. package/BarChart/BarChart.plugins.js +5 -0
  5. package/BarChart/useBarChartProps.d.ts +2 -3
  6. package/BarChart/useBarChartProps.js +5 -8
  7. package/CHANGELOG.md +107 -2
  8. package/ChartContainer/ChartContainer.d.ts +2 -2
  9. package/ChartContainer/ChartContainer.js +8 -1
  10. package/ChartContainer/useChartContainerProps.d.ts +4 -3
  11. package/ChartContainer/useChartContainerProps.js +11 -7
  12. package/ChartDataProvider/ChartDataProvider.js +4 -1
  13. package/ChartsSurface/ChartsSurface.d.ts +0 -6
  14. package/ChartsSurface/ChartsSurface.js +1 -10
  15. package/ChartsTooltip/ChartsTooltipContainer.js +2 -2
  16. package/Gauge/Gauge.js +0 -6
  17. package/Gauge/GaugeContainer.js +0 -6
  18. package/LineChart/LineChart.d.ts +1 -2
  19. package/LineChart/LineChart.js +2 -4
  20. package/LineChart/LineChart.plugins.d.ts +12 -0
  21. package/LineChart/LineChart.plugins.js +5 -0
  22. package/LineChart/useLineChartProps.d.ts +2 -3
  23. package/LineChart/useLineChartProps.js +5 -8
  24. package/PieChart/PieChart.d.ts +3 -1
  25. package/PieChart/PieChart.js +8 -115
  26. package/PieChart/PieChart.plugins.d.ts +5 -0
  27. package/PieChart/PieChart.plugins.js +3 -0
  28. package/ScatterChart/ScatterChart.js +8 -1
  29. package/ScatterChart/ScatterChart.plugins.d.ts +12 -0
  30. package/ScatterChart/ScatterChart.plugins.js +5 -0
  31. package/ScatterChart/useScatterChartProps.d.ts +2 -1
  32. package/ScatterChart/useScatterChartProps.js +3 -1
  33. package/SparkLineChart/SparkLineChart.d.ts +12 -0
  34. package/SparkLineChart/SparkLineChart.js +24 -4
  35. package/colorPalettes/colorPalettes.d.ts +2 -0
  36. package/context/ChartProvider/ChartProvider.types.d.ts +2 -1
  37. package/hooks/useAxisEvents.d.ts +0 -1
  38. package/hooks/useAxisEvents.js +0 -165
  39. package/index.d.ts +0 -1
  40. package/index.js +1 -2
  41. package/internals/plugins/allPlugins.d.ts +1 -1
  42. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +5 -2
  43. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +9 -0
  44. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +59 -0
  45. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.d.ts +1 -2
  46. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +142 -5
  47. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +19 -2
  48. package/models/axis.d.ts +17 -0
  49. package/models/axis.js +5 -1
  50. package/models/index.d.ts +1 -1
  51. package/modern/BarChart/BarChart.js +2 -4
  52. package/modern/BarChart/BarChart.plugins.js +5 -0
  53. package/modern/BarChart/useBarChartProps.js +5 -8
  54. package/modern/ChartContainer/ChartContainer.js +8 -1
  55. package/modern/ChartContainer/useChartContainerProps.js +11 -7
  56. package/modern/ChartDataProvider/ChartDataProvider.js +4 -1
  57. package/modern/ChartsSurface/ChartsSurface.js +1 -10
  58. package/modern/ChartsTooltip/ChartsTooltipContainer.js +2 -2
  59. package/modern/Gauge/Gauge.js +0 -6
  60. package/modern/Gauge/GaugeContainer.js +0 -6
  61. package/modern/LineChart/LineChart.js +2 -4
  62. package/modern/LineChart/LineChart.plugins.js +5 -0
  63. package/modern/LineChart/useLineChartProps.js +5 -8
  64. package/modern/PieChart/PieChart.js +8 -115
  65. package/modern/PieChart/PieChart.plugins.js +3 -0
  66. package/modern/ScatterChart/ScatterChart.js +8 -1
  67. package/modern/ScatterChart/ScatterChart.plugins.js +5 -0
  68. package/modern/ScatterChart/useScatterChartProps.js +3 -1
  69. package/modern/SparkLineChart/SparkLineChart.js +24 -4
  70. package/modern/hooks/useAxisEvents.js +0 -165
  71. package/modern/index.js +1 -2
  72. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +59 -0
  73. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +142 -5
  74. package/modern/models/axis.js +5 -1
  75. package/node/BarChart/BarChart.js +2 -4
  76. package/node/BarChart/BarChart.plugins.js +11 -0
  77. package/node/BarChart/useBarChartProps.js +5 -8
  78. package/node/ChartContainer/ChartContainer.js +8 -1
  79. package/node/ChartContainer/useChartContainerProps.js +11 -7
  80. package/node/ChartDataProvider/ChartDataProvider.js +4 -1
  81. package/node/ChartsSurface/ChartsSurface.js +1 -10
  82. package/node/ChartsTooltip/ChartsTooltipContainer.js +2 -2
  83. package/node/Gauge/Gauge.js +0 -6
  84. package/node/Gauge/GaugeContainer.js +0 -6
  85. package/node/LineChart/LineChart.js +2 -4
  86. package/node/LineChart/LineChart.plugins.js +11 -0
  87. package/node/LineChart/useLineChartProps.js +5 -8
  88. package/node/PieChart/PieChart.js +8 -115
  89. package/node/PieChart/PieChart.plugins.js +9 -0
  90. package/node/ScatterChart/ScatterChart.js +8 -1
  91. package/node/ScatterChart/ScatterChart.plugins.js +11 -0
  92. package/node/ScatterChart/useScatterChartProps.js +3 -1
  93. package/node/SparkLineChart/SparkLineChart.js +24 -4
  94. package/node/hooks/useAxisEvents.js +1 -173
  95. package/node/index.js +1 -12
  96. package/node/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +65 -0
  97. package/node/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +141 -4
  98. package/node/models/axis.js +5 -1
  99. package/package.json +2 -2
  100. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +0 -20
  101. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -82
  102. package/ChartsOnAxisClickHandler/index.d.ts +0 -1
  103. package/ChartsOnAxisClickHandler/index.js +0 -1
  104. package/ChartsOnAxisClickHandler/package.json +0 -6
  105. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -82
  106. package/modern/ChartsOnAxisClickHandler/index.js +0 -1
  107. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -88
  108. package/node/ChartsOnAxisClickHandler/index.js +0 -16
@@ -6,12 +6,18 @@ import { warnOnce } from '@mui/x-internals/warning';
6
6
  import { rainbowSurgePalette } from "../../../../colorPalettes/index.js";
7
7
  import { useSelector } from "../../../store/useSelector.js";
8
8
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
9
- import { selectorChartSeriesState } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
9
+ import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
10
10
  import { defaultizeAxis } from "./defaultizeAxis.js";
11
+ import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxis.selectors.js";
12
+ import { getAxisValue } from "./getAxisValue.js";
13
+ import { getSVGPoint } from "../../../getSVGPoint.js";
14
+ import { selectorChartsInteractionAxis } from "../useChartInteraction/index.js";
11
15
  export const useChartCartesianAxis = ({
12
16
  params,
13
17
  store,
14
- seriesConfig
18
+ seriesConfig,
19
+ svgRef,
20
+ instance
15
21
  }) => {
16
22
  const {
17
23
  xAxis,
@@ -26,7 +32,16 @@ export const useChartCartesianAxis = ({
26
32
  }
27
33
  }
28
34
  const drawingArea = useSelector(store, selectorChartDrawingArea);
29
- const formattedSeries = useSelector(store, selectorChartSeriesState);
35
+ const processedSeries = useSelector(store, selectorChartSeriesProcessed);
36
+ const interactionAxis = useSelector(store, selectorChartsInteractionAxis);
37
+ const {
38
+ axis: xAxisWithScale,
39
+ axisIds: xAxisIds
40
+ } = useSelector(store, selectorChartXAxis);
41
+ const {
42
+ axis: yAxisWithScale,
43
+ axisIds: yAxisIds
44
+ } = useSelector(store, selectorChartYAxis);
30
45
 
31
46
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useChartCartesianAxis`
32
47
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
@@ -42,13 +57,135 @@ export const useChartCartesianAxis = ({
42
57
  y: defaultizeAxis(yAxis, dataset, 'y')
43
58
  })
44
59
  }));
45
- }, [seriesConfig, drawingArea, formattedSeries, xAxis, yAxis, dataset, store]);
60
+ }, [seriesConfig, drawingArea, xAxis, yAxis, dataset, store]);
61
+ const usedXAxis = xAxisIds[0];
62
+ const usedYAxis = yAxisIds[0];
63
+
64
+ // Use a ref to avoid rerendering on every mousemove event.
65
+ const mousePosition = React.useRef({
66
+ isInChart: false,
67
+ x: -1,
68
+ y: -1
69
+ });
70
+ React.useEffect(() => {
71
+ const element = svgRef.current;
72
+ if (element === null || params.disableAxisListener) {
73
+ return () => {};
74
+ }
75
+ const handleOut = () => {
76
+ mousePosition.current = {
77
+ isInChart: false,
78
+ x: -1,
79
+ y: -1
80
+ };
81
+ instance.cleanInteraction();
82
+ };
83
+ const handleMove = event => {
84
+ const target = 'targetTouches' in event ? event.targetTouches[0] : event;
85
+ const svgPoint = getSVGPoint(element, target);
86
+ mousePosition.current.x = svgPoint.x;
87
+ mousePosition.current.y = svgPoint.y;
88
+ if (!instance.isPointInside(svgPoint, {
89
+ targetElement: event.target
90
+ })) {
91
+ if (mousePosition.current.isInChart) {
92
+ store.update(prev => _extends({}, prev, {
93
+ interaction: {
94
+ item: null,
95
+ axis: {
96
+ x: null,
97
+ y: null
98
+ }
99
+ }
100
+ }));
101
+ mousePosition.current.isInChart = false;
102
+ }
103
+ return;
104
+ }
105
+ mousePosition.current.isInChart = true;
106
+ instance.setAxisInteraction({
107
+ x: getAxisValue(xAxisWithScale[usedXAxis], svgPoint.x),
108
+ y: getAxisValue(yAxisWithScale[usedYAxis], svgPoint.y)
109
+ });
110
+ };
111
+ const handleDown = event => {
112
+ const target = event.currentTarget;
113
+ if (!target) {
114
+ return;
115
+ }
116
+ if (target.hasPointerCapture(event.pointerId)) {
117
+ target.releasePointerCapture(event.pointerId);
118
+ }
119
+ };
120
+ element.addEventListener('pointerdown', handleDown);
121
+ element.addEventListener('pointermove', handleMove);
122
+ element.addEventListener('pointerout', handleOut);
123
+ element.addEventListener('pointercancel', handleOut);
124
+ element.addEventListener('pointerleave', handleOut);
125
+ return () => {
126
+ element.removeEventListener('pointerdown', handleDown);
127
+ element.removeEventListener('pointermove', handleMove);
128
+ element.removeEventListener('pointerout', handleOut);
129
+ element.removeEventListener('pointercancel', handleOut);
130
+ element.removeEventListener('pointerleave', handleOut);
131
+ };
132
+ }, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener]);
133
+ React.useEffect(() => {
134
+ const element = svgRef.current;
135
+ if (element === null || !params.onAxisClick) {
136
+ return () => {};
137
+ }
138
+ const handleMouseClick = event => {
139
+ event.preventDefault();
140
+ let dataIndex = null;
141
+ let isXaxis = false;
142
+ if (interactionAxis.x === null && interactionAxis.y === null) {
143
+ const svgPoint = getSVGPoint(element, event);
144
+ const xIndex = getAxisValue(xAxisWithScale[usedXAxis], svgPoint.x)?.index ?? null;
145
+ isXaxis = xIndex !== null && xIndex !== -1;
146
+ dataIndex = isXaxis ? xIndex : getAxisValue(yAxisWithScale[usedYAxis], svgPoint.y)?.index ?? null;
147
+ } else {
148
+ isXaxis = interactionAxis.x !== null && interactionAxis.x.index !== -1;
149
+ dataIndex = isXaxis ? interactionAxis.x && interactionAxis.x.index : interactionAxis.y && interactionAxis.y.index;
150
+ }
151
+ const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
152
+ if (dataIndex == null || dataIndex === -1) {
153
+ return;
154
+ }
155
+
156
+ // The .data exist because otherwise the dataIndex would be null or -1.
157
+ const axisValue = (isXaxis ? xAxisWithScale : yAxisWithScale)[USED_AXIS_ID].data[dataIndex];
158
+ const seriesValues = {};
159
+ Object.keys(processedSeries).filter(seriesType => ['bar', 'line'].includes(seriesType)).forEach(seriesType => {
160
+ processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
161
+ const seriesItem = processedSeries[seriesType].series[seriesId];
162
+ const providedXAxisId = seriesItem.xAxisId;
163
+ const providedYAxisId = seriesItem.yAxisId;
164
+ const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
165
+ if (axisKey === undefined || axisKey === USED_AXIS_ID) {
166
+ seriesValues[seriesId] = seriesItem.data[dataIndex];
167
+ }
168
+ });
169
+ });
170
+ params.onAxisClick?.(event, {
171
+ dataIndex,
172
+ axisValue,
173
+ seriesValues
174
+ });
175
+ };
176
+ element.addEventListener('click', handleMouseClick);
177
+ return () => {
178
+ element.removeEventListener('click', handleMouseClick);
179
+ };
180
+ }, [params.onAxisClick, processedSeries, svgRef, xAxisWithScale, xAxisIds, yAxisWithScale, yAxisIds, params, interactionAxis, usedXAxis, usedYAxis]);
46
181
  return {};
47
182
  };
48
183
  useChartCartesianAxis.params = {
49
184
  xAxis: true,
50
185
  yAxis: true,
51
- dataset: true
186
+ dataset: true,
187
+ onAxisClick: true,
188
+ disableAxisListener: true
52
189
  };
53
190
  useChartCartesianAxis.getDefaultizedParams = ({
54
191
  params
@@ -8,4 +8,8 @@ export function isBandScaleConfig(scaleConfig) {
8
8
  }
9
9
  export function isPointScaleConfig(scaleConfig) {
10
10
  return scaleConfig.scaleType === 'point';
11
- }
11
+ }
12
+
13
+ /**
14
+ * The data format returned by onAxisClick.
15
+ */
@@ -18,7 +18,6 @@ var _ChartsLegend = require("../ChartsLegend");
18
18
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
19
19
  var _ChartsClipPath = require("../ChartsClipPath");
20
20
  var _ChartsGrid = require("../ChartsGrid");
21
- var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
22
21
  var _ChartsOverlay = require("../ChartsOverlay/ChartsOverlay");
23
22
  var _useBarChartProps = require("./useBarChartProps");
24
23
  var _ChartDataProvider = require("../ChartDataProvider");
@@ -46,7 +45,6 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
46
45
  chartsWrapperProps,
47
46
  chartContainerProps,
48
47
  barPlotProps,
49
- axisClickHandlerProps,
50
48
  gridProps,
51
49
  clipPathProps,
52
50
  clipPathGroupProps,
@@ -64,7 +62,7 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
64
62
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartDataProvider.ChartDataProvider, (0, _extends2.default)({}, chartDataProviderProps, {
65
63
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsWrapper.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
66
64
  children: [!props.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
67
- children: [props.onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, (0, _extends2.default)({}, axisClickHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
65
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
68
66
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_BarPlot.BarPlot, (0, _extends2.default)({}, barPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps))]
69
67
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, props.slotProps?.tooltip)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, (0, _extends2.default)({}, clipPathProps)), children]
70
68
  }))]
@@ -111,7 +109,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
111
109
  className: _propTypes.default.string,
112
110
  /**
113
111
  * Color palette used to colorize multiple series.
114
- * @default blueberryTwilightPalette
112
+ * @default rainbowSurgePalette
115
113
  */
116
114
  colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
117
115
  /**
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BAR_CHART_PLUGINS = void 0;
7
+ var _useChartZAxis = require("../internals/plugins/featurePlugins/useChartZAxis");
8
+ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
9
+ var _useChartInteraction = require("../internals/plugins/featurePlugins/useChartInteraction");
10
+ var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
11
+ const BAR_CHART_PLUGINS = exports.BAR_CHART_PLUGINS = [_useChartZAxis.useChartZAxis, _useChartCartesianAxis.useChartCartesianAxis, _useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight];
@@ -11,7 +11,8 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
11
11
  var _useId = _interopRequireDefault(require("@mui/utils/useId"));
12
12
  var _constants = require("../constants");
13
13
  var _calculateMargins = require("../internals/calculateMargins");
14
- const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "axisHighlight", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend"];
14
+ var _BarChart = require("./BarChart.plugins");
15
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend"];
15
16
  /**
16
17
  * A helper function that extracts BarChartProps from the input props
17
18
  * and returns an object with props for the children components of BarChart.
@@ -30,7 +31,6 @@ const useBarChartProps = props => {
30
31
  colors,
31
32
  dataset,
32
33
  sx,
33
- onAxisClick,
34
34
  axisHighlight,
35
35
  grid,
36
36
  topAxis,
@@ -85,9 +85,10 @@ const useBarChartProps = props => {
85
85
  }, defaultAxisConfig)] : undefined),
86
86
  highlightedItem,
87
87
  onHighlightChange,
88
- disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
88
+ disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
89
89
  className,
90
- skipAnimation
90
+ skipAnimation,
91
+ plugins: _BarChart.BAR_CHART_PLUGINS
91
92
  });
92
93
  const barPlotProps = {
93
94
  onItemClick,
@@ -96,9 +97,6 @@ const useBarChartProps = props => {
96
97
  borderRadius,
97
98
  barLabel
98
99
  };
99
- const axisClickHandlerProps = {
100
- onAxisClick
101
- };
102
100
  const gridProps = {
103
101
  vertical: grid?.vertical,
104
102
  horizontal: grid?.horizontal
@@ -140,7 +138,6 @@ const useBarChartProps = props => {
140
138
  chartsWrapperProps,
141
139
  chartContainerProps,
142
140
  barPlotProps,
143
- axisClickHandlerProps,
144
141
  gridProps,
145
142
  clipPathProps,
146
143
  clipPathGroupProps,
@@ -65,7 +65,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
65
65
  className: _propTypes.default.string,
66
66
  /**
67
67
  * Color palette used to colorize multiple series.
68
- * @default blueberryTwilightPalette
68
+ * @default rainbowSurgePalette
69
69
  */
70
70
  colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
71
71
  /**
@@ -107,6 +107,13 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
107
107
  right: _propTypes.default.number,
108
108
  top: _propTypes.default.number
109
109
  }),
110
+ /**
111
+ * The function called for onClick events.
112
+ * The second argument contains information about all line/bar elements at the current mouse position.
113
+ * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
114
+ * @param {null | AxisData} data The data about the clicked axis and items associated with it.
115
+ */
116
+ onAxisClick: _propTypes.default.func,
110
117
  /**
111
118
  * The callback fired when the highlighted item changes.
112
119
  *
@@ -9,9 +9,10 @@ exports.useChartContainerProps = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
11
  var _allPlugins = require("../internals/plugins/allPlugins");
12
- const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "skipAnimation", "seriesConfig"];
12
+ const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "skipAnimation", "seriesConfig", "plugins"];
13
13
  const useChartContainerProps = (props, ref) => {
14
- const {
14
+ const _ref = props,
15
+ {
15
16
  width,
16
17
  height,
17
18
  margin,
@@ -20,6 +21,7 @@ const useChartContainerProps = (props, ref) => {
20
21
  colors,
21
22
  dataset,
22
23
  desc,
24
+ onAxisClick,
23
25
  disableAxisListener,
24
26
  highlightedItem,
25
27
  onHighlightChange,
@@ -29,14 +31,14 @@ const useChartContainerProps = (props, ref) => {
29
31
  yAxis,
30
32
  zAxis,
31
33
  skipAnimation,
32
- seriesConfig
33
- } = props,
34
- other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
34
+ seriesConfig,
35
+ plugins
36
+ } = _ref,
37
+ other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
35
38
  const chartsSurfaceProps = (0, _extends2.default)({
36
39
  title,
37
40
  desc,
38
41
  sx,
39
- disableAxisListener,
40
42
  ref
41
43
  }, other);
42
44
  const chartDataProviderProps = {
@@ -46,14 +48,16 @@ const useChartContainerProps = (props, ref) => {
46
48
  dataset,
47
49
  highlightedItem,
48
50
  onHighlightChange,
51
+ onAxisClick,
49
52
  xAxis,
50
53
  yAxis,
51
54
  zAxis,
52
55
  skipAnimation,
53
56
  width,
54
57
  height,
58
+ disableAxisListener,
55
59
  seriesConfig,
56
- plugins: _allPlugins.ALL_PLUGINS
60
+ plugins: plugins ?? _allPlugins.ALL_PLUGINS
57
61
  };
58
62
  return {
59
63
  chartDataProviderProps,
@@ -62,9 +62,12 @@ process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
62
62
  children: _propTypes.default.node,
63
63
  /**
64
64
  * Color palette used to colorize multiple series.
65
- * @default blueberryTwilightPalette
65
+ * @default rainbowSurgePalette
66
66
  */
67
67
  colors: _propTypes.default.any,
68
+ /**
69
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
70
+ */
68
71
  dataset: _propTypes.default.any,
69
72
  /**
70
73
  * The height of the chart in px. If not defined, it takes the height of the parent element.
@@ -13,14 +13,13 @@ var _styles = require("@mui/material/styles");
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var React = _interopRequireWildcard(require("react"));
15
15
  var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
16
- var _useAxisEvents = require("../hooks/useAxisEvents");
17
16
  var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
18
17
  var _useSvgRef = require("../hooks/useSvgRef");
19
18
  var _useSelector = require("../internals/store/useSelector");
20
19
  var _useStore = require("../internals/store/useStore");
21
20
  var _useChartDimensions = require("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors");
22
21
  var _jsxRuntime = require("react/jsx-runtime");
23
- const _excluded = ["children", "disableAxisListener", "className", "title", "desc"];
22
+ const _excluded = ["children", "className", "title", "desc"];
24
23
  const ChartsSurfaceStyles = (0, _styles.styled)('svg', {
25
24
  name: 'MuiChartsSurface',
26
25
  slot: 'Root'
@@ -72,14 +71,12 @@ const ChartsSurface = exports.ChartsSurface = /*#__PURE__*/React.forwardRef(func
72
71
  });
73
72
  const {
74
73
  children,
75
- disableAxisListener = false,
76
74
  className,
77
75
  title,
78
76
  desc
79
77
  } = themeProps,
80
78
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
81
79
  const hasIntrinsicSize = svgHeight > 0 && svgWidth > 0;
82
- (0, _useAxisEvents.useAxisEvents)(disableAxisListener);
83
80
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChartsSurfaceStyles, (0, _extends2.default)({
84
81
  ownerState: {
85
82
  width: propsWidth,
@@ -104,12 +101,6 @@ process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
104
101
  children: _propTypes.default.node,
105
102
  className: _propTypes.default.string,
106
103
  desc: _propTypes.default.string,
107
- /**
108
- * If `true`, the charts will not listen to the mouse move event.
109
- * It might break interactive features, but will improve performance.
110
- * @default false
111
- */
112
- disableAxisListener: _propTypes.default.bool,
113
104
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
114
105
  title: _propTypes.default.string
115
106
  } : void 0;
@@ -34,6 +34,7 @@ const ChartsTooltipRoot = (0, _styles.styled)(_Popper.default, {
34
34
  pointerEvents: 'none',
35
35
  zIndex: theme.zIndex.modal
36
36
  }));
37
+ const axisHasData = axis => axis?.data !== undefined && axis.data.length !== 0;
37
38
 
38
39
  /**
39
40
  * Demos:
@@ -58,7 +59,6 @@ function ChartsTooltipContainer(inProps) {
58
59
  const svgRef = (0, _useSvgRef.useSvgRef)();
59
60
  const pointerType = (0, _utils.usePointerType)();
60
61
  const xAxis = (0, _hooks.useXAxis)();
61
- const xAxisHasData = xAxis.data !== undefined && xAxis.data.length !== 0;
62
62
  const popperRef = React.useRef(null);
63
63
  const positionRef = (0, _useLazyRef.default)(() => ({
64
64
  x: 0,
@@ -67,7 +67,7 @@ function ChartsTooltipContainer(inProps) {
67
67
  const store = (0, _useStore.useStore)();
68
68
  const isOpen = (0, _useSelector.useSelector)(store,
69
69
  // eslint-disable-next-line no-nested-ternary
70
- trigger === 'axis' ? xAxisHasData ? _useChartInteraction.selectorChartsInteractionXAxisIsDefined : _useChartInteraction.selectorChartsInteractionYAxisIsDefined : _useChartInteraction.selectorChartsInteractionItemIsDefined);
70
+ trigger === 'axis' ? axisHasData(xAxis) ? _useChartInteraction.selectorChartsInteractionXAxisIsDefined : _useChartInteraction.selectorChartsInteractionYAxisIsDefined : _useChartInteraction.selectorChartsInteractionItemIsDefined);
71
71
  const popperOpen = pointerType !== null && isOpen; // tooltipHasData;
72
72
 
73
73
  React.useEffect(() => {
@@ -80,12 +80,6 @@ process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
80
80
  */
81
81
  cy: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
82
82
  desc: _propTypes.default.string,
83
- /**
84
- * If `true`, the charts will not listen to the mouse move event.
85
- * It might break interactive features, but will improve performance.
86
- * @default false
87
- */
88
- disableAxisListener: _propTypes.default.bool,
89
83
  /**
90
84
  * The end angle (deg).
91
85
  * @default 360
@@ -110,12 +110,6 @@ process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
110
110
  */
111
111
  cy: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
112
112
  desc: _propTypes.default.string,
113
- /**
114
- * If `true`, the charts will not listen to the mouse move event.
115
- * It might break interactive features, but will improve performance.
116
- * @default false
117
- */
118
- disableAxisListener: _propTypes.default.bool,
119
113
  /**
120
114
  * The end angle (deg).
121
115
  * @default 360
@@ -21,7 +21,6 @@ var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
21
21
  var _ChartsClipPath = require("../ChartsClipPath");
22
22
  var _LineHighlightPlot = require("./LineHighlightPlot");
23
23
  var _ChartsGrid = require("../ChartsGrid");
24
- var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
25
24
  var _ChartsOverlay = require("../ChartsOverlay");
26
25
  var _useLineChartProps = require("./useLineChartProps");
27
26
  var _useChartContainerProps = require("../ChartContainer/useChartContainerProps");
@@ -47,7 +46,6 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
47
46
  const {
48
47
  chartsWrapperProps,
49
48
  chartContainerProps,
50
- axisClickHandlerProps,
51
49
  gridProps,
52
50
  clipPathProps,
53
51
  clipPathGroupProps,
@@ -69,7 +67,7 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
69
67
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartDataProvider.ChartDataProvider, (0, _extends2.default)({}, chartDataProviderProps, {
70
68
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsWrapper.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
71
69
  children: [!props.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
72
- children: [props.onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, (0, _extends2.default)({}, axisClickHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
70
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
73
71
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaPlot.AreaPlot, (0, _extends2.default)({}, areaPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinePlot.LinePlot, (0, _extends2.default)({}, linePlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps))]
74
72
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
75
73
  "data-drawing-container": true,
@@ -106,7 +104,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
106
104
  className: _propTypes.default.string,
107
105
  /**
108
106
  * Color palette used to colorize multiple series.
109
- * @default blueberryTwilightPalette
107
+ * @default rainbowSurgePalette
110
108
  */
111
109
  colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
112
110
  /**
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LINE_CHART_PLUGINS = void 0;
7
+ var _useChartZAxis = require("../internals/plugins/featurePlugins/useChartZAxis");
8
+ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
9
+ var _useChartInteraction = require("../internals/plugins/featurePlugins/useChartInteraction");
10
+ var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
11
+ const LINE_CHART_PLUGINS = exports.LINE_CHART_PLUGINS = [_useChartZAxis.useChartZAxis, _useChartCartesianAxis.useChartCartesianAxis, _useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight];
@@ -11,7 +11,8 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
11
11
  var _useId = _interopRequireDefault(require("@mui/utils/useId"));
12
12
  var _constants = require("../constants");
13
13
  var _calculateMargins = require("../internals/calculateMargins");
14
- const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
14
+ var _LineChart = require("./LineChart.plugins");
15
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
15
16
  /**
16
17
  * A helper function that extracts LineChartProps from the input props
17
18
  * and returns an object with props for the children components of LineChart.
@@ -30,7 +31,6 @@ const useLineChartProps = props => {
30
31
  colors,
31
32
  dataset,
32
33
  sx,
33
- onAxisClick,
34
34
  onAreaClick,
35
35
  onLineClick,
36
36
  onMarkClick,
@@ -79,13 +79,11 @@ const useLineChartProps = props => {
79
79
  yAxis,
80
80
  highlightedItem,
81
81
  onHighlightChange,
82
- disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
82
+ disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
83
83
  className,
84
- skipAnimation
84
+ skipAnimation,
85
+ plugins: _LineChart.LINE_CHART_PLUGINS
85
86
  });
86
- const axisClickHandlerProps = {
87
- onAxisClick
88
- };
89
87
  const gridProps = {
90
88
  vertical: grid?.vertical,
91
89
  horizontal: grid?.horizontal
@@ -144,7 +142,6 @@ const useLineChartProps = props => {
144
142
  return {
145
143
  chartsWrapperProps,
146
144
  chartContainerProps,
147
- axisClickHandlerProps,
148
145
  gridProps,
149
146
  clipPathProps,
150
147
  clipPathGroupProps,