@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
|
@@ -7,16 +7,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.ChartsAxesGradients = ChartsAxesGradients;
|
|
9
9
|
exports.useChartGradient = useChartGradient;
|
|
10
|
+
exports.useChartGradientObjectBound = useChartGradientObjectBound;
|
|
10
11
|
var React = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _CartesianProvider = require("../../../context/CartesianProvider");
|
|
12
13
|
var _hooks = require("../../../hooks");
|
|
13
14
|
var _ChartsPiecewiseGradient = _interopRequireDefault(require("./ChartsPiecewiseGradient"));
|
|
14
15
|
var _ChartsContinuousGradient = _interopRequireDefault(require("./ChartsContinuousGradient"));
|
|
16
|
+
var _ChartsContinuousGradientObjectBound = _interopRequireDefault(require("./ChartsContinuousGradientObjectBound"));
|
|
17
|
+
var _useZAxis = require("../../../hooks/useZAxis");
|
|
15
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
19
|
function useChartGradient() {
|
|
17
20
|
const chartId = (0, _hooks.useChartId)();
|
|
18
21
|
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
19
22
|
}
|
|
23
|
+
|
|
24
|
+
// TODO: make public?
|
|
25
|
+
function useChartGradientObjectBound() {
|
|
26
|
+
const chartId = (0, _hooks.useChartId)();
|
|
27
|
+
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}-object-bound`, [chartId]);
|
|
28
|
+
}
|
|
20
29
|
function ChartsAxesGradients() {
|
|
21
30
|
const {
|
|
22
31
|
top,
|
|
@@ -29,20 +38,27 @@ function ChartsAxesGradients() {
|
|
|
29
38
|
const svgHeight = top + height + bottom;
|
|
30
39
|
const svgWidth = left + width + right;
|
|
31
40
|
const getGradientId = useChartGradient();
|
|
41
|
+
const getObjectBoundGradientId = useChartGradientObjectBound();
|
|
32
42
|
const {
|
|
33
43
|
xAxisIds,
|
|
34
44
|
xAxis,
|
|
35
45
|
yAxisIds,
|
|
36
46
|
yAxis
|
|
37
47
|
} = (0, _CartesianProvider.useCartesianContext)();
|
|
48
|
+
const {
|
|
49
|
+
zAxisIds,
|
|
50
|
+
zAxis
|
|
51
|
+
} = (0, _useZAxis.useZAxis)();
|
|
38
52
|
const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
|
|
39
53
|
const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
|
|
40
|
-
|
|
54
|
+
const filteredZAxisIds = zAxisIds.filter(axisId => zAxis[axisId].colorMap !== undefined);
|
|
55
|
+
if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0 && filteredZAxisIds.length === 0) {
|
|
41
56
|
return null;
|
|
42
57
|
}
|
|
43
58
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("defs", {
|
|
44
59
|
children: [filteredYAxisIds.map(axisId => {
|
|
45
60
|
const gradientId = getGradientId(axisId, 'y');
|
|
61
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId, 'y');
|
|
46
62
|
const {
|
|
47
63
|
colorMap,
|
|
48
64
|
scale,
|
|
@@ -60,19 +76,27 @@ function ChartsAxesGradients() {
|
|
|
60
76
|
}, gradientId);
|
|
61
77
|
}
|
|
62
78
|
if (colorMap?.type === 'continuous') {
|
|
63
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
80
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
|
|
81
|
+
isReversed: !reverse,
|
|
82
|
+
scale: scale,
|
|
83
|
+
colorScale: colorScale,
|
|
84
|
+
colorMap: colorMap,
|
|
85
|
+
size: svgHeight,
|
|
86
|
+
gradientId: gradientId,
|
|
87
|
+
direction: "y"
|
|
88
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradientObjectBound.default, {
|
|
89
|
+
isReversed: reverse,
|
|
90
|
+
colorScale: colorScale,
|
|
91
|
+
colorMap: colorMap,
|
|
92
|
+
gradientId: objectBoundGradientId
|
|
93
|
+
})]
|
|
71
94
|
}, gradientId);
|
|
72
95
|
}
|
|
73
96
|
return null;
|
|
74
97
|
}), filteredXAxisIds.map(axisId => {
|
|
75
98
|
const gradientId = getGradientId(axisId, 'x');
|
|
99
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId, 'x');
|
|
76
100
|
const {
|
|
77
101
|
colorMap,
|
|
78
102
|
scale,
|
|
@@ -90,15 +114,36 @@ function ChartsAxesGradients() {
|
|
|
90
114
|
}, gradientId);
|
|
91
115
|
}
|
|
92
116
|
if (colorMap?.type === 'continuous') {
|
|
93
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
|
|
119
|
+
isReversed: reverse,
|
|
120
|
+
scale: scale,
|
|
121
|
+
colorScale: colorScale,
|
|
122
|
+
colorMap: colorMap,
|
|
123
|
+
size: svgWidth,
|
|
124
|
+
gradientId: gradientId,
|
|
125
|
+
direction: "x"
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradientObjectBound.default, {
|
|
127
|
+
isReversed: reverse,
|
|
128
|
+
colorScale: colorScale,
|
|
129
|
+
colorMap: colorMap,
|
|
130
|
+
gradientId: objectBoundGradientId
|
|
131
|
+
})]
|
|
132
|
+
}, gradientId);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}), filteredZAxisIds.map(axisId => {
|
|
136
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId, 'z');
|
|
137
|
+
const {
|
|
138
|
+
colorMap,
|
|
139
|
+
colorScale
|
|
140
|
+
} = zAxis[axisId];
|
|
141
|
+
if (colorMap?.type === 'continuous') {
|
|
142
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradientObjectBound.default, {
|
|
96
143
|
colorScale: colorScale,
|
|
97
144
|
colorMap: colorMap,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
direction: "x"
|
|
101
|
-
}, gradientId);
|
|
145
|
+
gradientId: objectBoundGradientId
|
|
146
|
+
}, objectBoundGradientId);
|
|
102
147
|
}
|
|
103
148
|
return null;
|
|
104
149
|
})]
|
|
@@ -20,14 +20,14 @@ function ChartsContinuousGradient(props) {
|
|
|
20
20
|
colorScale,
|
|
21
21
|
colorMap
|
|
22
22
|
} = props;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
23
|
+
const extremumValues = [colorMap.min ?? 0, colorMap.max ?? 100];
|
|
24
|
+
const extremumPositions = extremumValues.map(scale).filter(p => p !== undefined);
|
|
25
|
+
if (extremumPositions.length !== 2) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
|
-
const interpolator = typeof
|
|
29
|
-
const numberOfPoints = Math.round((Math.max(...
|
|
30
|
-
const keyPrefix = `${
|
|
28
|
+
const interpolator = typeof extremumValues[0] === 'number' ? (0, _d3Interpolate.interpolateNumber)(extremumValues[0], extremumValues[1]) : (0, _d3Interpolate.interpolateDate)(extremumValues[0], extremumValues[1]);
|
|
29
|
+
const numberOfPoints = Math.round((Math.max(...extremumPositions) - Math.min(...extremumPositions)) / PX_PRECISION);
|
|
30
|
+
const keyPrefix = `${extremumValues[0]}-${extremumValues[1]}-`;
|
|
31
31
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("linearGradient", {
|
|
32
32
|
id: gradientId,
|
|
33
33
|
x1: "0",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = ChartsContinuousGradientObjectBound;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
const PX_PRECISION = 10;
|
|
14
|
+
const getDirection = isReversed => {
|
|
15
|
+
if (isReversed) {
|
|
16
|
+
return {
|
|
17
|
+
x1: '1',
|
|
18
|
+
x2: '0',
|
|
19
|
+
y1: '0',
|
|
20
|
+
y2: '0'
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
x1: '0',
|
|
25
|
+
x2: '1',
|
|
26
|
+
y1: '0',
|
|
27
|
+
y2: '0'
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generates gradients to be used in tooltips and legends.
|
|
33
|
+
*/
|
|
34
|
+
function ChartsContinuousGradientObjectBound(props) {
|
|
35
|
+
const {
|
|
36
|
+
isReversed,
|
|
37
|
+
gradientId,
|
|
38
|
+
colorScale,
|
|
39
|
+
colorMap
|
|
40
|
+
} = props;
|
|
41
|
+
const extremumValues = [colorMap.min ?? 0, colorMap.max ?? 100];
|
|
42
|
+
const interpolator = typeof extremumValues[0] === 'number' ? (0, _d3Interpolate.interpolateNumber)(extremumValues[0], extremumValues[1]) : (0, _d3Interpolate.interpolateDate)(extremumValues[0], extremumValues[1]);
|
|
43
|
+
const numberOfPoints = PX_PRECISION;
|
|
44
|
+
const keyPrefix = `${extremumValues[0]}-${extremumValues[1]}-`;
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("linearGradient", (0, _extends2.default)({
|
|
46
|
+
id: gradientId
|
|
47
|
+
}, getDirection(isReversed), {
|
|
48
|
+
gradientUnits: 'objectBoundingBox' // Use the SVG coordinate instead of the component ones.
|
|
49
|
+
,
|
|
50
|
+
children: Array.from({
|
|
51
|
+
length: numberOfPoints + 1
|
|
52
|
+
}, (_, index) => {
|
|
53
|
+
const offset = index / numberOfPoints;
|
|
54
|
+
const value = interpolator(offset);
|
|
55
|
+
if (value === undefined) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const color = colorScale(value);
|
|
59
|
+
if (color === null) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("stop", {
|
|
63
|
+
offset: offset,
|
|
64
|
+
stopColor: color,
|
|
65
|
+
stopOpacity: 1
|
|
66
|
+
}, keyPrefix + index);
|
|
67
|
+
})
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
@@ -31,6 +31,9 @@ function ChartsPiecewiseGradient(props) {
|
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
const offset = isReversed ? 1 - x / size : x / size;
|
|
34
|
+
if (Number.isNaN(offset)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
34
37
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
35
38
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("stop", {
|
|
36
39
|
offset: offset,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsWrapper = ChartsWrapper;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _styles = require("@mui/material/styles");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const getDirection = (direction, position) => {
|
|
12
|
+
if (direction === 'vertical') {
|
|
13
|
+
if (position?.horizontal === 'left') {
|
|
14
|
+
return 'row';
|
|
15
|
+
}
|
|
16
|
+
return 'row-reverse';
|
|
17
|
+
}
|
|
18
|
+
if (position?.vertical === 'bottom') {
|
|
19
|
+
return 'column-reverse';
|
|
20
|
+
}
|
|
21
|
+
return 'column';
|
|
22
|
+
};
|
|
23
|
+
const getAlign = (direction, position) => {
|
|
24
|
+
if (direction === 'vertical') {
|
|
25
|
+
if (position?.vertical === 'top') {
|
|
26
|
+
return 'flex-start';
|
|
27
|
+
}
|
|
28
|
+
if (position?.vertical === 'bottom') {
|
|
29
|
+
return 'flex-end';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (direction === 'horizontal') {
|
|
33
|
+
if (position?.horizontal === 'left') {
|
|
34
|
+
return 'flex-start';
|
|
35
|
+
}
|
|
36
|
+
if (position?.horizontal === 'right') {
|
|
37
|
+
return 'flex-end';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return 'center';
|
|
41
|
+
};
|
|
42
|
+
const Root = (0, _styles.styled)('div', {
|
|
43
|
+
name: 'MuiChartsWrapper',
|
|
44
|
+
slot: 'Root',
|
|
45
|
+
overridesResolver: (props, styles) => styles.root
|
|
46
|
+
})(({
|
|
47
|
+
ownerState
|
|
48
|
+
}) => ({
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: getDirection(ownerState.legendDirection, ownerState.legendPosition),
|
|
51
|
+
flex: 1,
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition)
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @ignore - internal component.
|
|
58
|
+
*
|
|
59
|
+
* Wrapper for the charts components.
|
|
60
|
+
* Its main purpose is to position the HTML legend in the correct place.
|
|
61
|
+
*/
|
|
62
|
+
function ChartsWrapper(props) {
|
|
63
|
+
const {
|
|
64
|
+
children,
|
|
65
|
+
sx
|
|
66
|
+
} = props;
|
|
67
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
|
|
68
|
+
ownerState: props,
|
|
69
|
+
sx: sx,
|
|
70
|
+
children: children
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ChartsWrapper = require("./ChartsWrapper");
|
|
7
|
+
Object.keys(_ChartsWrapper).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ChartsWrapper[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ChartsWrapper[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.consumeSlots = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
|
|
13
|
+
var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
|
14
|
+
var React = _interopRequireWildcard(require("react"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
const _excluded = ["slots", "slotProps"],
|
|
17
|
+
_excluded2 = ["ownerState"];
|
|
18
|
+
/**
|
|
19
|
+
* A higher order component that consumes a slot from the props and renders the component provided in the slot.
|
|
20
|
+
*
|
|
21
|
+
* This HOC will wrap a single component, and will render the component provided in the slot, if it exists.
|
|
22
|
+
*
|
|
23
|
+
* If you need to render multiple components, you can manually consume the slots from the props and render them in your component instead of using this HOC.
|
|
24
|
+
*
|
|
25
|
+
* In the example below, `MyComponent` will render the component provided in `mySlot` slot, if it exists. Otherwise, it will render the `DefaultComponent`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* type MyComponentProps = {
|
|
31
|
+
* direction: 'row' | 'column';
|
|
32
|
+
* slots?: {
|
|
33
|
+
* mySlot?: React.JSXElementConstructor<{ direction: 'row' | 'column' }>;
|
|
34
|
+
* }
|
|
35
|
+
* };
|
|
36
|
+
*
|
|
37
|
+
* const MyComponent = consumeSlots(
|
|
38
|
+
* 'MuiMyComponent',
|
|
39
|
+
* 'mySlot',
|
|
40
|
+
* function DefaultComponent(props: MyComponentProps) {
|
|
41
|
+
* return (
|
|
42
|
+
* <div className={props.classes.root}>
|
|
43
|
+
* {props.direction}
|
|
44
|
+
* </div>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param {string} name The mui component name.
|
|
51
|
+
* @param {string} slotPropName The name of the prop to retrieve the slot from.
|
|
52
|
+
* @param {object} options Options for the HOC.
|
|
53
|
+
* @param {boolean} options.propagateSlots Whether to propagate the slots to the component, this is always false if the slot is provided.
|
|
54
|
+
* @param {Record<string, any>} options.defaultProps A set of defaults for the component, will be deep merged with the props.
|
|
55
|
+
* @param {Array<keyof Props>} options.omitProps An array of props to omit from the component.
|
|
56
|
+
* @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
|
|
57
|
+
* @param InComponent The component to render if the slot is not provided.
|
|
58
|
+
*/
|
|
59
|
+
const consumeSlots = (name, slotPropName, options, InComponent) => {
|
|
60
|
+
function ConsumeSlotsInternal(props, ref) {
|
|
61
|
+
const themedProps = (0, _styles.useThemeProps)({
|
|
62
|
+
props,
|
|
63
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
64
|
+
name
|
|
65
|
+
});
|
|
66
|
+
const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
|
|
67
|
+
const defaultizedProps = (0, _resolveProps.default)(defaultProps, themedProps);
|
|
68
|
+
const _ref = defaultizedProps,
|
|
69
|
+
{
|
|
70
|
+
slots,
|
|
71
|
+
slotProps
|
|
72
|
+
} = _ref,
|
|
73
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
74
|
+
const theme = (0, _styles.useTheme)();
|
|
75
|
+
const classes = options.classesResolver?.(defaultizedProps, theme);
|
|
76
|
+
|
|
77
|
+
// Can be a function component or a forward ref component.
|
|
78
|
+
const Component = slots?.[slotPropName] ?? InComponent;
|
|
79
|
+
const propagateSlots = options.propagateSlots && !slots?.[slotPropName];
|
|
80
|
+
const _useSlotProps = (0, _useSlotProps2.default)({
|
|
81
|
+
elementType: Component,
|
|
82
|
+
externalSlotProps: slotProps?.[slotPropName],
|
|
83
|
+
additionalProps: (0, _extends2.default)({}, other, {
|
|
84
|
+
classes
|
|
85
|
+
}, propagateSlots && {
|
|
86
|
+
slots,
|
|
87
|
+
slotProps
|
|
88
|
+
}),
|
|
89
|
+
ownerState: {}
|
|
90
|
+
}),
|
|
91
|
+
originalOutProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
|
|
92
|
+
const outProps = (0, _extends2.default)({}, originalOutProps);
|
|
93
|
+
for (const prop of options.omitProps ?? []) {
|
|
94
|
+
delete outProps[prop];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Component can be wrapped in React.forwardRef or just a function that accepts (props, ref).
|
|
98
|
+
// If it is a plain function which accepts two arguments, we need to wrap it in React.forwardRef.
|
|
99
|
+
const OutComponent = Component.length >= 2 ? /*#__PURE__*/React.forwardRef(Component) : Component;
|
|
100
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
101
|
+
OutComponent.displayName = `${name}.slots.${slotPropName}`;
|
|
102
|
+
}
|
|
103
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutComponent, (0, _extends2.default)({}, outProps, {
|
|
104
|
+
ref: ref
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/React.forwardRef(ConsumeSlotsInternal);
|
|
108
|
+
};
|
|
109
|
+
exports.consumeSlots = consumeSlots;
|
|
@@ -10,7 +10,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
10
10
|
var _styles = require("@mui/material/styles");
|
|
11
11
|
var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
-
var ReactIs = _interopRequireWildcard(require("react-is"));
|
|
14
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
14
|
/**
|
|
16
15
|
* A higher order component that consumes and merges the theme `defaultProps` and handles the `classes` and renders the component.
|
|
@@ -57,31 +56,23 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
57
56
|
* @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
|
|
58
57
|
* @param InComponent The component to render if the slot is not provided.
|
|
59
58
|
*/
|
|
60
|
-
const consumeThemeProps = (name, options, InComponent) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
InComponent.displayName = name;
|
|
74
|
-
}
|
|
75
|
-
const OutComponent = ReactIs.isForwardRef(InComponent) ? InComponent :
|
|
76
|
-
/*#__PURE__*/
|
|
77
|
-
// InComponent needs to be a function that accepts `(props, ref)`
|
|
78
|
-
// @ts-expect-error
|
|
79
|
-
React.forwardRef(InComponent);
|
|
80
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutComponent, (0, _extends2.default)({}, outProps, {
|
|
81
|
-
classes: classes,
|
|
82
|
-
ref: ref
|
|
83
|
-
}));
|
|
59
|
+
const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/React.forwardRef(function ConsumeThemeInternal(props, ref) {
|
|
60
|
+
const themedProps = (0, _styles.useThemeProps)({
|
|
61
|
+
props,
|
|
62
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
63
|
+
name
|
|
64
|
+
});
|
|
65
|
+
const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
|
|
66
|
+
const outProps = (0, _resolveProps.default)(defaultProps, themedProps);
|
|
67
|
+
const theme = (0, _styles.useTheme)();
|
|
68
|
+
const classes = options.classesResolver?.(outProps, theme);
|
|
69
|
+
const OutComponent = /*#__PURE__*/React.forwardRef(InComponent);
|
|
70
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
71
|
+
OutComponent.displayName = `consumeThemeProps(${name})`;
|
|
84
72
|
}
|
|
85
|
-
return /*#__PURE__*/
|
|
86
|
-
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutComponent, (0, _extends2.default)({}, outProps, {
|
|
74
|
+
classes: classes,
|
|
75
|
+
ref: ref
|
|
76
|
+
}));
|
|
77
|
+
});
|
|
87
78
|
exports.consumeThemeProps = consumeThemeProps;
|
package/node/internals/index.js
CHANGED
|
@@ -73,6 +73,18 @@ Object.keys(_ChartsAxesGradients).forEach(function (key) {
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
+
var _ChartsWrapper = require("./components/ChartsWrapper");
|
|
77
|
+
Object.keys(_ChartsWrapper).forEach(function (key) {
|
|
78
|
+
if (key === "default" || key === "__esModule") return;
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
|
+
if (key in exports && exports[key] === _ChartsWrapper[key]) return;
|
|
81
|
+
Object.defineProperty(exports, key, {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return _ChartsWrapper[key];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
76
88
|
var _useSeries = require("../hooks/useSeries");
|
|
77
89
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
78
90
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.7",
|
|
4
4
|
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"@react-spring/web": "^9.7.5",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"prop-types": "^15.8.1",
|
|
38
|
-
"react-is": "^18.3.1",
|
|
38
|
+
"react-is": "^18.3.1 || ^19.0.0",
|
|
39
39
|
"reselect": "^5.1.1",
|
|
40
40
|
"use-sync-external-store": "^1.4.0",
|
|
41
|
-
"@mui/x-charts-vendor": "8.0.0-alpha.
|
|
42
|
-
"@mui/x-internals": "8.0.0-alpha.
|
|
41
|
+
"@mui/x-charts-vendor": "8.0.0-alpha.7",
|
|
42
|
+
"@mui/x-internals": "8.0.0-alpha.7"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.9.0",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ChartsTextStyle } from '../ChartsText';
|
|
3
|
-
import { LegendItemParams } from './chartsLegend.types';
|
|
4
|
-
import { ChartsLegendClasses } from './chartsLegendClasses';
|
|
5
|
-
export interface ChartsLegendItemProps extends LegendItemParams {
|
|
6
|
-
positionY: number;
|
|
7
|
-
label: string;
|
|
8
|
-
positionX: number;
|
|
9
|
-
innerHeight: number;
|
|
10
|
-
innerWidth: number;
|
|
11
|
-
color: string;
|
|
12
|
-
gapX: number;
|
|
13
|
-
gapY: number;
|
|
14
|
-
legendWidth: number;
|
|
15
|
-
itemMarkHeight: number;
|
|
16
|
-
itemMarkWidth: number;
|
|
17
|
-
markGap: number;
|
|
18
|
-
labelStyle: ChartsTextStyle;
|
|
19
|
-
classes?: Omit<Partial<ChartsLegendClasses>, 'column' | 'row' | 'label'>;
|
|
20
|
-
onClick?: (event: React.MouseEvent<SVGRectElement, MouseEvent>) => void;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @ignore - internal component.
|
|
24
|
-
*/
|
|
25
|
-
declare function ChartsLegendItem(props: ChartsLegendItemProps): React.JSX.Element;
|
|
26
|
-
export { ChartsLegendItem };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { useRtl } from '@mui/system/RtlProvider';
|
|
5
|
-
import { ChartsText } from "../ChartsText/index.js";
|
|
6
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
/**
|
|
8
|
-
* @ignore - internal component.
|
|
9
|
-
*/
|
|
10
|
-
function ChartsLegendItem(props) {
|
|
11
|
-
const isRTL = useRtl();
|
|
12
|
-
const {
|
|
13
|
-
id,
|
|
14
|
-
positionY,
|
|
15
|
-
label,
|
|
16
|
-
positionX,
|
|
17
|
-
innerHeight,
|
|
18
|
-
innerWidth,
|
|
19
|
-
legendWidth,
|
|
20
|
-
color,
|
|
21
|
-
gapX,
|
|
22
|
-
gapY,
|
|
23
|
-
itemMarkHeight,
|
|
24
|
-
itemMarkWidth,
|
|
25
|
-
markGap,
|
|
26
|
-
labelStyle,
|
|
27
|
-
classes,
|
|
28
|
-
onClick
|
|
29
|
-
} = props;
|
|
30
|
-
return /*#__PURE__*/_jsxs("g", {
|
|
31
|
-
className: clsx(classes?.series, `${classes?.series}-${id}`),
|
|
32
|
-
transform: `translate(${gapX + (isRTL ? legendWidth - positionX : positionX)} ${gapY + positionY})`,
|
|
33
|
-
children: [/*#__PURE__*/_jsx("rect", {
|
|
34
|
-
x: isRTL ? -(innerWidth + 2) : -2,
|
|
35
|
-
y: -itemMarkHeight / 2 - 2,
|
|
36
|
-
width: innerWidth + 4,
|
|
37
|
-
height: innerHeight + 4,
|
|
38
|
-
fill: "transparent",
|
|
39
|
-
className: classes?.itemBackground,
|
|
40
|
-
onClick: onClick,
|
|
41
|
-
style: {
|
|
42
|
-
pointerEvents: onClick ? 'all' : 'none',
|
|
43
|
-
cursor: onClick ? 'pointer' : 'unset'
|
|
44
|
-
}
|
|
45
|
-
}), /*#__PURE__*/_jsx("rect", {
|
|
46
|
-
className: classes?.mark,
|
|
47
|
-
x: isRTL ? -itemMarkWidth : 0,
|
|
48
|
-
y: -itemMarkHeight / 2,
|
|
49
|
-
width: itemMarkWidth,
|
|
50
|
-
height: itemMarkHeight,
|
|
51
|
-
fill: color,
|
|
52
|
-
style: {
|
|
53
|
-
pointerEvents: 'none'
|
|
54
|
-
}
|
|
55
|
-
}), /*#__PURE__*/_jsx(ChartsText, {
|
|
56
|
-
style: _extends({
|
|
57
|
-
pointerEvents: 'none'
|
|
58
|
-
}, labelStyle),
|
|
59
|
-
text: label,
|
|
60
|
-
x: (isRTL ? -1 : 1) * (itemMarkWidth + markGap),
|
|
61
|
-
y: 0
|
|
62
|
-
})]
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
export { ChartsLegendItem };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { FormattedSeries } from '../context/SeriesProvider';
|
|
3
|
-
import { LegendPerItemProps } from './LegendPerItem';
|
|
4
|
-
import { SeriesLegendItemContext } from './chartsLegend.types';
|
|
5
|
-
export interface LegendRendererProps extends Omit<LegendPerItemProps, 'itemsToDisplay' | 'onItemClick'> {
|
|
6
|
-
series: FormattedSeries;
|
|
7
|
-
seriesToDisplay: LegendPerItemProps['itemsToDisplay'];
|
|
8
|
-
/**
|
|
9
|
-
* Callback fired when a legend item is clicked.
|
|
10
|
-
* @param {React.MouseEvent<SVGRectElement, MouseEvent>} event The click event.
|
|
11
|
-
* @param {SeriesLegendItemContext} legendItem The legend item data.
|
|
12
|
-
* @param {number} index The index of the clicked legend item.
|
|
13
|
-
*/
|
|
14
|
-
onItemClick?: (event: React.MouseEvent<SVGRectElement, MouseEvent>, legendItem: SeriesLegendItemContext, index: number) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Set to true to hide the legend.
|
|
17
|
-
* @default false
|
|
18
|
-
*/
|
|
19
|
-
hidden?: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare function DefaultChartsLegend(props: LegendRendererProps): React.JSX.Element | null;
|
|
22
|
-
declare namespace DefaultChartsLegend {
|
|
23
|
-
var propTypes: any;
|
|
24
|
-
}
|
|
25
|
-
export { DefaultChartsLegend };
|