@mui/x-charts 7.18.0 → 7.20.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 (90) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +1 -1
  3. package/BarChart/BarElement.d.ts +1 -1
  4. package/BarChart/BarLabel/BarLabel.d.ts +1 -1
  5. package/BarChart/formatter.js +5 -4
  6. package/CHANGELOG.md +213 -11
  7. package/ChartContainer/useDefaultizeAxis.d.ts +4 -4
  8. package/ChartContainer/useDefaultizeAxis.js +1 -1
  9. package/ChartsAxis/ChartsAxis.js +4 -4
  10. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -1
  11. package/ChartsGrid/styledCommonents.d.ts +2 -2
  12. package/ChartsLegend/DefaultChartsLegend.js +1 -1
  13. package/ChartsLegend/LegendPerItem.d.ts +1 -1
  14. package/ChartsLegend/LegendPerItem.js +1 -1
  15. package/ChartsLegend/PiecewiseColorLegend.js +1 -1
  16. package/ChartsReferenceLine/common.d.ts +1 -1
  17. package/ChartsTooltip/ChartsTooltipTable.d.ts +5 -5
  18. package/LineChart/AnimatedArea.d.ts +1 -1
  19. package/LineChart/AnimatedArea.js +9 -45
  20. package/LineChart/AnimatedLine.d.ts +1 -1
  21. package/LineChart/AnimatedLine.js +9 -36
  22. package/LineChart/AppearingMask.d.ts +12 -0
  23. package/LineChart/AppearingMask.js +42 -0
  24. package/LineChart/LineChart.d.ts +1 -1
  25. package/LineChart/LineChart.js +1 -1
  26. package/LineChart/formatter.js +5 -5
  27. package/PieChart/PieChart.d.ts +1 -1
  28. package/PieChart/PieChart.js +1 -1
  29. package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -1
  30. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -1
  31. package/ScatterChart/ScatterChart.d.ts +1 -1
  32. package/ScatterChart/ScatterChart.js +1 -1
  33. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  34. package/context/CartesianProvider/defaultizeAxis.d.ts +4 -4
  35. package/context/PluginProvider/mergePlugins.d.ts +6 -6
  36. package/context/ZAxisContextProvider.js +1 -1
  37. package/hooks/useReducedMotion.js +2 -2
  38. package/hooks/useSeries.d.ts +4 -4
  39. package/hooks/useSeries.js +4 -4
  40. package/index.js +1 -1
  41. package/internals/components/AxisSharedComponents.d.ts +1 -1
  42. package/internals/configInit.d.ts +1 -1
  43. package/internals/defaultizeColor.d.ts +8 -8
  44. package/internals/domUtils.js +1 -1
  45. package/internals/geometry.js +3 -5
  46. package/internals/getPercentageValue.js +1 -1
  47. package/models/seriesType/line.d.ts +5 -0
  48. package/modern/BarChart/BarChart.js +1 -1
  49. package/modern/BarChart/formatter.js +5 -4
  50. package/modern/ChartContainer/useDefaultizeAxis.js +1 -1
  51. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  52. package/modern/ChartsLegend/DefaultChartsLegend.js +1 -1
  53. package/modern/ChartsLegend/LegendPerItem.js +1 -1
  54. package/modern/ChartsLegend/PiecewiseColorLegend.js +1 -1
  55. package/modern/LineChart/AnimatedArea.js +9 -45
  56. package/modern/LineChart/AnimatedLine.js +9 -36
  57. package/modern/LineChart/AppearingMask.js +42 -0
  58. package/modern/LineChart/LineChart.js +1 -1
  59. package/modern/LineChart/formatter.js +5 -5
  60. package/modern/PieChart/PieChart.js +1 -1
  61. package/modern/ScatterChart/ScatterChart.js +1 -1
  62. package/modern/context/ZAxisContextProvider.js +1 -1
  63. package/modern/hooks/useReducedMotion.js +2 -2
  64. package/modern/hooks/useSeries.js +4 -4
  65. package/modern/index.js +1 -1
  66. package/modern/internals/domUtils.js +1 -1
  67. package/modern/internals/geometry.js +3 -5
  68. package/modern/internals/getPercentageValue.js +1 -1
  69. package/node/BarChart/BarChart.js +1 -1
  70. package/node/BarChart/formatter.js +5 -4
  71. package/node/ChartContainer/useDefaultizeAxis.js +1 -1
  72. package/node/ChartsAxis/ChartsAxis.js +4 -4
  73. package/node/ChartsLegend/DefaultChartsLegend.js +1 -1
  74. package/node/ChartsLegend/LegendPerItem.js +1 -1
  75. package/node/ChartsLegend/PiecewiseColorLegend.js +1 -1
  76. package/node/LineChart/AnimatedArea.js +8 -44
  77. package/node/LineChart/AnimatedLine.js +8 -35
  78. package/node/LineChart/AppearingMask.js +48 -0
  79. package/node/LineChart/LineChart.js +1 -1
  80. package/node/LineChart/formatter.js +5 -5
  81. package/node/PieChart/PieChart.js +1 -1
  82. package/node/ScatterChart/ScatterChart.js +1 -1
  83. package/node/context/ZAxisContextProvider.js +1 -1
  84. package/node/hooks/useReducedMotion.js +2 -2
  85. package/node/hooks/useSeries.js +4 -4
  86. package/node/index.js +1 -1
  87. package/node/internals/domUtils.js +1 -1
  88. package/node/internals/geometry.js +3 -5
  89. package/node/internals/getPercentageValue.js +1 -1
  90. package/package.json +5 -5
