@mui/x-charts 6.0.0-alpha.9 → 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 +735 -55
- 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 +11 -1
- package/LineChart/AreaElement.js +14 -6
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +27 -8
- package/LineChart/LineChart.d.ts +16 -3
- package/LineChart/LineChart.js +48 -13
- package/LineChart/LineElement.d.ts +11 -1
- package/LineChart/LineElement.js +14 -6
- package/LineChart/LineHighlightElement.d.ts +10 -0
- package/LineChart/LineHighlightElement.js +13 -4
- package/LineChart/LineHighlightPlot.d.ts +10 -0
- package/LineChart/LineHighlightPlot.js +14 -3
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +25 -12
- package/LineChart/MarkElement.d.ts +10 -0
- package/LineChart/MarkElement.js +14 -5
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +40 -9
- package/LineChart/formatter.js +5 -5
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +11 -13
- package/PieChart/PieArc.js +28 -60
- package/PieChart/PieArcLabel.d.ts +8 -9
- 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 +12 -3
- package/SparkLineChart/SparkLineChart.js +28 -7
- 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 +45 -9
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +10 -0
- package/esm/LineChart/LineHighlightPlot.js +12 -1
- package/esm/LineChart/LinePlot.js +25 -14
- package/esm/LineChart/MarkElement.js +11 -1
- package/esm/LineChart/MarkPlot.js +38 -7
- package/esm/LineChart/formatter.js +7 -3
- 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 +25 -3
- 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 +7 -2
- 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 +45 -9
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +10 -0
- package/legacy/LineChart/LineHighlightPlot.js +12 -1
- package/legacy/LineChart/LinePlot.js +29 -12
- package/legacy/LineChart/MarkElement.js +11 -1
- package/legacy/LineChart/MarkPlot.js +37 -7
- package/legacy/LineChart/formatter.js +7 -3
- 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 +25 -3
- 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 +8 -3
- 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 +45 -9
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +10 -0
- package/modern/LineChart/LineHighlightPlot.js +12 -1
- package/modern/LineChart/LinePlot.js +23 -10
- package/modern/LineChart/MarkElement.js +11 -1
- package/modern/LineChart/MarkPlot.js +38 -7
- package/modern/LineChart/formatter.js +4 -3
- 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 +25 -3
- 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
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["scale", "
|
|
3
|
+
const _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
11
|
import useTicks from '../hooks/useTicks';
|
|
11
|
-
import {
|
|
12
|
+
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
13
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
12
14
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
13
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -35,6 +37,16 @@ const defaultProps = {
|
|
|
35
37
|
labelFontSize: 14,
|
|
36
38
|
tickSize: 6
|
|
37
39
|
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Demos:
|
|
43
|
+
*
|
|
44
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
45
|
+
*
|
|
46
|
+
* API:
|
|
47
|
+
*
|
|
48
|
+
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
49
|
+
*/
|
|
38
50
|
function ChartsYAxis(inProps) {
|
|
39
51
|
var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
40
52
|
const props = useThemeProps({
|
|
@@ -47,7 +59,7 @@ function ChartsYAxis(inProps) {
|
|
|
47
59
|
yAxis: {
|
|
48
60
|
[_props$axisId]: {
|
|
49
61
|
scale: yScale,
|
|
50
|
-
|
|
62
|
+
tickNumber
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
65
|
} = _React$useContext,
|
|
@@ -78,18 +90,44 @@ function ChartsYAxis(inProps) {
|
|
|
78
90
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
79
91
|
const yTicks = useTicks({
|
|
80
92
|
scale: yScale,
|
|
81
|
-
|
|
93
|
+
tickNumber,
|
|
82
94
|
valueFormatter
|
|
83
95
|
});
|
|
84
|
-
const
|
|
96
|
+
const positionSign = position === 'right' ? 1 : -1;
|
|
85
97
|
const labelRefPoint = {
|
|
86
|
-
x:
|
|
98
|
+
x: positionSign * (tickFontSize + tickSize + 10),
|
|
87
99
|
y: top + height / 2
|
|
88
100
|
};
|
|
89
|
-
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine :
|
|
90
|
-
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick :
|
|
91
|
-
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel :
|
|
92
|
-
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel :
|
|
101
|
+
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
102
|
+
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
103
|
+
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
104
|
+
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
105
|
+
const axisTickLabelProps = useSlotProps({
|
|
106
|
+
elementType: TickLabel,
|
|
107
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
108
|
+
additionalProps: {
|
|
109
|
+
style: {
|
|
110
|
+
fontSize: tickFontSize,
|
|
111
|
+
textAnchor: position === 'right' ? 'start' : 'end',
|
|
112
|
+
dominantBaseline: 'central'
|
|
113
|
+
},
|
|
114
|
+
className: classes.tickLabel
|
|
115
|
+
},
|
|
116
|
+
ownerState: {}
|
|
117
|
+
});
|
|
118
|
+
const axisLabelProps = useSlotProps({
|
|
119
|
+
elementType: Label,
|
|
120
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
121
|
+
additionalProps: {
|
|
122
|
+
style: {
|
|
123
|
+
fontSize: labelFontSize,
|
|
124
|
+
angle: positionSign * 90,
|
|
125
|
+
textAnchor: 'middle',
|
|
126
|
+
dominantBaseline: 'auto'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
ownerState: {}
|
|
130
|
+
});
|
|
93
131
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
94
132
|
transform: `translate(${position === 'right' ? left + width : left}, 0)`,
|
|
95
133
|
className: classes.root,
|
|
@@ -102,36 +140,26 @@ function ChartsYAxis(inProps) {
|
|
|
102
140
|
offset,
|
|
103
141
|
labelOffset
|
|
104
142
|
}, index) => {
|
|
105
|
-
const xTickLabel =
|
|
143
|
+
const xTickLabel = positionSign * (tickSize + 2);
|
|
106
144
|
const yTickLabel = labelOffset;
|
|
107
145
|
return /*#__PURE__*/_jsxs("g", {
|
|
108
146
|
transform: `translate(0, ${offset})`,
|
|
109
147
|
className: classes.tickContainer,
|
|
110
148
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
111
|
-
x2:
|
|
149
|
+
x2: positionSign * tickSize,
|
|
112
150
|
className: classes.tick
|
|
113
151
|
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
114
152
|
x: xTickLabel,
|
|
115
153
|
y: yTickLabel,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
fontSize: tickFontSize
|
|
119
|
-
},
|
|
120
|
-
className: classes.tickLabel
|
|
121
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
122
|
-
children: formattedValue.toLocaleString()
|
|
123
|
-
}))]
|
|
154
|
+
text: formattedValue.toString()
|
|
155
|
+
}, axisTickLabelProps))]
|
|
124
156
|
}, index);
|
|
125
|
-
}), label && /*#__PURE__*/_jsx(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
className: classes.label
|
|
132
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
133
|
-
children: label
|
|
134
|
-
}))]
|
|
157
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
158
|
+
className: classes.label,
|
|
159
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
160
|
+
text: label
|
|
161
|
+
}))
|
|
162
|
+
})]
|
|
135
163
|
});
|
|
136
164
|
}
|
|
137
165
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
@@ -169,8 +197,13 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
169
197
|
/**
|
|
170
198
|
* The font size of the axis label.
|
|
171
199
|
* @default 14
|
|
200
|
+
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
172
201
|
*/
|
|
173
202
|
labelFontSize: PropTypes.number,
|
|
203
|
+
/**
|
|
204
|
+
* The style applied to the axis label.
|
|
205
|
+
*/
|
|
206
|
+
labelStyle: PropTypes.object,
|
|
174
207
|
/**
|
|
175
208
|
* Position of the axis.
|
|
176
209
|
*/
|
|
@@ -193,8 +226,28 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
193
226
|
/**
|
|
194
227
|
* The font size of the axis ticks text.
|
|
195
228
|
* @default 12
|
|
229
|
+
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
196
230
|
*/
|
|
197
231
|
tickFontSize: PropTypes.number,
|
|
232
|
+
/**
|
|
233
|
+
* Defines which ticks are displayed. Its value can be:
|
|
234
|
+
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
235
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
|
|
236
|
+
* - an array containing the values where ticks should be displayed.
|
|
237
|
+
* @default 'auto'
|
|
238
|
+
*/
|
|
239
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
240
|
+
/**
|
|
241
|
+
* Defines which ticks get its label displayed. Its value can be:
|
|
242
|
+
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
243
|
+
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
244
|
+
* @default 'auto'
|
|
245
|
+
*/
|
|
246
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
247
|
+
/**
|
|
248
|
+
* The style applied to ticks text.
|
|
249
|
+
*/
|
|
250
|
+
tickLabelStyle: PropTypes.object,
|
|
198
251
|
/**
|
|
199
252
|
* Maximal step between two ticks.
|
|
200
253
|
* When using time data, the value is assumed to be in ms.
|
|
@@ -55,6 +55,16 @@ AreaElementPath.propTypes = {
|
|
|
55
55
|
}).isRequired,
|
|
56
56
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Demos:
|
|
60
|
+
*
|
|
61
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
62
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
63
|
+
*
|
|
64
|
+
* API:
|
|
65
|
+
*
|
|
66
|
+
* - [AreaElement API](https://mui.com/x/api/charts/area-element/)
|
|
67
|
+
*/
|
|
58
68
|
function AreaElement(props) {
|
|
59
69
|
var _slots$area;
|
|
60
70
|
const {
|
|
@@ -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,
|
|
@@ -15,6 +15,16 @@ import { ChartsClipPath } from '../ChartsClipPath';
|
|
|
15
15
|
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
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
|
+
*/
|
|
18
28
|
const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
19
29
|
const {
|
|
20
30
|
xAxis,
|
|
@@ -91,7 +101,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
91
101
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
92
102
|
slots: slots,
|
|
93
103
|
slotProps: slotProps
|
|
94
|
-
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
104
|
+
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
105
|
+
slots: slots,
|
|
106
|
+
slotProps: slotProps
|
|
107
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
95
108
|
id: clipPathId
|
|
96
109
|
}), children]
|
|
97
110
|
});
|
|
@@ -118,11 +131,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
118
131
|
fill: PropTypes.string,
|
|
119
132
|
label: PropTypes.string,
|
|
120
133
|
labelFontSize: PropTypes.number,
|
|
134
|
+
labelStyle: PropTypes.object,
|
|
121
135
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
122
136
|
slotProps: PropTypes.object,
|
|
123
137
|
slots: PropTypes.object,
|
|
124
138
|
stroke: PropTypes.string,
|
|
125
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,
|
|
126
143
|
tickMaxStep: PropTypes.number,
|
|
127
144
|
tickMinStep: PropTypes.number,
|
|
128
145
|
tickNumber: PropTypes.number,
|
|
@@ -155,33 +172,33 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
155
172
|
fill: PropTypes.string,
|
|
156
173
|
label: PropTypes.string,
|
|
157
174
|
labelFontSize: PropTypes.number,
|
|
175
|
+
labelStyle: PropTypes.object,
|
|
158
176
|
position: PropTypes.oneOf(['left', 'right']),
|
|
159
177
|
slotProps: PropTypes.object,
|
|
160
178
|
slots: PropTypes.object,
|
|
161
179
|
stroke: PropTypes.string,
|
|
162
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,
|
|
163
184
|
tickMaxStep: PropTypes.number,
|
|
164
185
|
tickMinStep: PropTypes.number,
|
|
165
186
|
tickNumber: PropTypes.number,
|
|
166
187
|
tickSize: PropTypes.number
|
|
167
188
|
}), PropTypes.string]),
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
191
|
+
*/
|
|
168
192
|
legend: PropTypes.shape({
|
|
169
193
|
classes: PropTypes.object,
|
|
170
194
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
171
195
|
hidden: PropTypes.bool,
|
|
172
|
-
itemWidth: PropTypes.number,
|
|
173
|
-
markSize: PropTypes.number,
|
|
174
|
-
offset: PropTypes.shape({
|
|
175
|
-
x: PropTypes.number,
|
|
176
|
-
y: PropTypes.number
|
|
177
|
-
}),
|
|
178
196
|
position: PropTypes.shape({
|
|
179
197
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
180
198
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
181
199
|
}),
|
|
182
200
|
slotProps: PropTypes.object,
|
|
183
|
-
slots: PropTypes.object
|
|
184
|
-
spacing: PropTypes.number
|
|
201
|
+
slots: PropTypes.object
|
|
185
202
|
}),
|
|
186
203
|
margin: PropTypes.shape({
|
|
187
204
|
bottom: PropTypes.number,
|
|
@@ -202,11 +219,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
202
219
|
fill: PropTypes.string,
|
|
203
220
|
label: PropTypes.string,
|
|
204
221
|
labelFontSize: PropTypes.number,
|
|
222
|
+
labelStyle: PropTypes.object,
|
|
205
223
|
position: PropTypes.oneOf(['left', 'right']),
|
|
206
224
|
slotProps: PropTypes.object,
|
|
207
225
|
slots: PropTypes.object,
|
|
208
226
|
stroke: PropTypes.string,
|
|
209
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,
|
|
210
231
|
tickMaxStep: PropTypes.number,
|
|
211
232
|
tickMinStep: PropTypes.number,
|
|
212
233
|
tickNumber: PropTypes.number,
|
|
@@ -215,6 +236,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
215
236
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
216
237
|
area: PropTypes.bool,
|
|
217
238
|
color: PropTypes.string,
|
|
239
|
+
connectNulls: PropTypes.bool,
|
|
218
240
|
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
219
241
|
data: PropTypes.arrayOf(PropTypes.number),
|
|
220
242
|
dataKey: PropTypes.string,
|
|
@@ -250,6 +272,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
250
272
|
axisContent: PropTypes.elementType,
|
|
251
273
|
classes: PropTypes.object,
|
|
252
274
|
itemContent: PropTypes.elementType,
|
|
275
|
+
slotProps: PropTypes.object,
|
|
276
|
+
slots: PropTypes.object,
|
|
253
277
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
254
278
|
}),
|
|
255
279
|
/**
|
|
@@ -265,11 +289,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
265
289
|
fill: PropTypes.string,
|
|
266
290
|
label: PropTypes.string,
|
|
267
291
|
labelFontSize: PropTypes.number,
|
|
292
|
+
labelStyle: PropTypes.object,
|
|
268
293
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
269
294
|
slotProps: PropTypes.object,
|
|
270
295
|
slots: PropTypes.object,
|
|
271
296
|
stroke: PropTypes.string,
|
|
272
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,
|
|
273
301
|
tickMaxStep: PropTypes.number,
|
|
274
302
|
tickMinStep: PropTypes.number,
|
|
275
303
|
tickNumber: PropTypes.number,
|
|
@@ -294,6 +322,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
294
322
|
id: PropTypes.string,
|
|
295
323
|
label: PropTypes.string,
|
|
296
324
|
labelFontSize: PropTypes.number,
|
|
325
|
+
labelStyle: PropTypes.object,
|
|
297
326
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
298
327
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
299
328
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -302,6 +331,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
302
331
|
slots: PropTypes.object,
|
|
303
332
|
stroke: PropTypes.string,
|
|
304
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,
|
|
305
337
|
tickMaxStep: PropTypes.number,
|
|
306
338
|
tickMinStep: PropTypes.number,
|
|
307
339
|
tickNumber: PropTypes.number,
|
|
@@ -320,6 +352,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
320
352
|
id: PropTypes.string,
|
|
321
353
|
label: PropTypes.string,
|
|
322
354
|
labelFontSize: PropTypes.number,
|
|
355
|
+
labelStyle: PropTypes.object,
|
|
323
356
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
324
357
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
325
358
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -328,6 +361,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
328
361
|
slots: PropTypes.object,
|
|
329
362
|
stroke: PropTypes.string,
|
|
330
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,
|
|
331
367
|
tickMaxStep: PropTypes.number,
|
|
332
368
|
tickMinStep: PropTypes.number,
|
|
333
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 {
|
|
@@ -33,6 +33,16 @@ const HighlightElement = styled('circle', {
|
|
|
33
33
|
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
34
34
|
fill: ownerState.color
|
|
35
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
|
+
*/
|
|
36
46
|
function LineHighlightElement(props) {
|
|
37
47
|
const {
|
|
38
48
|
x,
|
|
@@ -9,6 +9,16 @@ import { LineHighlightElement } from './LineHighlightElement';
|
|
|
9
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
10
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
11
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
|
+
*/
|
|
12
22
|
function LineHighlightPlot(props) {
|
|
13
23
|
var _axis$x, _slots$lineHighlight;
|
|
14
24
|
const {
|
|
@@ -50,9 +60,10 @@ function LineHighlightPlot(props) {
|
|
|
50
60
|
xAxisKey = defaultXAxisId,
|
|
51
61
|
yAxisKey = defaultYAxisId,
|
|
52
62
|
stackedData,
|
|
63
|
+
data,
|
|
53
64
|
disableHighlight
|
|
54
65
|
} = series[seriesId];
|
|
55
|
-
if (disableHighlight) {
|
|
66
|
+
if (disableHighlight || data[highlightedIndex] == null) {
|
|
56
67
|
return null;
|
|
57
68
|
}
|
|
58
69
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
@@ -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,7 +38,7 @@ 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
43
|
strokeWidth: 2
|
|
44
44
|
}));
|
|
@@ -59,6 +59,16 @@ MarkElementPath.propTypes = {
|
|
|
59
59
|
}).isRequired,
|
|
60
60
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
61
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
|
+
*/
|
|
62
72
|
function MarkElement(props) {
|
|
63
73
|
var _axis$x;
|
|
64
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 {
|
|
@@ -42,6 +52,7 @@ function MarkPlot(props) {
|
|
|
42
52
|
xAxisKey = defaultXAxisId,
|
|
43
53
|
yAxisKey = defaultYAxisId,
|
|
44
54
|
stackedData,
|
|
55
|
+
data,
|
|
45
56
|
showMark = true
|
|
46
57
|
} = series[seriesId];
|
|
47
58
|
if (showMark === false) {
|
|
@@ -68,28 +79,48 @@ function MarkPlot(props) {
|
|
|
68
79
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
69
80
|
}
|
|
70
81
|
return xData == null ? void 0 : xData.map((x, index) => {
|
|
71
|
-
const
|
|
82
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
72
83
|
return {
|
|
73
84
|
x: xScale(x),
|
|
74
|
-
y: yScale(
|
|
85
|
+
y: value === null ? null : yScale(value),
|
|
75
86
|
position: x,
|
|
76
|
-
value
|
|
87
|
+
value,
|
|
77
88
|
index
|
|
78
89
|
};
|
|
79
|
-
}).filter(
|
|
90
|
+
}).filter(({
|
|
80
91
|
x,
|
|
81
92
|
y,
|
|
82
93
|
index,
|
|
83
94
|
position,
|
|
84
95
|
value
|
|
85
96
|
}) => {
|
|
86
|
-
|
|
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({
|
|
87
112
|
x,
|
|
88
113
|
y,
|
|
89
114
|
index,
|
|
90
115
|
position,
|
|
91
116
|
value
|
|
92
|
-
})
|
|
117
|
+
});
|
|
118
|
+
}).map(({
|
|
119
|
+
x,
|
|
120
|
+
y,
|
|
121
|
+
index
|
|
122
|
+
}) => {
|
|
123
|
+
return /*#__PURE__*/_jsx(Mark, _extends({
|
|
93
124
|
id: seriesId,
|
|
94
125
|
dataIndex: index,
|
|
95
126
|
shape: "circle",
|
|
@@ -97,7 +128,7 @@ function MarkPlot(props) {
|
|
|
97
128
|
x: x,
|
|
98
129
|
y: y,
|
|
99
130
|
highlightScope: series[seriesId].highlightScope
|
|
100
|
-
}, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`)
|
|
131
|
+
}, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`);
|
|
101
132
|
});
|
|
102
133
|
});
|
|
103
134
|
})
|