@mui/x-charts 7.2.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +1 -0
- package/BarChart/BarChart.js +40 -99
- package/BarChart/BarElement.d.ts +63 -62
- package/BarChart/BarElement.js +1 -2
- package/BarChart/BarPlot.js +14 -7
- package/BarChart/getColor.d.ts +3 -0
- package/BarChart/getColor.js +33 -0
- package/CHANGELOG.md +204 -2
- package/ChartContainer/ChartContainer.js +38 -5
- package/ChartsAxis/ChartsAxis.js +11 -103
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsClipPath/ChartsClipPath.js +3 -3
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsLegend/ChartsLegend.js +3 -3
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsSurface.js +1 -1
- package/ChartsText/ChartsText.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +4 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +21 -3
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +6 -0
- package/ChartsTooltip/ChartsItemTooltipContent.js +32 -2
- package/ChartsTooltip/ChartsTooltip.js +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -7
- package/ChartsTooltip/ChartsTooltipTable.js +8 -9
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -7
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -8
- package/ChartsTooltip/utils.d.ts +5 -1
- package/ChartsTooltip/utils.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +7 -7
- package/ChartsXAxis/ChartsXAxis.js +3 -3
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeProvider.js +6 -6
- package/Gauge/GaugeReferenceArc.js +1 -1
- package/Gauge/GaugeValueArc.js +1 -1
- package/Gauge/GaugeValueText.js +1 -1
- package/LineChart/AnimatedArea.d.ts +63 -62
- package/LineChart/AnimatedArea.js +7 -6
- package/LineChart/AnimatedLine.d.ts +63 -62
- package/LineChart/AnimatedLine.js +8 -6
- package/LineChart/AreaElement.d.ts +1 -0
- package/LineChart/AreaElement.js +5 -2
- package/LineChart/AreaPlot.js +8 -2
- package/LineChart/LineChart.d.ts +1 -0
- package/LineChart/LineChart.js +40 -99
- package/LineChart/LineElement.d.ts +1 -0
- package/LineChart/LineElement.js +5 -2
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +5 -2
- package/LineChart/LinePlot.js +8 -2
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.js +6 -6
- package/LineChart/getColor.d.ts +3 -0
- package/LineChart/getColor.js +31 -0
- package/PieChart/PieArc.d.ts +1 -0
- package/PieChart/PieArc.js +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -0
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.d.ts +1 -0
- package/PieChart/PieChart.js +40 -99
- package/PieChart/PiePlot.js +27 -7
- package/PieChart/dataTransform/transition.d.ts +1 -0
- package/PieChart/dataTransform/useTransformData.js +1 -1
- package/PieChart/formatter.js +4 -2
- package/PieChart/getColor.d.ts +2 -0
- package/PieChart/getColor.js +11 -0
- package/PieChart/getPieCoordinates.d.ts +7 -0
- package/PieChart/getPieCoordinates.js +25 -0
- package/PieChart/index.d.ts +1 -0
- package/PieChart/index.js +11 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +35 -3
- package/ResponsiveChartContainer/useChartContainerDimensions.js +1 -1
- package/ScatterChart/Scatter.d.ts +1 -0
- package/ScatterChart/Scatter.js +7 -4
- package/ScatterChart/ScatterChart.d.ts +3 -1
- package/ScatterChart/ScatterChart.js +95 -126
- package/ScatterChart/ScatterPlot.js +11 -1
- package/ScatterChart/getColor.d.ts +4 -0
- package/ScatterChart/getColor.js +48 -0
- package/SparkLineChart/SparkLineChart.js +16 -1
- package/context/CartesianContextProvider.d.ts +4 -3
- package/context/CartesianContextProvider.js +24 -9
- package/context/DrawingProvider.js +1 -1
- package/context/HighlightProvider.js +1 -1
- package/context/InteractionProvider.js +1 -1
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +33 -0
- package/context/ZAxisContextProvider.js +98 -0
- package/context/index.d.ts +2 -0
- package/context/index.js +8 -1
- package/esm/BarChart/BarChart.js +40 -100
- package/esm/BarChart/BarElement.js +0 -1
- package/esm/BarChart/BarPlot.js +15 -7
- package/esm/BarChart/getColor.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +38 -5
- package/esm/ChartsAxis/ChartsAxis.js +11 -104
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/esm/ChartsClipPath/ChartsClipPath.js +2 -2
- package/esm/ChartsGrid/ChartsGrid.js +1 -2
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/esm/ChartsSurface.js +1 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
- package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +3 -4
- package/esm/ChartsYAxis/ChartsYAxis.js +3 -4
- package/esm/Gauge/Gauge.js +1 -2
- package/esm/Gauge/GaugeProvider.js +5 -5
- package/esm/LineChart/AnimatedArea.js +7 -7
- package/esm/LineChart/AnimatedLine.js +8 -7
- package/esm/LineChart/AreaElement.js +4 -1
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/LineChart.js +40 -100
- package/esm/LineChart/LineElement.js +4 -1
- package/esm/LineChart/LineHighlightPlot.js +4 -1
- package/esm/LineChart/LinePlot.js +7 -1
- package/esm/LineChart/MarkPlot.js +5 -5
- package/esm/LineChart/getColor.js +25 -0
- package/esm/PieChart/PieChart.js +40 -100
- package/esm/PieChart/PiePlot.js +27 -8
- package/esm/PieChart/formatter.js +4 -2
- package/esm/PieChart/getColor.js +5 -0
- package/esm/PieChart/getPieCoordinates.js +19 -0
- package/esm/PieChart/index.js +2 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
- package/esm/ScatterChart/Scatter.js +6 -3
- package/esm/ScatterChart/ScatterChart.js +95 -127
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/ScatterChart/getColor.js +42 -0
- package/esm/SparkLineChart/SparkLineChart.js +16 -2
- package/esm/context/CartesianContextProvider.js +23 -8
- package/esm/context/ZAxisContextProvider.js +89 -0
- package/esm/context/index.js +1 -1
- package/esm/hooks/index.js +4 -1
- package/esm/hooks/useAxisEvents.js +7 -6
- package/esm/hooks/useChartId.js +8 -0
- package/esm/hooks/useSeries.js +64 -0
- package/esm/hooks/useSvgRef.js +9 -0
- package/esm/internals/colorGetter.js +22 -0
- package/esm/internals/colorScale.js +16 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
- package/esm/internals/components/ChartsAxesGradients/index.js +1 -0
- package/esm/models/colorMapping.js +1 -0
- package/esm/models/seriesType/index.js +6 -1
- package/esm/models/z-axis.js +1 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +65 -1
- package/hooks/useAxisEvents.js +8 -7
- package/hooks/useChartDimensions.js +1 -1
- package/hooks/useChartId.d.ts +1 -0
- package/hooks/useChartId.js +16 -0
- package/hooks/useDrawingArea.js +1 -1
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useMounted.js +1 -1
- package/hooks/useScale.js +1 -1
- package/hooks/useSeries.d.ts +45 -0
- package/hooks/useSeries.js +75 -0
- package/hooks/useSvgRef.d.ts +2 -0
- package/hooks/useSvgRef.js +17 -0
- package/hooks/useTicks.js +1 -1
- package/index.js +1 -1
- package/internals/colorGetter.d.ts +7 -0
- package/internals/colorGetter.js +29 -0
- package/internals/colorScale.d.ts +5 -0
- package/internals/colorScale.js +24 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +3 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +63 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +12 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
- package/internals/components/ChartsAxesGradients/index.d.ts +1 -0
- package/internals/components/ChartsAxesGradients/index.js +16 -0
- package/internals/defaultizeColor.d.ts +5 -4
- package/internals/defaultizeValueFormatter.d.ts +5 -5
- package/internals/getScale.d.ts +2 -2
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +1 -1
- package/models/axis.d.ts +44 -4
- package/models/colorMapping.d.ts +46 -0
- package/models/colorMapping.js +5 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/common.d.ts +10 -2
- package/models/seriesType/index.d.ts +2 -0
- package/models/seriesType/index.js +17 -1
- package/models/seriesType/pie.d.ts +5 -0
- package/models/seriesType/scatter.d.ts +5 -0
- package/models/z-axis.d.ts +14 -0
- package/models/z-axis.js +5 -0
- package/modern/BarChart/BarChart.js +40 -100
- package/modern/BarChart/BarElement.js +0 -1
- package/modern/BarChart/BarPlot.js +15 -7
- package/modern/BarChart/getColor.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +38 -5
- package/modern/ChartsAxis/ChartsAxis.js +11 -104
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/modern/ChartsClipPath/ChartsClipPath.js +2 -2
- package/modern/ChartsGrid/ChartsGrid.js +1 -2
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/modern/ChartsSurface.js +1 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
- package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +3 -4
- package/modern/ChartsYAxis/ChartsYAxis.js +3 -4
- package/modern/Gauge/Gauge.js +1 -2
- package/modern/Gauge/GaugeProvider.js +5 -5
- package/modern/LineChart/AnimatedArea.js +7 -7
- package/modern/LineChart/AnimatedLine.js +8 -7
- package/modern/LineChart/AreaElement.js +4 -1
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/LineChart.js +40 -100
- package/modern/LineChart/LineElement.js +4 -1
- package/modern/LineChart/LineHighlightPlot.js +4 -1
- package/modern/LineChart/LinePlot.js +7 -1
- package/modern/LineChart/MarkPlot.js +5 -5
- package/modern/LineChart/getColor.js +25 -0
- package/modern/PieChart/PieChart.js +40 -100
- package/modern/PieChart/PiePlot.js +27 -8
- package/modern/PieChart/formatter.js +4 -2
- package/modern/PieChart/getColor.js +5 -0
- package/modern/PieChart/getPieCoordinates.js +19 -0
- package/modern/PieChart/index.js +2 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
- package/modern/ScatterChart/Scatter.js +6 -3
- package/modern/ScatterChart/ScatterChart.js +95 -127
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/ScatterChart/getColor.js +42 -0
- package/modern/SparkLineChart/SparkLineChart.js +16 -2
- package/modern/context/CartesianContextProvider.js +23 -8
- package/modern/context/ZAxisContextProvider.js +89 -0
- package/modern/context/index.js +1 -1
- package/modern/hooks/index.js +4 -1
- package/modern/hooks/useAxisEvents.js +7 -6
- package/modern/hooks/useChartId.js +8 -0
- package/modern/hooks/useSeries.js +64 -0
- package/modern/hooks/useSvgRef.js +9 -0
- package/modern/index.js +1 -1
- package/modern/internals/colorGetter.js +22 -0
- package/modern/internals/colorScale.js +16 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
- package/modern/internals/components/ChartsAxesGradients/index.js +1 -0
- package/modern/models/colorMapping.js +1 -0
- package/modern/models/seriesType/index.js +6 -1
- package/modern/models/z-axis.js +1 -0
- package/package.json +3 -5
package/esm/PieChart/index.js
CHANGED
|
@@ -106,11 +106,27 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
106
106
|
width: PropTypes.number,
|
|
107
107
|
/**
|
|
108
108
|
* The configuration of the x-axes.
|
|
109
|
-
* If not provided, a default axis config is used
|
|
109
|
+
* If not provided, a default axis config is used.
|
|
110
|
+
* An array of [[AxisConfig]] objects.
|
|
110
111
|
*/
|
|
111
112
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
112
113
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
113
114
|
classes: PropTypes.object,
|
|
115
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
116
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
117
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
118
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
119
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
120
|
+
}), PropTypes.shape({
|
|
121
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
122
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
123
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
124
|
+
}), PropTypes.shape({
|
|
125
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
126
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
127
|
+
unknownColor: PropTypes.string,
|
|
128
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
129
|
+
})]),
|
|
114
130
|
data: PropTypes.array,
|
|
115
131
|
dataKey: PropTypes.string,
|
|
116
132
|
disableLine: PropTypes.bool,
|
|
@@ -143,11 +159,27 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
143
159
|
})),
|
|
144
160
|
/**
|
|
145
161
|
* The configuration of the y-axes.
|
|
146
|
-
* If not provided, a default axis config is used
|
|
162
|
+
* If not provided, a default axis config is used.
|
|
163
|
+
* An array of [[AxisConfig]] objects.
|
|
147
164
|
*/
|
|
148
165
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
149
166
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
150
167
|
classes: PropTypes.object,
|
|
168
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
169
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
170
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
171
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
172
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
173
|
+
}), PropTypes.shape({
|
|
174
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
175
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
176
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
177
|
+
}), PropTypes.shape({
|
|
178
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
179
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
180
|
+
unknownColor: PropTypes.string,
|
|
181
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
182
|
+
})]),
|
|
151
183
|
data: PropTypes.array,
|
|
152
184
|
dataKey: PropTypes.string,
|
|
153
185
|
disableLine: PropTypes.bool,
|
|
@@ -21,6 +21,7 @@ function Scatter(props) {
|
|
|
21
21
|
xScale,
|
|
22
22
|
yScale,
|
|
23
23
|
color,
|
|
24
|
+
colorGetter,
|
|
24
25
|
markerSize,
|
|
25
26
|
onItemClick
|
|
26
27
|
} = props;
|
|
@@ -63,19 +64,20 @@ function Scatter(props) {
|
|
|
63
64
|
isFaded: !isHighlighted && getIsFaded(item, pointCtx, highlightScope),
|
|
64
65
|
interactionProps: getInteractionItemProps(pointCtx),
|
|
65
66
|
id: scatterPoint.id,
|
|
66
|
-
dataIndex: i
|
|
67
|
+
dataIndex: i,
|
|
68
|
+
color: colorGetter ? colorGetter(i) : color
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
return temp;
|
|
71
|
-
}, [xScale, yScale, series.data, series.id, item, highlightScope, getInteractionItemProps]);
|
|
73
|
+
}, [xScale, yScale, series.data, series.id, item, highlightScope, getInteractionItemProps, color, colorGetter]);
|
|
72
74
|
return /*#__PURE__*/_jsx("g", {
|
|
73
75
|
children: cleanData.map(dataPoint => /*#__PURE__*/_jsx("circle", _extends({
|
|
74
76
|
cx: 0,
|
|
75
77
|
cy: 0,
|
|
76
78
|
r: (dataPoint.isHighlighted ? 1.2 : 1) * markerSize,
|
|
77
79
|
transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
|
|
78
|
-
fill: color,
|
|
80
|
+
fill: dataPoint.color,
|
|
79
81
|
opacity: dataPoint.isFaded && 0.3 || 1,
|
|
80
82
|
onClick: onItemClick && (event => onItemClick(event, {
|
|
81
83
|
type: 'scatter',
|
|
@@ -92,6 +94,7 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
|
|
|
92
94
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
93
95
|
// ----------------------------------------------------------------------
|
|
94
96
|
color: PropTypes.string.isRequired,
|
|
97
|
+
colorGetter: PropTypes.func,
|
|
95
98
|
markerSize: PropTypes.number.isRequired,
|
|
96
99
|
/**
|
|
97
100
|
* Callback fired when clicking on a scatter item.
|
|
@@ -9,8 +9,8 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
9
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
10
|
import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
11
11
|
import { ChartsGrid } from '../ChartsGrid';
|
|
12
|
-
import {
|
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { ZAxisContextProvider } from '../context/ZAxisContextProvider';
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
/**
|
|
15
15
|
* Demos:
|
|
16
16
|
*
|
|
@@ -25,6 +25,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
25
25
|
const {
|
|
26
26
|
xAxis,
|
|
27
27
|
yAxis,
|
|
28
|
+
zAxis,
|
|
28
29
|
series,
|
|
29
30
|
tooltip,
|
|
30
31
|
axisHighlight,
|
|
@@ -46,7 +47,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
46
47
|
slots,
|
|
47
48
|
slotProps
|
|
48
49
|
} = props;
|
|
49
|
-
return /*#__PURE__*/
|
|
50
|
+
return /*#__PURE__*/_jsx(ResponsiveChartContainer, {
|
|
50
51
|
ref: ref,
|
|
51
52
|
series: series.map(s => _extends({
|
|
52
53
|
type: 'scatter'
|
|
@@ -58,32 +59,35 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
58
59
|
xAxis: xAxis,
|
|
59
60
|
yAxis: yAxis,
|
|
60
61
|
sx: sx,
|
|
61
|
-
children:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
62
|
+
children: /*#__PURE__*/_jsxs(ZAxisContextProvider, {
|
|
63
|
+
zAxis: zAxis,
|
|
64
|
+
children: [!disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, {
|
|
65
|
+
voronoiMaxRadius: voronoiMaxRadius,
|
|
66
|
+
onItemClick: onItemClick
|
|
67
|
+
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
68
|
+
topAxis: topAxis,
|
|
69
|
+
leftAxis: leftAxis,
|
|
70
|
+
rightAxis: rightAxis,
|
|
71
|
+
bottomAxis: bottomAxis,
|
|
72
|
+
slots: slots,
|
|
73
|
+
slotProps: slotProps
|
|
74
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
75
|
+
vertical: grid.vertical,
|
|
76
|
+
horizontal: grid.horizontal
|
|
77
|
+
}), /*#__PURE__*/_jsx(ScatterPlot, {
|
|
78
|
+
slots: slots,
|
|
79
|
+
slotProps: slotProps,
|
|
80
|
+
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
81
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
82
|
+
slots: slots,
|
|
83
|
+
slotProps: slotProps
|
|
84
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
85
|
+
x: "none",
|
|
86
|
+
y: "none"
|
|
87
|
+
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
88
|
+
trigger: "item"
|
|
89
|
+
}, tooltip)), children]
|
|
90
|
+
})
|
|
87
91
|
});
|
|
88
92
|
});
|
|
89
93
|
process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
@@ -105,30 +109,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
105
109
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
106
110
|
* @default xAxisIds[0] The id of the first provided axis
|
|
107
111
|
*/
|
|
108
|
-
bottomAxis: PropTypes.oneOfType([PropTypes.
|
|
109
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
110
|
-
classes: PropTypes.object,
|
|
111
|
-
disableLine: PropTypes.bool,
|
|
112
|
-
disableTicks: PropTypes.bool,
|
|
113
|
-
fill: PropTypes.string,
|
|
114
|
-
label: PropTypes.string,
|
|
115
|
-
labelFontSize: PropTypes.number,
|
|
116
|
-
labelStyle: PropTypes.object,
|
|
117
|
-
position: PropTypes.oneOf(['bottom', 'top']),
|
|
118
|
-
slotProps: PropTypes.object,
|
|
119
|
-
slots: PropTypes.object,
|
|
120
|
-
stroke: PropTypes.string,
|
|
121
|
-
tickFontSize: PropTypes.number,
|
|
122
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
123
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
124
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
125
|
-
tickLabelStyle: PropTypes.object,
|
|
126
|
-
tickMaxStep: PropTypes.number,
|
|
127
|
-
tickMinStep: PropTypes.number,
|
|
128
|
-
tickNumber: PropTypes.number,
|
|
129
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
130
|
-
tickSize: PropTypes.number
|
|
131
|
-
}), PropTypes.string]),
|
|
112
|
+
bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
132
113
|
children: PropTypes.node,
|
|
133
114
|
className: PropTypes.string,
|
|
134
115
|
/**
|
|
@@ -168,30 +149,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
168
149
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
169
150
|
* @default yAxisIds[0] The id of the first provided axis
|
|
170
151
|
*/
|
|
171
|
-
leftAxis: PropTypes.oneOfType([PropTypes.
|
|
172
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
173
|
-
classes: PropTypes.object,
|
|
174
|
-
disableLine: PropTypes.bool,
|
|
175
|
-
disableTicks: PropTypes.bool,
|
|
176
|
-
fill: PropTypes.string,
|
|
177
|
-
label: PropTypes.string,
|
|
178
|
-
labelFontSize: PropTypes.number,
|
|
179
|
-
labelStyle: PropTypes.object,
|
|
180
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
181
|
-
slotProps: PropTypes.object,
|
|
182
|
-
slots: PropTypes.object,
|
|
183
|
-
stroke: PropTypes.string,
|
|
184
|
-
tickFontSize: PropTypes.number,
|
|
185
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
186
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
187
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
188
|
-
tickLabelStyle: PropTypes.object,
|
|
189
|
-
tickMaxStep: PropTypes.number,
|
|
190
|
-
tickMinStep: PropTypes.number,
|
|
191
|
-
tickNumber: PropTypes.number,
|
|
192
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
193
|
-
tickSize: PropTypes.number
|
|
194
|
-
}), PropTypes.string]),
|
|
152
|
+
leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
195
153
|
/**
|
|
196
154
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
197
155
|
*/
|
|
@@ -229,32 +187,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
229
187
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
230
188
|
* @default null
|
|
231
189
|
*/
|
|
232
|
-
rightAxis: PropTypes.oneOfType([PropTypes.
|
|
233
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
234
|
-
classes: PropTypes.object,
|
|
235
|
-
disableLine: PropTypes.bool,
|
|
236
|
-
disableTicks: PropTypes.bool,
|
|
237
|
-
fill: PropTypes.string,
|
|
238
|
-
label: PropTypes.string,
|
|
239
|
-
labelFontSize: PropTypes.number,
|
|
240
|
-
labelStyle: PropTypes.object,
|
|
241
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
242
|
-
slotProps: PropTypes.object,
|
|
243
|
-
slots: PropTypes.object,
|
|
244
|
-
stroke: PropTypes.string,
|
|
245
|
-
tickFontSize: PropTypes.number,
|
|
246
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
247
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
248
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
249
|
-
tickLabelStyle: PropTypes.object,
|
|
250
|
-
tickMaxStep: PropTypes.number,
|
|
251
|
-
tickMinStep: PropTypes.number,
|
|
252
|
-
tickNumber: PropTypes.number,
|
|
253
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
254
|
-
tickSize: PropTypes.number
|
|
255
|
-
}), PropTypes.string]),
|
|
190
|
+
rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
256
191
|
/**
|
|
257
192
|
* The series to display in the scatter chart.
|
|
193
|
+
* An array of [[ScatterSeriesType]] objects.
|
|
258
194
|
*/
|
|
259
195
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
260
196
|
/**
|
|
@@ -287,30 +223,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
287
223
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
288
224
|
* @default null
|
|
289
225
|
*/
|
|
290
|
-
topAxis: PropTypes.oneOfType([PropTypes.
|
|
291
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
292
|
-
classes: PropTypes.object,
|
|
293
|
-
disableLine: PropTypes.bool,
|
|
294
|
-
disableTicks: PropTypes.bool,
|
|
295
|
-
fill: PropTypes.string,
|
|
296
|
-
label: PropTypes.string,
|
|
297
|
-
labelFontSize: PropTypes.number,
|
|
298
|
-
labelStyle: PropTypes.object,
|
|
299
|
-
position: PropTypes.oneOf(['bottom', 'top']),
|
|
300
|
-
slotProps: PropTypes.object,
|
|
301
|
-
slots: PropTypes.object,
|
|
302
|
-
stroke: PropTypes.string,
|
|
303
|
-
tickFontSize: PropTypes.number,
|
|
304
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
305
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
306
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
307
|
-
tickLabelStyle: PropTypes.object,
|
|
308
|
-
tickMaxStep: PropTypes.number,
|
|
309
|
-
tickMinStep: PropTypes.number,
|
|
310
|
-
tickNumber: PropTypes.number,
|
|
311
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
312
|
-
tickSize: PropTypes.number
|
|
313
|
-
}), PropTypes.string]),
|
|
226
|
+
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
314
227
|
viewBox: PropTypes.shape({
|
|
315
228
|
height: PropTypes.number,
|
|
316
229
|
width: PropTypes.number,
|
|
@@ -328,11 +241,27 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
328
241
|
width: PropTypes.number,
|
|
329
242
|
/**
|
|
330
243
|
* The configuration of the x-axes.
|
|
331
|
-
* If not provided, a default axis config is used
|
|
244
|
+
* If not provided, a default axis config is used.
|
|
245
|
+
* An array of [[AxisConfig]] objects.
|
|
332
246
|
*/
|
|
333
247
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
334
248
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
335
249
|
classes: PropTypes.object,
|
|
250
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
251
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
252
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
253
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
254
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
255
|
+
}), PropTypes.shape({
|
|
256
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
257
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
258
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
259
|
+
}), PropTypes.shape({
|
|
260
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
261
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
262
|
+
unknownColor: PropTypes.string,
|
|
263
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
264
|
+
})]),
|
|
336
265
|
data: PropTypes.array,
|
|
337
266
|
dataKey: PropTypes.string,
|
|
338
267
|
disableLine: PropTypes.bool,
|
|
@@ -365,11 +294,27 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
365
294
|
})),
|
|
366
295
|
/**
|
|
367
296
|
* The configuration of the y-axes.
|
|
368
|
-
* If not provided, a default axis config is used
|
|
297
|
+
* If not provided, a default axis config is used.
|
|
298
|
+
* An array of [[AxisConfig]] objects.
|
|
369
299
|
*/
|
|
370
300
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
371
301
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
372
302
|
classes: PropTypes.object,
|
|
303
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
304
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
305
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
306
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
307
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
308
|
+
}), PropTypes.shape({
|
|
309
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
310
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
311
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
312
|
+
}), PropTypes.shape({
|
|
313
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
314
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
315
|
+
unknownColor: PropTypes.string,
|
|
316
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
317
|
+
})]),
|
|
373
318
|
data: PropTypes.array,
|
|
374
319
|
dataKey: PropTypes.string,
|
|
375
320
|
disableLine: PropTypes.bool,
|
|
@@ -399,6 +344,29 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
399
344
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
400
345
|
tickSize: PropTypes.number,
|
|
401
346
|
valueFormatter: PropTypes.func
|
|
347
|
+
})),
|
|
348
|
+
/**
|
|
349
|
+
* The configuration of the z-axes.
|
|
350
|
+
*/
|
|
351
|
+
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
352
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
353
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
354
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
355
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
356
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
357
|
+
}), PropTypes.shape({
|
|
358
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
359
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
360
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
361
|
+
}), PropTypes.shape({
|
|
362
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
363
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
364
|
+
unknownColor: PropTypes.string,
|
|
365
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
366
|
+
})]),
|
|
367
|
+
data: PropTypes.array,
|
|
368
|
+
dataKey: PropTypes.string,
|
|
369
|
+
id: PropTypes.string
|
|
402
370
|
}))
|
|
403
371
|
} : void 0;
|
|
404
372
|
export { ScatterChart };
|
|
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { Scatter } from './Scatter';
|
|
5
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
|
+
import getColor from './getColor';
|
|
8
|
+
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
7
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
10
|
/**
|
|
9
11
|
* Demos:
|
|
@@ -23,6 +25,10 @@ function ScatterPlot(props) {
|
|
|
23
25
|
} = props;
|
|
24
26
|
const seriesData = React.useContext(SeriesContext).scatter;
|
|
25
27
|
const axisData = React.useContext(CartesianContext);
|
|
28
|
+
const {
|
|
29
|
+
zAxis,
|
|
30
|
+
zAxisIds
|
|
31
|
+
} = React.useContext(ZAxisContext);
|
|
26
32
|
if (seriesData === undefined) {
|
|
27
33
|
return null;
|
|
28
34
|
}
|
|
@@ -38,6 +44,7 @@ function ScatterPlot(props) {
|
|
|
38
44
|
} = axisData;
|
|
39
45
|
const defaultXAxisId = xAxisIds[0];
|
|
40
46
|
const defaultYAxisId = yAxisIds[0];
|
|
47
|
+
const defaultZAxisId = zAxisIds[0];
|
|
41
48
|
const ScatterItems = slots?.scatter ?? Scatter;
|
|
42
49
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
43
50
|
children: seriesOrder.map(seriesId => {
|
|
@@ -45,15 +52,18 @@ function ScatterPlot(props) {
|
|
|
45
52
|
id,
|
|
46
53
|
xAxisKey,
|
|
47
54
|
yAxisKey,
|
|
55
|
+
zAxisKey,
|
|
48
56
|
markerSize,
|
|
49
57
|
color
|
|
50
58
|
} = series[seriesId];
|
|
59
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
|
|
51
60
|
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
52
61
|
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
53
62
|
return /*#__PURE__*/_jsx(ScatterItems, _extends({
|
|
54
63
|
xScale: xScale,
|
|
55
64
|
yScale: yScale,
|
|
56
65
|
color: color,
|
|
66
|
+
colorGetter: colorGetter,
|
|
57
67
|
markerSize: markerSize ?? 4,
|
|
58
68
|
series: series[seriesId],
|
|
59
69
|
onItemClick: onItemClick
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export default function getColor(series, xAxis, yAxis, zAxis) {
|
|
2
|
+
const zColorScale = zAxis?.colorScale;
|
|
3
|
+
const yColorScale = yAxis.colorScale;
|
|
4
|
+
const xColorScale = xAxis.colorScale;
|
|
5
|
+
if (zColorScale) {
|
|
6
|
+
return dataIndex => {
|
|
7
|
+
if (zAxis?.data?.[dataIndex] !== undefined) {
|
|
8
|
+
const color = zColorScale(zAxis?.data?.[dataIndex]);
|
|
9
|
+
if (color !== null) {
|
|
10
|
+
return color;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const value = series.data[dataIndex];
|
|
14
|
+
const color = value === null ? series.color : zColorScale(value.z);
|
|
15
|
+
if (color === null) {
|
|
16
|
+
return series.color;
|
|
17
|
+
}
|
|
18
|
+
return color;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (yColorScale) {
|
|
22
|
+
return dataIndex => {
|
|
23
|
+
const value = series.data[dataIndex];
|
|
24
|
+
const color = value === null ? series.color : yColorScale(value.y);
|
|
25
|
+
if (color === null) {
|
|
26
|
+
return series.color;
|
|
27
|
+
}
|
|
28
|
+
return color;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (xColorScale) {
|
|
32
|
+
return dataIndex => {
|
|
33
|
+
const value = series.data[dataIndex];
|
|
34
|
+
const color = value === null ? series.color : xColorScale(value.x);
|
|
35
|
+
if (color === null) {
|
|
36
|
+
return series.color;
|
|
37
|
+
}
|
|
38
|
+
return color;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return () => series.color;
|
|
42
|
+
}
|
|
@@ -7,8 +7,7 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
|
7
7
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
8
8
|
import { ChartsTooltip } from '../ChartsTooltip';
|
|
9
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
11
|
const SPARKLINE_DEFAULT_MARGIN = {
|
|
13
12
|
top: 5,
|
|
14
13
|
bottom: 5,
|
|
@@ -226,6 +225,21 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
226
225
|
xAxis: PropTypes.shape({
|
|
227
226
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
228
227
|
classes: PropTypes.object,
|
|
228
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
229
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
230
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
231
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
232
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
233
|
+
}), PropTypes.shape({
|
|
234
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
235
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
236
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
237
|
+
}), PropTypes.shape({
|
|
238
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
239
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
240
|
+
unknownColor: PropTypes.string,
|
|
241
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
242
|
+
})]),
|
|
229
243
|
data: PropTypes.array,
|
|
230
244
|
dataKey: PropTypes.string,
|
|
231
245
|
disableLine: PropTypes.bool,
|
|
@@ -6,10 +6,11 @@ import { getExtremumX as getScatterExtremumX, getExtremumY as getScatterExtremum
|
|
|
6
6
|
import { getExtremumX as getLineExtremumX, getExtremumY as getLineExtremumY } from '../LineChart/extremums';
|
|
7
7
|
import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
|
|
8
8
|
import { getScale } from '../internals/getScale';
|
|
9
|
-
import { DrawingContext } from './DrawingProvider';
|
|
10
9
|
import { SeriesContext } from './SeriesContextProvider';
|
|
11
10
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
12
11
|
import { getTickNumber } from '../hooks/useTicks';
|
|
12
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
13
|
+
import { getColorScale, getOrdinalColorScale } from '../internals/colorScale';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
15
16
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
@@ -42,7 +43,7 @@ function CartesianContextProvider(props) {
|
|
|
42
43
|
children
|
|
43
44
|
} = props;
|
|
44
45
|
const formattedSeries = React.useContext(SeriesContext);
|
|
45
|
-
const drawingArea =
|
|
46
|
+
const drawingArea = useDrawingArea();
|
|
46
47
|
const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
|
|
47
48
|
const dataKey = axisConfig.dataKey;
|
|
48
49
|
if (dataKey === undefined || axisConfig.data !== undefined) {
|
|
@@ -112,13 +113,19 @@ function CartesianContextProvider(props) {
|
|
|
112
113
|
barGapRatio
|
|
113
114
|
}, axis, {
|
|
114
115
|
scale: scaleBand(axis.data, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
115
|
-
tickNumber: axis.data.length
|
|
116
|
+
tickNumber: axis.data.length,
|
|
117
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
118
|
+
values: axis.data
|
|
119
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
122
|
if (isPointScaleConfig(axis)) {
|
|
119
123
|
completedXAxis[axis.id] = _extends({}, axis, {
|
|
120
124
|
scale: scalePoint(axis.data, range),
|
|
121
|
-
tickNumber: axis.data.length
|
|
125
|
+
tickNumber: axis.data.length,
|
|
126
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
127
|
+
values: axis.data
|
|
128
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
122
129
|
});
|
|
123
130
|
}
|
|
124
131
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
@@ -137,7 +144,8 @@ function CartesianContextProvider(props) {
|
|
|
137
144
|
completedXAxis[axis.id] = _extends({}, axis, {
|
|
138
145
|
scaleType,
|
|
139
146
|
scale: niceScale.domain(domain),
|
|
140
|
-
tickNumber
|
|
147
|
+
tickNumber,
|
|
148
|
+
colorScale: axis.colorMap && getColorScale(axis.colorMap)
|
|
141
149
|
});
|
|
142
150
|
});
|
|
143
151
|
const allYAxis = [...(yAxis?.map((axis, index) => _extends({
|
|
@@ -160,13 +168,19 @@ function CartesianContextProvider(props) {
|
|
|
160
168
|
barGapRatio: 0
|
|
161
169
|
}, axis, {
|
|
162
170
|
scale: scaleBand(axis.data, [range[1], range[0]]).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
163
|
-
tickNumber: axis.data.length
|
|
171
|
+
tickNumber: axis.data.length,
|
|
172
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
173
|
+
values: axis.data
|
|
174
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
164
175
|
});
|
|
165
176
|
}
|
|
166
177
|
if (isPointScaleConfig(axis)) {
|
|
167
178
|
completedYAxis[axis.id] = _extends({}, axis, {
|
|
168
179
|
scale: scalePoint(axis.data, [range[1], range[0]]),
|
|
169
|
-
tickNumber: axis.data.length
|
|
180
|
+
tickNumber: axis.data.length,
|
|
181
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
182
|
+
values: axis.data
|
|
183
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
170
184
|
});
|
|
171
185
|
}
|
|
172
186
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
@@ -185,7 +199,8 @@ function CartesianContextProvider(props) {
|
|
|
185
199
|
completedYAxis[axis.id] = _extends({}, axis, {
|
|
186
200
|
scaleType,
|
|
187
201
|
scale: niceScale.domain(domain),
|
|
188
|
-
tickNumber
|
|
202
|
+
tickNumber,
|
|
203
|
+
colorScale: axis.colorMap && getColorScale(axis.colorMap)
|
|
189
204
|
});
|
|
190
205
|
});
|
|
191
206
|
return {
|