@@ -25,7 +25,7 @@ export function useSeries() {
25
25
  * The returned object contains:
26
26
  * - series: a mapping from ids to series attributes.
27
27
  * - seriesOrder: the array of series ids.
28
- * @returns { series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined pieSeries
28
+ * @returns {{ series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined} pieSeries
29
29
  */
30
30
  export function usePieSeries() {
31
31
  const series = useSeries();
@@ -37,7 +37,7 @@ export function usePieSeries() {
37
37
  * The returned object contains:
38
38
  * - series: a mapping from ids to series attributes.
39
39
  * - seriesOrder: the array of series ids.
40
- * @returns { series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined lineSeries
40
+ * @returns {{ series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined} lineSeries
41
41
  */
42
42
  export function useLineSeries() {
43
43
  const series = useSeries();
@@ -49,7 +49,7 @@ export function useLineSeries() {
49
49
  * The returned object contains:
50
50
  * - series: a mapping from ids to series attributes.
51
51
  * - seriesOrder: the array of series ids.
52
- * @returns { series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined barSeries
52
+ * @returns {{ series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined} barSeries
53
53
  */
54
54
  export function useBarSeries() {
55
55
  const series = useSeries();
@@ -61,7 +61,7 @@ export function useBarSeries() {
61
61
  * The returned object contains:
62
62
  * - series: a mapping from ids to series attributes.
63
63
  * - seriesOrder: the array of series ids.
64
- * @returns { series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined scatterSeries
64
+ * @returns {{ series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined} scatterSeries
65
65
  */
66
66
  export function useScatterSeries() {
67
67
  const series = useSeries();
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.18.0
2
+ * @mui/x-charts v7.20.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1 +1 @@
1
- export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
1
+ export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
@@ -3,7 +3,7 @@ declare class CartesianSeriesTypes {
3
3
  types: Set<ChartSeriesType>;
4
4
  constructor();
5
5
  addType(value: ChartSeriesType): void;
6
- getTypes(): Set<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
6
+ getTypes(): Set<keyof import(".").ChartsSeriesConfig>;
7
7
  }
8
8
  export declare const cartesianSeriesTypes: CartesianSeriesTypes;
9
9
  export {};
@@ -4,7 +4,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
4
4
  color: string;
5
5
  label?: (string | ((location: "tooltip" | "legend" | "arc") => string)) | undefined;
6
6
  value: number;
7
- id?: import("../models/seriesType").PieItemId | undefined;
7
+ id?: import("..").PieItemId | undefined;
8
8
  }[];
9
9
  type: "pie";
10
10
  innerRadius?: number | string;
@@ -14,8 +14,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
14
14
  startAngle?: number;
15
15
  endAngle?: number;
16
16
  paddingAngle?: number;
17
- sortingValues?: import("../models/seriesType").ChartsPieSorting;
18
- arcLabel?: "formattedValue" | "label" | "value" | ((item: Omit<import("../models/seriesType").DefaultizedPieValueType, "label"> & {
17
+ sortingValues?: import("..").ChartsPieSorting;
18
+ arcLabel?: "formattedValue" | "label" | "value" | ((item: Omit<import("..").DefaultizedPieValueType, "label"> & {
19
19
  label?: string;
20
20
  }) => string);
21
21
  arcLabelMinAngle?: number;
@@ -41,7 +41,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
41
41
  };
42
42
  id?: import(".").SeriesId;
43
43
  color?: string;
44
- valueFormatter?: import(".").SeriesValueFormatter<import(".").MakeOptional<import("../models/seriesType").PieValueType, "id">> | undefined;
44
+ valueFormatter?: import(".").SeriesValueFormatter<import(".").MakeOptional<import("..").PieValueType, "id">> | undefined;
45
45
  highlightScope?: Partial<import("..").HighlightScope>;
46
46
  } | {
47
47
  type: "bar";
@@ -62,7 +62,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
62
62
  stackOrder?: import("..").StackOrderType;
63
63
  } | {
64
64
  type: "scatter";
65
- data: import("../models/seriesType").ScatterValueType[];
65
+ data: import("..").ScatterValueType[];
66
66
  markerSize?: number;
67
67
  label?: string | ((location: "tooltip" | "legend") => string);
68
68
  disableHover?: boolean;
@@ -70,7 +70,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
70
70
  zAxisId?: string;
71
71
  id?: import(".").SeriesId;
72
72
  color: string;
73
- valueFormatter?: import(".").SeriesValueFormatter<import("../models/seriesType").ScatterValueType> | undefined;
73
+ valueFormatter?: import(".").SeriesValueFormatter<import("..").ScatterValueType> | undefined;
74
74
  highlightScope?: Partial<import("..").HighlightScope>;
75
75
  xAxisKey?: string;
76
76
  yAxisKey?: string;
@@ -83,8 +83,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
83
83
  stack?: string;
84
84
  area?: boolean;
85
85
  label?: string | ((location: "tooltip" | "legend") => string);
86
- curve?: import("../models/seriesType").CurveType;
87
- showMark?: boolean | ((params: import("../models/seriesType").ShowMarkParams) => boolean);
86
+ curve?: import("..").CurveType;
87
+ showMark?: boolean | ((params: import("..").ShowMarkParams) => boolean);
88
88
  disableHighlight?: boolean;
89
89
  connectNulls?: boolean;
90
90
  stackOffset?: import("..").StackOffsetType;
@@ -113,7 +113,7 @@ export const getStringSize = (text, style = {}) => {
113
113
  measurementSpan.textContent = '';
114
114
  }, 0);
115
115
  return result;
116
- } catch (e) {
116
+ } catch {
117
117
  return {
118
118
  width: 0,
119
119
  height: 0
@@ -1,7 +1,6 @@
1
+ import { warnOnce } from '@mui/x-internals/warning';
1
2
  const ANGLE_APPROX = 5; // Angle (in deg) for which we approximate the rectangle as perfectly horizontal/vertical
2
3
 
3
- let warnedOnce = false;
4
-
5
4
  /**
6
5
  * Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
7
6
  * This assumes that all rectangles have the same height and angle between -90 and 90.
@@ -12,9 +11,8 @@ let warnedOnce = false;
12
11
  */
13
12
  export function getMinXTranslation(width, height, angle = 0) {
14
13
  if (process.env.NODE_ENV !== 'production') {
15
- if (!warnedOnce && angle > 90 && angle < -90) {
16
- warnedOnce = true;
17
- console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
14
+ if (angle > 90 && angle < -90) {
15
+ warnOnce([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`]);
18
16
  }
19
17
  }
20
18
  const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
@@ -24,5 +24,5 @@ export function getPercentageValue(value, refValue) {
24
24
  return val;
25
25
  }
26
26
  }
27
- throw Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
27
+ throw new Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
28
28
  }
@@ -40,6 +40,11 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
40
40
  * The label to display on the tooltip or the legend. It can be a string or a function.
41
41
  */
42
42
  label?: string | ((location: 'tooltip' | 'legend') => string);
43
+ /**
44
+ * The type of curve to use for the line.
45
+ * Read more about curves at [line interpolation](https://mui.com/x/react-charts/lines/#interpolation).
46
+ * @default 'monotoneX'
47
+ */
43
48
  curve?: CurveType;
44
49
  /**
45
50
  * Define which items of the series should display a mark.
@@ -63,7 +63,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
63
63
  * The configuration of axes highlight.
64
64
  * Default is set to 'band' in the bar direction.
65
65
  * Depends on `layout` prop.
66
- * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
66
+ * @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
67
67
  */
68
68
  axisHighlight: PropTypes.shape({
69
69
  x: PropTypes.oneOf(['band', 'line', 'none']),
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
3
+ import { warnOnce } from '@mui/x-internals/warning';
3
4
  import { getStackingGroups } from "../internals/stackSeries.js";
4
5
  import { defaultizeValueFormatter } from "../internals/defaultizeValueFormatter.js";
5
- let warnOnce = false;
6
6
  const formatter = (params, dataset) => {
7
7
  const {
8
8
  seriesOrder,
@@ -50,9 +50,10 @@ const formatter = (params, dataset) => {
50
50
  data: dataKey ? dataset.map(data => {
51
51
  const value = data[dataKey];
52
52
  if (typeof value !== 'number') {
53
- if (process.env.NODE_ENV !== 'production' && !warnOnce && value !== null) {
54
- warnOnce = true;
55
- console.error([`MUI X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.'].join('\n'));
53
+ if (process.env.NODE_ENV !== 'production') {
54
+ if (value !== null) {
55
+ warnOnce([`MUI X: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.']);
56
+ }
56
57
  }
57
58
  return 0;
58
59
  }
@@ -18,7 +18,7 @@ const defaultizeAxis = (inAxis, dataset, axisName) => {
18
18
  return axisConfig;
19
19
  }
20
20
  if (dataset === undefined) {
21
- throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
21
+ throw new Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
22
22
  }
23
23
  return _extends({}, axisConfig, {
24
24
  data: dataset.map(d => d[dataKey])
@@ -59,16 +59,16 @@ function ChartsAxis(props) {
59
59
  const topId = getAxisId(topAxis, xAxisIds[0]);
60
60
  const rightId = getAxisId(rightAxis, yAxisIds[0]);
61
61
  if (topId !== null && !xAxis[topId]) {
62
- throw Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
62
+ throw new Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
63
63
  }
64
64
  if (leftId !== null && !yAxis[leftId]) {
65
- throw Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
65
+ throw new Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
66
66
  }
67
67
  if (rightId !== null && !yAxis[rightId]) {
68
- throw Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
68
+ throw new Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
69
69
  }
70
70
  if (bottomId !== null && !xAxis[bottomId]) {
71
- throw Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
71
+ throw new Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
72
72
  }
73
73
  const topAxisProps = mergeProps(topAxis, slots, slotProps);
74
74
  const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
@@ -26,7 +26,7 @@ function DefaultChartsLegend(props) {
26
26
  }
27
27
  return /*#__PURE__*/_jsx(LegendPerItem, _extends({}, other, {
28
28
  itemsToDisplay: seriesToDisplay,
29
- onItemClick: onItemClick ? (e, i) => onItemClick(e, seriesContextBuilder(seriesToDisplay[i]), i) : undefined
29
+ onItemClick: onItemClick ? (event, i) => onItemClick(event, seriesContextBuilder(seriesToDisplay[i]), i) : undefined
30
30
  }));
31
31
  }
32
32
  process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
@@ -122,7 +122,7 @@ export function LegendPerItem(props) {
122
122
  markGap: markGap,
123
123
  labelStyle: labelStyle,
124
124
  classes: classes,
125
- onClick: onItemClick ? e => onItemClick(e, i) : undefined
125
+ onClick: onItemClick ? event => onItemClick(event, i) : undefined
126
126
  })))
127
127
  })
128
128
  });
@@ -80,7 +80,7 @@ function PiecewiseColorLegend(props) {
80
80
  }).filter(notNull);
81
81
  return /*#__PURE__*/_jsx(LegendPerItem, _extends({}, other, {
82
82
  itemsToDisplay: itemsToDisplay,
83
- onItemClick: onItemClick ? (e, i) => onItemClick(e, piecewiseColorContextBuilder(itemsToDisplay[i]), i) : undefined
83
+ onItemClick: onItemClick ? (event, i) => onItemClick(event, piecewiseColorContextBuilder(itemsToDisplay[i]), i) : undefined
84
84
  }));
85
85
  }
86
86
  process.env.NODE_ENV !== "production" ? PiecewiseColorLegend.propTypes = {
@@ -8,10 +8,9 @@ import PropTypes from 'prop-types';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import { animated, useTransition } from '@react-spring/web';
10
10
  import { color as d3Color } from '@mui/x-charts-vendor/d3-color';
11
- import { cleanId } from "../internals/cleanId.js";
12
- import { useChartId, useDrawingArea } from "../hooks/index.js";
13
11
  import { useStringInterpolator } from "../internals/useStringInterpolator.js";
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { AppearingMask } from "./AppearingMask.js";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
15
14
  export const AreaElementPath = styled(animated.path, {
16
15
  name: 'MuiAreaElement',
17
16
  slot: 'Root',
@@ -41,32 +40,7 @@ function AnimatedArea(props) {
41
40
  ownerState
42
41
  } = props,
43
42
  other = _objectWithoutPropertiesLoose(props, _excluded);
44
- const {
45
- left,
46
- top,
47
- right,
48
- bottom,
49
- width,
50
- height
51
- } = useDrawingArea();
52
- const chartId = useChartId();
53
43
  const stringInterpolator = useStringInterpolator(d);
54
- const transitionAppear = useTransition([1], {
55
- from: {
56
- animatedWidth: left
57
- },
58
- to: {
59
- animatedWidth: width + left + right
60
- },
61
- enter: {
62
- animatedWidth: width + left + right
63
- },
64
- leave: {
65
- animatedWidth: left
66
- },
67
- reset: false,
68
- immediate: skipAnimation
69
- });
70
44
  const transitionChange = useTransition([stringInterpolator], {
71
45
  from: {
72
46
  value: 0
@@ -80,23 +54,13 @@ function AnimatedArea(props) {
80
54
  reset: false,
81
55
  immediate: skipAnimation
82
56
  });
83
- const clipId = cleanId(`${chartId}-${ownerState.id}-area-clip`);
84
- return /*#__PURE__*/_jsxs(React.Fragment, {
85
- children: [/*#__PURE__*/_jsx("clipPath", {
86
- id: clipId,
87
- children: transitionAppear(style => /*#__PURE__*/_jsx(animated.rect, {
88
- x: 0,
89
- y: 0,
90
- width: style.animatedWidth,
91
- height: top + height + bottom
92
- }))
93
- }), /*#__PURE__*/_jsx("g", {
94
- clipPath: `url(#${clipId})`,
95
- children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(AreaElementPath, _extends({}, other, {
96
- ownerState: ownerState,
97
- d: style.value.to(interpolator)
98
- })))
99
- })]
57
+ return /*#__PURE__*/_jsx(AppearingMask, {
58
+ skipAnimation: skipAnimation,
59
+ id: `${ownerState.id}-area-clip`,
60
+ children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(AreaElementPath, _extends({}, other, {
61
+ ownerState: ownerState,
62
+ d: style.value.to(interpolator)
63
+ })))
100
64
  });
101
65
  }
102
66
  process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
@@ -8,11 +8,9 @@ import PropTypes from 'prop-types';
8
8
  import { animated, useTransition } from '@react-spring/web';
9
9
  import { color as d3Color } from '@mui/x-charts-vendor/d3-color';
10
10
  import { styled } from '@mui/material/styles';
11
- import { cleanId } from "../internals/cleanId.js";
12
- import { useChartId } from "../hooks/useChartId.js";
13
- import { useDrawingArea } from "../hooks/useDrawingArea.js";
14
11
  import { useStringInterpolator } from "../internals/useStringInterpolator.js";
15
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { AppearingMask } from "./AppearingMask.js";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
16
14
  export const LineElementPath = styled(animated.path, {
17
15
  name: 'MuiLineElement',
18
16
  slot: 'Root',
@@ -44,22 +42,7 @@ function AnimatedLine(props) {
44
42
  ownerState
45
43
  } = props,
46
44
  other = _objectWithoutPropertiesLoose(props, _excluded);
47
- const drawingArea = useDrawingArea();
48
- const chartId = useChartId();
49
45
  const stringInterpolator = useStringInterpolator(d);
50
- const transitionAppear = useTransition([drawingArea], {
51
- from: v => ({
52
- animatedWidth: v.left
53
- }),
54
- enter: v => ({
55
- animatedWidth: v.width + v.left + v.right
56
- }),
57
- leave: v => ({
58
- animatedWidth: v.width + v.left + v.right
59
- }),
60
- reset: false,
61
- immediate: skipAnimation
62
- });
63
46
  const transitionChange = useTransition([stringInterpolator], {
64
47
  from: {
65
48
  value: 0
@@ -73,23 +56,13 @@ function AnimatedLine(props) {
73
56
  reset: false,
74
57
  immediate: skipAnimation
75
58
  });
76
- const clipId = cleanId(`${chartId}-${ownerState.id}-line-clip`);
77
- return /*#__PURE__*/_jsxs(React.Fragment, {
78
- children: [/*#__PURE__*/_jsx("clipPath", {
79
- id: clipId,
80
- children: transitionAppear(style => /*#__PURE__*/_jsx(animated.rect, {
81
- x: 0,
82
- y: 0,
83
- width: style.animatedWidth,
84
- height: drawingArea.top + drawingArea.height + drawingArea.bottom
85
- }))
86
- }), /*#__PURE__*/_jsx("g", {
87
- clipPath: `url(#${clipId})`,
88
- children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
89
- ownerState: ownerState,
90
- d: style.value.to(interpolator)
91
- })))
92
- })]
59
+ return /*#__PURE__*/_jsx(AppearingMask, {
60
+ skipAnimation: skipAnimation,
61
+ id: `${ownerState.id}-line-clip`,
62
+ children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
63
+ ownerState: ownerState,
64
+ d: style.value.to(interpolator)
65
+ })))
93
66
  });
94
67
  }
95
68
  process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { animated, useTransition } from '@react-spring/web';
5
+ import { cleanId } from "../internals/cleanId.js";
6
+ import { useChartId, useDrawingArea } from "../hooks/index.js";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ /**
9
+ * @ignore - internal component.
10
+ */
11
+ export function AppearingMask(props) {
12
+ const drawingArea = useDrawingArea();
13
+ const chartId = useChartId();
14
+ const transitionAppear = useTransition([drawingArea], {
15
+ from: v => ({
16
+ animatedWidth: v.left
17
+ }),
18
+ enter: v => ({
19
+ animatedWidth: v.width + v.left + v.right
20
+ }),
21
+ leave: v => ({
22
+ animatedWidth: v.width + v.left + v.right
23
+ }),
24
+ reset: false,
25
+ immediate: props.skipAnimation
26
+ });
27
+ const clipId = cleanId(`${chartId}-${props.id}`);
28
+ return /*#__PURE__*/_jsxs(React.Fragment, {
29
+ children: [/*#__PURE__*/_jsx("clipPath", {
30
+ id: clipId,
31
+ children: transitionAppear(style => /*#__PURE__*/_jsx(animated.rect, {
32
+ x: 0,
33
+ y: 0,
34
+ width: style.animatedWidth,
35
+ height: drawingArea.top + drawingArea.height + drawingArea.bottom
36
+ }))
37
+ }), /*#__PURE__*/_jsx("g", {
38
+ clipPath: `url(#${clipId})`,
39
+ children: props.children
40
+ })]
41
+ });
42
+ }
@@ -69,7 +69,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
69
69
  // ----------------------------------------------------------------------
70
70
  /**
71
71
  * The configuration of axes highlight.
72
- * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
72
+ * @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
73
73
  * @default { x: 'line' }
74
74
  */
75
75
  axisHighlight: PropTypes.shape({
@@ -1,9 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
3
+ import { warnOnce } from '@mui/x-internals/warning';
3
4
  import { getStackingGroups } from "../internals/stackSeries.js";
4
5
  import { defaultizeValueFormatter } from "../internals/defaultizeValueFormatter.js";
5
- let warnedOnce = false;
6
-
7
6
  // For now it's a copy past of bar charts formatter, but maybe will diverge later
8
7
  const formatter = (params, dataset) => {
9
8
  const {
@@ -54,9 +53,10 @@ const formatter = (params, dataset) => {
54
53
  data: dataKey ? dataset.map(data => {
55
54
  const value = data[dataKey];
56
55
  if (typeof value !== 'number') {
57
- if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
58
- warnedOnce = true;
59
- console.error([`MUI X: Your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
56
+ if (process.env.NODE_ENV !== 'production') {
57
+ if (value !== null) {
58
+ warnOnce([`MUI X: Your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
59
+ }
60
60
  }
61
61
  return null;
62
62
  }
@@ -137,7 +137,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
137
137
  // ----------------------------------------------------------------------
138
138
  /**
139
139
  * The configuration of axes highlight.
140
- * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
140
+ * @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
141
141
  * @default { x: 'none', y: 'none' }
142
142
  */
143
143
  axisHighlight: PropTypes.shape({
@@ -62,7 +62,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
62
62
  // ----------------------------------------------------------------------
63
63
  /**
64
64
  * The configuration of axes highlight.
65
- * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
65
+ * @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
66
66
  * @default { x: 'none', y: 'none' }
67
67
  */
68
68
  axisHighlight: PropTypes.shape({
@@ -24,7 +24,7 @@ function ZAxisContextProvider(props) {
24
24
  return axisConfig;
25
25
  }
26
26
  if (dataset === undefined) {
27
- throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
27
+ throw new Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
28
28
  }
29
29
  return _extends({}, axisConfig, {
30
30
  data: dataset.map(d => d[dataKey])
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
4
- const handleMediaChange = e => {
4
+ const handleMediaChange = event => {
5
5
  Globals.assign({
6
6
  // Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
7
- skipAnimation: e.matches || undefined
7
+ skipAnimation: event.matches || undefined
8
8
  });
9
9
  };
10
10
 
@@ -25,7 +25,7 @@ export function useSeries() {
25
25
  * The returned object contains:
26
26
  * - series: a mapping from ids to series attributes.
27
27
  * - seriesOrder: the array of series ids.
28
- * @returns { series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined pieSeries
28
+ * @returns {{ series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined} pieSeries
29
29
  */
30
30
  export function usePieSeries() {
31
31
  const series = useSeries();
@@ -37,7 +37,7 @@ export function usePieSeries() {
37
37
  * The returned object contains:
38
38
  * - series: a mapping from ids to series attributes.
39
39
  * - seriesOrder: the array of series ids.
40
- * @returns { series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined lineSeries
40
+ * @returns {{ series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined} lineSeries
41
41
  */
42
42
  export function useLineSeries() {
43
43
  const series = useSeries();
@@ -49,7 +49,7 @@ export function useLineSeries() {
49
49
  * The returned object contains:
50
50
  * - series: a mapping from ids to series attributes.
51
51
  * - seriesOrder: the array of series ids.
52
- * @returns { series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined barSeries
52
+ * @returns {{ series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined} barSeries
53
53
  */
54
54
  export function useBarSeries() {
55
55
  const series = useSeries();
@@ -61,7 +61,7 @@ export function useBarSeries() {
61
61
  * The returned object contains:
62
62
  * - series: a mapping from ids to series attributes.
63
63
  * - seriesOrder: the array of series ids.
64
- * @returns { series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined scatterSeries
64
+ * @returns {{ series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined} scatterSeries
65
65
  */
66
66
  export function useScatterSeries() {
67
67
  const series = useSeries();
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.18.0
2
+ * @mui/x-charts v7.20.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -113,7 +113,7 @@ export const getStringSize = (text, style = {}) => {
113
113
  measurementSpan.textContent = '';
114
114
  }, 0);
115
115
  return result;
116
- } catch (e) {
116
+ } catch {
117
117
  return {
118
118
  width: 0,
119
119
  height: 0
@@ -1,7 +1,6 @@
1
+ import { warnOnce } from '@mui/x-internals/warning';
1
2
  const ANGLE_APPROX = 5; // Angle (in deg) for which we approximate the rectangle as perfectly horizontal/vertical
2
3
 
3
- let warnedOnce = false;
4
-
5
4
  /**
6
5
  * Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
7
6
  * This assumes that all rectangles have the same height and angle between -90 and 90.
@@ -12,9 +11,8 @@ let warnedOnce = false;
12
11
  */
13
12
  export function getMinXTranslation(width, height, angle = 0) {
14
13
  if (process.env.NODE_ENV !== 'production') {
15
- if (!warnedOnce && angle > 90 && angle < -90) {
16
- warnedOnce = true;
17
- console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
14
+ if (angle > 90 && angle < -90) {
15
+ warnOnce([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`]);
18
16
  }
19
17
  }
20
18
  const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
@@ -24,5 +24,5 @@ export function getPercentageValue(value, refValue) {
24
24
  return val;
25
25
  }
26
26
  }
27
- throw Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
27
+ throw new Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
28
28
  }
@@ -70,7 +70,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
70
70
  * The configuration of axes highlight.
71
71
  * Default is set to 'band' in the bar direction.
72
72
  * Depends on `layout` prop.
73
- * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
73
+ * @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
74
74
  */
75
75
  axisHighlight: _propTypes.default.shape({
76
76
  x: _propTypes.default.oneOf(['band', 'line', 'none']),