@mui/x-charts 7.9.0 → 7.11.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 (222) hide show
  1. package/BarChart/BarChart.js +2 -2
  2. package/BarChart/formatter.js +1 -1
  3. package/BarChart/useBarChartProps.js +38 -33
  4. package/CHANGELOG.md +159 -0
  5. package/ChartContainer/ChartContainer.d.ts +28 -2
  6. package/ChartContainer/ChartContainer.js +25 -66
  7. package/ChartContainer/useChartContainerHooks.d.ts +1 -1
  8. package/ChartContainer/useChartContainerHooks.js +2 -2
  9. package/ChartContainer/useChartContainerProps.d.ts +86 -0
  10. package/ChartContainer/useChartContainerProps.js +95 -0
  11. package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
  12. package/ChartContainer/useDefaultizeAxis.js +29 -0
  13. package/ChartsLegend/ChartsLegend.d.ts +3 -12
  14. package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
  15. package/ChartsLegend/ContinuousColorLegend.js +398 -0
  16. package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
  17. package/ChartsLegend/DefaultChartsLegend.js +13 -198
  18. package/ChartsLegend/LegendPerItem.d.ts +61 -0
  19. package/ChartsLegend/LegendPerItem.js +151 -0
  20. package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
  21. package/ChartsLegend/PiecewiseColorLegend.js +169 -0
  22. package/ChartsLegend/chartsLegend.types.d.ts +31 -0
  23. package/ChartsLegend/chartsLegend.types.js +5 -0
  24. package/ChartsLegend/index.d.ts +2 -0
  25. package/ChartsLegend/index.js +22 -0
  26. package/ChartsLegend/legend.types.d.ts +62 -0
  27. package/ChartsLegend/legend.types.js +5 -0
  28. package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
  29. package/ChartsLegend/legendItemsPlacement.js +79 -0
  30. package/ChartsLegend/useAxis.d.ts +7 -0
  31. package/ChartsLegend/useAxis.js +47 -0
  32. package/ChartsLegend/utils.d.ts +1 -8
  33. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  34. package/ChartsSurface.js +3 -1
  35. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
  36. package/ChartsXAxis/ChartsXAxis.js +1 -1
  37. package/ChartsYAxis/ChartsYAxis.js +15 -3
  38. package/Gauge/Gauge.d.ts +1 -4
  39. package/Gauge/Gauge.js +9 -6
  40. package/Gauge/GaugeContainer.js +8 -4
  41. package/Gauge/GaugeProvider.js +9 -9
  42. package/LineChart/AnimatedArea.js +2 -2
  43. package/LineChart/AnimatedLine.js +2 -2
  44. package/LineChart/AreaPlot.js +7 -1
  45. package/LineChart/LineChart.js +2 -2
  46. package/LineChart/LineHighlightPlot.js +8 -0
  47. package/LineChart/MarkElement.js +2 -2
  48. package/LineChart/MarkPlot.js +4 -20
  49. package/LineChart/extremums.js +1 -1
  50. package/LineChart/formatter.js +1 -1
  51. package/LineChart/useLineChartProps.js +38 -33
  52. package/PieChart/PieChart.d.ts +1 -4
  53. package/PieChart/PieChart.js +40 -34
  54. package/PieChart/PiePlot.js +6 -6
  55. package/PieChart/getPieCoordinates.js +3 -3
  56. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  57. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
  58. package/ResponsiveChartContainer/useChartContainerDimensions.js +6 -2
  59. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
  60. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
  61. package/ScatterChart/Scatter.js +6 -9
  62. package/ScatterChart/useScatterChartProps.js +35 -30
  63. package/SparkLineChart/SparkLineChart.js +27 -22
  64. package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
  65. package/context/CartesianProvider/CartesianProvider.js +18 -7
  66. package/context/CartesianProvider/computeValue.d.ts +32 -9
  67. package/context/CartesianProvider/computeValue.js +20 -16
  68. package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
  69. package/context/CartesianProvider/defaultizeAxis.js +21 -0
  70. package/context/CartesianProvider/index.d.ts +0 -1
  71. package/context/CartesianProvider/index.js +1 -3
  72. package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
  73. package/context/CartesianProvider/normalizeAxis.js +1 -1
  74. package/context/DrawingProvider.d.ts +11 -0
  75. package/context/DrawingProvider.js +9 -2
  76. package/context/HighlightedProvider/HighlightedProvider.js +2 -2
  77. package/esm/BarChart/BarChart.js +2 -2
  78. package/esm/BarChart/formatter.js +1 -1
  79. package/esm/BarChart/useBarChartProps.js +38 -33
  80. package/esm/ChartContainer/ChartContainer.js +25 -66
  81. package/esm/ChartContainer/useChartContainerHooks.js +2 -2
  82. package/esm/ChartContainer/useChartContainerProps.js +87 -0
  83. package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
  84. package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
  85. package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
  86. package/esm/ChartsLegend/LegendPerItem.js +141 -0
  87. package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
  88. package/esm/ChartsLegend/chartsLegend.types.js +1 -0
  89. package/esm/ChartsLegend/index.js +2 -0
  90. package/esm/ChartsLegend/legend.types.js +1 -0
  91. package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
  92. package/esm/ChartsLegend/useAxis.js +39 -0
  93. package/esm/ChartsSurface.js +3 -1
  94. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
  95. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  96. package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
  97. package/esm/Gauge/Gauge.js +8 -5
  98. package/esm/Gauge/GaugeContainer.js +8 -4
  99. package/esm/Gauge/GaugeProvider.js +1 -1
  100. package/esm/LineChart/AnimatedArea.js +1 -1
  101. package/esm/LineChart/AnimatedLine.js +1 -1
  102. package/esm/LineChart/AreaPlot.js +7 -1
  103. package/esm/LineChart/LineChart.js +2 -2
  104. package/esm/LineChart/LineHighlightPlot.js +8 -0
  105. package/esm/LineChart/MarkElement.js +1 -1
  106. package/esm/LineChart/MarkPlot.js +3 -19
  107. package/esm/LineChart/extremums.js +1 -1
  108. package/esm/LineChart/formatter.js +1 -1
  109. package/esm/LineChart/useLineChartProps.js +38 -33
  110. package/esm/PieChart/PieChart.js +39 -33
  111. package/esm/PieChart/PiePlot.js +1 -1
  112. package/esm/PieChart/getPieCoordinates.js +1 -1
  113. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  114. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +6 -2
  115. package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  116. package/esm/ScatterChart/Scatter.js +6 -9
  117. package/esm/ScatterChart/useScatterChartProps.js +35 -30
  118. package/esm/SparkLineChart/SparkLineChart.js +27 -22
  119. package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
  120. package/esm/context/CartesianProvider/computeValue.js +20 -16
  121. package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
  122. package/esm/context/CartesianProvider/index.js +1 -3
  123. package/esm/context/CartesianProvider/normalizeAxis.js +1 -1
  124. package/esm/context/DrawingProvider.js +9 -2
  125. package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
  126. package/esm/hooks/useAxisEvents.js +3 -10
  127. package/esm/hooks/useDrawingArea.js +5 -3
  128. package/esm/hooks/useReducedMotion.js +4 -2
  129. package/esm/internals/cleanId.js +6 -0
  130. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  131. package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
  132. package/esm/internals/getSymbol.js +5 -0
  133. package/esm/internals/index.js +3 -1
  134. package/esm/internals/isDefined.js +3 -0
  135. package/esm/internals/notNull.js +3 -0
  136. package/esm/internals/ts-generic.js +1 -0
  137. package/hooks/useAxisEvents.js +3 -10
  138. package/hooks/useDrawingArea.js +5 -3
  139. package/hooks/useReducedMotion.js +4 -2
  140. package/index.js +1 -1
  141. package/internals/cleanId.d.ts +4 -0
  142. package/internals/cleanId.js +12 -0
  143. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
  144. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  145. package/internals/getPercentageValue.d.ts +7 -0
  146. package/internals/{utils.js → getPercentageValue.js} +1 -15
  147. package/internals/getSymbol.d.ts +2 -0
  148. package/internals/getSymbol.js +11 -0
  149. package/internals/index.d.ts +3 -1
  150. package/internals/index.js +25 -5
  151. package/internals/isDefined.d.ts +1 -0
  152. package/internals/isDefined.js +9 -0
  153. package/internals/notNull.d.ts +1 -0
  154. package/internals/notNull.js +9 -0
  155. package/internals/ts-generic.d.ts +5 -0
  156. package/internals/ts-generic.js +5 -0
  157. package/models/axis.d.ts +5 -2
  158. package/models/helpers.d.ts +1 -0
  159. package/models/seriesType/config.d.ts +2 -16
  160. package/modern/BarChart/BarChart.js +2 -2
  161. package/modern/BarChart/formatter.js +1 -1
  162. package/modern/BarChart/useBarChartProps.js +38 -33
  163. package/modern/ChartContainer/ChartContainer.js +25 -66
  164. package/modern/ChartContainer/useChartContainerHooks.js +2 -2
  165. package/modern/ChartContainer/useChartContainerProps.js +87 -0
  166. package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
  167. package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
  168. package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
  169. package/modern/ChartsLegend/LegendPerItem.js +141 -0
  170. package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
  171. package/modern/ChartsLegend/chartsLegend.types.js +1 -0
  172. package/modern/ChartsLegend/index.js +2 -0
  173. package/modern/ChartsLegend/legend.types.js +1 -0
  174. package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
  175. package/modern/ChartsLegend/useAxis.js +39 -0
  176. package/modern/ChartsSurface.js +3 -1
  177. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
  178. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  179. package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
  180. package/modern/Gauge/Gauge.js +8 -5
  181. package/modern/Gauge/GaugeContainer.js +8 -4
  182. package/modern/Gauge/GaugeProvider.js +1 -1
  183. package/modern/LineChart/AnimatedArea.js +1 -1
  184. package/modern/LineChart/AnimatedLine.js +1 -1
  185. package/modern/LineChart/AreaPlot.js +7 -1
  186. package/modern/LineChart/LineChart.js +2 -2
  187. package/modern/LineChart/LineHighlightPlot.js +8 -0
  188. package/modern/LineChart/MarkElement.js +1 -1
  189. package/modern/LineChart/MarkPlot.js +3 -19
  190. package/modern/LineChart/extremums.js +1 -1
  191. package/modern/LineChart/formatter.js +1 -1
  192. package/modern/LineChart/useLineChartProps.js +38 -33
  193. package/modern/PieChart/PieChart.js +39 -33
  194. package/modern/PieChart/PiePlot.js +1 -1
  195. package/modern/PieChart/getPieCoordinates.js +1 -1
  196. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  197. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +6 -2
  198. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  199. package/modern/ScatterChart/Scatter.js +6 -9
  200. package/modern/ScatterChart/useScatterChartProps.js +35 -30
  201. package/modern/SparkLineChart/SparkLineChart.js +27 -22
  202. package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
  203. package/modern/context/CartesianProvider/computeValue.js +20 -16
  204. package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
  205. package/modern/context/CartesianProvider/index.js +1 -3
  206. package/modern/context/CartesianProvider/normalizeAxis.js +1 -1
  207. package/modern/context/DrawingProvider.js +9 -2
  208. package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
  209. package/modern/hooks/useAxisEvents.js +3 -10
  210. package/modern/hooks/useDrawingArea.js +5 -3
  211. package/modern/hooks/useReducedMotion.js +4 -2
  212. package/modern/index.js +1 -1
  213. package/modern/internals/cleanId.js +6 -0
  214. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  215. package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
  216. package/modern/internals/getSymbol.js +5 -0
  217. package/modern/internals/index.js +3 -1
  218. package/modern/internals/isDefined.js +3 -0
  219. package/modern/internals/notNull.js +3 -0
  220. package/modern/internals/ts-generic.js +1 -0
  221. package/package.json +4 -4
  222. package/internals/utils.d.ts +0 -18
