@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
|
@@ -5,6 +5,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className", "experimentalMarkRendering"];
|
|
6
6
|
import useId from '@mui/utils/useId';
|
|
7
7
|
import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|
|
8
|
+
import { calculateMargins } from "../internals/calculateMargins.js";
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* A helper function that extracts LineChartProps from the input props
|
|
10
12
|
* and returns an object with props for the children components of LineChart.
|
|
@@ -29,6 +31,7 @@ export const useLineChartProps = props => {
|
|
|
29
31
|
onMarkClick,
|
|
30
32
|
axisHighlight,
|
|
31
33
|
disableLineItemHighlight,
|
|
34
|
+
hideLegend,
|
|
32
35
|
grid,
|
|
33
36
|
topAxis,
|
|
34
37
|
leftAxis,
|
|
@@ -54,7 +57,12 @@ export const useLineChartProps = props => {
|
|
|
54
57
|
}, s)),
|
|
55
58
|
width,
|
|
56
59
|
height,
|
|
57
|
-
margin
|
|
60
|
+
margin: calculateMargins({
|
|
61
|
+
margin,
|
|
62
|
+
hideLegend,
|
|
63
|
+
slotProps,
|
|
64
|
+
series
|
|
65
|
+
}),
|
|
58
66
|
colors,
|
|
59
67
|
dataset,
|
|
60
68
|
xAxis: xAxis ?? [{
|
|
@@ -65,7 +73,6 @@ export const useLineChartProps = props => {
|
|
|
65
73
|
}, (_, index) => index)
|
|
66
74
|
}],
|
|
67
75
|
yAxis,
|
|
68
|
-
sx,
|
|
69
76
|
highlightedItem,
|
|
70
77
|
onHighlightChange,
|
|
71
78
|
disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
@@ -126,7 +133,13 @@ export const useLineChartProps = props => {
|
|
|
126
133
|
slots,
|
|
127
134
|
slotProps
|
|
128
135
|
};
|
|
136
|
+
const chartsWrapperProps = {
|
|
137
|
+
sx,
|
|
138
|
+
legendPosition: props.slotProps?.legend?.position,
|
|
139
|
+
legendDirection: props.slotProps?.legend?.direction
|
|
140
|
+
};
|
|
129
141
|
return {
|
|
142
|
+
chartsWrapperProps,
|
|
130
143
|
chartContainerProps,
|
|
131
144
|
axisClickHandlerProps,
|
|
132
145
|
gridProps,
|
|
@@ -76,7 +76,9 @@ function PieArc(props) {
|
|
|
76
76
|
innerRadius: iR,
|
|
77
77
|
outerRadius: oR
|
|
78
78
|
})),
|
|
79
|
-
visibility: to([startAngle, endAngle], (sA, eA) => sA === eA ? 'hidden' : 'visible')
|
|
79
|
+
visibility: to([startAngle, endAngle], (sA, eA) => sA === eA ? 'hidden' : 'visible')
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
,
|
|
80
82
|
onClick: onClick,
|
|
81
83
|
cursor: onClick ? 'pointer' : 'unset',
|
|
82
84
|
ownerState: ownerState,
|
|
@@ -84,15 +84,19 @@ function PieArcLabel(props) {
|
|
|
84
84
|
isHighlighted
|
|
85
85
|
};
|
|
86
86
|
const classes = useUtilityClasses(ownerState);
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
return (
|
|
88
|
+
/*#__PURE__*/
|
|
89
|
+
// @ts-expect-error
|
|
90
|
+
_jsx(PieArcLabelRoot, _extends({
|
|
91
|
+
className: classes.root
|
|
92
|
+
}, other, {
|
|
93
|
+
style: _extends({
|
|
94
|
+
x: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
|
|
95
|
+
y: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
|
|
96
|
+
}, style),
|
|
97
|
+
children: formattedArcLabel
|
|
98
|
+
}))
|
|
99
|
+
);
|
|
96
100
|
}
|
|
97
101
|
process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
98
102
|
// ----------------------------- Warning --------------------------------
|
|
@@ -133,6 +133,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
133
133
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
134
134
|
index: PropTypes.number.isRequired,
|
|
135
135
|
label: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
136
|
+
labelMarkType: PropTypes.oneOf(['circle', 'line', 'square']),
|
|
136
137
|
padAngle: PropTypes.number.isRequired,
|
|
137
138
|
startAngle: PropTypes.number.isRequired,
|
|
138
139
|
value: PropTypes.number.isRequired
|
|
@@ -99,6 +99,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
99
99
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
100
100
|
index: PropTypes.number.isRequired,
|
|
101
101
|
label: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
102
|
+
labelMarkType: PropTypes.oneOf(['circle', 'line', 'square']),
|
|
102
103
|
padAngle: PropTypes.number.isRequired,
|
|
103
104
|
startAngle: PropTypes.number.isRequired,
|
|
104
105
|
value: PropTypes.number.isRequired
|
|
@@ -5,24 +5,20 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "sx", "skipAnimation", "hideLegend", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { useRtl } from '@mui/system/RtlProvider';
|
|
9
8
|
import { useThemeProps } from '@mui/material/styles';
|
|
10
|
-
import { ChartContainer } from "../ChartContainer/index.js";
|
|
11
9
|
import { ChartsTooltip } from "../ChartsTooltip/index.js";
|
|
12
10
|
import { ChartsLegend } from "../ChartsLegend/index.js";
|
|
13
11
|
import { PiePlot } from "./PiePlot.js";
|
|
14
12
|
import { ChartsOverlay } from "../ChartsOverlay/index.js";
|
|
13
|
+
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
14
|
+
import { ChartDataProvider } from "../context/index.js";
|
|
15
|
+
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
16
|
+
import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
|
|
15
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
18
|
const defaultMargin = {
|
|
17
19
|
top: 5,
|
|
18
20
|
bottom: 5,
|
|
19
21
|
left: 5,
|
|
20
|
-
right: 100
|
|
21
|
-
};
|
|
22
|
-
const defaultRTLMargin = {
|
|
23
|
-
top: 5,
|
|
24
|
-
bottom: 5,
|
|
25
|
-
left: 100,
|
|
26
22
|
right: 5
|
|
27
23
|
};
|
|
28
24
|
|
|
@@ -60,43 +56,48 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
|
60
56
|
className
|
|
61
57
|
} = props,
|
|
62
58
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
const margin = _extends({}, defaultMargin, marginProps);
|
|
60
|
+
const {
|
|
61
|
+
chartDataProviderProps,
|
|
62
|
+
chartsSurfaceProps
|
|
63
|
+
} = useChartContainerProps(_extends({}, other, {
|
|
68
64
|
series: series.map(s => _extends({
|
|
69
65
|
type: 'pie'
|
|
70
66
|
}, s)),
|
|
71
|
-
width
|
|
72
|
-
height
|
|
73
|
-
margin
|
|
74
|
-
colors
|
|
75
|
-
sx: sx,
|
|
67
|
+
width,
|
|
68
|
+
height,
|
|
69
|
+
margin,
|
|
70
|
+
colors,
|
|
76
71
|
disableAxisListener: true,
|
|
77
|
-
highlightedItem
|
|
78
|
-
onHighlightChange
|
|
79
|
-
className
|
|
80
|
-
skipAnimation
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
highlightedItem,
|
|
73
|
+
onHighlightChange,
|
|
74
|
+
className,
|
|
75
|
+
skipAnimation
|
|
76
|
+
}), ref);
|
|
77
|
+
const Tooltip = slots?.tooltip ?? ChartsTooltip;
|
|
78
|
+
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
79
|
+
children: /*#__PURE__*/_jsxs(ChartsWrapper, {
|
|
80
|
+
legendPosition: props.slotProps?.legend?.position,
|
|
81
|
+
legendDirection: props?.slotProps?.legend?.direction ?? 'vertical',
|
|
82
|
+
sx: sx,
|
|
83
|
+
children: [!hideLegend && /*#__PURE__*/_jsx(ChartsLegend, {
|
|
84
|
+
direction: props?.slotProps?.legend?.direction ?? 'vertical',
|
|
85
|
+
slots: slots,
|
|
86
|
+
slotProps: slotProps
|
|
87
|
+
}), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
88
|
+
children: [/*#__PURE__*/_jsx(PiePlot, {
|
|
89
|
+
slots: slots,
|
|
90
|
+
slotProps: slotProps,
|
|
91
|
+
onItemClick: onItemClick
|
|
92
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
93
|
+
loading: loading,
|
|
94
|
+
slots: slots,
|
|
95
|
+
slotProps: slotProps
|
|
96
|
+
}), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({
|
|
97
|
+
trigger: "item"
|
|
98
|
+
}, slotProps?.tooltip)), children]
|
|
99
|
+
}))]
|
|
100
|
+
})
|
|
100
101
|
}));
|
|
101
102
|
});
|
|
102
103
|
process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
@@ -5,7 +5,6 @@ import * as React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import { ScatterPlot } from "./ScatterPlot.js";
|
|
8
|
-
import { ChartContainer } from "../ChartContainer/index.js";
|
|
9
8
|
import { ChartsAxis } from "../ChartsAxis/index.js";
|
|
10
9
|
import { ChartsTooltip } from "../ChartsTooltip/index.js";
|
|
11
10
|
import { ChartsLegend } from "../ChartsLegend/index.js";
|
|
@@ -15,6 +14,10 @@ import { ChartsVoronoiHandler } from "../ChartsVoronoiHandler/ChartsVoronoiHandl
|
|
|
15
14
|
import { ChartsGrid } from "../ChartsGrid/index.js";
|
|
16
15
|
import { ZAxisContextProvider } from "../context/ZAxisContextProvider.js";
|
|
17
16
|
import { useScatterChartProps } from "./useScatterChartProps.js";
|
|
17
|
+
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
18
|
+
import { ChartDataProvider } from "../context/index.js";
|
|
19
|
+
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
20
|
+
import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
|
|
18
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
22
|
/**
|
|
20
23
|
* Demos:
|
|
@@ -32,6 +35,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps
|
|
|
32
35
|
name: 'MuiScatterChart'
|
|
33
36
|
});
|
|
34
37
|
const {
|
|
38
|
+
chartsWrapperProps,
|
|
35
39
|
chartContainerProps,
|
|
36
40
|
zAxisProps,
|
|
37
41
|
voronoiHandlerProps,
|
|
@@ -43,17 +47,23 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps
|
|
|
43
47
|
axisHighlightProps,
|
|
44
48
|
children
|
|
45
49
|
} = useScatterChartProps(props);
|
|
50
|
+
const {
|
|
51
|
+
chartDataProviderProps,
|
|
52
|
+
chartsSurfaceProps
|
|
53
|
+
} = useChartContainerProps(chartContainerProps, ref);
|
|
46
54
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
47
|
-
return /*#__PURE__*/_jsx(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
56
|
+
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
57
|
+
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
58
|
+
children: /*#__PURE__*/_jsxs(ZAxisContextProvider, _extends({}, zAxisProps, {
|
|
59
|
+
children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
60
|
+
"data-drawing-container": true,
|
|
61
|
+
children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
|
|
62
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({
|
|
63
|
+
trigger: "item"
|
|
64
|
+
}, props.slotProps?.tooltip)), children]
|
|
65
|
+
}))
|
|
66
|
+
}))]
|
|
57
67
|
}))
|
|
58
68
|
}));
|
|
59
69
|
});
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
const _excluded = ["xAxis", "yAxis", "zAxis", "series", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "hideLegend", "width", "height", "margin", "colors", "sx", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
6
|
+
import { calculateMargins } from "../internals/calculateMargins.js";
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* A helper function that extracts ScatterChartProps from the input props
|
|
8
10
|
* and returns an object with props for the children components of ScatterChart.
|
|
@@ -19,6 +21,7 @@ export const useScatterChartProps = props => {
|
|
|
19
21
|
axisHighlight,
|
|
20
22
|
voronoiMaxRadius,
|
|
21
23
|
disableVoronoi,
|
|
24
|
+
hideLegend,
|
|
22
25
|
width,
|
|
23
26
|
height,
|
|
24
27
|
margin,
|
|
@@ -45,11 +48,15 @@ export const useScatterChartProps = props => {
|
|
|
45
48
|
}, s)),
|
|
46
49
|
width,
|
|
47
50
|
height,
|
|
48
|
-
margin
|
|
51
|
+
margin: calculateMargins({
|
|
52
|
+
margin,
|
|
53
|
+
hideLegend,
|
|
54
|
+
slotProps,
|
|
55
|
+
series
|
|
56
|
+
}),
|
|
49
57
|
colors,
|
|
50
58
|
xAxis,
|
|
51
59
|
yAxis,
|
|
52
|
-
sx,
|
|
53
60
|
highlightedItem,
|
|
54
61
|
onHighlightChange,
|
|
55
62
|
className
|
|
@@ -91,7 +98,13 @@ export const useScatterChartProps = props => {
|
|
|
91
98
|
y: 'none',
|
|
92
99
|
x: 'none'
|
|
93
100
|
}, axisHighlight);
|
|
101
|
+
const chartsWrapperProps = {
|
|
102
|
+
sx,
|
|
103
|
+
legendPosition: props.slotProps?.legend?.position,
|
|
104
|
+
legendDirection: props.slotProps?.legend?.direction
|
|
105
|
+
};
|
|
94
106
|
return {
|
|
107
|
+
chartsWrapperProps,
|
|
95
108
|
chartContainerProps,
|
|
96
109
|
zAxisProps,
|
|
97
110
|
voronoiHandlerProps,
|
|
@@ -90,10 +90,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
90
90
|
children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
|
|
91
91
|
skipAnimation: true,
|
|
92
92
|
slots: slots,
|
|
93
|
-
slotProps: slotProps
|
|
94
|
-
sx: {
|
|
95
|
-
shapeRendering: 'auto'
|
|
96
|
-
}
|
|
93
|
+
slotProps: slotProps
|
|
97
94
|
}), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
98
95
|
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
99
96
|
skipAnimation: true,
|
package/modern/hooks/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export * from "./useScale.js";
|
|
|
4
4
|
export * from "./useAxis.js";
|
|
5
5
|
export * from "./useColorScale.js";
|
|
6
6
|
export * from "./useSvgRef.js";
|
|
7
|
-
export { useSeries as unstable_useSeries, usePieSeries as unstable_usePieSeries, useLineSeries as unstable_useLineSeries, useBarSeries as unstable_useBarSeries, useScatterSeries as unstable_useScatterSeries } from "./useSeries.js";
|
|
7
|
+
export { useSeries as unstable_useSeries, usePieSeries as unstable_usePieSeries, useLineSeries as unstable_useLineSeries, useBarSeries as unstable_useBarSeries, useScatterSeries as unstable_useScatterSeries } from "./useSeries.js";
|
|
8
|
+
export * from "./useLegend.js";
|
|
@@ -1,16 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import getBarLegend from "../BarChart/legend.js";
|
|
2
4
|
import getScatterLegend from "../ScatterChart/legend.js";
|
|
3
5
|
import getLineLegend from "../LineChart/legend.js";
|
|
4
6
|
import getPieLegend from "../PieChart/legend.js";
|
|
7
|
+
import { useSeries } from "./useSeries.js";
|
|
5
8
|
const legendGetter = {
|
|
6
9
|
bar: getBarLegend,
|
|
7
10
|
scatter: getScatterLegend,
|
|
8
11
|
line: getLineLegend,
|
|
9
12
|
pie: getPieLegend
|
|
10
13
|
};
|
|
11
|
-
|
|
14
|
+
function getSeriesToDisplay(series) {
|
|
12
15
|
return Object.keys(series).flatMap(seriesType => {
|
|
13
16
|
const getter = legendGetter[seriesType];
|
|
14
17
|
return getter === undefined ? [] : getter(series[seriesType]);
|
|
15
18
|
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the legend items to display.
|
|
23
|
+
*
|
|
24
|
+
* This hook is used by the `ChartsLegend` component. And will return the legend items formatted for display.
|
|
25
|
+
*
|
|
26
|
+
* An alternative is to use the `useSeries` hook and format the legend items yourself.
|
|
27
|
+
*
|
|
28
|
+
* @returns legend data
|
|
29
|
+
*/
|
|
30
|
+
export function useLegend() {
|
|
31
|
+
const series = useSeries();
|
|
32
|
+
return {
|
|
33
|
+
items: getSeriesToDisplay(series)
|
|
34
|
+
};
|
|
16
35
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v8.0.0-alpha.
|
|
2
|
+
* @mui/x-charts v8.0.0-alpha.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -18,6 +18,7 @@ export * from "./ChartsYAxis/index.js";
|
|
|
18
18
|
export * from "./ChartsGrid/index.js";
|
|
19
19
|
export * from "./ChartsText/index.js";
|
|
20
20
|
export * from "./ChartsTooltip/index.js";
|
|
21
|
+
export * from "./ChartsLabel/index.js";
|
|
21
22
|
export * from "./ChartsLegend/index.js";
|
|
22
23
|
export * from "./ChartsAxisHighlight/index.js";
|
|
23
24
|
export * from "./ChartsVoronoiHandler/index.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { DEFAULT_MARGINS, DEFAULT_LEGEND_FACING_MARGIN } from "../constants/index.js";
|
|
3
|
+
export const calculateMargins = props => {
|
|
4
|
+
if (props.hideLegend || !props.series?.some(s => s.label)) {
|
|
5
|
+
return _extends({}, DEFAULT_MARGINS, props.margin);
|
|
6
|
+
}
|
|
7
|
+
if (props.slotProps?.legend?.direction === 'vertical') {
|
|
8
|
+
if (props.slotProps?.legend?.position?.horizontal === 'left') {
|
|
9
|
+
return _extends({}, DEFAULT_MARGINS, {
|
|
10
|
+
left: DEFAULT_LEGEND_FACING_MARGIN
|
|
11
|
+
}, props.margin);
|
|
12
|
+
}
|
|
13
|
+
return _extends({}, DEFAULT_MARGINS, {
|
|
14
|
+
right: DEFAULT_LEGEND_FACING_MARGIN
|
|
15
|
+
}, props.margin);
|
|
16
|
+
}
|
|
17
|
+
if (props.slotProps?.legend?.position?.vertical === 'bottom') {
|
|
18
|
+
return _extends({}, DEFAULT_MARGINS, {
|
|
19
|
+
bottom: DEFAULT_LEGEND_FACING_MARGIN
|
|
20
|
+
}, props.margin);
|
|
21
|
+
}
|
|
22
|
+
return _extends({}, DEFAULT_MARGINS, {
|
|
23
|
+
top: DEFAULT_LEGEND_FACING_MARGIN
|
|
24
|
+
}, props.margin);
|
|
25
|
+
};
|
|
@@ -3,11 +3,19 @@ import { useCartesianContext } from "../../../context/CartesianProvider/index.js
|
|
|
3
3
|
import { useChartId, useDrawingArea } from "../../../hooks/index.js";
|
|
4
4
|
import ChartsPiecewiseGradient from "./ChartsPiecewiseGradient.js";
|
|
5
5
|
import ChartsContinuousGradient from "./ChartsContinuousGradient.js";
|
|
6
|
+
import ChartsContinuousGradientObjectBound from "./ChartsContinuousGradientObjectBound.js";
|
|
7
|
+
import { useZAxis } from "../../../hooks/useZAxis.js";
|
|
6
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
9
|
export function useChartGradient() {
|
|
8
10
|
const chartId = useChartId();
|
|
9
11
|
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
10
12
|
}
|
|
13
|
+
|
|
14
|
+
// TODO: make public?
|
|
15
|
+
export function useChartGradientObjectBound() {
|
|
16
|
+
const chartId = useChartId();
|
|
17
|
+
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}-object-bound`, [chartId]);
|
|
18
|
+
}
|
|
11
19
|
export function ChartsAxesGradients() {
|
|
12
20
|
const {
|
|
13
21
|
top,
|
|
@@ -20,20 +28,27 @@ export function ChartsAxesGradients() {
|
|
|
20
28
|
const svgHeight = top + height + bottom;
|
|
21
29
|
const svgWidth = left + width + right;
|
|
22
30
|
const getGradientId = useChartGradient();
|
|
31
|
+
const getObjectBoundGradientId = useChartGradientObjectBound();
|
|
23
32
|
const {
|
|
24
33
|
xAxisIds,
|
|
25
34
|
xAxis,
|
|
26
35
|
yAxisIds,
|
|
27
36
|
yAxis
|
|
28
37
|
} = useCartesianContext();
|
|
38
|
+
const {
|
|
39
|
+
zAxisIds,
|
|
40
|
+
zAxis
|
|
41
|
+
} = useZAxis();
|
|
29
42
|
const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
|
|
30
43
|
const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
|
|
31
|
-
|
|
44
|
+
const filteredZAxisIds = zAxisIds.filter(axisId => zAxis[axisId].colorMap !== undefined);
|
|
45
|
+
if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0 && filteredZAxisIds.length === 0) {
|
|
32
46
|
return null;
|
|
33
47
|
}
|
|
34
48
|
return /*#__PURE__*/_jsxs("defs", {
|
|
35
49
|
children: [filteredYAxisIds.map(axisId => {
|
|
36
50
|
const gradientId = getGradientId(axisId, 'y');
|
|
51
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId, 'y');
|
|
37
52
|
const {
|
|
38
53
|
colorMap,
|
|
39
54
|
scale,
|
|
@@ -51,19 +66,27 @@ export function ChartsAxesGradients() {
|
|
|
51
66
|
}, gradientId);
|
|
52
67
|
}
|
|
53
68
|
if (colorMap?.type === 'continuous') {
|
|
54
|
-
return /*#__PURE__*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
70
|
+
children: [/*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
71
|
+
isReversed: !reverse,
|
|
72
|
+
scale: scale,
|
|
73
|
+
colorScale: colorScale,
|
|
74
|
+
colorMap: colorMap,
|
|
75
|
+
size: svgHeight,
|
|
76
|
+
gradientId: gradientId,
|
|
77
|
+
direction: "y"
|
|
78
|
+
}), /*#__PURE__*/_jsx(ChartsContinuousGradientObjectBound, {
|
|
79
|
+
isReversed: reverse,
|
|
80
|
+
colorScale: colorScale,
|
|
81
|
+
colorMap: colorMap,
|
|
82
|
+
gradientId: objectBoundGradientId
|
|
83
|
+
})]
|
|
62
84
|
}, gradientId);
|
|
63
85
|
}
|
|
64
86
|
return null;
|
|
65
87
|
}), filteredXAxisIds.map(axisId => {
|
|
66
88
|
const gradientId = getGradientId(axisId, 'x');
|
|
89
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId, 'x');
|
|
67
90
|
const {
|
|
68
91
|
colorMap,
|
|
69
92
|
scale,
|
|
@@ -81,15 +104,36 @@ export function ChartsAxesGradients() {
|
|
|
81
104
|
}, gradientId);
|
|
82
105
|
}
|
|
83
106
|
if (colorMap?.type === 'continuous') {
|
|
84
|
-
return /*#__PURE__*/
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
108
|
+
children: [/*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
109
|
+
isReversed: reverse,
|
|
110
|
+
scale: scale,
|
|
111
|
+
colorScale: colorScale,
|
|
112
|
+
colorMap: colorMap,
|
|
113
|
+
size: svgWidth,
|
|
114
|
+
gradientId: gradientId,
|
|
115
|
+
direction: "x"
|
|
116
|
+
}), /*#__PURE__*/_jsx(ChartsContinuousGradientObjectBound, {
|
|
117
|
+
isReversed: reverse,
|
|
118
|
+
colorScale: colorScale,
|
|
119
|
+
colorMap: colorMap,
|
|
120
|
+
gradientId: objectBoundGradientId
|
|
121
|
+
})]
|
|
122
|
+
}, gradientId);
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}), filteredZAxisIds.map(axisId => {
|
|
126
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId, 'z');
|
|
127
|
+
const {
|
|
128
|
+
colorMap,
|
|
129
|
+
colorScale
|
|
130
|
+
} = zAxis[axisId];
|
|
131
|
+
if (colorMap?.type === 'continuous') {
|
|
132
|
+
return /*#__PURE__*/_jsx(ChartsContinuousGradientObjectBound, {
|
|
87
133
|
colorScale: colorScale,
|
|
88
134
|
colorMap: colorMap,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
direction: "x"
|
|
92
|
-
}, gradientId);
|
|
135
|
+
gradientId: objectBoundGradientId
|
|
136
|
+
}, objectBoundGradientId);
|
|
93
137
|
}
|
|
94
138
|
return null;
|
|
95
139
|
})]
|
|
@@ -13,14 +13,14 @@ export default function ChartsContinuousGradient(props) {
|
|
|
13
13
|
colorScale,
|
|
14
14
|
colorMap
|
|
15
15
|
} = props;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
16
|
+
const extremumValues = [colorMap.min ?? 0, colorMap.max ?? 100];
|
|
17
|
+
const extremumPositions = extremumValues.map(scale).filter(p => p !== undefined);
|
|
18
|
+
if (extremumPositions.length !== 2) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
const interpolator = typeof
|
|
22
|
-
const numberOfPoints = Math.round((Math.max(...
|
|
23
|
-
const keyPrefix = `${
|
|
21
|
+
const interpolator = typeof extremumValues[0] === 'number' ? interpolateNumber(extremumValues[0], extremumValues[1]) : interpolateDate(extremumValues[0], extremumValues[1]);
|
|
22
|
+
const numberOfPoints = Math.round((Math.max(...extremumPositions) - Math.min(...extremumPositions)) / PX_PRECISION);
|
|
23
|
+
const keyPrefix = `${extremumValues[0]}-${extremumValues[1]}-`;
|
|
24
24
|
return /*#__PURE__*/_jsx("linearGradient", {
|
|
25
25
|
id: gradientId,
|
|
26
26
|
x1: "0",
|