@mui/x-charts 8.0.0-alpha.6 → 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 +127 -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,327 +1,210 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
const _excluded = ["minLabel", "maxLabel", "direction", "axisDirection", "axisId", "rotateGradient", "reverse", "classes", "className", "gradientId", "labelPosition", "thickness"];
|
|
4
6
|
import * as React from 'react';
|
|
5
7
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import ChartsContinuousGradient from "../internals/components/ChartsAxesGradients/ChartsContinuousGradient.js";
|
|
9
|
-
import { useChartId, useDrawingArea } from "../hooks/index.js";
|
|
10
|
-
import { getScale } from "../internals/getScale.js";
|
|
11
|
-
import { getPercentageValue } from "../internals/getPercentageValue.js";
|
|
12
|
-
import { ChartsText } from "../ChartsText/index.js";
|
|
13
|
-
import { getStringSize } from "../internals/domUtils.js";
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import clsx from 'clsx';
|
|
14
10
|
import { useAxis } from "./useAxis.js";
|
|
11
|
+
import { ChartsLabel } from "../ChartsLabel/ChartsLabel.js";
|
|
12
|
+
import { ChartsLabelGradient } from "../ChartsLabel/ChartsLabelGradient.js";
|
|
13
|
+
import { consumeThemeProps } from "../internals/consumeThemeProps.js";
|
|
14
|
+
import { continuousColorLegendClasses, useUtilityClasses } from "./continuousColorLegendClasses.js";
|
|
15
|
+
import { useChartGradientObjectBound } from "../internals/components/ChartsAxesGradients/index.js";
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
switch (position.horizontal) {
|
|
20
|
-
case 'left':
|
|
21
|
-
offsetX = 0;
|
|
22
|
-
break;
|
|
23
|
-
case 'middle':
|
|
24
|
-
offsetX = (svgBox.width - legendBox.width) / 2;
|
|
25
|
-
break;
|
|
26
|
-
case 'right':
|
|
27
|
-
default:
|
|
28
|
-
offsetX = svgBox.width - legendBox.width;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
switch (position.vertical) {
|
|
32
|
-
case 'top':
|
|
33
|
-
offsetY = 0;
|
|
34
|
-
break;
|
|
35
|
-
case 'middle':
|
|
36
|
-
offsetY = (svgBox.height - legendBox.height) / 2;
|
|
37
|
-
break;
|
|
38
|
-
case 'bottom':
|
|
39
|
-
default:
|
|
40
|
-
offsetY = svgBox.height - legendBox.height;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
17
|
+
const templateAreas = reverse => {
|
|
18
|
+
const startLabel = reverse ? 'max-label' : 'min-label';
|
|
19
|
+
const endLabel = reverse ? 'min-label' : 'max-label';
|
|
43
20
|
return {
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
row: {
|
|
22
|
+
start: `
|
|
23
|
+
'${startLabel} . ${endLabel}'
|
|
24
|
+
'gradient gradient gradient'
|
|
25
|
+
`,
|
|
26
|
+
end: `
|
|
27
|
+
'gradient gradient gradient'
|
|
28
|
+
'${startLabel} . ${endLabel}'
|
|
29
|
+
`,
|
|
30
|
+
extremes: `
|
|
31
|
+
'${startLabel} gradient ${endLabel}'
|
|
32
|
+
`
|
|
33
|
+
},
|
|
34
|
+
column: {
|
|
35
|
+
start: `
|
|
36
|
+
'${endLabel} gradient'
|
|
37
|
+
'. gradient'
|
|
38
|
+
'${startLabel} gradient'
|
|
39
|
+
`,
|
|
40
|
+
end: `
|
|
41
|
+
'gradient ${endLabel}'
|
|
42
|
+
'gradient .'
|
|
43
|
+
'gradient ${startLabel}'
|
|
44
|
+
`,
|
|
45
|
+
extremes: `
|
|
46
|
+
'${endLabel}'
|
|
47
|
+
'gradient'
|
|
48
|
+
'${startLabel}'
|
|
49
|
+
`
|
|
50
|
+
}
|
|
46
51
|
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
text2: _extends({}, text2, {
|
|
80
|
-
textAnchor: 'start',
|
|
81
|
-
x: 0
|
|
82
|
-
}),
|
|
83
|
-
bar: _extends({}, bar, {
|
|
84
|
-
x: 0
|
|
85
|
-
}),
|
|
86
|
-
boundingBox
|
|
87
|
-
};
|
|
88
|
-
case 'end':
|
|
89
|
-
return {
|
|
90
|
-
text1: _extends({}, text1, {
|
|
91
|
-
textAnchor: 'end',
|
|
92
|
-
x: totalWidth
|
|
93
|
-
}),
|
|
94
|
-
text2: _extends({}, text2, {
|
|
95
|
-
textAnchor: 'end',
|
|
96
|
-
x: totalWidth
|
|
97
|
-
}),
|
|
98
|
-
bar: _extends({}, bar, {
|
|
99
|
-
x: totalWidth - barBox.width
|
|
100
|
-
}),
|
|
101
|
-
boundingBox
|
|
102
|
-
};
|
|
103
|
-
case 'middle':
|
|
104
|
-
default:
|
|
105
|
-
return {
|
|
106
|
-
text1: _extends({}, text1, {
|
|
107
|
-
textAnchor: 'middle',
|
|
108
|
-
x: totalWidth / 2
|
|
109
|
-
}),
|
|
110
|
-
text2: _extends({}, text2, {
|
|
111
|
-
textAnchor: 'middle',
|
|
112
|
-
x: totalWidth / 2
|
|
113
|
-
}),
|
|
114
|
-
bar: _extends({}, bar, {
|
|
115
|
-
x: totalWidth / 2 - barBox.width / 2
|
|
116
|
-
}),
|
|
117
|
-
boundingBox
|
|
118
|
-
};
|
|
52
|
+
};
|
|
53
|
+
const RootElement = styled('ul', {
|
|
54
|
+
name: 'MuiContinuousColorLegend',
|
|
55
|
+
slot: 'Root',
|
|
56
|
+
overridesResolver: (props, styles) => styles.root
|
|
57
|
+
})(({
|
|
58
|
+
theme,
|
|
59
|
+
ownerState
|
|
60
|
+
}) => _extends({}, theme.typography.caption, {
|
|
61
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
62
|
+
lineHeight: '100%',
|
|
63
|
+
display: 'grid',
|
|
64
|
+
flexShrink: 0,
|
|
65
|
+
gap: theme.spacing(0.5),
|
|
66
|
+
listStyleType: 'none',
|
|
67
|
+
paddingInlineStart: 0,
|
|
68
|
+
marginBlock: theme.spacing(1),
|
|
69
|
+
marginInline: theme.spacing(1),
|
|
70
|
+
[`&.${continuousColorLegendClasses.horizontal}`]: {
|
|
71
|
+
gridTemplateRows: 'min-content min-content',
|
|
72
|
+
gridTemplateColumns: 'min-content auto min-content',
|
|
73
|
+
[`&.${continuousColorLegendClasses.start}`]: {
|
|
74
|
+
gridTemplateAreas: templateAreas(ownerState.reverse).row.start
|
|
75
|
+
},
|
|
76
|
+
[`&.${continuousColorLegendClasses.end}`]: {
|
|
77
|
+
gridTemplateAreas: templateAreas(ownerState.reverse).row.end
|
|
78
|
+
},
|
|
79
|
+
[`&.${continuousColorLegendClasses.extremes}`]: {
|
|
80
|
+
gridTemplateAreas: templateAreas(ownerState.reverse).row.extremes,
|
|
81
|
+
gridTemplateRows: 'min-content',
|
|
82
|
+
alignItems: 'center'
|
|
119
83
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
dominantBaseline: 'hanging',
|
|
143
|
-
y: 0
|
|
144
|
-
}),
|
|
145
|
-
text2: _extends({}, text2, {
|
|
146
|
-
dominantBaseline: 'hanging',
|
|
147
|
-
y: 0
|
|
148
|
-
}),
|
|
149
|
-
bar: _extends({}, bar, {
|
|
150
|
-
y: 0
|
|
151
|
-
}),
|
|
152
|
-
boundingBox
|
|
153
|
-
};
|
|
154
|
-
case 'end':
|
|
155
|
-
return {
|
|
156
|
-
text1: _extends({}, text1, {
|
|
157
|
-
dominantBaseline: 'auto',
|
|
158
|
-
y: totalHeight
|
|
159
|
-
}),
|
|
160
|
-
text2: _extends({}, text2, {
|
|
161
|
-
dominantBaseline: 'auto',
|
|
162
|
-
y: totalHeight
|
|
163
|
-
}),
|
|
164
|
-
bar: _extends({}, bar, {
|
|
165
|
-
y: totalHeight - barBox.height
|
|
166
|
-
}),
|
|
167
|
-
boundingBox
|
|
168
|
-
};
|
|
169
|
-
case 'middle':
|
|
170
|
-
default:
|
|
171
|
-
return {
|
|
172
|
-
text1: _extends({}, text1, {
|
|
173
|
-
dominantBaseline: 'central',
|
|
174
|
-
y: totalHeight / 2
|
|
175
|
-
}),
|
|
176
|
-
text2: _extends({}, text2, {
|
|
177
|
-
dominantBaseline: 'central',
|
|
178
|
-
y: totalHeight / 2
|
|
179
|
-
}),
|
|
180
|
-
bar: _extends({}, bar, {
|
|
181
|
-
y: totalHeight / 2 - barBox.height / 2
|
|
182
|
-
}),
|
|
183
|
-
boundingBox
|
|
184
|
-
};
|
|
84
|
+
},
|
|
85
|
+
[`&.${continuousColorLegendClasses.vertical}`]: {
|
|
86
|
+
gridTemplateRows: 'min-content auto min-content',
|
|
87
|
+
gridTemplateColumns: 'min-content min-content',
|
|
88
|
+
[`&.${continuousColorLegendClasses.start}`]: {
|
|
89
|
+
gridTemplateAreas: templateAreas(ownerState.reverse).column.start,
|
|
90
|
+
[`.${continuousColorLegendClasses.maxLabel}, .${continuousColorLegendClasses.minLabel}`]: {
|
|
91
|
+
justifySelf: 'end'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
[`&.${continuousColorLegendClasses.end}`]: {
|
|
95
|
+
gridTemplateAreas: templateAreas(ownerState.reverse).column.end,
|
|
96
|
+
[`.${continuousColorLegendClasses.maxLabel}, .${continuousColorLegendClasses.minLabel}`]: {
|
|
97
|
+
justifySelf: 'start'
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[`&.${continuousColorLegendClasses.extremes}`]: {
|
|
101
|
+
gridTemplateAreas: templateAreas(ownerState.reverse).column.extremes,
|
|
102
|
+
gridTemplateColumns: 'min-content',
|
|
103
|
+
[`.${continuousColorLegendClasses.maxLabel}, .${continuousColorLegendClasses.minLabel}`]: {
|
|
104
|
+
justifySelf: 'center'
|
|
105
|
+
}
|
|
185
106
|
}
|
|
107
|
+
},
|
|
108
|
+
[`.${continuousColorLegendClasses.gradient}`]: {
|
|
109
|
+
gridArea: 'gradient'
|
|
110
|
+
},
|
|
111
|
+
[`.${continuousColorLegendClasses.maxLabel}`]: {
|
|
112
|
+
gridArea: 'max-label'
|
|
113
|
+
},
|
|
114
|
+
[`.${continuousColorLegendClasses.minLabel}`]: {
|
|
115
|
+
gridArea: 'min-label'
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
const getText = (label, value, formattedValue) => {
|
|
119
|
+
if (typeof label === 'string') {
|
|
120
|
+
return label;
|
|
186
121
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
122
|
+
return label?.({
|
|
123
|
+
value,
|
|
124
|
+
formattedValue
|
|
125
|
+
}) ?? formattedValue;
|
|
126
|
+
};
|
|
127
|
+
const ContinuousColorLegend = consumeThemeProps('MuiContinuousColorLegend', {
|
|
128
|
+
defaultProps: {
|
|
129
|
+
direction: 'horizontal',
|
|
130
|
+
labelPosition: 'end',
|
|
131
|
+
axisDirection: 'z'
|
|
132
|
+
},
|
|
133
|
+
classesResolver: useUtilityClasses
|
|
134
|
+
}, function ContinuousColorLegend(props, ref) {
|
|
194
135
|
const {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const chartId = useChartId();
|
|
210
|
-
const id = idProp ?? `gradient-legend-${chartId}`;
|
|
136
|
+
minLabel,
|
|
137
|
+
maxLabel,
|
|
138
|
+
direction,
|
|
139
|
+
axisDirection,
|
|
140
|
+
axisId,
|
|
141
|
+
rotateGradient,
|
|
142
|
+
reverse,
|
|
143
|
+
classes,
|
|
144
|
+
className,
|
|
145
|
+
gradientId,
|
|
146
|
+
thickness
|
|
147
|
+
} = props,
|
|
148
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
149
|
+
const generateGradientId = useChartGradientObjectBound();
|
|
211
150
|
const axisItem = useAxis({
|
|
212
151
|
axisDirection,
|
|
213
152
|
axisId
|
|
214
153
|
});
|
|
215
|
-
const {
|
|
216
|
-
width,
|
|
217
|
-
height,
|
|
218
|
-
left,
|
|
219
|
-
right,
|
|
220
|
-
top,
|
|
221
|
-
bottom
|
|
222
|
-
} = useDrawingArea();
|
|
223
|
-
const refLength = direction === 'column' ? height + top + bottom : width + left + right;
|
|
224
|
-
const size = getPercentageValue(length, refLength);
|
|
225
|
-
const isReversed = direction === 'column';
|
|
226
154
|
const colorMap = axisItem?.colorMap;
|
|
227
155
|
if (!colorMap || !colorMap.type || colorMap.type !== 'continuous') {
|
|
228
156
|
return null;
|
|
229
157
|
}
|
|
230
|
-
|
|
231
|
-
// Define the coordinate to color mapping
|
|
232
|
-
|
|
233
|
-
const colorScale = axisItem.colorScale;
|
|
234
158
|
const minValue = colorMap.min ?? 0;
|
|
235
159
|
const maxValue = colorMap.max ?? 100;
|
|
236
|
-
const scale = getScale(scaleType, [minValue, maxValue], isReversed ? [size, 0] : [0, size]);
|
|
237
160
|
|
|
238
161
|
// Get texts to display
|
|
239
162
|
|
|
240
|
-
const
|
|
163
|
+
const valueFormatter = axisItem?.valueFormatter;
|
|
164
|
+
const formattedMin = valueFormatter ? valueFormatter(minValue, {
|
|
241
165
|
location: 'legend'
|
|
242
|
-
})
|
|
243
|
-
const formattedMax =
|
|
166
|
+
}) : minValue.toLocaleString();
|
|
167
|
+
const formattedMax = valueFormatter ? valueFormatter(maxValue, {
|
|
244
168
|
location: 'legend'
|
|
245
|
-
})
|
|
246
|
-
const minText =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const text1 = isReversed ? maxText : minText;
|
|
255
|
-
const text2 = isReversed ? minText : maxText;
|
|
256
|
-
const text1Box = getStringSize(text1, _extends({}, labelStyle));
|
|
257
|
-
const text2Box = getStringSize(text2, _extends({}, labelStyle));
|
|
258
|
-
|
|
259
|
-
// Place bar and texts
|
|
260
|
-
|
|
261
|
-
const barBox = direction === 'column' || isRtl && direction === 'row' ? {
|
|
262
|
-
width: thickness,
|
|
263
|
-
height: size
|
|
264
|
-
} : {
|
|
265
|
-
width: size,
|
|
266
|
-
height: thickness
|
|
267
|
-
};
|
|
268
|
-
const legendPositions = getElementPositions(text1Box, barBox, text2Box, {
|
|
269
|
-
spacing,
|
|
270
|
-
align,
|
|
271
|
-
direction
|
|
169
|
+
}) : maxValue.toLocaleString();
|
|
170
|
+
const minText = getText(minLabel, minValue, formattedMin);
|
|
171
|
+
const maxText = getText(maxLabel, maxValue, formattedMax);
|
|
172
|
+
const minComponent = /*#__PURE__*/_jsx("li", {
|
|
173
|
+
className: classes?.minLabel,
|
|
174
|
+
children: /*#__PURE__*/_jsx(ChartsLabel, {
|
|
175
|
+
className: classes?.label,
|
|
176
|
+
children: minText
|
|
177
|
+
})
|
|
272
178
|
});
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
vertical: 'top'
|
|
280
|
-
}, position), legendPositions.boundingBox, svgBoundingBox);
|
|
281
|
-
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
282
|
-
children: [/*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
283
|
-
isReversed: isReversed,
|
|
284
|
-
gradientId: id,
|
|
285
|
-
size: size,
|
|
286
|
-
direction: direction === 'row' ? 'x' : 'y',
|
|
287
|
-
scale: scale,
|
|
288
|
-
colorScale: colorScale,
|
|
289
|
-
colorMap: colorMap,
|
|
290
|
-
gradientUnits: "objectBoundingBox"
|
|
291
|
-
}), /*#__PURE__*/_jsx(ChartsText, {
|
|
292
|
-
text: text1,
|
|
293
|
-
x: positionOffset.offsetX + legendPositions.text1.x,
|
|
294
|
-
y: positionOffset.offsetY + legendPositions.text1.y,
|
|
295
|
-
style: _extends({
|
|
296
|
-
dominantBaseline: legendPositions.text1.dominantBaseline,
|
|
297
|
-
textAnchor: legendPositions.text1.textAnchor
|
|
298
|
-
}, labelStyle)
|
|
299
|
-
}), /*#__PURE__*/_jsx("rect", _extends({
|
|
300
|
-
x: positionOffset.offsetX + legendPositions.bar.x,
|
|
301
|
-
y: positionOffset.offsetY + legendPositions.bar.y
|
|
302
|
-
}, barBox, {
|
|
303
|
-
fill: `url(#${id})`
|
|
304
|
-
})), /*#__PURE__*/_jsx(ChartsText, {
|
|
305
|
-
text: text2,
|
|
306
|
-
x: positionOffset.offsetX + legendPositions.text2.x,
|
|
307
|
-
y: positionOffset.offsetY + legendPositions.text2.y,
|
|
308
|
-
style: _extends({
|
|
309
|
-
dominantBaseline: legendPositions.text2.dominantBaseline,
|
|
310
|
-
textAnchor: legendPositions.text2.textAnchor
|
|
311
|
-
}, labelStyle)
|
|
312
|
-
})]
|
|
179
|
+
const maxComponent = /*#__PURE__*/_jsx("li", {
|
|
180
|
+
className: classes?.maxLabel,
|
|
181
|
+
children: /*#__PURE__*/_jsx(ChartsLabel, {
|
|
182
|
+
className: classes?.label,
|
|
183
|
+
children: maxText
|
|
184
|
+
})
|
|
313
185
|
});
|
|
314
|
-
|
|
186
|
+
return /*#__PURE__*/_jsxs(RootElement, _extends({
|
|
187
|
+
className: clsx(classes?.root, className),
|
|
188
|
+
ref: ref
|
|
189
|
+
}, other, {
|
|
190
|
+
ownerState: props,
|
|
191
|
+
children: [reverse ? maxComponent : minComponent, /*#__PURE__*/_jsx("li", {
|
|
192
|
+
className: classes?.gradient,
|
|
193
|
+
children: /*#__PURE__*/_jsx(ChartsLabelGradient, {
|
|
194
|
+
direction: direction,
|
|
195
|
+
rotate: rotateGradient,
|
|
196
|
+
reverse: reverse,
|
|
197
|
+
thickness: thickness,
|
|
198
|
+
gradientId: gradientId ?? generateGradientId(axisItem.id, axisDirection)
|
|
199
|
+
})
|
|
200
|
+
}), reverse ? minComponent : maxComponent]
|
|
201
|
+
}));
|
|
202
|
+
});
|
|
315
203
|
process.env.NODE_ENV !== "production" ? ContinuousColorLegend.propTypes = {
|
|
316
204
|
// ----------------------------- Warning --------------------------------
|
|
317
205
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
318
206
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
319
207
|
// ----------------------------------------------------------------------
|
|
320
|
-
/**
|
|
321
|
-
* The alignment of the texts with the gradient bar.
|
|
322
|
-
* @default 'middle'
|
|
323
|
-
*/
|
|
324
|
-
align: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
325
208
|
/**
|
|
326
209
|
* The axis direction containing the color configuration to represent.
|
|
327
210
|
* @default 'z'
|
|
@@ -333,61 +216,55 @@ process.env.NODE_ENV !== "production" ? ContinuousColorLegend.propTypes = {
|
|
|
333
216
|
*/
|
|
334
217
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
335
218
|
/**
|
|
336
|
-
*
|
|
337
|
-
* The default depends on the chart.
|
|
219
|
+
* Override or extend the styles applied to the component.
|
|
338
220
|
*/
|
|
339
|
-
|
|
221
|
+
classes: PropTypes.object,
|
|
222
|
+
className: PropTypes.string,
|
|
340
223
|
/**
|
|
341
|
-
*
|
|
342
|
-
* @default
|
|
224
|
+
* The direction of the legend layout.
|
|
225
|
+
* @default 'horizontal'
|
|
343
226
|
*/
|
|
344
|
-
|
|
227
|
+
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
345
228
|
/**
|
|
346
|
-
* The
|
|
347
|
-
*
|
|
229
|
+
* The id for the gradient to use.
|
|
230
|
+
* If not provided, it will use the generated gradient from the axis configuration.
|
|
231
|
+
* The `gradientId` will be used as `fill="url(#gradientId)"`.
|
|
232
|
+
* @default auto-generated id
|
|
348
233
|
*/
|
|
349
|
-
|
|
234
|
+
gradientId: PropTypes.string,
|
|
350
235
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
* The '100%' is the length of the svg.
|
|
354
|
-
* @default '50%'
|
|
236
|
+
* Where to position the labels relative to the gradient.
|
|
237
|
+
* @default 'end'
|
|
355
238
|
*/
|
|
356
|
-
|
|
239
|
+
labelPosition: PropTypes.oneOf(['start', 'end', 'extremes']),
|
|
357
240
|
/**
|
|
358
241
|
* The label to display at the maximum side of the gradient.
|
|
359
242
|
* Can either be a string, or a function.
|
|
360
243
|
* If not defined, the formatted maximal value is display.
|
|
361
|
-
* @default
|
|
244
|
+
* @default formattedValue
|
|
362
245
|
*/
|
|
363
246
|
maxLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
364
247
|
/**
|
|
365
248
|
* The label to display at the minimum side of the gradient.
|
|
366
249
|
* Can either be a string, or a function.
|
|
367
|
-
* @default
|
|
250
|
+
* @default formattedValue
|
|
368
251
|
*/
|
|
369
252
|
minLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
370
253
|
/**
|
|
371
|
-
*
|
|
372
|
-
|
|
373
|
-
position: PropTypes.shape({
|
|
374
|
-
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
375
|
-
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
376
|
-
}),
|
|
377
|
-
/**
|
|
378
|
-
* The scale used to display gradient colors.
|
|
379
|
-
* @default 'linear'
|
|
254
|
+
* If `true`, the gradient and labels will be reversed.
|
|
255
|
+
* @default false
|
|
380
256
|
*/
|
|
381
|
-
|
|
257
|
+
reverse: PropTypes.bool,
|
|
382
258
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
259
|
+
* If provided, the gradient will be rotated by 90deg.
|
|
260
|
+
* Useful for linear gradients that are not in the correct orientation.
|
|
385
261
|
*/
|
|
386
|
-
|
|
262
|
+
rotateGradient: PropTypes.bool,
|
|
387
263
|
/**
|
|
388
|
-
* The thickness of the gradient
|
|
389
|
-
* @default
|
|
264
|
+
* The thickness of the gradient
|
|
265
|
+
* @default 12
|
|
390
266
|
*/
|
|
391
|
-
thickness: PropTypes.number
|
|
267
|
+
thickness: PropTypes.number,
|
|
268
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
392
269
|
} : void 0;
|
|
393
270
|
export { ContinuousColorLegend };
|