@@ -1,6 +1,6 @@
1
1
  // @ignore - do not document.
2
2
  import * as React from 'react';
3
- import { getPercentageValue } from '../internals/utils';
3
+ import { getPercentageValue } from '../internals/getPercentageValue';
4
4
  import { getArcRatios, getAvailableRadius } from './utils';
5
5
  import { useDrawingArea } from '../hooks/useDrawingArea';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -7,7 +7,7 @@ import { styled } from '@mui/material/styles';
7
7
  import { color as d3Color } from 'd3-color';
8
8
  import { animated, useSpring } from '@react-spring/web';
9
9
  import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { cleanId } from '../internals/utils';
10
+ import { cleanId } from '../internals/cleanId';
11
11
  import { useChartId, useDrawingArea } from '../hooks';
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  export const AreaElementPath = styled(animated.path, {
@@ -7,7 +7,7 @@ import { animated, useSpring } from '@react-spring/web';
7
7
  import { color as d3Color } from 'd3-color';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { cleanId } from '../internals/utils';
10
+ import { cleanId } from '../internals/cleanId';
11
11
  import { useChartId } from '../hooks/useChartId';
12
12
  import { useDrawingArea } from '../hooks/useDrawingArea';
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -54,7 +54,13 @@ const useAggregatedData = () => {
54
54
  throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
55
55
  }
56
56
  }
57
- const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
57
+ const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
58
+ const value = d.y && yScale(d.y[0]);
59
+ if (Number.isNaN(value)) {
60
+ return yScale.range()[0];
61
+ }
62
+ return value;
63
+ }).y1(d => d.y && yScale(d.y[1]));
58
64
  const curve = getCurveFactory(series[seriesId].curve);
