@mui/x-charts 7.18.0 → 7.19.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.
- package/BarChart/BarElement.d.ts +1 -1
- package/BarChart/BarLabel/BarLabel.d.ts +1 -1
- package/BarChart/formatter.js +5 -4
- package/CHANGELOG.md +110 -0
- package/ChartContainer/useDefaultizeAxis.d.ts +4 -4
- package/ChartContainer/useDefaultizeAxis.js +1 -1
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -1
- package/ChartsGrid/styledCommonents.d.ts +2 -2
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsLegend/LegendPerItem.d.ts +1 -1
- package/ChartsLegend/LegendPerItem.js +1 -1
- package/ChartsLegend/PiecewiseColorLegend.js +1 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +5 -5
- package/LineChart/AnimatedArea.d.ts +1 -1
- package/LineChart/AnimatedArea.js +9 -45
- package/LineChart/AnimatedLine.d.ts +1 -1
- package/LineChart/AnimatedLine.js +9 -36
- package/LineChart/AppearingMask.d.ts +12 -0
- package/LineChart/AppearingMask.js +42 -0
- package/LineChart/formatter.js +5 -5
- package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -1
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/context/CartesianProvider/defaultizeAxis.d.ts +4 -4
- package/context/PluginProvider/mergePlugins.d.ts +6 -6
- package/context/ZAxisContextProvider.js +1 -1
- package/hooks/useReducedMotion.js +2 -2
- package/hooks/useSeries.d.ts +4 -4
- package/hooks/useSeries.js +4 -4
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +1 -1
- package/internals/configInit.d.ts +1 -1
- package/internals/defaultizeColor.d.ts +8 -8
- package/internals/domUtils.js +1 -1
- package/internals/geometry.js +3 -5
- package/internals/getPercentageValue.js +1 -1
- package/models/seriesType/line.d.ts +5 -0
- package/modern/BarChart/formatter.js +5 -4
- package/modern/ChartContainer/useDefaultizeAxis.js +1 -1
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/modern/ChartsLegend/LegendPerItem.js +1 -1
- package/modern/ChartsLegend/PiecewiseColorLegend.js +1 -1
- package/modern/LineChart/AnimatedArea.js +9 -45
- package/modern/LineChart/AnimatedLine.js +9 -36
- package/modern/LineChart/AppearingMask.js +42 -0
- package/modern/LineChart/formatter.js +5 -5
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useReducedMotion.js +2 -2
- package/modern/hooks/useSeries.js +4 -4
- package/modern/index.js +1 -1
- package/modern/internals/domUtils.js +1 -1
- package/modern/internals/geometry.js +3 -5
- package/modern/internals/getPercentageValue.js +1 -1
- package/node/BarChart/formatter.js +5 -4
- package/node/ChartContainer/useDefaultizeAxis.js +1 -1
- package/node/ChartsAxis/ChartsAxis.js +4 -4
- package/node/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/node/ChartsLegend/LegendPerItem.js +1 -1
- package/node/ChartsLegend/PiecewiseColorLegend.js +1 -1
- package/node/LineChart/AnimatedArea.js +8 -44
- package/node/LineChart/AnimatedLine.js +8 -35
- package/node/LineChart/AppearingMask.js +48 -0
- package/node/LineChart/formatter.js +5 -5
- package/node/context/ZAxisContextProvider.js +1 -1
- package/node/hooks/useReducedMotion.js +2 -2
- package/node/hooks/useSeries.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/domUtils.js +1 -1
- package/node/internals/geometry.js +3 -5
- package/node/internals/getPercentageValue.js +1 -1
- package/package.json +2 -2
|
@@ -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 {
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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 {
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
}
|
|
@@ -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'
|
|
58
|
-
|
|
59
|
-
|
|
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
|
}
|
|
@@ -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 =
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,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 (
|
|
16
|
-
|
|
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
|
}
|
|
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
10
|
+
var _warning = require("@mui/x-internals/warning");
|
|
10
11
|
var _stackSeries = require("../internals/stackSeries");
|
|
11
12
|
var _defaultizeValueFormatter = require("../internals/defaultizeValueFormatter");
|
|
12
|
-
let warnOnce = false;
|
|
13
13
|
const formatter = (params, dataset) => {
|
|
14
14
|
const {
|
|
15
15
|
seriesOrder,
|
|
@@ -57,9 +57,10 @@ const formatter = (params, dataset) => {
|
|
|
57
57
|
data: dataKey ? dataset.map(data => {
|
|
58
58
|
const value = data[dataKey];
|
|
59
59
|
if (typeof value !== 'number') {
|
|
60
|
-
if (process.env.NODE_ENV !== 'production'
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
61
|
+
if (value !== null) {
|
|
62
|
+
(0, _warning.warnOnce)([`MUI X: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.']);
|
|
63
|
+
}
|
|
63
64
|
}
|
|
64
65
|
return 0;
|
|
65
66
|
}
|
|
@@ -25,7 +25,7 @@ const defaultizeAxis = (inAxis, dataset, axisName) => {
|
|
|
25
25
|
return axisConfig;
|
|
26
26
|
}
|
|
27
27
|
if (dataset === undefined) {
|
|
28
|
-
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
28
|
+
throw new Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
29
29
|
}
|
|
30
30
|
return (0, _extends2.default)({}, axisConfig, {
|
|
31
31
|
data: dataset.map(d => d[dataKey])
|
|
@@ -66,16 +66,16 @@ function ChartsAxis(props) {
|
|
|
66
66
|
const topId = getAxisId(topAxis, xAxisIds[0]);
|
|
67
67
|
const rightId = getAxisId(rightAxis, yAxisIds[0]);
|
|
68
68
|
if (topId !== null && !xAxis[topId]) {
|
|
69
|
-
throw Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
69
|
+
throw new Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
70
70
|
}
|
|
71
71
|
if (leftId !== null && !yAxis[leftId]) {
|
|
72
|
-
throw Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
72
|
+
throw new Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
73
73
|
}
|
|
74
74
|
if (rightId !== null && !yAxis[rightId]) {
|
|
75
|
-
throw Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
75
|
+
throw new Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
76
76
|
}
|
|
77
77
|
if (bottomId !== null && !xAxis[bottomId]) {
|
|
78
|
-
throw Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
78
|
+
throw new Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
79
79
|
}
|
|
80
80
|
const topAxisProps = mergeProps(topAxis, slots, slotProps);
|
|
81
81
|
const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
|
|
@@ -33,7 +33,7 @@ function DefaultChartsLegend(props) {
|
|
|
33
33
|
}
|
|
34
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LegendPerItem.LegendPerItem, (0, _extends2.default)({}, other, {
|
|
35
35
|
itemsToDisplay: seriesToDisplay,
|
|
36
|
-
onItemClick: onItemClick ? (
|
|
36
|
+
onItemClick: onItemClick ? (event, i) => onItemClick(event, seriesContextBuilder(seriesToDisplay[i]), i) : undefined
|
|
37
37
|
}));
|
|
38
38
|
}
|
|
39
39
|
process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
@@ -130,7 +130,7 @@ function LegendPerItem(props) {
|
|
|
130
130
|
markGap: markGap,
|
|
131
131
|
labelStyle: labelStyle,
|
|
132
132
|
classes: classes,
|
|
133
|
-
onClick: onItemClick ?
|
|
133
|
+
onClick: onItemClick ? event => onItemClick(event, i) : undefined
|
|
134
134
|
})))
|
|
135
135
|
})
|
|
136
136
|
});
|
|
@@ -87,7 +87,7 @@ function PiecewiseColorLegend(props) {
|
|
|
87
87
|
}).filter(_notNull.notNull);
|
|
88
88
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LegendPerItem.LegendPerItem, (0, _extends2.default)({}, other, {
|
|
89
89
|
itemsToDisplay: itemsToDisplay,
|
|
90
|
-
onItemClick: onItemClick ? (
|
|
90
|
+
onItemClick: onItemClick ? (event, i) => onItemClick(event, piecewiseColorContextBuilder(itemsToDisplay[i]), i) : undefined
|
|
91
91
|
}));
|
|
92
92
|
}
|
|
93
93
|
process.env.NODE_ENV !== "production" ? PiecewiseColorLegend.propTypes = {
|
|
@@ -15,9 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
var _styles = require("@mui/material/styles");
|
|
16
16
|
var _web = require("@react-spring/web");
|
|
17
17
|
var _d3Color = require("@mui/x-charts-vendor/d3-color");
|
|
18
|
-
var _cleanId = require("../internals/cleanId");
|
|
19
|
-
var _hooks = require("../hooks");
|
|
20
18
|
var _useStringInterpolator = require("../internals/useStringInterpolator");
|
|
19
|
+
var _AppearingMask = require("./AppearingMask");
|
|
21
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
21
|
const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
23
22
|
const AreaElementPath = exports.AreaElementPath = (0, _styles.styled)(_web.animated.path, {
|
|
@@ -49,32 +48,7 @@ function AnimatedArea(props) {
|
|
|
49
48
|
ownerState
|
|
50
49
|
} = props,
|
|
51
50
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
52
|
-
const {
|
|
53
|
-
left,
|
|
54
|
-
top,
|
|
55
|
-
right,
|
|
56
|
-
bottom,
|
|
57
|
-
width,
|
|
58
|
-
height
|
|
59
|
-
} = (0, _hooks.useDrawingArea)();
|
|
60
|
-
const chartId = (0, _hooks.useChartId)();
|
|
61
51
|
const stringInterpolator = (0, _useStringInterpolator.useStringInterpolator)(d);
|
|
62
|
-
const transitionAppear = (0, _web.useTransition)([1], {
|
|
63
|
-
from: {
|
|
64
|
-
animatedWidth: left
|
|
65
|
-
},
|
|
66
|
-
to: {
|
|
67
|
-
animatedWidth: width + left + right
|
|
68
|
-
},
|
|
69
|
-
enter: {
|
|
70
|
-
animatedWidth: width + left + right
|
|
71
|
-
},
|
|
72
|
-
leave: {
|
|
73
|
-
animatedWidth: left
|
|
74
|
-
},
|
|
75
|
-
reset: false,
|
|
76
|
-
immediate: skipAnimation
|
|
77
|
-
});
|
|
78
52
|
const transitionChange = (0, _web.useTransition)([stringInterpolator], {
|
|
79
53
|
from: {
|
|
80
54
|
value: 0
|
|
@@ -88,23 +62,13 @@ function AnimatedArea(props) {
|
|
|
88
62
|
reset: false,
|
|
89
63
|
immediate: skipAnimation
|
|
90
64
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
width: style.animatedWidth,
|
|
99
|
-
height: top + height + bottom
|
|
100
|
-
}))
|
|
101
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
102
|
-
clipPath: `url(#${clipId})`,
|
|
103
|
-
children: transitionChange((style, interpolator) => /*#__PURE__*/(0, _jsxRuntime.jsx)(AreaElementPath, (0, _extends2.default)({}, other, {
|
|
104
|
-
ownerState: ownerState,
|
|
105
|
-
d: style.value.to(interpolator)
|
|
106
|
-
})))
|
|
107
|
-
})]
|
|
65
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppearingMask.AppearingMask, {
|
|
66
|
+
skipAnimation: skipAnimation,
|
|
67
|
+
id: `${ownerState.id}-area-clip`,
|
|
68
|
+
children: transitionChange((style, interpolator) => /*#__PURE__*/(0, _jsxRuntime.jsx)(AreaElementPath, (0, _extends2.default)({}, other, {
|
|
69
|
+
ownerState: ownerState,
|
|
70
|
+
d: style.value.to(interpolator)
|
|
71
|
+
})))
|
|
108
72
|
});
|
|
109
73
|
}
|
|
110
74
|
process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
|
|
@@ -15,10 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
var _web = require("@react-spring/web");
|
|
16
16
|
var _d3Color = require("@mui/x-charts-vendor/d3-color");
|
|
17
17
|
var _styles = require("@mui/material/styles");
|
|
18
|
-
var _cleanId = require("../internals/cleanId");
|
|
19
|
-
var _useChartId = require("../hooks/useChartId");
|
|
20
|
-
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
21
18
|
var _useStringInterpolator = require("../internals/useStringInterpolator");
|
|
19
|
+
var _AppearingMask = require("./AppearingMask");
|
|
22
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
21
|
const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
24
22
|
const LineElementPath = exports.LineElementPath = (0, _styles.styled)(_web.animated.path, {
|
|
@@ -52,22 +50,7 @@ function AnimatedLine(props) {
|
|
|
52
50
|
ownerState
|
|
53
51
|
} = props,
|
|
54
52
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
55
|
-
const drawingArea = (0, _useDrawingArea.useDrawingArea)();
|
|
56
|
-
const chartId = (0, _useChartId.useChartId)();
|
|
57
53
|
const stringInterpolator = (0, _useStringInterpolator.useStringInterpolator)(d);
|
|
58
|
-
const transitionAppear = (0, _web.useTransition)([drawingArea], {
|
|
59
|
-
from: v => ({
|
|
60
|
-
animatedWidth: v.left
|
|
61
|
-
}),
|
|
62
|
-
enter: v => ({
|
|
63
|
-
animatedWidth: v.width + v.left + v.right
|
|
64
|
-
}),
|
|
65
|
-
leave: v => ({
|
|
66
|
-
animatedWidth: v.width + v.left + v.right
|
|
67
|
-
}),
|
|
68
|
-
reset: false,
|
|
69
|
-
immediate: skipAnimation
|
|
70
|
-
});
|
|
71
54
|
const transitionChange = (0, _web.useTransition)([stringInterpolator], {
|
|
72
55
|
from: {
|
|
73
56
|
value: 0
|
|
@@ -81,23 +64,13 @@ function AnimatedLine(props) {
|
|
|
81
64
|
reset: false,
|
|
82
65
|
immediate: skipAnimation
|
|
83
66
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
width: style.animatedWidth,
|
|
92
|
-
height: drawingArea.top + drawingArea.height + drawingArea.bottom
|
|
93
|
-
}))
|
|
94
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
95
|
-
clipPath: `url(#${clipId})`,
|
|
96
|
-
children: transitionChange((style, interpolator) => /*#__PURE__*/(0, _jsxRuntime.jsx)(LineElementPath, (0, _extends2.default)({}, other, {
|
|
97
|
-
ownerState: ownerState,
|
|
98
|
-
d: style.value.to(interpolator)
|
|
99
|
-
})))
|
|
100
|
-
})]
|
|
67
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppearingMask.AppearingMask, {
|
|
68
|
+
skipAnimation: skipAnimation,
|
|
69
|
+
id: `${ownerState.id}-line-clip`,
|
|
70
|
+
children: transitionChange((style, interpolator) => /*#__PURE__*/(0, _jsxRuntime.jsx)(LineElementPath, (0, _extends2.default)({}, other, {
|
|
71
|
+
ownerState: ownerState,
|
|
72
|
+
d: style.value.to(interpolator)
|
|
73
|
+
})))
|
|
101
74
|
});
|
|
102
75
|
}
|
|
103
76
|
process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.AppearingMask = AppearingMask;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _web = require("@react-spring/web");
|
|
11
|
+
var _cleanId = require("../internals/cleanId");
|
|
12
|
+
var _hooks = require("../hooks");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
/**
|
|
15
|
+
* @ignore - internal component.
|
|
16
|
+
*/
|
|
17
|
+
function AppearingMask(props) {
|
|
18
|
+
const drawingArea = (0, _hooks.useDrawingArea)();
|
|
19
|
+
const chartId = (0, _hooks.useChartId)();
|
|
20
|
+
const transitionAppear = (0, _web.useTransition)([drawingArea], {
|
|
21
|
+
from: v => ({
|
|
22
|
+
animatedWidth: v.left
|
|
23
|
+
}),
|
|
24
|
+
enter: v => ({
|
|
25
|
+
animatedWidth: v.width + v.left + v.right
|
|
26
|
+
}),
|
|
27
|
+
leave: v => ({
|
|
28
|
+
animatedWidth: v.width + v.left + v.right
|
|
29
|
+
}),
|
|
30
|
+
reset: false,
|
|
31
|
+
immediate: props.skipAnimation
|
|
32
|
+
});
|
|
33
|
+
const clipId = (0, _cleanId.cleanId)(`${chartId}-${props.id}`);
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
35
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("clipPath", {
|
|
36
|
+
id: clipId,
|
|
37
|
+
children: transitionAppear(style => /*#__PURE__*/(0, _jsxRuntime.jsx)(_web.animated.rect, {
|
|
38
|
+
x: 0,
|
|
39
|
+
y: 0,
|
|
40
|
+
width: style.animatedWidth,
|
|
41
|
+
height: drawingArea.top + drawingArea.height + drawingArea.bottom
|
|
42
|
+
}))
|
|
43
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
44
|
+
clipPath: `url(#${clipId})`,
|
|
45
|
+
children: props.children
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -7,10 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
10
|
+
var _warning = require("@mui/x-internals/warning");
|
|
10
11
|
var _stackSeries = require("../internals/stackSeries");
|
|
11
12
|
var _defaultizeValueFormatter = require("../internals/defaultizeValueFormatter");
|
|
12
|
-
let warnedOnce = false;
|
|
13
|
-
|
|
14
13
|
// For now it's a copy past of bar charts formatter, but maybe will diverge later
|
|
15
14
|
const formatter = (params, dataset) => {
|
|
16
15
|
const {
|
|
@@ -61,9 +60,10 @@ const formatter = (params, dataset) => {
|
|
|
61
60
|
data: dataKey ? dataset.map(data => {
|
|
62
61
|
const value = data[dataKey];
|
|
63
62
|
if (typeof value !== 'number') {
|
|
64
|
-
if (process.env.NODE_ENV !== 'production'
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
+
if (value !== null) {
|
|
65
|
+
(0, _warning.warnOnce)([`MUI X: Your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
|
|
66
|
+
}
|
|
67
67
|
}
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
@@ -32,7 +32,7 @@ function ZAxisContextProvider(props) {
|
|
|
32
32
|
return axisConfig;
|
|
33
33
|
}
|
|
34
34
|
if (dataset === undefined) {
|
|
35
|
-
throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
35
|
+
throw new Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
36
36
|
}
|
|
37
37
|
return (0, _extends2.default)({}, axisConfig, {
|
|
38
38
|
data: dataset.map(d => d[dataKey])
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useReducedMotion = void 0;
|
|
8
8
|
var _web = require("@react-spring/web");
|
|
9
|
-
const handleMediaChange =
|
|
9
|
+
const handleMediaChange = event => {
|
|
10
10
|
_web.Globals.assign({
|
|
11
11
|
// Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
|
|
12
|
-
skipAnimation:
|
|
12
|
+
skipAnimation: event.matches || undefined
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|