@mui/x-charts 8.0.0-alpha.5 → 8.0.0-alpha.7
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/AnimatedBarElement.js +1 -0
- package/BarChart/BarChart.js +17 -7
- package/BarChart/BarLabel/BarLabel.d.ts +1 -479
- package/BarChart/BarLabel/barLabelClasses.d.ts +1 -1
- package/BarChart/legend.js +1 -0
- package/BarChart/useBarChartProps.d.ts +4 -2
- package/BarChart/useBarChartProps.js +16 -3
- package/CHANGELOG.md +206 -1
- package/ChartsLabel/ChartsLabel.d.ts +2 -3
- package/ChartsLabel/ChartsLabel.js +3 -18
- package/ChartsLabel/ChartsLabelGradient.d.ts +9 -8
- package/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -3
- package/ChartsLabel/ChartsLabelMark.js +5 -2
- package/ChartsLabel/index.d.ts +7 -0
- package/ChartsLabel/index.js +6 -0
- package/ChartsLabel/labelClasses.d.ts +0 -1
- package/ChartsLabel/labelGradientClasses.d.ts +5 -4
- package/ChartsLabel/labelGradientClasses.js +3 -2
- package/ChartsLabel/labelMarkClasses.d.ts +3 -2
- package/ChartsLabel/labelMarkClasses.js +3 -2
- package/ChartsLabel/package.json +6 -0
- package/ChartsLegend/ChartsLegend.d.ts +18 -22
- package/ChartsLegend/ChartsLegend.js +100 -109
- package/ChartsLegend/ContinuousColorLegend.d.ts +29 -38
- package/ChartsLegend/ContinuousColorLegend.js +198 -321
- package/ChartsLegend/PiecewiseColorLegend.d.ts +27 -19
- package/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/ChartsLegend/chartsLegend.types.d.ts +17 -60
- package/ChartsLegend/chartsLegendClasses.d.ts +7 -8
- package/ChartsLegend/chartsLegendClasses.js +16 -2
- package/ChartsLegend/colorLegend.types.d.ts +13 -0
- package/ChartsLegend/colorLegend.types.js +1 -0
- package/ChartsLegend/continuousColorLegendClasses.d.ts +26 -0
- package/ChartsLegend/continuousColorLegendClasses.js +23 -0
- package/ChartsLegend/direction.d.ts +1 -0
- package/ChartsLegend/direction.js +1 -0
- package/ChartsLegend/index.d.ts +13 -3
- package/ChartsLegend/index.js +9 -3
- package/ChartsLegend/legend.types.d.ts +10 -54
- package/ChartsLegend/legendContext.types.d.ts +55 -0
- package/ChartsLegend/legendContext.types.js +1 -0
- package/ChartsLegend/onClickContextBuilder.d.ts +2 -0
- package/ChartsLegend/onClickContextBuilder.js +7 -0
- package/ChartsLegend/piecewiseColorDefaultLabelFormatter.d.ts +2 -0
- package/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
- package/ChartsLegend/piecewiseColorLegend.types.d.ts +26 -0
- package/ChartsLegend/piecewiseColorLegend.types.js +1 -0
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +28 -0
- package/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
- package/ChartsLegend/useAxis.d.ts +1 -1
- package/ChartsLegend/useAxis.js +0 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
- package/ChartsSurface/ChartsSurface.js +0 -1
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
- package/LineChart/AnimatedArea.js +1 -0
- package/LineChart/AnimatedLine.js +1 -0
- package/LineChart/AppearingMask.js +1 -0
- package/LineChart/CircleMarkElement.js +1 -0
- package/LineChart/LineChart.js +20 -10
- package/LineChart/MarkElement.js +3 -1
- package/LineChart/legend.js +1 -0
- package/LineChart/useLineChartProps.d.ts +4 -2
- package/LineChart/useLineChartProps.js +15 -2
- package/PieChart/PieArc.js +3 -1
- package/PieChart/PieArcLabel.js +13 -9
- package/PieChart/PieArcLabelPlot.js +1 -0
- package/PieChart/PieArcPlot.js +1 -0
- package/PieChart/PieChart.js +42 -41
- package/PieChart/legend.js +1 -0
- package/ScatterChart/ScatterChart.js +21 -11
- package/ScatterChart/legend.js +1 -0
- package/ScatterChart/useScatterChartProps.d.ts +4 -2
- package/ScatterChart/useScatterChartProps.js +15 -2
- package/SparkLineChart/SparkLineChart.js +1 -4
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/context/CartesianProvider/defaultizeAxis.d.ts +9 -9
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -18
- package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -9
- package/context/ChartProvider/ChartProvider.types.d.ts +1 -1
- package/context/InteractionSelectors.d.ts +11 -11
- package/context/PluginProvider/SeriesFormatter.types.d.ts +1 -1
- package/context/PluginProvider/mergePlugins.d.ts +8 -8
- package/context/SizeProvider/Size.types.d.ts +1 -1
- package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useLegend.d.ts +13 -0
- package/{modern/ChartsLegend/utils.js → hooks/useLegend.js} +20 -1
- package/hooks/useSvgRef.d.ts +1 -1
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/internals/calculateMargins.d.ts +7 -0
- package/internals/calculateMargins.js +25 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +17 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
- package/internals/components/ChartsWrapper/index.d.ts +1 -0
- package/internals/components/ChartsWrapper/index.js +1 -0
- package/internals/consumeSlots.d.ts +48 -0
- package/internals/consumeSlots.js +101 -0
- package/internals/consumeThemeProps.d.ts +3 -7
- package/internals/consumeThemeProps.js +18 -27
- package/internals/defaultizeColor.d.ts +6 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
- package/internals/plugins/models/plugin.d.ts +1 -1
- package/internals/store/useCharts.d.ts +2 -2
- package/internals/store/useCharts.types.d.ts +1 -1
- package/models/seriesType/common.d.ts +9 -0
- package/models/seriesType/pie.d.ts +9 -0
- package/modern/BarChart/AnimatedBarElement.js +1 -0
- package/modern/BarChart/BarChart.js +17 -7
- package/modern/BarChart/legend.js +1 -0
- package/modern/BarChart/useBarChartProps.js +16 -3
- package/modern/ChartsLabel/ChartsLabel.js +3 -18
- package/modern/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/modern/ChartsLabel/ChartsLabelMark.js +5 -2
- package/modern/ChartsLabel/index.js +6 -0
- package/modern/ChartsLabel/labelGradientClasses.js +3 -2
- package/modern/ChartsLabel/labelMarkClasses.js +3 -2
- package/modern/ChartsLegend/ChartsLegend.js +100 -109
- package/modern/ChartsLegend/ContinuousColorLegend.js +198 -321
- package/modern/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/modern/ChartsLegend/chartsLegendClasses.js +16 -2
- package/modern/ChartsLegend/colorLegend.types.js +1 -0
- package/modern/ChartsLegend/continuousColorLegendClasses.js +23 -0
- package/modern/ChartsLegend/direction.js +1 -0
- package/modern/ChartsLegend/index.js +9 -3
- package/modern/ChartsLegend/legendContext.types.js +1 -0
- package/modern/ChartsLegend/onClickContextBuilder.js +7 -0
- package/modern/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
- package/modern/ChartsLegend/piecewiseColorLegend.types.js +1 -0
- package/modern/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
- package/modern/ChartsLegend/useAxis.js +0 -1
- package/modern/ChartsSurface/ChartsSurface.js +0 -1
- package/modern/LineChart/AnimatedArea.js +1 -0
- package/modern/LineChart/AnimatedLine.js +1 -0
- package/modern/LineChart/AppearingMask.js +1 -0
- package/modern/LineChart/CircleMarkElement.js +1 -0
- package/modern/LineChart/LineChart.js +20 -10
- package/modern/LineChart/MarkElement.js +3 -1
- package/modern/LineChart/legend.js +1 -0
- package/modern/LineChart/useLineChartProps.js +15 -2
- package/modern/PieChart/PieArc.js +3 -1
- package/modern/PieChart/PieArcLabel.js +13 -9
- package/modern/PieChart/PieArcLabelPlot.js +1 -0
- package/modern/PieChart/PieArcPlot.js +1 -0
- package/modern/PieChart/PieChart.js +42 -41
- package/modern/PieChart/legend.js +1 -0
- package/modern/ScatterChart/ScatterChart.js +21 -11
- package/modern/ScatterChart/legend.js +1 -0
- package/modern/ScatterChart/useScatterChartProps.js +15 -2
- package/modern/SparkLineChart/SparkLineChart.js +1 -4
- package/modern/constants/index.js +2 -1
- package/modern/hooks/index.js +2 -1
- package/{ChartsLegend/utils.js → modern/hooks/useLegend.js} +20 -1
- package/modern/index.js +2 -1
- package/modern/internals/calculateMargins.js +25 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/modern/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
- package/modern/internals/components/ChartsWrapper/index.js +1 -0
- package/modern/internals/consumeSlots.js +101 -0
- package/modern/internals/consumeThemeProps.js +18 -27
- package/modern/internals/index.js +1 -0
- package/node/BarChart/AnimatedBarElement.js +1 -0
- package/node/BarChart/BarChart.js +17 -7
- package/node/BarChart/legend.js +1 -0
- package/node/BarChart/useBarChartProps.js +15 -3
- package/node/ChartsLabel/ChartsLabel.js +3 -18
- package/node/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/node/ChartsLabel/ChartsLabelMark.js +5 -2
- package/node/ChartsLabel/index.js +26 -0
- package/node/ChartsLabel/labelGradientClasses.js +3 -2
- package/node/ChartsLabel/labelMarkClasses.js +3 -2
- package/node/ChartsLegend/ChartsLegend.js +99 -108
- package/node/ChartsLegend/ContinuousColorLegend.js +199 -322
- package/node/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/node/ChartsLegend/chartsLegendClasses.js +17 -3
- package/node/ChartsLegend/colorLegend.types.js +5 -0
- package/node/ChartsLegend/continuousColorLegendClasses.js +31 -0
- package/node/ChartsLegend/direction.js +5 -0
- package/node/ChartsLegend/index.js +80 -16
- package/node/ChartsLegend/legendContext.types.js +5 -0
- package/node/ChartsLegend/onClickContextBuilder.js +14 -0
- package/node/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +15 -0
- package/node/ChartsLegend/piecewiseColorLegend.types.js +5 -0
- package/node/ChartsLegend/piecewiseColorLegendClasses.js +31 -0
- package/node/ChartsSurface/ChartsSurface.js +0 -1
- package/node/LineChart/AnimatedArea.js +1 -0
- package/node/LineChart/AnimatedLine.js +1 -0
- package/node/LineChart/AppearingMask.js +1 -0
- package/node/LineChart/CircleMarkElement.js +1 -0
- package/node/LineChart/LineChart.js +20 -10
- package/node/LineChart/MarkElement.js +3 -1
- package/node/LineChart/legend.js +1 -0
- package/node/LineChart/useLineChartProps.js +14 -2
- package/node/PieChart/PieArc.js +3 -1
- package/node/PieChart/PieArcLabel.js +13 -9
- package/node/PieChart/PieArcLabelPlot.js +1 -0
- package/node/PieChart/PieArcPlot.js +1 -0
- package/node/PieChart/PieChart.js +42 -41
- package/node/PieChart/legend.js +1 -0
- package/node/ScatterChart/ScatterChart.js +21 -11
- package/node/ScatterChart/legend.js +1 -0
- package/node/ScatterChart/useScatterChartProps.js +14 -2
- package/node/SparkLineChart/SparkLineChart.js +1 -4
- package/node/constants/index.js +3 -2
- package/node/hooks/index.js +13 -1
- package/node/{ChartsLegend/utils.js → hooks/useLegend.js} +19 -1
- package/node/index.js +12 -1
- package/node/internals/calculateMargins.js +33 -0
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +61 -16
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +69 -0
- package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/node/internals/components/ChartsWrapper/ChartsWrapper.js +72 -0
- package/node/internals/components/ChartsWrapper/index.js +16 -0
- package/node/internals/consumeSlots.js +109 -0
- package/node/internals/consumeThemeProps.js +18 -27
- package/node/internals/index.js +12 -0
- package/package.json +4 -4
- package/ChartsLegend/ChartsLegendItem.d.ts +0 -26
- package/ChartsLegend/ChartsLegendItem.js +0 -65
- package/ChartsLegend/DefaultChartsLegend.d.ts +0 -25
- package/ChartsLegend/DefaultChartsLegend.js +0 -112
- package/ChartsLegend/LegendPerItem.d.ts +0 -65
- package/ChartsLegend/LegendPerItem.js +0 -129
- package/ChartsLegend/legendItemsPlacement.d.ts +0 -3
- package/ChartsLegend/legendItemsPlacement.js +0 -72
- package/ChartsLegend/utils.d.ts +0 -2
- package/modern/ChartsLegend/ChartsLegendItem.js +0 -65
- package/modern/ChartsLegend/DefaultChartsLegend.js +0 -112
- package/modern/ChartsLegend/LegendPerItem.js +0 -129
- package/modern/ChartsLegend/legendItemsPlacement.js +0 -72
- package/node/ChartsLegend/ChartsLegendItem.js +0 -72
- package/node/ChartsLegend/DefaultChartsLegend.js +0 -118
- package/node/ChartsLegend/LegendPerItem.js +0 -137
- package/node/ChartsLegend/legendItemsPlacement.js +0 -79
|
@@ -1,40 +1,130 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
const _excluded = ["direction", "classes", "className", "markType", "labelPosition", "axisDirection", "axisId", "labelFormatter", "onItemClick"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { ChartsLabel } from "../ChartsLabel/ChartsLabel.js";
|
|
11
|
+
import { ChartsLabelMark } from "../ChartsLabel/ChartsLabelMark.js";
|
|
12
|
+
import { consumeThemeProps } from "../internals/consumeThemeProps.js";
|
|
13
|
+
import { piecewiseColorLegendClasses, useUtilityClasses } from "./piecewiseColorLegendClasses.js";
|
|
8
14
|
import { useAxis } from "./useAxis.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
import { piecewiseColorDefaultLabelFormatter } from "./piecewiseColorDefaultLabelFormatter.js";
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const RootElement = styled('ul', {
|
|
18
|
+
name: 'MuiPiecewiseColorLegend',
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
})(({
|
|
22
|
+
theme,
|
|
23
|
+
ownerState
|
|
24
|
+
}) => {
|
|
25
|
+
return _extends({}, theme.typography.caption, {
|
|
26
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
27
|
+
lineHeight: '100%',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexDirection: ownerState.direction === 'vertical' ? 'column' : 'row',
|
|
30
|
+
flexShrink: 0,
|
|
31
|
+
gap: theme.spacing(0.5),
|
|
32
|
+
listStyleType: 'none',
|
|
33
|
+
paddingInlineStart: 0,
|
|
34
|
+
marginBlock: theme.spacing(1),
|
|
35
|
+
marginInline: theme.spacing(1),
|
|
36
|
+
width: 'max-content',
|
|
37
|
+
[`button.${piecewiseColorLegendClasses.item}`]: {
|
|
38
|
+
// Reset button styles
|
|
39
|
+
background: 'none',
|
|
40
|
+
border: 'none',
|
|
41
|
+
padding: 0,
|
|
42
|
+
cursor: ownerState.onItemClick ? 'pointer' : 'unset',
|
|
43
|
+
fontFamily: 'inherit',
|
|
44
|
+
fontWeight: 'inherit',
|
|
45
|
+
fontSize: 'inherit',
|
|
46
|
+
letterSpacing: 'inherit',
|
|
47
|
+
color: 'inherit'
|
|
48
|
+
},
|
|
49
|
+
[`.${piecewiseColorLegendClasses.item}`]: {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
gap: theme.spacing(0.5)
|
|
52
|
+
},
|
|
53
|
+
[`li :not(.${piecewiseColorLegendClasses.minLabel}, .${piecewiseColorLegendClasses.maxLabel}) .${piecewiseColorLegendClasses?.mark}`]: {
|
|
54
|
+
alignSelf: 'center'
|
|
55
|
+
},
|
|
56
|
+
[`&.${piecewiseColorLegendClasses.start}`]: {
|
|
57
|
+
alignItems: 'end'
|
|
58
|
+
},
|
|
59
|
+
[`&.${piecewiseColorLegendClasses.end}`]: {
|
|
60
|
+
alignItems: 'start'
|
|
61
|
+
},
|
|
62
|
+
[`&.${piecewiseColorLegendClasses.horizontal}`]: {
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
[`.${piecewiseColorLegendClasses.item}`]: {
|
|
65
|
+
flexDirection: 'column'
|
|
66
|
+
},
|
|
67
|
+
[`&.${piecewiseColorLegendClasses.start}`]: {
|
|
68
|
+
alignItems: 'end'
|
|
69
|
+
},
|
|
70
|
+
[`&.${piecewiseColorLegendClasses.end}`]: {
|
|
71
|
+
alignItems: 'start'
|
|
72
|
+
},
|
|
73
|
+
[`.${piecewiseColorLegendClasses.minLabel}`]: {
|
|
74
|
+
alignItems: 'end'
|
|
75
|
+
},
|
|
76
|
+
[`&.${piecewiseColorLegendClasses.extremes}`]: {
|
|
77
|
+
[`.${piecewiseColorLegendClasses.minLabel}, .${piecewiseColorLegendClasses.maxLabel}`]: {
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
display: 'flex',
|
|
80
|
+
flexDirection: 'row'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[`&.${piecewiseColorLegendClasses.vertical}`]: {
|
|
85
|
+
[`.${piecewiseColorLegendClasses.item}`]: {
|
|
86
|
+
flexDirection: 'row',
|
|
87
|
+
alignItems: 'center'
|
|
88
|
+
},
|
|
89
|
+
[`&.${piecewiseColorLegendClasses.start}`]: {
|
|
90
|
+
alignItems: 'end'
|
|
91
|
+
},
|
|
92
|
+
[`&.${piecewiseColorLegendClasses.end}`]: {
|
|
93
|
+
alignItems: 'start'
|
|
94
|
+
},
|
|
95
|
+
[`&.${piecewiseColorLegendClasses.extremes}`]: {
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
[`.${piecewiseColorLegendClasses.minLabel}, .${piecewiseColorLegendClasses.maxLabel}`]: {
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
display: 'flex',
|
|
100
|
+
flexDirection: 'column'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
27
105
|
});
|
|
28
|
-
|
|
106
|
+
const PiecewiseColorLegend = consumeThemeProps('MuiPiecewiseColorLegend', {
|
|
107
|
+
defaultProps: {
|
|
108
|
+
direction: 'horizontal',
|
|
109
|
+
labelPosition: 'extremes',
|
|
110
|
+
labelFormatter: piecewiseColorDefaultLabelFormatter
|
|
111
|
+
},
|
|
112
|
+
classesResolver: useUtilityClasses
|
|
113
|
+
}, function PiecewiseColorLegend(props, ref) {
|
|
29
114
|
const {
|
|
115
|
+
direction,
|
|
116
|
+
classes,
|
|
117
|
+
className,
|
|
118
|
+
markType,
|
|
119
|
+
labelPosition,
|
|
30
120
|
axisDirection,
|
|
31
121
|
axisId,
|
|
32
|
-
|
|
33
|
-
hideLast,
|
|
34
|
-
labelFormatter = defaultLabelFormatter,
|
|
122
|
+
labelFormatter,
|
|
35
123
|
onItemClick
|
|
36
124
|
} = props,
|
|
37
125
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
126
|
+
const isVertical = direction === 'vertical';
|
|
127
|
+
const isReverse = isVertical;
|
|
38
128
|
const axisItem = useAxis({
|
|
39
129
|
axisDirection,
|
|
40
130
|
axisId
|
|
@@ -47,42 +137,83 @@ function PiecewiseColorLegend(props) {
|
|
|
47
137
|
location: 'legend'
|
|
48
138
|
}) ?? v.toLocaleString();
|
|
49
139
|
const formattedLabels = colorMap.thresholds.map(valueFormatter);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
max: colorMap.thresholds[index],
|
|
67
|
-
formattedMax: formattedLabels[index]
|
|
68
|
-
});
|
|
69
|
-
const label = labelFormatter(data);
|
|
70
|
-
if (label === null) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
id: label,
|
|
140
|
+
const startClass = isReverse ? classes?.maxLabel : classes?.minLabel;
|
|
141
|
+
const endClass = isReverse ? classes?.minLabel : classes?.maxLabel;
|
|
142
|
+
const colors = colorMap.colors.map((color, colorIndex) => ({
|
|
143
|
+
color,
|
|
144
|
+
colorIndex
|
|
145
|
+
}));
|
|
146
|
+
const orderedColors = isReverse ? colors.reverse() : colors;
|
|
147
|
+
const isStart = labelPosition === 'start';
|
|
148
|
+
const isEnd = labelPosition === 'end';
|
|
149
|
+
const isExtremes = labelPosition === 'extremes';
|
|
150
|
+
return /*#__PURE__*/_jsx(RootElement, _extends({
|
|
151
|
+
className: clsx(classes?.root, className),
|
|
152
|
+
ref: ref
|
|
153
|
+
}, other, {
|
|
154
|
+
ownerState: props,
|
|
155
|
+
children: orderedColors.map(({
|
|
75
156
|
color,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
157
|
+
colorIndex
|
|
158
|
+
}, index) => {
|
|
159
|
+
const isFirst = index === 0;
|
|
160
|
+
const isLast = index === colorMap.colors.length - 1;
|
|
161
|
+
const isFirstColor = colorIndex === 0;
|
|
162
|
+
const isLastColor = colorIndex === colorMap.colors.length - 1;
|
|
163
|
+
const data = _extends({
|
|
164
|
+
index: colorIndex,
|
|
165
|
+
length: formattedLabels.length
|
|
166
|
+
}, isFirstColor ? {
|
|
167
|
+
min: null,
|
|
168
|
+
formattedMin: null
|
|
169
|
+
} : {
|
|
170
|
+
min: colorMap.thresholds[colorIndex - 1],
|
|
171
|
+
formattedMin: formattedLabels[colorIndex - 1]
|
|
172
|
+
}, isLastColor ? {
|
|
173
|
+
max: null,
|
|
174
|
+
formattedMax: null
|
|
175
|
+
} : {
|
|
176
|
+
max: colorMap.thresholds[colorIndex],
|
|
177
|
+
formattedMax: formattedLabels[colorIndex]
|
|
178
|
+
});
|
|
179
|
+
const label = labelFormatter?.(data);
|
|
180
|
+
if (label === null || label === undefined) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const isTextBefore = isStart || isExtremes && isFirst;
|
|
184
|
+
const isTextAfter = isEnd || isExtremes && isLast;
|
|
185
|
+
const clickObject = {
|
|
186
|
+
type: 'piecewiseColor',
|
|
187
|
+
color,
|
|
188
|
+
label,
|
|
189
|
+
minValue: data.min,
|
|
190
|
+
maxValue: data.max
|
|
191
|
+
};
|
|
192
|
+
const Element = onItemClick ? 'button' : 'div';
|
|
193
|
+
return /*#__PURE__*/_jsx("li", {
|
|
194
|
+
children: /*#__PURE__*/_jsxs(Element, {
|
|
195
|
+
role: onItemClick ? 'button' : undefined,
|
|
196
|
+
type: onItemClick ? 'button' : undefined,
|
|
197
|
+
onClick:
|
|
198
|
+
// @ts-ignore onClick is only attached to a button
|
|
199
|
+
onItemClick ? event => onItemClick(event, clickObject, index) : undefined,
|
|
200
|
+
className: clsx(classes?.item, index === 0 && `${startClass}`, index === orderedColors.length - 1 && `${endClass}`),
|
|
201
|
+
children: [isTextBefore && /*#__PURE__*/_jsx(ChartsLabel, {
|
|
202
|
+
className: classes?.label,
|
|
203
|
+
children: label
|
|
204
|
+
}), /*#__PURE__*/_jsx(ChartsLabelMark, {
|
|
205
|
+
className: classes?.mark,
|
|
206
|
+
type: markType,
|
|
207
|
+
color: color
|
|
208
|
+
}), isTextAfter && /*#__PURE__*/_jsx(ChartsLabel, {
|
|
209
|
+
className: classes?.label,
|
|
210
|
+
children: label
|
|
211
|
+
})]
|
|
212
|
+
})
|
|
213
|
+
}, colorIndex);
|
|
214
|
+
})
|
|
84
215
|
}));
|
|
85
|
-
}
|
|
216
|
+
});
|
|
86
217
|
process.env.NODE_ENV !== "production" ? PiecewiseColorLegend.propTypes = {
|
|
87
218
|
// ----------------------------- Warning --------------------------------
|
|
88
219
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -102,76 +233,35 @@ process.env.NODE_ENV !== "production" ? PiecewiseColorLegend.propTypes = {
|
|
|
102
233
|
* Override or extend the styles applied to the component.
|
|
103
234
|
*/
|
|
104
235
|
classes: PropTypes.object,
|
|
236
|
+
className: PropTypes.string,
|
|
105
237
|
/**
|
|
106
238
|
* The direction of the legend layout.
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
direction: PropTypes.oneOf(['column', 'row']).isRequired,
|
|
110
|
-
/**
|
|
111
|
-
* Hide the first item of the legend, corresponding to the [-infinity, min] piece.
|
|
112
|
-
* @default false
|
|
239
|
+
* @default 'horizontal'
|
|
113
240
|
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Hide the last item of the legend, corresponding to the [max, +infinity] piece.
|
|
117
|
-
* @default false
|
|
118
|
-
*/
|
|
119
|
-
hideLast: PropTypes.bool,
|
|
120
|
-
/**
|
|
121
|
-
* Space between two legend items (in px).
|
|
122
|
-
* @default 10
|
|
123
|
-
*/
|
|
124
|
-
itemGap: PropTypes.number,
|
|
125
|
-
/**
|
|
126
|
-
* Height of the item mark (in px).
|
|
127
|
-
* @default 20
|
|
128
|
-
*/
|
|
129
|
-
itemMarkHeight: PropTypes.number,
|
|
130
|
-
/**
|
|
131
|
-
* Width of the item mark (in px).
|
|
132
|
-
* @default 20
|
|
133
|
-
*/
|
|
134
|
-
itemMarkWidth: PropTypes.number,
|
|
241
|
+
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
135
242
|
/**
|
|
136
243
|
* Format the legend labels.
|
|
137
244
|
* @param {PiecewiseLabelFormatterParams} params The bound of the piece to format.
|
|
138
|
-
* @returns {string|null} The displayed label, or `null` to skip
|
|
245
|
+
* @returns {string|null} The displayed label, `''` to skip the label but show the color mark, or `null` to skip it entirely.
|
|
139
246
|
*/
|
|
140
247
|
labelFormatter: PropTypes.func,
|
|
141
248
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @default
|
|
249
|
+
* Where to position the labels relative to the gradient.
|
|
250
|
+
* @default 'extremes'
|
|
144
251
|
*/
|
|
145
|
-
|
|
252
|
+
labelPosition: PropTypes.oneOf(['start', 'end', 'extremes']),
|
|
146
253
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @default
|
|
254
|
+
* The type of the mark.
|
|
255
|
+
* @default 'square'
|
|
149
256
|
*/
|
|
150
|
-
|
|
257
|
+
markType: PropTypes.oneOf(['square', 'circle', 'line']),
|
|
151
258
|
/**
|
|
152
259
|
* Callback fired when a legend item is clicked.
|
|
153
|
-
* @param {React.MouseEvent<
|
|
260
|
+
* @param {React.MouseEvent<HTMLButtonElement, MouseEvent>} event The click event.
|
|
154
261
|
* @param {PiecewiseColorLegendItemContext} legendItem The legend item data.
|
|
155
262
|
* @param {number} index The index of the clicked legend item.
|
|
156
263
|
*/
|
|
157
264
|
onItemClick: PropTypes.func,
|
|
158
|
-
|
|
159
|
-
* Legend padding (in px).
|
|
160
|
-
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
161
|
-
* @default 10
|
|
162
|
-
*/
|
|
163
|
-
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
164
|
-
bottom: PropTypes.number,
|
|
165
|
-
left: PropTypes.number,
|
|
166
|
-
right: PropTypes.number,
|
|
167
|
-
top: PropTypes.number
|
|
168
|
-
})]),
|
|
169
|
-
/**
|
|
170
|
-
* The position of the legend.
|
|
171
|
-
*/
|
|
172
|
-
position: PropTypes.shape({
|
|
173
|
-
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
174
|
-
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
175
|
-
}).isRequired
|
|
265
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
176
266
|
} : void 0;
|
|
177
267
|
export { PiecewiseColorLegend };
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
2
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
-
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
function getLegendUtilityClass(slot) {
|
|
4
5
|
return generateUtilityClass('MuiChartsLegend', slot);
|
|
5
6
|
}
|
|
6
|
-
export const
|
|
7
|
+
export const useUtilityClasses = props => {
|
|
8
|
+
const {
|
|
9
|
+
classes,
|
|
10
|
+
direction
|
|
11
|
+
} = props;
|
|
12
|
+
const slots = {
|
|
13
|
+
root: ['root', direction],
|
|
14
|
+
mark: ['mark'],
|
|
15
|
+
label: ['label'],
|
|
16
|
+
series: ['series']
|
|
17
|
+
};
|
|
18
|
+
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
19
|
+
};
|
|
20
|
+
export const legendClasses = generateUtilityClasses('MuiChartsLegend', ['root', 'series', 'mark', 'label', 'vertical', 'horizontal']);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
function getLegendUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiContinuousColorLegend', slot);
|
|
6
|
+
}
|
|
7
|
+
export const useUtilityClasses = props => {
|
|
8
|
+
const {
|
|
9
|
+
classes,
|
|
10
|
+
direction,
|
|
11
|
+
labelPosition
|
|
12
|
+
} = props;
|
|
13
|
+
const slots = {
|
|
14
|
+
root: ['root', direction, labelPosition],
|
|
15
|
+
minLabel: ['minLabel'],
|
|
16
|
+
maxLabel: ['maxLabel'],
|
|
17
|
+
gradient: ['gradient'],
|
|
18
|
+
mark: ['mark'],
|
|
19
|
+
label: ['label']
|
|
20
|
+
};
|
|
21
|
+
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
22
|
+
};
|
|
23
|
+
export const continuousColorLegendClasses = generateUtilityClasses('MuiContinuousColorLegend', ['root', 'minLabel', 'maxLabel', 'gradient', 'vertical', 'horizontal', 'start', 'end', 'extremes', 'label']);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export * from "./ChartsLegend.js";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./chartsLegend.types.js";
|
|
3
|
+
export * from "./direction.js";
|
|
4
|
+
export * from "./legendContext.types.js";
|
|
5
|
+
export { legendClasses } from "./chartsLegendClasses.js";
|
|
3
6
|
export * from "./ContinuousColorLegend.js";
|
|
7
|
+
export * from "./colorLegend.types.js";
|
|
8
|
+
export { continuousColorLegendClasses } from "./continuousColorLegendClasses.js";
|
|
4
9
|
export * from "./PiecewiseColorLegend.js";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
10
|
+
export { piecewiseColorLegendClasses } from "./piecewiseColorLegendClasses.js";
|
|
11
|
+
export { piecewiseColorDefaultLabelFormatter } from "./piecewiseColorDefaultLabelFormatter.js";
|
|
12
|
+
export * from "./legend.types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
function getLegendUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiPiecewiseColorLegendClasses', slot);
|
|
6
|
+
}
|
|
7
|
+
export const useUtilityClasses = props => {
|
|
8
|
+
const {
|
|
9
|
+
classes,
|
|
10
|
+
direction,
|
|
11
|
+
labelPosition
|
|
12
|
+
} = props;
|
|
13
|
+
const slots = {
|
|
14
|
+
root: ['root', direction, labelPosition],
|
|
15
|
+
minLabel: ['minLabel'],
|
|
16
|
+
maxLabel: ['maxLabel'],
|
|
17
|
+
item: ['item'],
|
|
18
|
+
mark: ['mark'],
|
|
19
|
+
label: ['label']
|
|
20
|
+
};
|
|
21
|
+
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
22
|
+
};
|
|
23
|
+
export const piecewiseColorLegendClasses = generateUtilityClasses('MuiPiecewiseColorLegendClasses', ['root', 'minLabel', 'maxLabel', 'item', 'vertical', 'horizontal', 'start', 'end', 'extremes', 'mark', 'label']);
|
|
@@ -44,6 +44,7 @@ function AnimatedArea(props) {
|
|
|
44
44
|
skipAnimation: skipAnimation,
|
|
45
45
|
id: `${ownerState.id}-area-clip`,
|
|
46
46
|
children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(animated.path, _extends({
|
|
47
|
+
// @ts-expect-error
|
|
47
48
|
d: style.value.to(interpolator),
|
|
48
49
|
fill: ownerState.gradientId ? `url(#${ownerState.gradientId})` : ownerState.color,
|
|
49
50
|
filter:
|
|
@@ -44,6 +44,7 @@ function AnimatedLine(props) {
|
|
|
44
44
|
skipAnimation: skipAnimation,
|
|
45
45
|
id: `${ownerState.id}-line-clip`,
|
|
46
46
|
children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(animated.path, _extends({
|
|
47
|
+
// @ts-expect-error
|
|
47
48
|
d: style.value.to(interpolator),
|
|
48
49
|
stroke: ownerState.gradientId ? `url(#${ownerState.gradientId})` : ownerState.color,
|
|
49
50
|
strokeWidth: 2,
|
|
@@ -6,7 +6,6 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import { AreaPlot } from "./AreaPlot.js";
|
|
8
8
|
import { LinePlot } from "./LinePlot.js";
|
|
9
|
-
import { ChartContainer } from "../ChartContainer/index.js";
|
|
10
9
|
import { MarkPlot } from "./MarkPlot.js";
|
|
11
10
|
import { ChartsAxis } from "../ChartsAxis/ChartsAxis.js";
|
|
12
11
|
import { ChartsTooltip } from "../ChartsTooltip/index.js";
|
|
@@ -18,6 +17,10 @@ import { ChartsGrid } from "../ChartsGrid/index.js";
|
|
|
18
17
|
import { ChartsOnAxisClickHandler } from "../ChartsOnAxisClickHandler/index.js";
|
|
19
18
|
import { ChartsOverlay } from "../ChartsOverlay/index.js";
|
|
20
19
|
import { useLineChartProps } from "./useLineChartProps.js";
|
|
20
|
+
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
21
|
+
import { ChartDataProvider } from "../context/index.js";
|
|
22
|
+
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
23
|
+
import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
|
|
21
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
25
|
/**
|
|
23
26
|
* Demos:
|
|
@@ -35,6 +38,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref)
|
|
|
35
38
|
name: 'MuiLineChart'
|
|
36
39
|
});
|
|
37
40
|
const {
|
|
41
|
+
chartsWrapperProps,
|
|
38
42
|
chartContainerProps,
|
|
39
43
|
axisClickHandlerProps,
|
|
40
44
|
gridProps,
|
|
@@ -50,16 +54,22 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref)
|
|
|
50
54
|
legendProps,
|
|
51
55
|
children
|
|
52
56
|
} = useLineChartProps(props);
|
|
57
|
+
const {
|
|
58
|
+
chartDataProviderProps,
|
|
59
|
+
chartsSurfaceProps
|
|
60
|
+
} = useChartContainerProps(chartContainerProps, ref);
|
|
53
61
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
54
|
-
return /*#__PURE__*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
63
|
+
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
64
|
+
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
65
|
+
children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
66
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
67
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
|
|
68
|
+
"data-drawing-container": true,
|
|
69
|
+
children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
|
|
70
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
71
|
+
}))]
|
|
72
|
+
}))
|
|
63
73
|
}));
|
|
64
74
|
});
|
|
65
75
|
process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
@@ -80,7 +80,9 @@ function MarkElement(props) {
|
|
|
80
80
|
transform: to([position.x, position.y], (pX, pY) => `translate(${pX}px, ${pY}px)`),
|
|
81
81
|
transformOrigin: to([position.x, position.y], (pX, pY) => `${pX}px ${pY}px`)
|
|
82
82
|
},
|
|
83
|
-
ownerState: ownerState
|
|
83
|
+
ownerState: ownerState
|
|
84
|
+
// @ts-expect-error
|
|
85
|
+
,
|
|
84
86
|
className: classes.root,
|
|
85
87
|
d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
|
|
86
88
|
onClick: onClick,
|