@mui/x-charts 6.0.0-alpha.8 → 6.18.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/BarChart.d.ts +19 -5
- package/BarChart/BarChart.js +52 -13
- package/BarChart/BarElement.d.ts +1319 -4
- package/BarChart/BarElement.js +10 -10
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/BarChart/formatter.js +2 -3
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +786 -48
- package/ChartContainer/index.js +7 -5
- package/ChartsAxis/ChartsAxis.d.ts +9 -0
- package/ChartsAxis/ChartsAxis.js +28 -2
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +21 -0
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +61 -22
- package/ChartsClipPath/ChartsClipPath.d.ts +5 -0
- package/ChartsClipPath/ChartsClipPath.js +7 -2
- package/ChartsLegend/ChartsLegend.d.ts +44 -24
- package/ChartsLegend/ChartsLegend.js +192 -150
- package/ChartsLegend/chartsLegendClasses.js +1 -2
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.d.ts +1 -1
- package/ChartsSurface.js +9 -18
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +46 -32
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +18 -9
- package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
- package/ChartsTooltip/ChartsTooltip.js +62 -18
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -10
- package/ChartsTooltip/ChartsTooltipTable.js +22 -20
- package/ChartsTooltip/tooltipClasses.js +1 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.d.ts +9 -0
- package/ChartsXAxis/ChartsXAxis.js +161 -40
- package/ChartsYAxis/ChartsYAxis.d.ts +9 -0
- package/ChartsYAxis/ChartsYAxis.js +86 -33
- package/LineChart/AreaElement.d.ts +12 -2
- package/LineChart/AreaElement.js +14 -6
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +27 -8
- package/LineChart/LineChart.d.ts +21 -3
- package/LineChart/LineChart.js +61 -14
- package/LineChart/LineElement.d.ts +12 -2
- package/LineChart/LineElement.js +14 -6
- package/LineChart/LineHighlightElement.d.ts +31 -0
- package/LineChart/LineHighlightElement.js +88 -0
- package/LineChart/LineHighlightPlot.d.ts +35 -0
- package/LineChart/LineHighlightPlot.js +110 -0
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +25 -12
- package/LineChart/MarkElement.d.ts +11 -1
- package/LineChart/MarkElement.js +15 -9
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +62 -15
- package/LineChart/formatter.js +5 -5
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +20 -0
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +12 -14
- package/PieChart/PieArc.js +28 -60
- package/PieChart/PieArcLabel.d.ts +9 -10
- package/PieChart/PieArcLabel.js +46 -38
- package/PieChart/PieArcLabelPlot.d.ts +28 -0
- package/PieChart/PieArcLabelPlot.js +99 -0
- package/PieChart/PieArcPlot.d.ts +35 -0
- package/PieChart/PieArcPlot.js +92 -0
- package/PieChart/PieChart.d.ts +19 -5
- package/PieChart/PieChart.js +61 -14
- package/PieChart/PiePlot.d.ts +15 -9
- package/PieChart/PiePlot.js +77 -55
- package/PieChart/dataTransform/transition.d.ts +4 -0
- package/PieChart/dataTransform/transition.js +136 -0
- package/PieChart/dataTransform/useTransformData.d.ts +15 -0
- package/PieChart/dataTransform/useTransformData.js +67 -0
- package/PieChart/formatter.js +1 -2
- package/PieChart/legend.js +1 -2
- package/README.md +8 -14
- package/ResponsiveChartContainer/index.js +7 -8
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +16 -3
- package/ScatterChart/ScatterChart.js +43 -12
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/ScatterChart/formatter.js +1 -2
- package/ScatterChart/legend.js +1 -2
- package/SparkLineChart/SparkLineChart.d.ts +13 -3
- package/SparkLineChart/SparkLineChart.js +34 -18
- package/colorPalettes/colorPalettes.js +6 -12
- package/constants.js +5 -8
- package/context/CartesianContextProvider.d.ts +5 -0
- package/context/CartesianContextProvider.js +31 -16
- package/context/DrawingProvider.d.ts +7 -0
- package/context/DrawingProvider.js +12 -6
- package/context/HighlightProvider.js +3 -4
- package/context/InteractionProvider.js +3 -4
- package/context/SeriesContextProvider.js +3 -4
- package/esm/BarChart/BarChart.js +49 -9
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +26 -0
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/esm/ChartsClipPath/ChartsClipPath.js +5 -0
- package/esm/ChartsLegend/ChartsLegend.js +188 -142
- package/esm/ChartsSurface.js +4 -12
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/esm/ChartsTooltip/ChartsTooltip.js +59 -14
- package/esm/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/esm/ChartsXAxis/ChartsXAxis.js +158 -37
- package/esm/ChartsYAxis/ChartsYAxis.js +83 -30
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +26 -6
- package/esm/LineChart/LineChart.js +58 -10
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +78 -0
- package/esm/LineChart/LineHighlightPlot.js +103 -0
- package/esm/LineChart/LinePlot.js +25 -14
- package/esm/LineChart/MarkElement.js +12 -5
- package/esm/LineChart/MarkPlot.js +60 -13
- package/esm/LineChart/formatter.js +7 -3
- package/esm/LineChart/index.js +3 -1
- package/esm/PieChart/PieArc.js +26 -58
- package/esm/PieChart/PieArcLabel.js +43 -34
- package/esm/PieChart/PieArcLabelPlot.js +92 -0
- package/esm/PieChart/PieArcPlot.js +84 -0
- package/esm/PieChart/PieChart.js +59 -12
- package/esm/PieChart/PiePlot.js +76 -57
- package/esm/PieChart/dataTransform/transition.js +130 -0
- package/esm/PieChart/dataTransform/useTransformData.js +59 -0
- package/esm/ResponsiveChartContainer/index.js +3 -3
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +40 -8
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +32 -15
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +30 -14
- package/esm/context/DrawingProvider.js +8 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +15 -9
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +77 -0
- package/esm/internals/domUtils.js +113 -0
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +5 -4
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +19 -11
- package/hooks/useTicks.js +19 -14
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +18 -78
- package/internals/components/ChartsText.d.ts +35 -0
- package/internals/components/ChartsText.js +87 -0
- package/internals/defaultizeColor.d.ts +8 -1
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/domUtils.d.ts +13 -0
- package/internals/domUtils.js +122 -0
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/internals/stackSeries.js +2 -4
- package/legacy/BarChart/BarChart.js +49 -9
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +26 -0
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -20
- package/legacy/ChartsClipPath/ChartsClipPath.js +5 -0
- package/legacy/ChartsLegend/ChartsLegend.js +203 -140
- package/legacy/ChartsSurface.js +3 -12
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +22 -10
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/legacy/ChartsTooltip/ChartsTooltip.js +62 -14
- package/legacy/ChartsTooltip/ChartsTooltipTable.js +34 -26
- package/legacy/ChartsXAxis/ChartsXAxis.js +162 -39
- package/legacy/ChartsYAxis/ChartsYAxis.js +83 -30
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +31 -7
- package/legacy/LineChart/LineChart.js +58 -10
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +77 -0
- package/legacy/LineChart/LineHighlightPlot.js +96 -0
- package/legacy/LineChart/LinePlot.js +29 -12
- package/legacy/LineChart/MarkElement.js +12 -5
- package/legacy/LineChart/MarkPlot.js +50 -5
- package/legacy/LineChart/formatter.js +7 -3
- package/legacy/LineChart/index.js +3 -1
- package/legacy/PieChart/PieArc.js +30 -62
- package/legacy/PieChart/PieArcLabel.js +48 -34
- package/legacy/PieChart/PieArcLabelPlot.js +93 -0
- package/legacy/PieChart/PieArcPlot.js +84 -0
- package/legacy/PieChart/PieChart.js +59 -12
- package/legacy/PieChart/PiePlot.js +76 -59
- package/legacy/PieChart/dataTransform/transition.js +142 -0
- package/legacy/PieChart/dataTransform/useTransformData.js +60 -0
- package/legacy/ResponsiveChartContainer/index.js +3 -3
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +40 -8
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +32 -13
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +30 -14
- package/legacy/context/DrawingProvider.js +8 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +16 -9
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +11 -65
- package/legacy/internals/components/ChartsText.js +79 -0
- package/legacy/internals/domUtils.js +121 -0
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +27 -9
- package/models/layout.d.ts +7 -6
- package/models/seriesType/line.d.ts +39 -1
- package/models/seriesType/pie.d.ts +5 -1
- package/modern/BarChart/BarChart.js +49 -9
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +26 -0
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/modern/ChartsClipPath/ChartsClipPath.js +5 -0
- package/modern/ChartsLegend/ChartsLegend.js +188 -142
- package/modern/ChartsSurface.js +4 -12
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/modern/ChartsTooltip/ChartsTooltip.js +58 -14
- package/modern/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/modern/ChartsXAxis/ChartsXAxis.js +158 -37
- package/modern/ChartsYAxis/ChartsYAxis.js +83 -30
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +25 -6
- package/modern/LineChart/LineChart.js +58 -10
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +78 -0
- package/modern/LineChart/LineHighlightPlot.js +102 -0
- package/modern/LineChart/LinePlot.js +23 -10
- package/modern/LineChart/MarkElement.js +12 -5
- package/modern/LineChart/MarkPlot.js +60 -13
- package/modern/LineChart/formatter.js +4 -3
- package/modern/LineChart/index.js +3 -1
- package/modern/PieChart/PieArc.js +26 -57
- package/modern/PieChart/PieArcLabel.js +43 -34
- package/modern/PieChart/PieArcLabelPlot.js +90 -0
- package/modern/PieChart/PieArcPlot.js +83 -0
- package/modern/PieChart/PieChart.js +59 -12
- package/modern/PieChart/PiePlot.js +76 -55
- package/modern/PieChart/dataTransform/transition.js +130 -0
- package/modern/PieChart/dataTransform/useTransformData.js +58 -0
- package/modern/ResponsiveChartContainer/index.js +3 -3
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +40 -8
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +32 -15
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +29 -13
- package/modern/context/DrawingProvider.js +8 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +15 -9
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +77 -0
- package/modern/internals/domUtils.js +113 -0
- package/modern/internals/geometry.js +36 -0
- package/package.json +9 -6
- package/themeAugmentation/components.d.ts +1 -0
- package/themeAugmentation/overrides.d.ts +2 -0
|
@@ -10,6 +10,17 @@ import { AreaElement } from './AreaElement';
|
|
|
10
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
11
|
import getCurveFactory from '../internals/getCurve';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Demos:
|
|
15
|
+
*
|
|
16
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
17
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
18
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
19
|
+
*
|
|
20
|
+
* API:
|
|
21
|
+
*
|
|
22
|
+
* - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
|
|
23
|
+
*/
|
|
13
24
|
function AreaPlot(props) {
|
|
14
25
|
const {
|
|
15
26
|
slots,
|
|
@@ -38,23 +49,32 @@ function AreaPlot(props) {
|
|
|
38
49
|
ids: groupIds
|
|
39
50
|
}) => {
|
|
40
51
|
return groupIds.flatMap(seriesId => {
|
|
52
|
+
var _xData$map;
|
|
41
53
|
const {
|
|
42
54
|
xAxisKey = defaultXAxisId,
|
|
43
55
|
yAxisKey = defaultYAxisId,
|
|
44
|
-
stackedData
|
|
56
|
+
stackedData,
|
|
57
|
+
data,
|
|
58
|
+
connectNulls
|
|
45
59
|
} = series[seriesId];
|
|
46
60
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
47
61
|
const yScale = yAxis[yAxisKey].scale;
|
|
48
62
|
const xData = xAxis[xAxisKey].data;
|
|
49
|
-
if (
|
|
50
|
-
|
|
63
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
+
if (xData === undefined) {
|
|
65
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
|
|
66
|
+
}
|
|
67
|
+
if (xData.length < stackedData.length) {
|
|
68
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
69
|
+
}
|
|
51
70
|
}
|
|
52
|
-
const areaPath = d3Area().x(d => xScale(d.x)).y0(d => yScale(d.y[0])).y1(d => yScale(d.y[1]));
|
|
71
|
+
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
53
72
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
54
|
-
const
|
|
73
|
+
const formattedData = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
|
|
55
74
|
x,
|
|
56
75
|
y: stackedData[index]
|
|
57
|
-
}));
|
|
76
|
+
}))) != null ? _xData$map : [];
|
|
77
|
+
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
58
78
|
return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
|
|
59
79
|
id: seriesId,
|
|
60
80
|
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
@@ -12,8 +12,19 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
12
12
|
import { ChartsLegend } from '../ChartsLegend';
|
|
13
13
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
14
14
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
15
|
+
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
/**
|
|
19
|
+
* Demos:
|
|
20
|
+
*
|
|
21
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
22
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
23
|
+
*
|
|
24
|
+
* API:
|
|
25
|
+
*
|
|
26
|
+
* - [LineChart API](https://mui.com/x/api/charts/line-chart/)
|
|
27
|
+
*/
|
|
17
28
|
const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
18
29
|
const {
|
|
19
30
|
xAxis,
|
|
@@ -29,6 +40,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
29
40
|
axisHighlight = {
|
|
30
41
|
x: 'line'
|
|
31
42
|
},
|
|
43
|
+
disableLineItemHighlight,
|
|
32
44
|
legend,
|
|
33
45
|
topAxis,
|
|
34
46
|
leftAxis,
|
|
@@ -43,6 +55,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
43
55
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
44
56
|
ref: ref,
|
|
45
57
|
series: series.map(s => _extends({
|
|
58
|
+
disableHighlight: !!disableLineItemHighlight,
|
|
46
59
|
type: 'line'
|
|
47
60
|
}, s)),
|
|
48
61
|
width: width,
|
|
@@ -79,13 +92,19 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
79
92
|
bottomAxis: bottomAxis,
|
|
80
93
|
slots: slots,
|
|
81
94
|
slotProps: slotProps
|
|
82
|
-
}), /*#__PURE__*/_jsx(MarkPlot, {
|
|
95
|
+
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(MarkPlot, {
|
|
96
|
+
slots: slots,
|
|
97
|
+
slotProps: slotProps
|
|
98
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
83
99
|
slots: slots,
|
|
84
100
|
slotProps: slotProps
|
|
85
101
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
86
102
|
slots: slots,
|
|
87
103
|
slotProps: slotProps
|
|
88
|
-
})), /*#__PURE__*/_jsx(
|
|
104
|
+
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
105
|
+
slots: slots,
|
|
106
|
+
slotProps: slotProps
|
|
107
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
89
108
|
id: clipPathId
|
|
90
109
|
}), children]
|
|
91
110
|
});
|
|
@@ -112,11 +131,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
112
131
|
fill: PropTypes.string,
|
|
113
132
|
label: PropTypes.string,
|
|
114
133
|
labelFontSize: PropTypes.number,
|
|
134
|
+
labelStyle: PropTypes.object,
|
|
115
135
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
116
136
|
slotProps: PropTypes.object,
|
|
117
137
|
slots: PropTypes.object,
|
|
118
138
|
stroke: PropTypes.string,
|
|
119
139
|
tickFontSize: PropTypes.number,
|
|
140
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
141
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
142
|
+
tickLabelStyle: PropTypes.object,
|
|
120
143
|
tickMaxStep: PropTypes.number,
|
|
121
144
|
tickMinStep: PropTypes.number,
|
|
122
145
|
tickNumber: PropTypes.number,
|
|
@@ -131,6 +154,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
131
154
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
132
155
|
desc: PropTypes.string,
|
|
133
156
|
disableAxisListener: PropTypes.bool,
|
|
157
|
+
/**
|
|
158
|
+
* If `true`, render the line highlight item.
|
|
159
|
+
*/
|
|
160
|
+
disableLineItemHighlight: PropTypes.bool,
|
|
134
161
|
height: PropTypes.number,
|
|
135
162
|
/**
|
|
136
163
|
* Indicate which axis to display the left of the charts.
|
|
@@ -145,33 +172,33 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
145
172
|
fill: PropTypes.string,
|
|
146
173
|
label: PropTypes.string,
|
|
147
174
|
labelFontSize: PropTypes.number,
|
|
175
|
+
labelStyle: PropTypes.object,
|
|
148
176
|
position: PropTypes.oneOf(['left', 'right']),
|
|
149
177
|
slotProps: PropTypes.object,
|
|
150
178
|
slots: PropTypes.object,
|
|
151
179
|
stroke: PropTypes.string,
|
|
152
180
|
tickFontSize: PropTypes.number,
|
|
181
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
182
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
183
|
+
tickLabelStyle: PropTypes.object,
|
|
153
184
|
tickMaxStep: PropTypes.number,
|
|
154
185
|
tickMinStep: PropTypes.number,
|
|
155
186
|
tickNumber: PropTypes.number,
|
|
156
187
|
tickSize: PropTypes.number
|
|
157
188
|
}), PropTypes.string]),
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
191
|
+
*/
|
|
158
192
|
legend: PropTypes.shape({
|
|
159
193
|
classes: PropTypes.object,
|
|
160
194
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
161
195
|
hidden: PropTypes.bool,
|
|
162
|
-
itemWidth: PropTypes.number,
|
|
163
|
-
markSize: PropTypes.number,
|
|
164
|
-
offset: PropTypes.shape({
|
|
165
|
-
x: PropTypes.number,
|
|
166
|
-
y: PropTypes.number
|
|
167
|
-
}),
|
|
168
196
|
position: PropTypes.shape({
|
|
169
197
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
170
198
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
171
199
|
}),
|
|
172
200
|
slotProps: PropTypes.object,
|
|
173
|
-
slots: PropTypes.object
|
|
174
|
-
spacing: PropTypes.number
|
|
201
|
+
slots: PropTypes.object
|
|
175
202
|
}),
|
|
176
203
|
margin: PropTypes.shape({
|
|
177
204
|
bottom: PropTypes.number,
|
|
@@ -192,11 +219,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
192
219
|
fill: PropTypes.string,
|
|
193
220
|
label: PropTypes.string,
|
|
194
221
|
labelFontSize: PropTypes.number,
|
|
222
|
+
labelStyle: PropTypes.object,
|
|
195
223
|
position: PropTypes.oneOf(['left', 'right']),
|
|
196
224
|
slotProps: PropTypes.object,
|
|
197
225
|
slots: PropTypes.object,
|
|
198
226
|
stroke: PropTypes.string,
|
|
199
227
|
tickFontSize: PropTypes.number,
|
|
228
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
229
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
230
|
+
tickLabelStyle: PropTypes.object,
|
|
200
231
|
tickMaxStep: PropTypes.number,
|
|
201
232
|
tickMinStep: PropTypes.number,
|
|
202
233
|
tickNumber: PropTypes.number,
|
|
@@ -205,15 +236,18 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
205
236
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
206
237
|
area: PropTypes.bool,
|
|
207
238
|
color: PropTypes.string,
|
|
239
|
+
connectNulls: PropTypes.bool,
|
|
208
240
|
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
209
241
|
data: PropTypes.arrayOf(PropTypes.number),
|
|
210
242
|
dataKey: PropTypes.string,
|
|
243
|
+
disableHighlight: PropTypes.bool,
|
|
211
244
|
highlightScope: PropTypes.shape({
|
|
212
245
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
213
246
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
214
247
|
}),
|
|
215
248
|
id: PropTypes.string,
|
|
216
249
|
label: PropTypes.string,
|
|
250
|
+
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
217
251
|
stack: PropTypes.string,
|
|
218
252
|
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
|
|
219
253
|
stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
|
|
@@ -238,6 +272,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
238
272
|
axisContent: PropTypes.elementType,
|
|
239
273
|
classes: PropTypes.object,
|
|
240
274
|
itemContent: PropTypes.elementType,
|
|
275
|
+
slotProps: PropTypes.object,
|
|
276
|
+
slots: PropTypes.object,
|
|
241
277
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
242
278
|
}),
|
|
243
279
|
/**
|
|
@@ -253,11 +289,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
253
289
|
fill: PropTypes.string,
|
|
254
290
|
label: PropTypes.string,
|
|
255
291
|
labelFontSize: PropTypes.number,
|
|
292
|
+
labelStyle: PropTypes.object,
|
|
256
293
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
257
294
|
slotProps: PropTypes.object,
|
|
258
295
|
slots: PropTypes.object,
|
|
259
296
|
stroke: PropTypes.string,
|
|
260
297
|
tickFontSize: PropTypes.number,
|
|
298
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
299
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
300
|
+
tickLabelStyle: PropTypes.object,
|
|
261
301
|
tickMaxStep: PropTypes.number,
|
|
262
302
|
tickMinStep: PropTypes.number,
|
|
263
303
|
tickNumber: PropTypes.number,
|
|
@@ -282,6 +322,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
282
322
|
id: PropTypes.string,
|
|
283
323
|
label: PropTypes.string,
|
|
284
324
|
labelFontSize: PropTypes.number,
|
|
325
|
+
labelStyle: PropTypes.object,
|
|
285
326
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
286
327
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
287
328
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -290,6 +331,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
290
331
|
slots: PropTypes.object,
|
|
291
332
|
stroke: PropTypes.string,
|
|
292
333
|
tickFontSize: PropTypes.number,
|
|
334
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
335
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
336
|
+
tickLabelStyle: PropTypes.object,
|
|
293
337
|
tickMaxStep: PropTypes.number,
|
|
294
338
|
tickMinStep: PropTypes.number,
|
|
295
339
|
tickNumber: PropTypes.number,
|
|
@@ -308,6 +352,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
308
352
|
id: PropTypes.string,
|
|
309
353
|
label: PropTypes.string,
|
|
310
354
|
labelFontSize: PropTypes.number,
|
|
355
|
+
labelStyle: PropTypes.object,
|
|
311
356
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
312
357
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
313
358
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -316,6 +361,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
316
361
|
slots: PropTypes.object,
|
|
317
362
|
stroke: PropTypes.string,
|
|
318
363
|
tickFontSize: PropTypes.number,
|
|
364
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
365
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
366
|
+
tickLabelStyle: PropTypes.object,
|
|
319
367
|
tickMaxStep: PropTypes.number,
|
|
320
368
|
tickMinStep: PropTypes.number,
|
|
321
369
|
tickNumber: PropTypes.number,
|
|
@@ -57,6 +57,16 @@ LineElementPath.propTypes = {
|
|
|
57
57
|
}).isRequired,
|
|
58
58
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Demos:
|
|
62
|
+
*
|
|
63
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
64
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
65
|
+
*
|
|
66
|
+
* API:
|
|
67
|
+
*
|
|
68
|
+
* - [LineElement API](https://mui.com/x/api/charts/line-element/)
|
|
69
|
+
*/
|
|
60
70
|
function LineElement(props) {
|
|
61
71
|
var _slots$line;
|
|
62
72
|
const {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["x", "y", "id", "classes", "color"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export function getHighlightElementUtilityClass(slot) {
|
|
12
|
+
return generateUtilityClass('MuiHighlightElement', slot);
|
|
13
|
+
}
|
|
14
|
+
export const lineHighlightElementClasses = generateUtilityClasses('MuiHighlightElement', ['root']);
|
|
15
|
+
const useUtilityClasses = ownerState => {
|
|
16
|
+
const {
|
|
17
|
+
classes,
|
|
18
|
+
id
|
|
19
|
+
} = ownerState;
|
|
20
|
+
const slots = {
|
|
21
|
+
root: ['root', `series-${id}`]
|
|
22
|
+
};
|
|
23
|
+
return composeClasses(slots, getHighlightElementUtilityClass, classes);
|
|
24
|
+
};
|
|
25
|
+
const HighlightElement = styled('circle', {
|
|
26
|
+
name: 'MuiHighlightElement',
|
|
27
|
+
slot: 'Root',
|
|
28
|
+
overridesResolver: (_, styles) => styles.root
|
|
29
|
+
})(({
|
|
30
|
+
ownerState
|
|
31
|
+
}) => ({
|
|
32
|
+
transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
|
|
33
|
+
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
34
|
+
fill: ownerState.color
|
|
35
|
+
}));
|
|
36
|
+
/**
|
|
37
|
+
* Demos:
|
|
38
|
+
*
|
|
39
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
40
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
41
|
+
*
|
|
42
|
+
* API:
|
|
43
|
+
*
|
|
44
|
+
* - [LineHighlightElement API](https://mui.com/x/api/charts/line-highlight-element/)
|
|
45
|
+
*/
|
|
46
|
+
function LineHighlightElement(props) {
|
|
47
|
+
const {
|
|
48
|
+
x,
|
|
49
|
+
y,
|
|
50
|
+
id,
|
|
51
|
+
classes: innerClasses,
|
|
52
|
+
color
|
|
53
|
+
} = props,
|
|
54
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
55
|
+
const ownerState = {
|
|
56
|
+
id,
|
|
57
|
+
classes: innerClasses,
|
|
58
|
+
color,
|
|
59
|
+
x,
|
|
60
|
+
y
|
|
61
|
+
};
|
|
62
|
+
const classes = useUtilityClasses(ownerState);
|
|
63
|
+
return /*#__PURE__*/_jsx(HighlightElement, _extends({}, other, {
|
|
64
|
+
ownerState: ownerState,
|
|
65
|
+
className: classes.root,
|
|
66
|
+
cx: 0,
|
|
67
|
+
cy: 0,
|
|
68
|
+
r: other.r === undefined ? 5 : other.r
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
72
|
+
// ----------------------------- Warning --------------------------------
|
|
73
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
74
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
75
|
+
// ----------------------------------------------------------------------
|
|
76
|
+
classes: PropTypes.object
|
|
77
|
+
} : void 0;
|
|
78
|
+
export { LineHighlightElement };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["slots", "slotProps"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
7
|
+
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
|
+
import { LineHighlightElement } from './LineHighlightElement';
|
|
9
|
+
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
|
+
import { InteractionContext } from '../context/InteractionProvider';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* Demos:
|
|
14
|
+
*
|
|
15
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
16
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
17
|
+
*
|
|
18
|
+
* API:
|
|
19
|
+
*
|
|
20
|
+
* - [LineHighlightPlot API](https://mui.com/x/api/charts/line-highlight-plot/)
|
|
21
|
+
*/
|
|
22
|
+
function LineHighlightPlot(props) {
|
|
23
|
+
var _axis$x, _slots$lineHighlight;
|
|
24
|
+
const {
|
|
25
|
+
slots,
|
|
26
|
+
slotProps
|
|
27
|
+
} = props,
|
|
28
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
29
|
+
const seriesData = React.useContext(SeriesContext).line;
|
|
30
|
+
const axisData = React.useContext(CartesianContext);
|
|
31
|
+
const {
|
|
32
|
+
axis
|
|
33
|
+
} = React.useContext(InteractionContext);
|
|
34
|
+
const highlightedIndex = (_axis$x = axis.x) == null ? void 0 : _axis$x.index;
|
|
35
|
+
if (highlightedIndex === undefined) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (seriesData === undefined) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const {
|
|
42
|
+
series,
|
|
43
|
+
stackingGroups
|
|
44
|
+
} = seriesData;
|
|
45
|
+
const {
|
|
46
|
+
xAxis,
|
|
47
|
+
yAxis,
|
|
48
|
+
xAxisIds,
|
|
49
|
+
yAxisIds
|
|
50
|
+
} = axisData;
|
|
51
|
+
const defaultXAxisId = xAxisIds[0];
|
|
52
|
+
const defaultYAxisId = yAxisIds[0];
|
|
53
|
+
const Element = (_slots$lineHighlight = slots == null ? void 0 : slots.lineHighlight) != null ? _slots$lineHighlight : LineHighlightElement;
|
|
54
|
+
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
55
|
+
children: stackingGroups.flatMap(({
|
|
56
|
+
ids: groupIds
|
|
57
|
+
}) => {
|
|
58
|
+
return groupIds.flatMap(seriesId => {
|
|
59
|
+
const {
|
|
60
|
+
xAxisKey = defaultXAxisId,
|
|
61
|
+
yAxisKey = defaultYAxisId,
|
|
62
|
+
stackedData,
|
|
63
|
+
data,
|
|
64
|
+
disableHighlight
|
|
65
|
+
} = series[seriesId];
|
|
66
|
+
if (disableHighlight || data[highlightedIndex] == null) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
70
|
+
const yScale = yAxis[yAxisKey].scale;
|
|
71
|
+
const xData = xAxis[xAxisKey].data;
|
|
72
|
+
if (xData === undefined) {
|
|
73
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
|
|
74
|
+
}
|
|
75
|
+
const x = xScale(xData[highlightedIndex]);
|
|
76
|
+
const y = yScale(stackedData[highlightedIndex][1]);
|
|
77
|
+
return /*#__PURE__*/_jsx(Element, _extends({
|
|
78
|
+
id: seriesId,
|
|
79
|
+
color: series[seriesId].color,
|
|
80
|
+
x: x,
|
|
81
|
+
y: y
|
|
82
|
+
}, slotProps == null ? void 0 : slotProps.lineHighlight), `${seriesId}`);
|
|
83
|
+
});
|
|
84
|
+
})
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
|
|
88
|
+
// ----------------------------- Warning --------------------------------
|
|
89
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
90
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
91
|
+
// ----------------------------------------------------------------------
|
|
92
|
+
/**
|
|
93
|
+
* The props used for each component slot.
|
|
94
|
+
* @default {}
|
|
95
|
+
*/
|
|
96
|
+
slotProps: PropTypes.object,
|
|
97
|
+
/**
|
|
98
|
+
* Overridable component slots.
|
|
99
|
+
* @default {}
|
|
100
|
+
*/
|
|
101
|
+
slots: PropTypes.object
|
|
102
|
+
} : void 0;
|
|
103
|
+
export { LineHighlightPlot };
|
|
@@ -10,6 +10,16 @@ import { LineElement } from './LineElement';
|
|
|
10
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
11
|
import getCurveFactory from '../internals/getCurve';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Demos:
|
|
15
|
+
*
|
|
16
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
17
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
18
|
+
*
|
|
19
|
+
* API:
|
|
20
|
+
*
|
|
21
|
+
* - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
|
|
22
|
+
*/
|
|
13
23
|
function LinePlot(props) {
|
|
14
24
|
const {
|
|
15
25
|
slots,
|
|
@@ -38,31 +48,32 @@ function LinePlot(props) {
|
|
|
38
48
|
ids: groupIds
|
|
39
49
|
}) => {
|
|
40
50
|
return groupIds.flatMap(seriesId => {
|
|
51
|
+
var _xData$map;
|
|
41
52
|
const {
|
|
42
53
|
xAxisKey = defaultXAxisId,
|
|
43
54
|
yAxisKey = defaultYAxisId,
|
|
44
|
-
stackedData
|
|
55
|
+
stackedData,
|
|
56
|
+
data,
|
|
57
|
+
connectNulls
|
|
45
58
|
} = series[seriesId];
|
|
46
59
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
47
60
|
const yScale = yAxis[yAxisKey].scale;
|
|
48
61
|
const xData = xAxis[xAxisKey].data;
|
|
49
|
-
if (xData === undefined) {
|
|
50
|
-
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
51
|
-
}
|
|
52
|
-
const linePath = d3Line().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
|
|
53
62
|
if (process.env.NODE_ENV !== 'production') {
|
|
54
|
-
if (xData
|
|
55
|
-
throw new Error(`
|
|
63
|
+
if (xData === undefined) {
|
|
64
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
65
|
+
}
|
|
66
|
+
if (xData.length < stackedData.length) {
|
|
67
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
56
68
|
}
|
|
57
69
|
}
|
|
70
|
+
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
58
71
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
});
|
|
72
|
+
const formattedData = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
|
|
73
|
+
x,
|
|
74
|
+
y: stackedData[index]
|
|
75
|
+
}))) != null ? _xData$map : [];
|
|
76
|
+
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
66
77
|
return /*#__PURE__*/_jsx(LineElement, {
|
|
67
78
|
id: seriesId,
|
|
68
79
|
d: linePath.curve(curve)(d3Data) || undefined,
|
|
@@ -38,12 +38,9 @@ const MarkElementPath = styled('path', {
|
|
|
38
38
|
}) => ({
|
|
39
39
|
transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
|
|
40
40
|
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
41
|
-
fill: theme.palette.background.paper,
|
|
41
|
+
fill: (theme.vars || theme).palette.background.paper,
|
|
42
42
|
stroke: ownerState.color,
|
|
43
|
-
strokeWidth: 2
|
|
44
|
-
'&.MuiMarkElement-highlighted': {
|
|
45
|
-
fill: ownerState.color
|
|
46
|
-
}
|
|
43
|
+
strokeWidth: 2
|
|
47
44
|
}));
|
|
48
45
|
MarkElementPath.propTypes = {
|
|
49
46
|
// ----------------------------- Warning --------------------------------
|
|
@@ -62,6 +59,16 @@ MarkElementPath.propTypes = {
|
|
|
62
59
|
}).isRequired,
|
|
63
60
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
64
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Demos:
|
|
64
|
+
*
|
|
65
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
66
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
67
|
+
*
|
|
68
|
+
* API:
|
|
69
|
+
*
|
|
70
|
+
* - [MarkElement API](https://mui.com/x/api/charts/mark-element/)
|
|
71
|
+
*/
|
|
65
72
|
function MarkElement(props) {
|
|
66
73
|
var _axis$x;
|
|
67
74
|
const {
|
|
@@ -8,6 +8,16 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
8
8
|
import { MarkElement } from './MarkElement';
|
|
9
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Demos:
|
|
13
|
+
*
|
|
14
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
15
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
16
|
+
*
|
|
17
|
+
* API:
|
|
18
|
+
*
|
|
19
|
+
* - [MarkPlot API](https://mui.com/x/api/charts/mark-plot/)
|
|
20
|
+
*/
|
|
11
21
|
function MarkPlot(props) {
|
|
12
22
|
var _slots$mark;
|
|
13
23
|
const {
|
|
@@ -41,8 +51,13 @@ function MarkPlot(props) {
|
|
|
41
51
|
const {
|
|
42
52
|
xAxisKey = defaultXAxisId,
|
|
43
53
|
yAxisKey = defaultYAxisId,
|
|
44
|
-
stackedData
|
|
54
|
+
stackedData,
|
|
55
|
+
data,
|
|
56
|
+
showMark = true
|
|
45
57
|
} = series[seriesId];
|
|
58
|
+
if (showMark === false) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
46
61
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
47
62
|
const yScale = yAxis[yAxisKey].scale;
|
|
48
63
|
const xData = xAxis[xAxisKey].data;
|
|
@@ -64,25 +79,57 @@ function MarkPlot(props) {
|
|
|
64
79
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
65
80
|
}
|
|
66
81
|
return xData == null ? void 0 : xData.map((x, index) => {
|
|
67
|
-
const
|
|
82
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
68
83
|
return {
|
|
69
84
|
x: xScale(x),
|
|
70
|
-
y: yScale(
|
|
85
|
+
y: value === null ? null : yScale(value),
|
|
86
|
+
position: x,
|
|
87
|
+
value,
|
|
71
88
|
index
|
|
72
89
|
};
|
|
73
|
-
}).filter(
|
|
90
|
+
}).filter(({
|
|
91
|
+
x,
|
|
92
|
+
y,
|
|
93
|
+
index,
|
|
94
|
+
position,
|
|
95
|
+
value
|
|
96
|
+
}) => {
|
|
97
|
+
if (value === null || y === null) {
|
|
98
|
+
// Remove missing data point
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (!isInRange({
|
|
102
|
+
x,
|
|
103
|
+
y
|
|
104
|
+
})) {
|
|
105
|
+
// Remove out of range
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (showMark === true) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return showMark({
|
|
112
|
+
x,
|
|
113
|
+
y,
|
|
114
|
+
index,
|
|
115
|
+
position,
|
|
116
|
+
value
|
|
117
|
+
});
|
|
118
|
+
}).map(({
|
|
74
119
|
x,
|
|
75
120
|
y,
|
|
76
121
|
index
|
|
77
|
-
}) =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
122
|
+
}) => {
|
|
123
|
+
return /*#__PURE__*/_jsx(Mark, _extends({
|
|
124
|
+
id: seriesId,
|
|
125
|
+
dataIndex: index,
|
|
126
|
+
shape: "circle",
|
|
127
|
+
color: series[seriesId].color,
|
|
128
|
+
x: x,
|
|
129
|
+
y: y,
|
|
130
|
+
highlightScope: series[seriesId].highlightScope
|
|
131
|
+
}, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`);
|
|
132
|
+
});
|
|
86
133
|
});
|
|
87
134
|
})
|
|
88
135
|
}));
|