59
65
  const formattedData = xData?.map((x, index) => ({
60
66
  x,
@@ -48,8 +48,8 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
48
48
  ref: ref
49
49
  }, chartContainerProps, {
50
50
  children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
51
- children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps))]
52
- })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps)), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
51
+ children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
52
+ })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps)), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
53
53
  }));
54
54
  });
55
55
  process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
@@ -10,6 +10,7 @@ import { InteractionContext } from '../context/InteractionProvider';
10
10
  import { DEFAULT_X_AXIS_KEY } from '../constants';
11
11
  import getColor from './getColor';
12
12
  import { useLineSeries } from '../hooks/useSeries';
13
+ import { useDrawingArea } from '../hooks/useDrawingArea';
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  /**
15
16
  * Demos:
@@ -29,6 +30,7 @@ function LineHighlightPlot(props) {
29
30
  other = _objectWithoutPropertiesLoose(props, _excluded);
30
31
  const seriesData = useLineSeries();
31
32
  const axisData = useCartesianContext();
33
+ const drawingArea = useDrawingArea();
32
34
  const {
33
35
  axis
34
36
  } = React.useContext(InteractionContext);
@@ -76,6 +78,12 @@ function LineHighlightPlot(props) {
76
78
  const x = xScale(xData[highlightedIndex]);
77
79
  const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
78
80
 
81
+ if (!drawingArea.isPointInside({
82
+ x,
83
+ y
84
+ })) {
85
+ return null;
86
+ }
79
87
  const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
80
88
  return /*#__PURE__*/_jsx(Element, _extends({
81
89
  id: seriesId,
@@ -9,7 +9,7 @@ import { styled } from '@mui/material/styles';
9
9
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
10
  import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
11
11
  import { animated, to, useSpring } from '@react-spring/web';
12
- import { getSymbol } from '../internals/utils';
12
+ import { getSymbol } from '../internals/getSymbol';
13
13
  import { InteractionContext } from '../context/InteractionProvider';
14
14
  import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
15
15
  import { useItemHighlighted } from '../context';
@@ -8,7 +8,7 @@ import { MarkElement } from './MarkElement';
8
8
  import { getValueToPositionMapper } from '../hooks/useScale';
9
9
  import { useChartId } from '../hooks/useChartId';
10
10
  import { DEFAULT_X_AXIS_KEY } from '../constants';
11
- import { cleanId } from '../internals/utils';
11
+ import { cleanId } from '../internals/cleanId';
12
12
  import getColor from './getColor';
13
13
  import { useLineSeries } from '../hooks/useSeries';
14
14
  import { useDrawingArea } from '../hooks/useDrawingArea';
@@ -34,10 +34,7 @@ function MarkPlot(props) {
34
34
  const seriesData = useLineSeries();
35
35
  const axisData = useCartesianContext();
36
36
  const chartId = useChartId();
37
- const {
38
- left,
39
- width
40
- } = useDrawingArea();
37
+ const drawingArea = useDrawingArea();
41
38
  const Mark = slots?.mark ?? MarkElement;
42
39
  if (seriesData === undefined) {
43
40
  return null;
@@ -72,19 +69,6 @@ function MarkPlot(props) {
72
69
  const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
73
70
  const yScale = yAxis[yAxisKey].scale;
74
71
  const xData = xAxis[xAxisKey].data;
75
- const yRange = yScale.range();
76
- const isInRange = ({
77
- x,
78
- y
79
- }) => {
80
- if (x < left || x > left + width) {
81
- return false;
82
- }
83
- if (y < Math.min(...yRange) || y > Math.max(...yRange)) {
84
- return false;
85
- }
86
- return true;
87
- };
88
72
  if (xData === undefined) {
89
73
  throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
90
74
  }
@@ -113,7 +97,7 @@ function MarkPlot(props) {
113
97
  // Remove missing data point
114
98
  return false;
115
99
  }
116
- if (!isInRange({
100
+ if (!drawingArea.isPointInside({
117
101
  x,
118
102
  y
119
103
  })) {
@@ -30,7 +30,7 @@ export const getExtremumY = params => {
30
30
  stackedData
31
31
  } = series[seriesId];
32
32
  const isArea = area !== undefined;
33
- const getValues = isArea ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
33
+ const getValues = isArea && axis.scaleType !== 'log' ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
34
34
 
35
35
  const seriesExtremums = getSeriesExtremums(getValues, stackedData);
36
36
  if (acc[0] === null) {
@@ -56,7 +56,7 @@ const formatter = (params, dataset) => {
56
56
  if (typeof value !== 'number') {
57
57
  if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
58
58
  warnedOnce = true;
59
- console.error([`MUI-X charts: your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
59
+ console.error([`MUI X charts: your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
60
60
  }
61
61
  return null;
62
62
  }
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "tooltip", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "legend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
2
4
  import useId from '@mui/utils/useId';
3
5
  import { DEFAULT_X_AXIS_KEY } from '../constants';
4
6
  /**
@@ -10,39 +12,41 @@ import { DEFAULT_X_AXIS_KEY } from '../constants';
10
12
  */
11
13
  export const useLineChartProps = props => {
12
14
  const {
13
- xAxis,
14
- yAxis,
15
- series,
16
- width,
17
- height,
18
- margin,
19
- colors,
20
- dataset,
21
- sx,
22
- tooltip,
23
- onAxisClick,
24
- onAreaClick,
25
- onLineClick,
26
- onMarkClick,
27
- axisHighlight,
28
- disableLineItemHighlight,
29
- legend,
30
- grid,
31
- topAxis,
32
- leftAxis,
33
- rightAxis,
34
- bottomAxis,
35
- children,
36
- slots,
37
- slotProps,
38
- skipAnimation,
39
- loading,
40
- highlightedItem,
41
- onHighlightChange
42
- } = props;
15
+ xAxis,
16
+ yAxis,
17
+ series,
18
+ width,
19
+ height,
20
+ margin,
21
+ colors,
22
+ dataset,
23
+ sx,
24
+ tooltip,
25
+ onAxisClick,
26
+ onAreaClick,
27
+ onLineClick,
28
+ onMarkClick,
29
+ axisHighlight,
30
+ disableLineItemHighlight,
31
+ legend,
32
+ grid,
33
+ topAxis,
34
+ leftAxis,
35
+ rightAxis,
36
+ bottomAxis,
37
+ children,
38
+ slots,
39
+ slotProps,
40
+ skipAnimation,
41
+ loading,
42
+ highlightedItem,
43
+ onHighlightChange,
44
+ className
45
+ } = props,
46
+ other = _objectWithoutPropertiesLoose(props, _excluded);
43
47
  const id = useId();
44
48
  const clipPathId = `${id}-clip-path`;
45
- const chartContainerProps = {
49
+ const chartContainerProps = _extends({}, other, {
46
50
  series: series.map(s => _extends({
47
51
  disableHighlight: !!disableLineItemHighlight,
48
52
  type: 'line'
@@ -63,8 +67,9 @@ export const useLineChartProps = props => {
63
67
  sx,
64
68
  highlightedItem,
65
69
  onHighlightChange,
66
- disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
67
- };
70
+ disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
71
+ className
72
+ });
68
73
  const axisClickHandlerProps = {
69
74
  onAxisClick
70
75
  };
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "sx", "tooltip", "axisHighlight", "skipAnimation", "legend", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className"];
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
4
6
  import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
@@ -34,37 +36,39 @@ const defaultRTLMargin = {
34
36
  *
35
37
  * - [PieChart API](https://mui.com/x/api/charts/pie-chart/)
36
38
  */
37
- function PieChart(props) {
39
+ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(props, ref) {
38
40
  const {
39
- xAxis,
40
- yAxis,
41
- series,
42
- width,
43
- height,
44
- margin: marginProps,
45
- colors,
46
- sx,
47
- tooltip = {
48
- trigger: 'item'
49
- },
50
- axisHighlight = {
51
- x: 'none',
52
- y: 'none'
53
- },
54
- skipAnimation,
55
- legend: legendProps,
56
- topAxis = null,
57
- leftAxis = null,
58
- rightAxis = null,
59
- bottomAxis = null,
60
- children,
61
- slots,
62
- slotProps,
63
- onItemClick,
64
- loading,
65
- highlightedItem,
66
- onHighlightChange
67
- } = props;
41
+ xAxis,
42
+ yAxis,
43
+ series,
44
+ width,
45
+ height,
46
+ margin: marginProps,
47
+ colors,
48
+ sx,
49
+ tooltip = {
50
+ trigger: 'item'
51
+ },
52
+ axisHighlight = {
53
+ x: 'none',
54
+ y: 'none'
55
+ },
56
+ skipAnimation,
57
+ legend: legendProps,
58
+ topAxis = null,
59
+ leftAxis = null,
60
+ rightAxis = null,
61
+ bottomAxis = null,
62
+ children,
63
+ slots,
64
+ slotProps,
65
+ onItemClick,
66
+ loading,
67
+ highlightedItem,
68
+ onHighlightChange,
69
+ className
70
+ } = props,
71
+ other = _objectWithoutPropertiesLoose(props, _excluded);
68
72
  const isRTL = useIsRTL();
69
73
  const margin = _extends({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
70
74
  const legend = _extends({
@@ -74,7 +78,8 @@ function PieChart(props) {
74
78
  horizontal: isRTL ? 'left' : 'right'
75
79
  }
76
80
  }, legendProps);
77
- return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
81
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, _extends({}, other, {
82
+ ref: ref,
78
83
  series: series.map(s => _extends({
79
84
  type: 'pie'
80
85
  }, s)),
@@ -92,6 +97,7 @@ function PieChart(props) {
92
97
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
93
98
  highlightedItem: highlightedItem,
94
99
  onHighlightChange: onHighlightChange,
100
+ className: className,
95
101
  children: [/*#__PURE__*/_jsx(ChartsAxis, {
96
102
  topAxis: topAxis,
97
103
  leftAxis: leftAxis,
@@ -115,8 +121,8 @@ function PieChart(props) {
115
121
  slots: slots,
116
122
  slotProps: slotProps
117
123
  })), children]
118
- });
119
- }
124
+ }));
125
+ });
120
126
  process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
121
127
  // ----------------------------- Warning --------------------------------
122
128
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { DrawingContext } from '../context/DrawingProvider';
4
4
  import { PieArcPlot } from './PieArcPlot';
5
5
  import { PieArcLabelPlot } from './PieArcLabelPlot';
6
- import { getPercentageValue } from '../internals/utils';
6
+ import { getPercentageValue } from '../internals/getPercentageValue';
7
7
  import { getPieCoordinates } from './getPieCoordinates';
8
8
  import { usePieSeries } from '../hooks/useSeries';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { getPercentageValue } from '../internals/utils';
1
+ import { getPercentageValue } from '../internals/getPercentageValue';
2
2
  export function getPieCoordinates(series, drawing) {
3
3
  const {
4
4
  height,
@@ -1,31 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["width", "height"];
4
2
  import * as React from 'react';
5
3
  import PropTypes from 'prop-types';
6
4
  import { ChartContainer } from '../ChartContainer';
7
- import { useChartContainerDimensions } from './useChartContainerDimensions';
8
5
  import { ResizableContainer } from './ResizableContainer';
6
+ import { useResponsiveChartContainerProps } from './useResponsiveChartContainerProps';
9
7
  import { jsx as _jsx } from "react/jsx-runtime";
10
8
  const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
11
9
  const {
12
- width: inWidth,
13
- height: inHeight
14
- } = props,
15
- other = _objectWithoutPropertiesLoose(props, _excluded);
16
- const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
17
- return /*#__PURE__*/_jsx(ResizableContainer, {
18
- ref: containerRef,
19
- ownerState: {
20
- width: inWidth,
21
- height: inHeight
22
- },
23
- children: width && height ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, other, {
24
- width: width,
25
- height: height,
26
- ref: ref
27
- })) : null
28
- });
10
+ hasIntrinsicSize,
11
+ chartContainerProps,
12
+ resizableChartContainerProps
13
+ } = useResponsiveChartContainerProps(props, ref);
14
+ return /*#__PURE__*/_jsx(ResizableContainer, _extends({}, resizableChartContainerProps, {
15
+ children: hasIntrinsicSize ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, chartContainerProps)) : null
16
+ }));
29
17
  });
30
18
  process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
31
19
  // ----------------------------- Warning --------------------------------
@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
3
  import ownerWindow from '@mui/utils/ownerWindow';
4
4
  export const useChartContainerDimensions = (inWidth, inHeight) => {
5
- const rootRef = React.useRef(null);
6
5
  const displayError = React.useRef(false);
6
+ const rootRef = React.useRef(null);
7
7
  const [width, setWidth] = React.useState(0);
8
8
  const [height, setHeight] = React.useState(0);
9
9
 
@@ -62,5 +62,9 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
62
62
  displayError.current = false;
63
63
  }
64
64
  }
65
- return [rootRef, inWidth ?? width, inHeight ?? height];
65
+ return {
66
+ containerRef: rootRef,
67
+ width: inWidth ?? width,
68
+ height: inHeight ?? height
69
+ };
66
70
  };
@@ -0,0 +1,65 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
4
+ import { useChartContainerDimensions } from './useChartContainerDimensions';
5
+ export const useResponsiveChartContainerProps = (props, ref) => {
6
+ const {
7
+ width,
8
+ height,
9
+ margin,
10
+ children,
11
+ series,
12
+ colors,
13
+ dataset,
14
+ desc,
15
+ disableAxisListener,
16
+ highlightedItem,
17
+ onHighlightChange,
18
+ plugins,
19
+ sx,
20
+ title,
21
+ viewBox,
22
+ xAxis,
23
+ yAxis,
24
+ zAxis
25
+ } = props,
26
+ other = _objectWithoutPropertiesLoose(props, _excluded);
27
+ const {
28
+ containerRef,
29
+ width: dWidth,
30
+ height: dHeight
31
+ } = useChartContainerDimensions(width, height);
32
+ const resizableChartContainerProps = _extends({}, other, {
33
+ ownerState: {
34
+ width,
35
+ height
36
+ },
37
+ ref: containerRef
38
+ });
39
+ const chartContainerProps = {
40
+ margin,
41
+ children,
42
+ series,
43
+ colors,
44
+ dataset,
45
+ desc,
46
+ disableAxisListener,
47
+ highlightedItem,
48
+ onHighlightChange,
49
+ plugins,
50
+ sx,
51
+ title,
52
+ viewBox,
53
+ xAxis,
54
+ yAxis,
55
+ zAxis,
56
+ width: dWidth,
57
+ height: dHeight,
58
+ ref
59
+ };
60
+ return {
61
+ hasIntrinsicSize: dWidth && dHeight,
62
+ chartContainerProps,
63
+ resizableChartContainerProps
64
+ };
65
+ };
@@ -27,10 +27,7 @@ function Scatter(props) {
27
27
  markerSize,
28
28
  onItemClick
29
29
  } = props;
30
- const {
31
- left,
32
- width
33
- } = useDrawingArea();
30
+ const drawingArea = useDrawingArea();
34
31
  const {
35
32
  useVoronoiInteraction
36
33
  } = React.useContext(InteractionContext);
@@ -43,15 +40,15 @@ function Scatter(props) {
43
40
  const cleanData = React.useMemo(() => {
44
41
  const getXPosition = getValueToPositionMapper(xScale);
45
42
  const getYPosition = getValueToPositionMapper(yScale);
46
- const yRange = yScale.range();
47
- const minYRange = Math.min(...yRange);
48
- const maxYRange = Math.max(...yRange);
49
43
  const temp = [];
50
44
  for (let i = 0; i < series.data.length; i += 1) {
51
45
  const scatterPoint = series.data[i];
52
46
  const x = getXPosition(scatterPoint.x);
53
47
  const y = getYPosition(scatterPoint.y);
54
- const isInRange = x >= left && x <= left + width && y >= minYRange && y <= maxYRange;
48
+ const isInRange = drawingArea.isPointInside({
49
+ x,
50
+ y
51
+ });
55
52
  const pointCtx = {
56
53
  type: 'scatter',
57
54
  seriesId: series.id,
@@ -76,7 +73,7 @@ function Scatter(props) {
76
73
  }
77
74
  }
78
75
  return temp;
79
- }, [xScale, yScale, left, width, series.data, series.id, isHighlighted, isFaded, getInteractionItemProps, colorGetter, color]);
76
+ }, [xScale, yScale, drawingArea, series.data, series.id, isHighlighted, isFaded, getInteractionItemProps, colorGetter, color]);
80
77
  return /*#__PURE__*/_jsx("g", {
81
78
  children: cleanData.map(dataPoint => /*#__PURE__*/_jsx("circle", _extends({
82
79
  cx: 0,
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["xAxis", "yAxis", "zAxis", "series", "tooltip", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "legend", "width", "height", "margin", "colors", "sx", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
2
4
  /**
3
5
  * A helper function that extracts ScatterChartProps from the input props
4
6
  * and returns an object with props for the children components of ScatterChart.
@@ -8,34 +10,36 @@ import _extends from "@babel/runtime/helpers/esm/extends";
8
10
  */
9
11
  export const useScatterChartProps = props => {
10
12
  const {
11
- xAxis,
12
- yAxis,
13
- zAxis,
14
- series,
15
- tooltip,
16
- axisHighlight,
17
- voronoiMaxRadius,
18
- disableVoronoi,
19
- legend,
20
- width,
21
- height,
22
- margin,
23
- colors,
24
- sx,
25
- grid,
26
- topAxis,
27
- leftAxis,
28
- rightAxis,
29
- bottomAxis,
30
- onItemClick,
31
- children,
32
- slots,
33
- slotProps,
34
- loading,
35
- highlightedItem,
36
- onHighlightChange
37
- } = props;
38
- const chartContainerProps = {
13
+ xAxis,
14
+ yAxis,
15
+ zAxis,
16
+ series,
17
+ tooltip,
18
+ axisHighlight,
19
+ voronoiMaxRadius,
20
+ disableVoronoi,
21
+ legend,
22
+ width,
23
+ height,
24
+ margin,
25
+ colors,
26
+ sx,
27
+ grid,
28
+ topAxis,
29
+ leftAxis,
30
+ rightAxis,
31
+ bottomAxis,
32
+ onItemClick,
33
+ children,
34
+ slots,
35
+ slotProps,
36
+ loading,
37
+ highlightedItem,
38
+ onHighlightChange,
39
+ className
40
+ } = props,
41
+ other = _objectWithoutPropertiesLoose(props, _excluded);
42
+ const chartContainerProps = _extends({}, other, {
39
43
  series: series.map(s => _extends({
40
44
  type: 'scatter'
41
45
  }, s)),
@@ -47,8 +51,9 @@ export const useScatterChartProps = props => {
47
51
  yAxis,
48
52
  sx,
49
53
  highlightedItem,
50
- onHighlightChange
51
- };
54
+ onHighlightChange,
55
+ className
56
+ });
52
57
  const zAxisProps = {
53
58
  zAxis
54
59
  };