@mui/x-charts 7.6.2 → 7.7.1
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/BarChart.d.ts +1 -1
- package/BarChart/BarChart.js +21 -104
- package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
- package/BarChart/BarLabel/BarLabelPlot.js +1 -24
- package/BarChart/BarPlot.js +2 -2
- package/BarChart/checkScaleErrors.d.ts +5 -9
- package/BarChart/types.d.ts +2 -2
- package/BarChart/useBarChartProps.d.ts +102 -0
- package/BarChart/useBarChartProps.js +143 -0
- package/CHANGELOG.md +163 -0
- package/ChartContainer/ChartContainer.d.ts +4 -4
- package/ChartContainer/ChartContainer.js +64 -31
- package/ChartContainer/useChartContainerHooks.d.ts +11 -0
- package/ChartContainer/useChartContainerHooks.js +34 -0
- package/ChartContainer/usePluginsMerge.d.ts +1 -2
- package/ChartsAxis/ChartsAxis.js +2 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/ChartsGrid/ChartsGrid.js +2 -2
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/ChartsOverlay/index.d.ts +1 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
- package/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
- package/ChartsText/ChartsText.js +1 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
- package/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -3
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +2 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- package/LineChart/AreaPlot.js +2 -2
- package/LineChart/LineChart.d.ts +2 -2
- package/LineChart/LineChart.js +25 -107
- package/LineChart/LineHighlightPlot.js +2 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/MarkPlot.js +2 -2
- package/LineChart/useLineChartProps.d.ts +117 -0
- package/LineChart/useLineChartProps.js +152 -0
- package/PieChart/PieChart.d.ts +2 -2
- package/PieChart/PieChart.js +1 -1
- package/ResponsiveChartContainer/ResizableContainer.d.ts +10 -0
- package/ResponsiveChartContainer/ResizableContainer.js +32 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +25 -22
- package/ScatterChart/ScatterChart.d.ts +1 -1
- package/ScatterChart/ScatterChart.js +21 -76
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/useScatterChartProps.d.ts +86 -0
- package/ScatterChart/useScatterChartProps.js +116 -0
- package/SparkLineChart/SparkLineChart.d.ts +8 -3
- package/SparkLineChart/SparkLineChart.js +57 -1
- package/context/CartesianProvider/CartesianContext.d.ts +25 -0
- package/context/CartesianProvider/CartesianContext.js +21 -0
- package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
- package/context/CartesianProvider/CartesianProvider.js +44 -0
- package/context/CartesianProvider/computeValue.d.ts +19 -0
- package/context/CartesianProvider/computeValue.js +89 -0
- package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
- package/context/CartesianProvider/getAxisExtremum.js +28 -0
- package/context/CartesianProvider/index.d.ts +9 -0
- package/context/CartesianProvider/index.js +51 -0
- package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
- package/context/CartesianProvider/normalizeAxis.js +23 -0
- package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
- package/context/CartesianProvider/useCartesianContext.js +17 -0
- package/context/ColorProvider.d.ts +12 -0
- package/context/ColorProvider.js +25 -0
- package/esm/BarChart/BarChart.js +21 -104
- package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
- package/esm/BarChart/BarPlot.js +2 -2
- package/esm/BarChart/useBarChartProps.js +136 -0
- package/esm/ChartContainer/ChartContainer.js +65 -32
- package/esm/ChartContainer/useChartContainerHooks.js +24 -0
- package/esm/ChartsAxis/ChartsAxis.js +2 -2
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/esm/ChartsGrid/ChartsGrid.js +2 -2
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
- package/esm/ChartsText/ChartsText.js +1 -3
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -3
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/LineChart/AreaPlot.js +2 -2
- package/esm/LineChart/LineChart.js +25 -107
- package/esm/LineChart/LineHighlightPlot.js +2 -2
- package/esm/LineChart/LinePlot.js +2 -2
- package/esm/LineChart/MarkPlot.js +2 -2
- package/esm/LineChart/useLineChartProps.js +144 -0
- package/esm/PieChart/PieChart.js +1 -1
- package/esm/ResponsiveChartContainer/ResizableContainer.js +26 -0
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +24 -21
- package/esm/ScatterChart/ScatterChart.js +21 -76
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/useScatterChartProps.js +108 -0
- package/esm/SparkLineChart/SparkLineChart.js +57 -1
- package/esm/context/CartesianProvider/CartesianContext.js +13 -0
- package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
- package/esm/context/CartesianProvider/computeValue.js +82 -0
- package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
- package/esm/context/CartesianProvider/index.js +10 -0
- package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
- package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
- package/esm/context/ColorProvider.js +16 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useAxisEvents.js +2 -2
- package/esm/hooks/useColor.js +9 -0
- package/esm/hooks/useColorScale.js +27 -0
- package/esm/hooks/useReducedMotion.js +7 -0
- package/esm/hooks/useScale.js +3 -4
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/esm/internals/index.js +31 -1
- package/esm/internals/warning.js +13 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +12 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useColor.d.ts +4 -0
- package/hooks/useColor.js +17 -0
- package/hooks/useColorScale.d.ts +4 -0
- package/hooks/useColorScale.js +37 -0
- package/hooks/useDrawingArea.d.ts +2 -8
- package/hooks/useReducedMotion.js +7 -0
- package/hooks/useScale.js +3 -6
- package/index.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/internals/defaultizeColor.d.ts +8 -8
- package/internals/index.d.ts +22 -0
- package/internals/index.js +231 -0
- package/internals/warning.d.ts +1 -0
- package/internals/warning.js +19 -0
- package/models/axis.d.ts +1 -2
- package/models/plugin.d.ts +4 -1
- package/modern/BarChart/BarChart.js +21 -104
- package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
- package/modern/BarChart/BarPlot.js +2 -2
- package/modern/BarChart/useBarChartProps.js +136 -0
- package/modern/ChartContainer/ChartContainer.js +65 -32
- package/modern/ChartContainer/useChartContainerHooks.js +24 -0
- package/modern/ChartsAxis/ChartsAxis.js +2 -2
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/modern/ChartsGrid/ChartsGrid.js +2 -2
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
- package/modern/ChartsText/ChartsText.js +1 -3
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -3
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/LineChart/AreaPlot.js +2 -2
- package/modern/LineChart/LineChart.js +25 -107
- package/modern/LineChart/LineHighlightPlot.js +2 -2
- package/modern/LineChart/LinePlot.js +2 -2
- package/modern/LineChart/MarkPlot.js +2 -2
- package/modern/LineChart/useLineChartProps.js +144 -0
- package/modern/PieChart/PieChart.js +1 -1
- package/modern/ResponsiveChartContainer/ResizableContainer.js +26 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +24 -21
- package/modern/ScatterChart/ScatterChart.js +21 -76
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/useScatterChartProps.js +108 -0
- package/modern/SparkLineChart/SparkLineChart.js +57 -1
- package/modern/context/CartesianProvider/CartesianContext.js +13 -0
- package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
- package/modern/context/CartesianProvider/computeValue.js +82 -0
- package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
- package/modern/context/CartesianProvider/index.js +10 -0
- package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
- package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
- package/modern/context/ColorProvider.js +16 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/useAxisEvents.js +2 -2
- package/modern/hooks/useColor.js +9 -0
- package/modern/hooks/useColorScale.js +27 -0
- package/modern/hooks/useReducedMotion.js +7 -0
- package/modern/hooks/useScale.js +3 -4
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/modern/internals/index.js +31 -1
- package/modern/internals/warning.js +13 -0
- package/package.json +4 -4
- package/themeAugmentation/components.d.ts +12 -12
- package/context/CartesianContextProvider.d.ts +0 -53
- package/context/CartesianContextProvider.js +0 -233
- package/esm/context/CartesianContextProvider.js +0 -224
- package/esm/internals/colorGetter.js +0 -22
- package/internals/colorGetter.d.ts +0 -7
- package/internals/colorGetter.js +0 -29
- package/modern/context/CartesianContextProvider.js +0 -224
- package/modern/internals/colorGetter.js +0 -22
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
4
3
|
import { DrawingProvider } from '../context/DrawingProvider';
|
|
5
4
|
import { SeriesContextProvider } from '../context/SeriesContextProvider';
|
|
6
5
|
import { InteractionProvider } from '../context/InteractionProvider';
|
|
7
|
-
import {
|
|
6
|
+
import { ColorProvider } from '../context/ColorProvider';
|
|
8
7
|
import { ChartsSurface } from '../ChartsSurface';
|
|
9
|
-
import { CartesianContextProvider } from '../context/
|
|
8
|
+
import { CartesianContextProvider } from '../context/CartesianProvider';
|
|
10
9
|
import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
|
|
11
|
-
import { HighlightedProvider } from '../context';
|
|
12
|
-
import {
|
|
10
|
+
import { HighlightedProvider, ZAxisContextProvider } from '../context';
|
|
11
|
+
import { useChartContainerHooks } from './useChartContainerHooks';
|
|
13
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
13
|
const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
15
14
|
const {
|
|
@@ -19,6 +18,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
19
18
|
margin,
|
|
20
19
|
xAxis,
|
|
21
20
|
yAxis,
|
|
21
|
+
zAxis,
|
|
22
22
|
colors,
|
|
23
23
|
dataset,
|
|
24
24
|
sx,
|
|
@@ -30,40 +30,50 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
30
30
|
plugins,
|
|
31
31
|
children
|
|
32
32
|
} = props;
|
|
33
|
-
const svgRef = React.useRef(null);
|
|
34
|
-
const handleRef = useForkRef(ref, svgRef);
|
|
35
33
|
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
svgRef,
|
|
35
|
+
handleRef,
|
|
36
|
+
xExtremumGetters,
|
|
37
|
+
yExtremumGetters,
|
|
38
|
+
seriesFormatters,
|
|
39
|
+
colorProcessors
|
|
40
|
+
} = useChartContainerHooks(ref, plugins);
|
|
40
41
|
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
41
42
|
width: width,
|
|
42
43
|
height: height,
|
|
43
44
|
margin: margin,
|
|
44
45
|
svgRef: svgRef,
|
|
45
|
-
children: /*#__PURE__*/_jsx(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
|
|
51
|
-
xAxis: xAxis,
|
|
52
|
-
yAxis: yAxis,
|
|
46
|
+
children: /*#__PURE__*/_jsx(ColorProvider, {
|
|
47
|
+
colorProcessors: colorProcessors,
|
|
48
|
+
children: /*#__PURE__*/_jsx(SeriesContextProvider, {
|
|
49
|
+
series: series,
|
|
50
|
+
colors: colors,
|
|
53
51
|
dataset: dataset,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
seriesFormatters: seriesFormatters,
|
|
53
|
+
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
|
|
54
|
+
xAxis: xAxis,
|
|
55
|
+
yAxis: yAxis,
|
|
56
|
+
dataset: dataset,
|
|
57
|
+
xExtremumGetters: xExtremumGetters,
|
|
58
|
+
yExtremumGetters: yExtremumGetters,
|
|
59
|
+
children: /*#__PURE__*/_jsx(ZAxisContextProvider, {
|
|
60
|
+
zAxis: zAxis,
|
|
61
|
+
dataset: dataset,
|
|
62
|
+
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
63
|
+
children: /*#__PURE__*/_jsx(HighlightedProvider, {
|
|
64
|
+
highlightedItem: highlightedItem,
|
|
65
|
+
onHighlightChange: onHighlightChange,
|
|
66
|
+
children: /*#__PURE__*/_jsxs(ChartsSurface, {
|
|
67
|
+
width: width,
|
|
68
|
+
height: height,
|
|
69
|
+
ref: handleRef,
|
|
70
|
+
sx: sx,
|
|
71
|
+
title: title,
|
|
72
|
+
desc: desc,
|
|
73
|
+
disableAxisListener: disableAxisListener,
|
|
74
|
+
children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
|
|
75
|
+
})
|
|
76
|
+
})
|
|
67
77
|
})
|
|
68
78
|
})
|
|
69
79
|
})
|
|
@@ -251,6 +261,29 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
251
261
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
252
262
|
tickSize: PropTypes.number,
|
|
253
263
|
valueFormatter: PropTypes.func
|
|
264
|
+
})),
|
|
265
|
+
/**
|
|
266
|
+
* The configuration of the z-axes.
|
|
267
|
+
*/
|
|
268
|
+
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
269
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
270
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
271
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
272
|
+
unknownColor: PropTypes.string,
|
|
273
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
274
|
+
}), PropTypes.shape({
|
|
275
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
276
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
277
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
278
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
279
|
+
}), PropTypes.shape({
|
|
280
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
281
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
282
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
283
|
+
})]),
|
|
284
|
+
data: PropTypes.array,
|
|
285
|
+
dataKey: PropTypes.string,
|
|
286
|
+
id: PropTypes.string
|
|
254
287
|
}))
|
|
255
288
|
} : void 0;
|
|
256
289
|
export { ChartContainer };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { usePluginsMerge } from './usePluginsMerge';
|
|
4
|
+
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
5
|
+
export const useChartContainerHooks = (ref, plugins) => {
|
|
6
|
+
const svgRef = React.useRef(null);
|
|
7
|
+
const handleRef = useForkRef(ref, svgRef);
|
|
8
|
+
const {
|
|
9
|
+
xExtremumGetters,
|
|
10
|
+
yExtremumGetters,
|
|
11
|
+
seriesFormatters,
|
|
12
|
+
colorProcessors
|
|
13
|
+
} = usePluginsMerge(plugins);
|
|
14
|
+
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
svgRef,
|
|
18
|
+
handleRef,
|
|
19
|
+
xExtremumGetters,
|
|
20
|
+
yExtremumGetters,
|
|
21
|
+
seriesFormatters,
|
|
22
|
+
colorProcessors
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
4
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
5
5
|
import { ChartsXAxis } from '../ChartsXAxis';
|
|
6
6
|
import { ChartsYAxis } from '../ChartsYAxis';
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -47,7 +47,7 @@ function ChartsAxis(props) {
|
|
|
47
47
|
xAxisIds,
|
|
48
48
|
yAxis,
|
|
49
49
|
yAxisIds
|
|
50
|
-
} =
|
|
50
|
+
} = useCartesianContext();
|
|
51
51
|
|
|
52
52
|
// TODO: use for plotting line without ticks or any thing
|
|
53
53
|
// const drawingArea = React.useContext(DrawingContext);
|
|
@@ -6,7 +6,7 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
6
6
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
8
8
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
9
|
-
import {
|
|
9
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
10
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
11
|
import { isBandScale } from '../internals/isBandScale';
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -55,7 +55,7 @@ function ChartsAxisHighlight(props) {
|
|
|
55
55
|
xAxis,
|
|
56
56
|
yAxisIds,
|
|
57
57
|
yAxis
|
|
58
|
-
} =
|
|
58
|
+
} = useCartesianContext();
|
|
59
59
|
const classes = useUtilityClasses();
|
|
60
60
|
const USED_X_AXIS_ID = xAxisIds[0];
|
|
61
61
|
const USED_Y_AXIS_ID = yAxisIds[0];
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
7
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
|
-
import {
|
|
8
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
9
9
|
import { useTicks } from '../hooks/useTicks';
|
|
10
10
|
import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -63,7 +63,7 @@ function ChartsGrid(props) {
|
|
|
63
63
|
xAxisIds,
|
|
64
64
|
yAxis,
|
|
65
65
|
yAxisIds
|
|
66
|
-
} =
|
|
66
|
+
} = useCartesianContext();
|
|
67
67
|
const classes = useUtilityClasses(themeProps);
|
|
68
68
|
const horizontalAxisId = yAxisIds[0];
|
|
69
69
|
const verticalAxisId = xAxisIds[0];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
4
|
-
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
5
4
|
import { useSeries } from '../hooks/useSeries';
|
|
6
5
|
import { useSvgRef } from '../hooks';
|
|
6
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
function ChartsOnAxisClickHandler(props) {
|
|
9
9
|
const {
|
|
@@ -19,7 +19,7 @@ function ChartsOnAxisClickHandler(props) {
|
|
|
19
19
|
xAxis,
|
|
20
20
|
yAxisIds,
|
|
21
21
|
yAxis
|
|
22
|
-
} =
|
|
22
|
+
} = useCartesianContext();
|
|
23
23
|
React.useEffect(() => {
|
|
24
24
|
const element = svgRef.current;
|
|
25
25
|
if (element === null || !onAxisClick) {
|
|
@@ -5,6 +5,7 @@ import { useDrawingArea, useXScale } from '../hooks';
|
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
6
|
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
+
import { buildWarning } from '../internals/warning';
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const getTextParams = ({
|
|
10
11
|
top,
|
|
@@ -46,7 +47,7 @@ export function getXReferenceLineClasses(classes) {
|
|
|
46
47
|
label: ['label']
|
|
47
48
|
}, getReferenceLineUtilityClass, classes);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of x axis with id ${id}.`, 'error');
|
|
50
51
|
function ChartsXReferenceLine(props) {
|
|
51
52
|
const {
|
|
52
53
|
x,
|
|
@@ -66,10 +67,7 @@ function ChartsXReferenceLine(props) {
|
|
|
66
67
|
const xPosition = xAxisScale(x);
|
|
67
68
|
if (xPosition === undefined) {
|
|
68
69
|
if (process.env.NODE_ENV !== 'production') {
|
|
69
|
-
|
|
70
|
-
warnedOnce = true;
|
|
71
|
-
console.error(`MUI X Charts: the value ${x} does not exist in the data of x axis with id ${axisId}.`);
|
|
72
|
-
}
|
|
70
|
+
valueError(x, axisId);
|
|
73
71
|
}
|
|
74
72
|
return null;
|
|
75
73
|
}
|
|
@@ -5,6 +5,7 @@ import { useDrawingArea, useYScale } from '../hooks';
|
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
6
|
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
+
import { buildWarning } from '../internals/warning';
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const getTextParams = ({
|
|
10
11
|
left,
|
|
@@ -39,7 +40,6 @@ const getTextParams = ({
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
|
-
let warnedOnce = false;
|
|
43
43
|
export function getYReferenceLineClasses(classes) {
|
|
44
44
|
return composeClasses({
|
|
45
45
|
root: ['root', 'horizontal'],
|
|
@@ -47,6 +47,7 @@ export function getYReferenceLineClasses(classes) {
|
|
|
47
47
|
label: ['label']
|
|
48
48
|
}, getReferenceLineUtilityClass, classes);
|
|
49
49
|
}
|
|
50
|
+
const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of y axis with id ${id}.`, 'error');
|
|
50
51
|
function ChartsYReferenceLine(props) {
|
|
51
52
|
const {
|
|
52
53
|
y,
|
|
@@ -66,10 +67,7 @@ function ChartsYReferenceLine(props) {
|
|
|
66
67
|
const yPosition = yAxisScale(y);
|
|
67
68
|
if (yPosition === undefined) {
|
|
68
69
|
if (process.env.NODE_ENV !== 'production') {
|
|
69
|
-
|
|
70
|
-
warnedOnce = true;
|
|
71
|
-
console.error(`MUI X Charts: the value ${y} does not exist in the data of y axis with id ${axisId}.`);
|
|
72
|
-
}
|
|
70
|
+
valueError(y, axisId);
|
|
73
71
|
}
|
|
74
72
|
return null;
|
|
75
73
|
}
|
|
@@ -49,10 +49,8 @@ function ChartsText(props) {
|
|
|
49
49
|
if (angle) {
|
|
50
50
|
transforms.push(`rotate(${angle}, ${x}, ${y})`);
|
|
51
51
|
}
|
|
52
|
-
if (transforms.length) {
|
|
53
|
-
textProps.transform = transforms.join(' ');
|
|
54
|
-
}
|
|
55
52
|
return /*#__PURE__*/_jsx("text", _extends({}, textProps, {
|
|
53
|
+
transform: transforms.length > 0 ? transforms.join(' ') : undefined,
|
|
56
54
|
x: x,
|
|
57
55
|
y: y,
|
|
58
56
|
textAnchor: textAnchor,
|
|
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
6
6
|
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
7
|
-
import { isCartesianSeriesType } from '../internals/isCartesian';
|
|
8
|
-
import colorGetter from '../internals/colorGetter';
|
|
9
7
|
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
8
|
+
import { useColorProcessor } from '../hooks/useColor';
|
|
9
|
+
import { isCartesianSeriesType } from '../internals/isCartesian';
|
|
10
10
|
import { useSeries } from '../hooks/useSeries';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function ChartsAxisTooltipContent(props) {
|
|
@@ -25,12 +25,13 @@ function ChartsAxisTooltipContent(props) {
|
|
|
25
25
|
xAxis,
|
|
26
26
|
yAxisIds,
|
|
27
27
|
yAxis
|
|
28
|
-
} =
|
|
28
|
+
} = useCartesianContext();
|
|
29
29
|
const {
|
|
30
30
|
zAxisIds,
|
|
31
31
|
zAxis
|
|
32
32
|
} = React.useContext(ZAxisContext);
|
|
33
33
|
const series = useSeries();
|
|
34
|
+
const colorProcessors = useColorProcessor();
|
|
34
35
|
const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
|
|
35
36
|
const relevantSeries = React.useMemo(() => {
|
|
36
37
|
const rep = [];
|
|
@@ -40,15 +41,8 @@ function ChartsAxisTooltipContent(props) {
|
|
|
40
41
|
const axisKey = isXaxis ? item.xAxisKey : item.yAxisKey;
|
|
41
42
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
42
43
|
const seriesToAdd = series[seriesType].series[seriesId];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
case 'scatter':
|
|
46
|
-
getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxis[seriesToAdd.zAxisKey ?? zAxisIds[0]]);
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]]);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
44
|
+
const zAxisKey = seriesToAdd.zAxisKey ?? zAxisIds[0];
|
|
45
|
+
const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxisKey && zAxis[zAxisKey]) ?? (() => '');
|
|
52
46
|
rep.push(_extends({}, seriesToAdd, {
|
|
53
47
|
getColor
|
|
54
48
|
}));
|
|
@@ -56,7 +50,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
56
50
|
});
|
|
57
51
|
});
|
|
58
52
|
return rep;
|
|
59
|
-
}, [USED_AXIS_ID, isXaxis, series, xAxis, xAxisIds, yAxis, yAxisIds, zAxis, zAxisIds]);
|
|
53
|
+
}, [USED_AXIS_ID, colorProcessors, isXaxis, series, xAxis, xAxisIds, yAxis, yAxisIds, zAxis, zAxisIds]);
|
|
60
54
|
const relevantAxis = React.useMemo(() => {
|
|
61
55
|
return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
62
56
|
}, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
|
|
@@ -3,9 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
5
|
import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
|
|
6
|
-
import {
|
|
7
|
-
import colorGetter from '../internals/colorGetter';
|
|
6
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
8
7
|
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
8
|
+
import { useColorProcessor } from '../hooks/useColor';
|
|
9
9
|
import { useSeries } from '../hooks/useSeries';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
function ChartsItemTooltipContent(props) {
|
|
@@ -22,26 +22,16 @@ function ChartsItemTooltipContent(props) {
|
|
|
22
22
|
yAxis,
|
|
23
23
|
xAxisIds,
|
|
24
24
|
yAxisIds
|
|
25
|
-
} =
|
|
25
|
+
} = useCartesianContext();
|
|
26
26
|
const {
|
|
27
27
|
zAxis,
|
|
28
28
|
zAxisIds
|
|
29
29
|
} = React.useContext(ZAxisContext);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case 'pie':
|
|
36
|
-
getColor = colorGetter(series);
|
|
37
|
-
break;
|
|
38
|
-
case 'scatter':
|
|
39
|
-
getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId], zAxis[series.zAxisKey ?? defaultZAxisId]);
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId]);
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
30
|
+
const colorProcessors = useColorProcessor();
|
|
31
|
+
const xAxisKey = series.xAxisKey ?? xAxisIds[0];
|
|
32
|
+
const yAxisKey = series.yAxisKey ?? yAxisIds[0];
|
|
33
|
+
const zAxisKey = series.zAxisKey ?? zAxisIds[0];
|
|
34
|
+
const getColor = colorProcessors[series.type]?.(series, xAxisKey && xAxis[xAxisKey], yAxisKey && yAxis[yAxisKey], zAxisKey && zAxis[zAxisKey]) ?? (() => '');
|
|
45
35
|
const Content = content ?? DefaultChartsItemTooltipContent;
|
|
46
36
|
const chartTooltipContentProps = useSlotProps({
|
|
47
37
|
elementType: Content,
|
|
@@ -38,7 +38,6 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
38
38
|
})
|
|
39
39
|
}), /*#__PURE__*/_jsx("tbody", {
|
|
40
40
|
children: series.filter(isCartesianSeries).map(({
|
|
41
|
-
color,
|
|
42
41
|
id,
|
|
43
42
|
label,
|
|
44
43
|
valueFormatter,
|
|
@@ -53,12 +52,13 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
53
52
|
return null;
|
|
54
53
|
}
|
|
55
54
|
const formattedLabel = getLabel(label, 'tooltip');
|
|
55
|
+
const color = getColor(dataIndex);
|
|
56
56
|
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
57
57
|
className: classes.row,
|
|
58
58
|
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
59
59
|
className: clsx(classes.markCell, classes.cell),
|
|
60
|
-
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
61
|
-
color:
|
|
60
|
+
children: color && /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
61
|
+
color: color,
|
|
62
62
|
className: classes.mark
|
|
63
63
|
})
|
|
64
64
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
@@ -23,7 +23,7 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
23
23
|
color: getColor(itemData.dataIndex),
|
|
24
24
|
displayedLabel: getLabel(series.data[itemData.dataIndex].label, 'tooltip')
|
|
25
25
|
} : {
|
|
26
|
-
color: getColor(itemData.dataIndex)
|
|
26
|
+
color: getColor(itemData.dataIndex),
|
|
27
27
|
displayedLabel: getLabel(series.label, 'tooltip')
|
|
28
28
|
};
|
|
29
29
|
const value = series.type === 'pie' ? _extends({}, series.data[itemData.dataIndex], {
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { Delaunay } from 'd3-delaunay';
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
6
|
-
import {
|
|
6
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
7
7
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
8
8
|
import { getSVGPoint } from '../internals/utils';
|
|
9
9
|
import { useDrawingArea, useSvgRef } from '../hooks';
|
|
@@ -27,7 +27,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
27
27
|
yAxis,
|
|
28
28
|
xAxisIds,
|
|
29
29
|
yAxisIds
|
|
30
|
-
} =
|
|
30
|
+
} = useCartesianContext();
|
|
31
31
|
const {
|
|
32
32
|
dispatch
|
|
33
33
|
} = React.useContext(InteractionContext);
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useSlotProps } from '@mui/base/utils';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
|
-
import {
|
|
9
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
10
10
|
import { useTicks } from '../hooks/useTicks';
|
|
11
11
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
12
12
|
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
@@ -107,7 +107,7 @@ function ChartsXAxis(inProps) {
|
|
|
107
107
|
const {
|
|
108
108
|
xAxisIds,
|
|
109
109
|
xAxis
|
|
110
|
-
} =
|
|
110
|
+
} = useCartesianContext();
|
|
111
111
|
const _xAxis = xAxis[inProps.axisId ?? xAxisIds[0]],
|
|
112
112
|
{
|
|
113
113
|
scale: xScale,
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useSlotProps } from '@mui/base/utils';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
|
-
import {
|
|
9
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
10
10
|
import { useTicks } from '../hooks/useTicks';
|
|
11
11
|
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
12
12
|
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
@@ -50,7 +50,7 @@ function ChartsYAxis(inProps) {
|
|
|
50
50
|
const {
|
|
51
51
|
yAxisIds,
|
|
52
52
|
yAxis
|
|
53
|
-
} =
|
|
53
|
+
} = useCartesianContext();
|
|
54
54
|
const _yAxis = yAxis[inProps.axisId ?? yAxisIds[0]],
|
|
55
55
|
{
|
|
56
56
|
scale: yScale,
|
|
@@ -4,7 +4,7 @@ const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { area as d3Area } from 'd3-shape';
|
|
7
|
-
import {
|
|
7
|
+
import { useCartesianContext } from '../context/CartesianProvider';
|
|
8
8
|
import { AreaElement } from './AreaElement';
|
|
9
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
10
|
import getCurveFactory from '../internals/getCurve';
|
|
@@ -14,7 +14,7 @@ import { useLineSeries } from '../hooks/useSeries';
|
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const useAggregatedData = () => {
|
|
16
16
|
const seriesData = useLineSeries();
|
|
17
|
-
const axisData =
|
|
17
|
+
const axisData = useCartesianContext();
|
|
18
18
|
if (seriesData === undefined) {
|
|
19
19
|
return [];
|
|
20
20
|
}
|