@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
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import Box from '@mui/
|
|
3
|
-
import Paper from '@mui/material/Paper';
|
|
2
|
+
import Box from '@mui/system/Box';
|
|
4
3
|
import { styled } from '@mui/material/styles';
|
|
5
4
|
import { tooltipClasses } from './tooltipClasses';
|
|
6
|
-
export var ChartsTooltipPaper = styled(
|
|
5
|
+
export var ChartsTooltipPaper = styled('div', {
|
|
7
6
|
name: 'MuiChartsTooltip',
|
|
8
|
-
slot: '
|
|
9
|
-
})({
|
|
7
|
+
slot: 'Container'
|
|
8
|
+
})(function (_ref) {
|
|
9
|
+
var theme = _ref.theme;
|
|
10
|
+
return {
|
|
11
|
+
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
12
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
13
|
+
transition: theme.transitions.create('box-shadow'),
|
|
14
|
+
border: "1px solid ".concat((theme.vars || theme).palette.divider),
|
|
15
|
+
borderRadius: theme.shape.borderRadius
|
|
16
|
+
};
|
|
17
|
+
});
|
|
10
18
|
export var ChartsTooltipTable = styled('table', {
|
|
11
19
|
name: 'MuiChartsTooltip',
|
|
12
20
|
slot: 'Table'
|
|
13
|
-
})(function (
|
|
14
|
-
var theme =
|
|
21
|
+
})(function (_ref2) {
|
|
22
|
+
var theme = _ref2.theme;
|
|
15
23
|
return {
|
|
16
24
|
borderSpacing: 0,
|
|
17
25
|
'& thead td': {
|
|
18
|
-
borderBottom: "solid ".concat(theme.palette.divider, " 1px")
|
|
26
|
+
borderBottom: "solid ".concat((theme.vars || theme).palette.divider, " 1px")
|
|
19
27
|
}
|
|
20
28
|
};
|
|
21
29
|
});
|
|
22
30
|
export var ChartsTooltipRow = styled('tr', {
|
|
23
31
|
name: 'MuiChartsTooltip',
|
|
24
32
|
slot: 'Row'
|
|
25
|
-
})(function (
|
|
26
|
-
var theme =
|
|
33
|
+
})(function (_ref3) {
|
|
34
|
+
var theme = _ref3.theme;
|
|
27
35
|
return {
|
|
28
36
|
'tr:first-of-type& td': {
|
|
29
37
|
paddingTop: theme.spacing(1)
|
|
@@ -36,36 +44,36 @@ export var ChartsTooltipRow = styled('tr', {
|
|
|
36
44
|
export var ChartsTooltipCell = styled('td', {
|
|
37
45
|
name: 'MuiChartsTooltip',
|
|
38
46
|
slot: 'Cell'
|
|
39
|
-
})(function (
|
|
40
|
-
var
|
|
41
|
-
var theme =
|
|
42
|
-
return
|
|
47
|
+
})(function (_ref4) {
|
|
48
|
+
var _ref5;
|
|
49
|
+
var theme = _ref4.theme;
|
|
50
|
+
return _ref5 = {
|
|
43
51
|
verticalAlign: 'middle',
|
|
44
|
-
color: theme.palette.text.secondary
|
|
45
|
-
}, _defineProperty(
|
|
52
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
53
|
+
}, _defineProperty(_ref5, "&.".concat(tooltipClasses.labelCell), {
|
|
46
54
|
paddingLeft: theme.spacing(1)
|
|
47
|
-
}), _defineProperty(
|
|
55
|
+
}), _defineProperty(_ref5, "&.".concat(tooltipClasses.valueCell), {
|
|
48
56
|
paddingLeft: theme.spacing(4),
|
|
49
|
-
color: theme.palette.text.primary
|
|
50
|
-
}), _defineProperty(
|
|
57
|
+
color: (theme.vars || theme).palette.text.primary
|
|
58
|
+
}), _defineProperty(_ref5, 'td:first-of-type&', {
|
|
51
59
|
paddingLeft: theme.spacing(2)
|
|
52
|
-
}), _defineProperty(
|
|
60
|
+
}), _defineProperty(_ref5, 'td:last-of-type&', {
|
|
53
61
|
paddingRight: theme.spacing(2)
|
|
54
|
-
}),
|
|
62
|
+
}), _ref5;
|
|
55
63
|
});
|
|
56
64
|
export var ChartsTooltipMark = styled(Box, {
|
|
57
65
|
name: 'MuiChartsTooltip',
|
|
58
66
|
slot: 'Mark'
|
|
59
|
-
})(function (
|
|
60
|
-
var theme =
|
|
61
|
-
ownerState =
|
|
67
|
+
})(function (_ref6) {
|
|
68
|
+
var theme = _ref6.theme,
|
|
69
|
+
ownerState = _ref6.ownerState;
|
|
62
70
|
return {
|
|
63
71
|
width: theme.spacing(1),
|
|
64
72
|
height: theme.spacing(1),
|
|
65
73
|
borderRadius: '50%',
|
|
66
74
|
backgroundColor: ownerState.color,
|
|
67
|
-
borderColor: theme.palette.background.paper,
|
|
68
|
-
border: "solid ".concat(theme.palette.background.paper, " ").concat(theme.spacing(0.25)),
|
|
75
|
+
borderColor: (theme.vars || theme).palette.background.paper,
|
|
76
|
+
border: "solid ".concat((theme.vars || theme).palette.background.paper, " ").concat(theme.spacing(0.25)),
|
|
69
77
|
boxSizing: 'content-box'
|
|
70
78
|
};
|
|
71
79
|
});
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["scale", "
|
|
4
|
+
var _excluded = ["scale", "tickNumber"];
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
7
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
8
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
9
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
10
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
11
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
12
|
import useTicks from '../hooks/useTicks';
|
|
11
13
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
12
|
-
import {
|
|
14
|
+
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
15
|
+
import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
|
|
16
|
+
import { getMinXTranslation } from '../internals/geometry';
|
|
17
|
+
import { useMounted } from '../hooks/useMounted';
|
|
13
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
20
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
@@ -25,14 +30,77 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
25
30
|
};
|
|
26
31
|
return composeClasses(slots, getAxisUtilityClass, classes);
|
|
27
32
|
};
|
|
33
|
+
function addLabelDimension(xTicks, _ref) {
|
|
34
|
+
var style = _ref.tickLabelStyle,
|
|
35
|
+
tickLabelInterval = _ref.tickLabelInterval,
|
|
36
|
+
isMounted = _ref.isMounted;
|
|
37
|
+
var withDimension = xTicks.map(function (tick) {
|
|
38
|
+
if (!isMounted || tick.formattedValue === undefined) {
|
|
39
|
+
return _extends({}, tick, {
|
|
40
|
+
width: 0,
|
|
41
|
+
height: 0
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
var tickSizes = getWordsByLines({
|
|
45
|
+
style: style,
|
|
46
|
+
needsComputation: true,
|
|
47
|
+
text: tick.formattedValue
|
|
48
|
+
});
|
|
49
|
+
return _extends({}, tick, {
|
|
50
|
+
width: Math.max.apply(Math, _toConsumableArray(tickSizes.map(function (size) {
|
|
51
|
+
return size.width;
|
|
52
|
+
}))),
|
|
53
|
+
height: Math.max(tickSizes.length * tickSizes[0].height)
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
if (typeof tickLabelInterval === 'function') {
|
|
57
|
+
return withDimension.map(function (item, index) {
|
|
58
|
+
return _extends({}, item, {
|
|
59
|
+
skipLabel: !tickLabelInterval(item.value, index)
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Filter label to avoid overlap
|
|
65
|
+
var textStart = 0;
|
|
66
|
+
var textEnd = 0;
|
|
67
|
+
return withDimension.map(function (item, labelIndex) {
|
|
68
|
+
var width = item.width,
|
|
69
|
+
offset = item.offset,
|
|
70
|
+
labelOffset = item.labelOffset,
|
|
71
|
+
height = item.height;
|
|
72
|
+
var distance = getMinXTranslation(width, height, style == null ? void 0 : style.angle);
|
|
73
|
+
var textPosition = offset + labelOffset;
|
|
74
|
+
var gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
75
|
+
|
|
76
|
+
textStart = textPosition - gapRatio * distance / 2;
|
|
77
|
+
if (labelIndex > 0 && textStart < textEnd) {
|
|
78
|
+
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
79
|
+
// Notice that the early return prevents `textEnd` from being updated.
|
|
80
|
+
return _extends({}, item, {
|
|
81
|
+
skipLabel: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
textEnd = textPosition + gapRatio * distance / 2;
|
|
85
|
+
return item;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
28
88
|
var defaultProps = {
|
|
29
89
|
position: 'bottom',
|
|
30
90
|
disableLine: false,
|
|
31
91
|
disableTicks: false,
|
|
32
|
-
tickFontSize: 12,
|
|
33
|
-
labelFontSize: 14,
|
|
34
92
|
tickSize: 6
|
|
35
93
|
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Demos:
|
|
97
|
+
*
|
|
98
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
99
|
+
*
|
|
100
|
+
* API:
|
|
101
|
+
*
|
|
102
|
+
* - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
|
|
103
|
+
*/
|
|
36
104
|
function ChartsXAxis(inProps) {
|
|
37
105
|
var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
38
106
|
var props = useThemeProps({
|
|
@@ -42,19 +110,24 @@ function ChartsXAxis(inProps) {
|
|
|
42
110
|
var _React$useContext = React.useContext(CartesianContext),
|
|
43
111
|
_React$useContext$xAx = _React$useContext.xAxis[props.axisId],
|
|
44
112
|
xScale = _React$useContext$xAx.scale,
|
|
45
|
-
|
|
113
|
+
tickNumber = _React$useContext$xAx.tickNumber,
|
|
46
114
|
settings = _objectWithoutProperties(_React$useContext$xAx, _excluded);
|
|
115
|
+
var isMounted = useMounted();
|
|
47
116
|
var defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
48
117
|
var position = defaultizedProps.position,
|
|
49
118
|
disableLine = defaultizedProps.disableLine,
|
|
50
119
|
disableTicks = defaultizedProps.disableTicks,
|
|
51
|
-
|
|
120
|
+
tickLabelStyle = defaultizedProps.tickLabelStyle,
|
|
52
121
|
label = defaultizedProps.label,
|
|
122
|
+
labelStyle = defaultizedProps.labelStyle,
|
|
123
|
+
tickFontSize = defaultizedProps.tickFontSize,
|
|
53
124
|
labelFontSize = defaultizedProps.labelFontSize,
|
|
54
125
|
tickSizeProp = defaultizedProps.tickSize,
|
|
55
126
|
valueFormatter = defaultizedProps.valueFormatter,
|
|
56
127
|
slots = defaultizedProps.slots,
|
|
57
|
-
slotProps = defaultizedProps.slotProps
|
|
128
|
+
slotProps = defaultizedProps.slotProps,
|
|
129
|
+
tickInterval = defaultizedProps.tickInterval,
|
|
130
|
+
tickLabelInterval = defaultizedProps.tickLabelInterval;
|
|
58
131
|
var theme = useTheme();
|
|
59
132
|
var classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
60
133
|
theme: theme
|
|
@@ -65,20 +138,52 @@ function ChartsXAxis(inProps) {
|
|
|
65
138
|
width = _React$useContext2.width,
|
|
66
139
|
height = _React$useContext2.height;
|
|
67
140
|
var tickSize = disableTicks ? 4 : tickSizeProp;
|
|
141
|
+
var positionSign = position === 'bottom' ? 1 : -1;
|
|
142
|
+
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
143
|
+
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
144
|
+
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
145
|
+
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
146
|
+
var axisTickLabelProps = useSlotProps({
|
|
147
|
+
elementType: TickLabel,
|
|
148
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
149
|
+
additionalProps: {
|
|
150
|
+
style: _extends({
|
|
151
|
+
textAnchor: 'middle',
|
|
152
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
153
|
+
fontSize: tickFontSize != null ? tickFontSize : 12
|
|
154
|
+
}, tickLabelStyle),
|
|
155
|
+
className: classes.tickLabel
|
|
156
|
+
},
|
|
157
|
+
className: classes.tickLabel,
|
|
158
|
+
ownerState: {}
|
|
159
|
+
});
|
|
68
160
|
var xTicks = useTicks({
|
|
69
161
|
scale: xScale,
|
|
70
|
-
|
|
71
|
-
valueFormatter: valueFormatter
|
|
162
|
+
tickNumber: tickNumber,
|
|
163
|
+
valueFormatter: valueFormatter,
|
|
164
|
+
tickInterval: tickInterval
|
|
165
|
+
});
|
|
166
|
+
var xTicksWithDimension = addLabelDimension(xTicks, {
|
|
167
|
+
tickLabelStyle: axisTickLabelProps.style,
|
|
168
|
+
tickLabelInterval: tickLabelInterval,
|
|
169
|
+
isMounted: isMounted
|
|
72
170
|
});
|
|
73
|
-
var positionSigne = position === 'bottom' ? 1 : -1;
|
|
74
171
|
var labelRefPoint = {
|
|
75
172
|
x: left + width / 2,
|
|
76
|
-
y:
|
|
173
|
+
y: positionSign * (tickSize + 22)
|
|
77
174
|
};
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
175
|
+
var axisLabelProps = useSlotProps({
|
|
176
|
+
elementType: Label,
|
|
177
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
178
|
+
additionalProps: {
|
|
179
|
+
style: _extends({
|
|
180
|
+
fontSize: labelFontSize != null ? labelFontSize : 14,
|
|
181
|
+
textAnchor: 'middle',
|
|
182
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
|
|
183
|
+
}, labelStyle)
|
|
184
|
+
},
|
|
185
|
+
ownerState: {}
|
|
186
|
+
});
|
|
82
187
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
83
188
|
transform: "translate(0, ".concat(position === 'bottom' ? top + height : top, ")"),
|
|
84
189
|
className: classes.root,
|
|
@@ -86,39 +191,32 @@ function ChartsXAxis(inProps) {
|
|
|
86
191
|
x1: xScale.range()[0],
|
|
87
192
|
x2: xScale.range()[1],
|
|
88
193
|
className: classes.line
|
|
89
|
-
}, slotProps == null ? void 0 : slotProps.axisLine)),
|
|
90
|
-
var formattedValue =
|
|
91
|
-
offset =
|
|
92
|
-
labelOffset =
|
|
194
|
+
}, slotProps == null ? void 0 : slotProps.axisLine)), xTicksWithDimension.map(function (_ref2, index) {
|
|
195
|
+
var formattedValue = _ref2.formattedValue,
|
|
196
|
+
offset = _ref2.offset,
|
|
197
|
+
labelOffset = _ref2.labelOffset,
|
|
198
|
+
skipLabel = _ref2.skipLabel;
|
|
93
199
|
var xTickLabel = labelOffset != null ? labelOffset : 0;
|
|
94
|
-
var yTickLabel =
|
|
200
|
+
var yTickLabel = positionSign * (tickSize + 3);
|
|
95
201
|
return /*#__PURE__*/_jsxs("g", {
|
|
96
202
|
transform: "translate(".concat(offset, ", 0)"),
|
|
97
203
|
className: classes.tickContainer,
|
|
98
204
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
99
|
-
y2:
|
|
205
|
+
y2: positionSign * tickSize,
|
|
100
206
|
className: classes.tick
|
|
101
|
-
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
207
|
+
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
102
208
|
x: xTickLabel,
|
|
103
|
-
y: yTickLabel
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
fontSize: tickFontSize
|
|
107
|
-
},
|
|
108
|
-
className: classes.tickLabel
|
|
109
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
110
|
-
children: formattedValue
|
|
209
|
+
y: yTickLabel
|
|
210
|
+
}, axisTickLabelProps, {
|
|
211
|
+
text: formattedValue.toString()
|
|
111
212
|
}))]
|
|
112
213
|
}, index);
|
|
113
|
-
}), label && /*#__PURE__*/_jsx(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
120
|
-
children: label
|
|
121
|
-
}))]
|
|
214
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
215
|
+
className: classes.label,
|
|
216
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
217
|
+
text: label
|
|
218
|
+
}))
|
|
219
|
+
})]
|
|
122
220
|
});
|
|
123
221
|
}
|
|
124
222
|
process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
@@ -156,8 +254,13 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
156
254
|
/**
|
|
157
255
|
* The font size of the axis label.
|
|
158
256
|
* @default 14
|
|
257
|
+
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
159
258
|
*/
|
|
160
259
|
labelFontSize: PropTypes.number,
|
|
260
|
+
/**
|
|
261
|
+
* The style applied to the axis label.
|
|
262
|
+
*/
|
|
263
|
+
labelStyle: PropTypes.object,
|
|
161
264
|
/**
|
|
162
265
|
* Position of the axis.
|
|
163
266
|
*/
|
|
@@ -180,8 +283,28 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
180
283
|
/**
|
|
181
284
|
* The font size of the axis ticks text.
|
|
182
285
|
* @default 12
|
|
286
|
+
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
183
287
|
*/
|
|
184
288
|
tickFontSize: PropTypes.number,
|
|
289
|
+
/**
|
|
290
|
+
* Defines which ticks are displayed. Its value can be:
|
|
291
|
+
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
292
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
|
|
293
|
+
* - an array containing the values where ticks should be displayed.
|
|
294
|
+
* @default 'auto'
|
|
295
|
+
*/
|
|
296
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
297
|
+
/**
|
|
298
|
+
* Defines which ticks get its label displayed. Its value can be:
|
|
299
|
+
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
300
|
+
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
301
|
+
* @default 'auto'
|
|
302
|
+
*/
|
|
303
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
304
|
+
/**
|
|
305
|
+
* The style applied to ticks text.
|
|
306
|
+
*/
|
|
307
|
+
tickLabelStyle: PropTypes.object,
|
|
185
308
|
/**
|
|
186
309
|
* Maximal step between two ticks.
|
|
187
310
|
* When using time data, the value is assumed to be in ms.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["scale", "
|
|
3
|
+
var _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";
|
|
@@ -33,6 +35,16 @@ var defaultProps = {
|
|
|
33
35
|
labelFontSize: 14,
|
|
34
36
|
tickSize: 6
|
|
35
37
|
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Demos:
|
|
41
|
+
*
|
|
42
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
43
|
+
*
|
|
44
|
+
* API:
|
|
45
|
+
*
|
|
46
|
+
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
47
|
+
*/
|
|
36
48
|
function ChartsYAxis(inProps) {
|
|
37
49
|
var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
38
50
|
var props = useThemeProps({
|
|
@@ -42,7 +54,7 @@ function ChartsYAxis(inProps) {
|
|
|
42
54
|
var _React$useContext = React.useContext(CartesianContext),
|
|
43
55
|
_React$useContext$yAx = _React$useContext.yAxis[props.axisId],
|
|
44
56
|
yScale = _React$useContext$yAx.scale,
|
|
45
|
-
|
|
57
|
+
tickNumber = _React$useContext$yAx.tickNumber,
|
|
46
58
|
settings = _objectWithoutProperties(_React$useContext$yAx, _excluded);
|
|
47
59
|
var defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
48
60
|
var position = defaultizedProps.position,
|
|
@@ -67,18 +79,44 @@ function ChartsYAxis(inProps) {
|
|
|
67
79
|
var tickSize = disableTicks ? 4 : tickSizeProp;
|
|
68
80
|
var yTicks = useTicks({
|
|
69
81
|
scale: yScale,
|
|
70
|
-
|
|
82
|
+
tickNumber: tickNumber,
|
|
71
83
|
valueFormatter: valueFormatter
|
|
72
84
|
});
|
|
73
|
-
var
|
|
85
|
+
var positionSign = position === 'right' ? 1 : -1;
|
|
74
86
|
var labelRefPoint = {
|
|
75
|
-
x:
|
|
87
|
+
x: positionSign * (tickFontSize + tickSize + 10),
|
|
76
88
|
y: top + height / 2
|
|
77
89
|
};
|
|
78
|
-
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine :
|
|
79
|
-
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick :
|
|
80
|
-
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel :
|
|
81
|
-
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel :
|
|
90
|
+
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
91
|
+
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
92
|
+
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
93
|
+
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
94
|
+
var axisTickLabelProps = useSlotProps({
|
|
95
|
+
elementType: TickLabel,
|
|
96
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
97
|
+
additionalProps: {
|
|
98
|
+
style: {
|
|
99
|
+
fontSize: tickFontSize,
|
|
100
|
+
textAnchor: position === 'right' ? 'start' : 'end',
|
|
101
|
+
dominantBaseline: 'central'
|
|
102
|
+
},
|
|
103
|
+
className: classes.tickLabel
|
|
104
|
+
},
|
|
105
|
+
ownerState: {}
|
|
106
|
+
});
|
|
107
|
+
var axisLabelProps = useSlotProps({
|
|
108
|
+
elementType: Label,
|
|
109
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
110
|
+
additionalProps: {
|
|
111
|
+
style: {
|
|
112
|
+
fontSize: labelFontSize,
|
|
113
|
+
angle: positionSign * 90,
|
|
114
|
+
textAnchor: 'middle',
|
|
115
|
+
dominantBaseline: 'auto'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
ownerState: {}
|
|
119
|
+
});
|
|
82
120
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
83
121
|
transform: "translate(".concat(position === 'right' ? left + width : left, ", 0)"),
|
|
84
122
|
className: classes.root,
|
|
@@ -90,36 +128,26 @@ function ChartsYAxis(inProps) {
|
|
|
90
128
|
var formattedValue = _ref.formattedValue,
|
|
91
129
|
offset = _ref.offset,
|
|
92
130
|
labelOffset = _ref.labelOffset;
|
|
93
|
-
var xTickLabel =
|
|
131
|
+
var xTickLabel = positionSign * (tickSize + 2);
|
|
94
132
|
var yTickLabel = labelOffset;
|
|
95
133
|
return /*#__PURE__*/_jsxs("g", {
|
|
96
134
|
transform: "translate(0, ".concat(offset, ")"),
|
|
97
135
|
className: classes.tickContainer,
|
|
98
136
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
99
|
-
x2:
|
|
137
|
+
x2: positionSign * tickSize,
|
|
100
138
|
className: classes.tick
|
|
101
139
|
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
102
140
|
x: xTickLabel,
|
|
103
141
|
y: yTickLabel,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
fontSize: tickFontSize
|
|
107
|
-
},
|
|
108
|
-
className: classes.tickLabel
|
|
109
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
110
|
-
children: formattedValue.toLocaleString()
|
|
111
|
-
}))]
|
|
142
|
+
text: formattedValue.toString()
|
|
143
|
+
}, axisTickLabelProps))]
|
|
112
144
|
}, index);
|
|
113
|
-
}), label && /*#__PURE__*/_jsx(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
className: classes.label
|
|
120
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
121
|
-
children: label
|
|
122
|
-
}))]
|
|
145
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
146
|
+
className: classes.label,
|
|
147
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
148
|
+
text: label
|
|
149
|
+
}))
|
|
150
|
+
})]
|
|
123
151
|
});
|
|
124
152
|
}
|
|
125
153
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
@@ -157,8 +185,13 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
157
185
|
/**
|
|
158
186
|
* The font size of the axis label.
|
|
159
187
|
* @default 14
|
|
188
|
+
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
160
189
|
*/
|
|
161
190
|
labelFontSize: PropTypes.number,
|
|
191
|
+
/**
|
|
192
|
+
* The style applied to the axis label.
|
|
193
|
+
*/
|
|
194
|
+
labelStyle: PropTypes.object,
|
|
162
195
|
/**
|
|
163
196
|
* Position of the axis.
|
|
164
197
|
*/
|
|
@@ -181,8 +214,28 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
181
214
|
/**
|
|
182
215
|
* The font size of the axis ticks text.
|
|
183
216
|
* @default 12
|
|
217
|
+
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
184
218
|
*/
|
|
185
219
|
tickFontSize: PropTypes.number,
|
|
220
|
+
/**
|
|
221
|
+
* Defines which ticks are displayed. Its value can be:
|
|
222
|
+
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
223
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
|
|
224
|
+
* - an array containing the values where ticks should be displayed.
|
|
225
|
+
* @default 'auto'
|
|
226
|
+
*/
|
|
227
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
228
|
+
/**
|
|
229
|
+
* Defines which ticks get its label displayed. Its value can be:
|
|
230
|
+
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
231
|
+
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
232
|
+
* @default 'auto'
|
|
233
|
+
*/
|
|
234
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
235
|
+
/**
|
|
236
|
+
* The style applied to ticks text.
|
|
237
|
+
*/
|
|
238
|
+
tickLabelStyle: PropTypes.object,
|
|
186
239
|
/**
|
|
187
240
|
* Maximal step between two ticks.
|
|
188
241
|
* When using time data, the value is assumed to be in ms.
|
|
@@ -56,6 +56,16 @@ AreaElementPath.propTypes = {
|
|
|
56
56
|
}).isRequired,
|
|
57
57
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Demos:
|
|
61
|
+
*
|
|
62
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
63
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
64
|
+
*
|
|
65
|
+
* API:
|
|
66
|
+
*
|
|
67
|
+
* - [AreaElement API](https://mui.com/x/api/charts/area-element/)
|
|
68
|
+
*/
|
|
59
69
|
function AreaElement(props) {
|
|
60
70
|
var _slots$area;
|
|
61
71
|
var id = props.id,
|
|
@@ -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
|
var slots = props.slots,
|
|
15
26
|
slotProps = props.slotProps,
|
|
@@ -31,32 +42,45 @@ function AreaPlot(props) {
|
|
|
31
42
|
children: stackingGroups.flatMap(function (_ref) {
|
|
32
43
|
var groupIds = _ref.ids;
|
|
33
44
|
return groupIds.flatMap(function (seriesId) {
|
|
45
|
+
var _xData$map;
|
|
34
46
|
var _series$seriesId = series[seriesId],
|
|
35
47
|
_series$seriesId$xAxi = _series$seriesId.xAxisKey,
|
|
36
48
|
xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
|
|
37
49
|
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
38
50
|
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
39
|
-
stackedData = _series$seriesId.stackedData
|
|
51
|
+
stackedData = _series$seriesId.stackedData,
|
|
52
|
+
data = _series$seriesId.data,
|
|
53
|
+
connectNulls = _series$seriesId.connectNulls;
|
|
40
54
|
var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
41
55
|
var yScale = yAxis[yAxisKey].scale;
|
|
42
56
|
var xData = xAxis[xAxisKey].data;
|
|
43
|
-
if (
|
|
44
|
-
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
+
if (xData === undefined) {
|
|
59
|
+
throw new Error("Axis of id \"".concat(xAxisKey, "\" should have data property to be able to display a line plot."));
|
|
60
|
+
}
|
|
61
|
+
if (xData.length < stackedData.length) {
|
|
62
|
+
throw new Error("MUI: data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)"));
|
|
63
|
+
}
|
|
45
64
|
}
|
|
46
65
|
var areaPath = d3Area().x(function (d) {
|
|
47
66
|
return xScale(d.x);
|
|
67
|
+
}).defined(function (_, i) {
|
|
68
|
+
return connectNulls || data[i] != null;
|
|
48
69
|
}).y0(function (d) {
|
|
49
|
-
return yScale(d.y[0]);
|
|
70
|
+
return d.y && yScale(d.y[0]);
|
|
50
71
|
}).y1(function (d) {
|
|
51
|
-
return yScale(d.y[1]);
|
|
72
|
+
return d.y && yScale(d.y[1]);
|
|
52
73
|
});
|
|
53
74
|
var curve = getCurveFactory(series[seriesId].curve);
|
|
54
|
-
var
|
|
75
|
+
var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
55
76
|
return {
|
|
56
77
|
x: x,
|
|
57
78
|
y: stackedData[index]
|
|
58
79
|
};
|
|
59
|
-
});
|
|
80
|
+
})) != null ? _xData$map : [];
|
|
81
|
+
var d3Data = connectNulls ? formattedData.filter(function (_, i) {
|
|
82
|
+
return data[i] != null;
|
|
83
|
+
}) : formattedData;
|
|
60
84
|
return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
|
|
61
85
|
id: seriesId,
|
|
62
86
|
d: areaPath.curve(curve)(d3Data) || undefined,
|