@mui/x-charts 7.3.0 → 7.3.2
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 +5 -3
- package/BarChart/BarChart.js +23 -102
- package/BarChart/BarElement.d.ts +63 -62
- package/BarChart/BarElement.js +1 -2
- package/BarChart/BarPlot.js +9 -9
- package/CHANGELOG.md +155 -7
- package/ChartContainer/ChartContainer.js +3 -1
- package/ChartsAxis/ChartsAxis.js +7 -99
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsClipPath/ChartsClipPath.js +1 -1
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsLegend/ChartsLegend.js +1 -1
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsOverlay/ChartsLoadingOverlay.d.ts +3 -0
- package/ChartsOverlay/ChartsLoadingOverlay.js +43 -0
- package/ChartsOverlay/ChartsNoDataOverlay.d.ts +3 -0
- package/ChartsOverlay/ChartsNoDataOverlay.js +43 -0
- package/ChartsOverlay/ChartsOverlay.d.ts +35 -0
- package/ChartsOverlay/ChartsOverlay.js +41 -0
- package/ChartsOverlay/index.d.ts +3 -0
- package/ChartsOverlay/index.js +26 -0
- package/ChartsOverlay/package.json +6 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsSurface.js +1 -1
- package/ChartsText/ChartsText.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +18 -5
- package/ChartsTooltip/ChartsItemTooltipContent.js +20 -4
- package/ChartsTooltip/ChartsTooltip.d.ts +2 -2
- package/ChartsTooltip/ChartsTooltip.js +3 -3
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -7
- package/ChartsTooltip/ChartsTooltipTable.js +8 -9
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -6
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -4
- package/ChartsTooltip/utils.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -1
- package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
- package/ChartsXAxis/ChartsXAxis.js +8 -1
- package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
- package/ChartsYAxis/ChartsYAxis.js +8 -1
- package/Gauge/Gauge.js +2 -2
- package/Gauge/GaugeContainer.js +2 -2
- package/Gauge/GaugeProvider.d.ts +2 -2
- package/Gauge/GaugeProvider.js +2 -2
- package/Gauge/GaugeReferenceArc.js +1 -1
- package/Gauge/GaugeValueArc.js +1 -1
- package/Gauge/GaugeValueText.js +1 -1
- package/Gauge/gaugeClasses.d.ts +2 -2
- package/Gauge/utils.d.ts +1 -1
- package/Gauge/utils.js +4 -4
- package/LineChart/AnimatedArea.d.ts +63 -62
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.d.ts +63 -62
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/AreaElement.js +1 -1
- package/LineChart/AreaPlot.js +1 -1
- package/LineChart/LineChart.d.ts +5 -3
- package/LineChart/LineChart.js +20 -99
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineElement.js +1 -1
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +1 -1
- package/LineChart/LinePlot.js +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.js +1 -1
- package/PieChart/PieArc.d.ts +2 -1
- package/PieChart/PieArc.js +1 -1
- package/PieChart/PieArcLabel.d.ts +2 -1
- package/PieChart/PieArcLabel.js +2 -2
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +4 -4
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +4 -4
- package/PieChart/PieChart.d.ts +5 -3
- package/PieChart/PieChart.js +23 -99
- package/PieChart/PiePlot.js +1 -1
- package/PieChart/dataTransform/transition.d.ts +1 -0
- package/PieChart/dataTransform/useTransformData.js +1 -1
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +1 -1
- package/ScatterChart/Scatter.js +1 -1
- package/ScatterChart/ScatterChart.d.ts +6 -3
- package/ScatterChart/ScatterChart.js +74 -125
- package/ScatterChart/ScatterPlot.js +9 -2
- package/ScatterChart/getColor.d.ts +2 -1
- package/ScatterChart/getColor.js +18 -1
- package/SparkLineChart/SparkLineChart.js +1 -1
- package/context/CartesianContextProvider.d.ts +2 -1
- package/context/CartesianContextProvider.js +1 -1
- package/context/DrawingProvider.js +1 -1
- package/context/HighlightProvider.js +1 -1
- package/context/InteractionProvider.js +1 -1
- package/context/SeriesContextProvider.js +2 -2
- 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 +23 -103
- package/esm/BarChart/BarElement.js +0 -1
- package/esm/BarChart/BarPlot.js +8 -8
- package/esm/ChartContainer/ChartContainer.js +3 -2
- package/esm/ChartsAxis/ChartsAxis.js +7 -100
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/esm/ChartsGrid/ChartsGrid.js +1 -2
- package/esm/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
- package/esm/ChartsOverlay/ChartsOverlay.js +31 -0
- package/esm/ChartsOverlay/index.js +3 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- 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 +17 -4
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +19 -3
- package/esm/ChartsTooltip/ChartsTooltip.js +2 -2
- package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -7
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -5
- package/esm/ChartsXAxis/ChartsXAxis.js +8 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +8 -2
- package/esm/Gauge/Gauge.js +2 -3
- package/esm/Gauge/GaugeContainer.js +1 -1
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/Gauge/utils.js +4 -4
- package/esm/LineChart/AnimatedArea.js +1 -2
- package/esm/LineChart/AnimatedLine.js +1 -2
- package/esm/LineChart/LineChart.js +20 -100
- package/esm/PieChart/PieArcLabel.js +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +3 -3
- package/esm/PieChart/PieArcPlot.js +3 -3
- package/esm/PieChart/PieChart.js +23 -100
- package/esm/PieChart/PiePlot.js +1 -2
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
- package/esm/ScatterChart/ScatterChart.js +74 -126
- package/esm/ScatterChart/ScatterPlot.js +8 -1
- package/esm/ScatterChart/getColor.js +18 -1
- package/esm/SparkLineChart/SparkLineChart.js +1 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/context/ZAxisContextProvider.js +89 -0
- package/esm/context/index.js +1 -1
- package/esm/hooks/useReducedMotion.js +1 -1
- package/esm/hooks/useScale.js +1 -1
- package/esm/hooks/useTicks.js +4 -0
- package/esm/internals/colorGetter.js +2 -2
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +6 -7
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +4 -5
- package/esm/internals/utils.js +1 -1
- package/esm/models/z-axis.js +1 -0
- package/hooks/useAxisEvents.js +1 -1
- package/hooks/useChartDimensions.js +1 -1
- package/hooks/useChartId.js +1 -1
- package/hooks/useDrawingArea.js +1 -1
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useMounted.js +1 -1
- package/hooks/useReducedMotion.d.ts +1 -1
- package/hooks/useReducedMotion.js +1 -1
- package/hooks/useScale.d.ts +4 -4
- package/hooks/useScale.js +2 -2
- package/hooks/useSeries.js +1 -1
- package/hooks/useSvgRef.js +1 -1
- package/hooks/useTicks.js +5 -1
- package/index.js +1 -1
- package/internals/colorGetter.d.ts +3 -1
- package/internals/colorGetter.js +2 -2
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +6 -6
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +4 -4
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +4 -4
- package/internals/defaultizeColor.d.ts +1 -0
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +1 -1
- package/internals/utils.d.ts +1 -1
- package/internals/utils.js +1 -1
- package/models/axis.d.ts +1 -1
- package/models/colorMapping.d.ts +3 -2
- package/models/seriesType/bar.d.ts +1 -1
- package/models/seriesType/line.d.ts +1 -1
- package/models/seriesType/pie.d.ts +9 -4
- 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 +23 -103
- package/modern/BarChart/BarElement.js +0 -1
- package/modern/BarChart/BarPlot.js +8 -8
- package/modern/ChartContainer/ChartContainer.js +3 -2
- package/modern/ChartsAxis/ChartsAxis.js +7 -100
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/modern/ChartsGrid/ChartsGrid.js +1 -2
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
- package/modern/ChartsOverlay/ChartsOverlay.js +31 -0
- package/modern/ChartsOverlay/index.js +3 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- 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 +17 -4
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +19 -3
- package/modern/ChartsTooltip/ChartsTooltip.js +2 -2
- package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -7
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -5
- package/modern/ChartsXAxis/ChartsXAxis.js +8 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +8 -2
- package/modern/Gauge/Gauge.js +2 -3
- package/modern/Gauge/GaugeContainer.js +1 -1
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/Gauge/utils.js +4 -4
- package/modern/LineChart/AnimatedArea.js +1 -2
- package/modern/LineChart/AnimatedLine.js +1 -2
- package/modern/LineChart/LineChart.js +20 -100
- package/modern/PieChart/PieArcLabel.js +1 -1
- package/modern/PieChart/PieArcLabelPlot.js +3 -3
- package/modern/PieChart/PieArcPlot.js +3 -3
- package/modern/PieChart/PieChart.js +23 -100
- package/modern/PieChart/PiePlot.js +1 -2
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
- package/modern/ScatterChart/ScatterChart.js +74 -126
- package/modern/ScatterChart/ScatterPlot.js +8 -1
- package/modern/ScatterChart/getColor.js +18 -1
- package/modern/SparkLineChart/SparkLineChart.js +1 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/context/ZAxisContextProvider.js +89 -0
- package/modern/context/index.js +1 -1
- package/modern/hooks/useReducedMotion.js +1 -1
- package/modern/hooks/useScale.js +1 -1
- package/modern/hooks/useTicks.js +4 -0
- package/modern/index.js +1 -1
- package/modern/internals/colorGetter.js +2 -2
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +6 -7
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +4 -5
- package/modern/internals/utils.js +1 -1
- package/modern/models/z-axis.js +1 -0
- package/package.json +3 -5
|
@@ -6,11 +6,12 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
|
6
6
|
import { ChartsAxis } from '../ChartsAxis';
|
|
7
7
|
import { ChartsTooltip } from '../ChartsTooltip';
|
|
8
8
|
import { ChartsLegend } from '../ChartsLegend';
|
|
9
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
9
10
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
11
|
import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
11
12
|
import { ChartsGrid } from '../ChartsGrid';
|
|
12
|
-
import {
|
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { ZAxisContextProvider } from '../context/ZAxisContextProvider';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
/**
|
|
15
16
|
* Demos:
|
|
16
17
|
*
|
|
@@ -25,6 +26,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
25
26
|
const {
|
|
26
27
|
xAxis,
|
|
27
28
|
yAxis,
|
|
29
|
+
zAxis,
|
|
28
30
|
series,
|
|
29
31
|
tooltip,
|
|
30
32
|
axisHighlight,
|
|
@@ -44,9 +46,10 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
44
46
|
onItemClick,
|
|
45
47
|
children,
|
|
46
48
|
slots,
|
|
47
|
-
slotProps
|
|
49
|
+
slotProps,
|
|
50
|
+
loading
|
|
48
51
|
} = props;
|
|
49
|
-
return /*#__PURE__*/
|
|
52
|
+
return /*#__PURE__*/_jsx(ResponsiveChartContainer, {
|
|
50
53
|
ref: ref,
|
|
51
54
|
series: series.map(s => _extends({
|
|
52
55
|
type: 'scatter'
|
|
@@ -58,32 +61,39 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
58
61
|
xAxis: xAxis,
|
|
59
62
|
yAxis: yAxis,
|
|
60
63
|
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
|
-
|
|
64
|
+
children: /*#__PURE__*/_jsxs(ZAxisContextProvider, {
|
|
65
|
+
zAxis: zAxis,
|
|
66
|
+
children: [!disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, {
|
|
67
|
+
voronoiMaxRadius: voronoiMaxRadius,
|
|
68
|
+
onItemClick: onItemClick
|
|
69
|
+
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
70
|
+
topAxis: topAxis,
|
|
71
|
+
leftAxis: leftAxis,
|
|
72
|
+
rightAxis: rightAxis,
|
|
73
|
+
bottomAxis: bottomAxis,
|
|
74
|
+
slots: slots,
|
|
75
|
+
slotProps: slotProps
|
|
76
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
77
|
+
vertical: grid.vertical,
|
|
78
|
+
horizontal: grid.horizontal
|
|
79
|
+
}), /*#__PURE__*/_jsx(ScatterPlot, {
|
|
80
|
+
slots: slots,
|
|
81
|
+
slotProps: slotProps,
|
|
82
|
+
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
83
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
84
|
+
loading: loading,
|
|
85
|
+
slots: slots,
|
|
86
|
+
slotProps: slotProps
|
|
87
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
88
|
+
slots: slots,
|
|
89
|
+
slotProps: slotProps
|
|
90
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
91
|
+
x: "none",
|
|
92
|
+
y: "none"
|
|
93
|
+
}, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
94
|
+
trigger: "item"
|
|
95
|
+
}, tooltip)), children]
|
|
96
|
+
})
|
|
87
97
|
});
|
|
88
98
|
});
|
|
89
99
|
process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
@@ -105,30 +115,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
105
115
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
106
116
|
* @default xAxisIds[0] The id of the first provided axis
|
|
107
117
|
*/
|
|
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]),
|
|
118
|
+
bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
132
119
|
children: PropTypes.node,
|
|
133
120
|
className: PropTypes.string,
|
|
134
121
|
/**
|
|
@@ -168,30 +155,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
168
155
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
169
156
|
* @default yAxisIds[0] The id of the first provided axis
|
|
170
157
|
*/
|
|
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]),
|
|
158
|
+
leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
195
159
|
/**
|
|
196
160
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
197
161
|
*/
|
|
@@ -206,6 +170,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
206
170
|
slotProps: PropTypes.object,
|
|
207
171
|
slots: PropTypes.object
|
|
208
172
|
}),
|
|
173
|
+
/**
|
|
174
|
+
* If `true`, a loading overlay is displayed.
|
|
175
|
+
*/
|
|
176
|
+
loading: PropTypes.bool,
|
|
209
177
|
/**
|
|
210
178
|
* The margin between the SVG and the drawing area.
|
|
211
179
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -229,32 +197,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
229
197
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
230
198
|
* @default null
|
|
231
199
|
*/
|
|
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]),
|
|
200
|
+
rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
256
201
|
/**
|
|
257
202
|
* The series to display in the scatter chart.
|
|
203
|
+
* An array of [[ScatterSeriesType]] objects.
|
|
258
204
|
*/
|
|
259
205
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
260
206
|
/**
|
|
@@ -287,30 +233,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
287
233
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
288
234
|
* @default null
|
|
289
235
|
*/
|
|
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]),
|
|
236
|
+
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
314
237
|
viewBox: PropTypes.shape({
|
|
315
238
|
height: PropTypes.number,
|
|
316
239
|
width: PropTypes.number,
|
|
@@ -329,6 +252,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
329
252
|
/**
|
|
330
253
|
* The configuration of the x-axes.
|
|
331
254
|
* If not provided, a default axis config is used.
|
|
255
|
+
* An array of [[AxisConfig]] objects.
|
|
332
256
|
*/
|
|
333
257
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
334
258
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -381,6 +305,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
381
305
|
/**
|
|
382
306
|
* The configuration of the y-axes.
|
|
383
307
|
* If not provided, a default axis config is used.
|
|
308
|
+
* An array of [[AxisConfig]] objects.
|
|
384
309
|
*/
|
|
385
310
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
386
311
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -429,6 +354,29 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
429
354
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
430
355
|
tickSize: PropTypes.number,
|
|
431
356
|
valueFormatter: PropTypes.func
|
|
357
|
+
})),
|
|
358
|
+
/**
|
|
359
|
+
* The configuration of the z-axes.
|
|
360
|
+
*/
|
|
361
|
+
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
362
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
363
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
364
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
365
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
366
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
367
|
+
}), PropTypes.shape({
|
|
368
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
369
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
370
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
371
|
+
}), PropTypes.shape({
|
|
372
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
373
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
374
|
+
unknownColor: PropTypes.string,
|
|
375
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
376
|
+
})]),
|
|
377
|
+
data: PropTypes.array,
|
|
378
|
+
dataKey: PropTypes.string,
|
|
379
|
+
id: PropTypes.string
|
|
432
380
|
}))
|
|
433
381
|
} : void 0;
|
|
434
382
|
export { ScatterChart };
|
|
@@ -5,6 +5,7 @@ import { Scatter } from './Scatter';
|
|
|
5
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
7
|
import getColor from './getColor';
|
|
8
|
+
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
/**
|
|
10
11
|
* Demos:
|
|
@@ -24,6 +25,10 @@ function ScatterPlot(props) {
|
|
|
24
25
|
} = props;
|
|
25
26
|
const seriesData = React.useContext(SeriesContext).scatter;
|
|
26
27
|
const axisData = React.useContext(CartesianContext);
|
|
28
|
+
const {
|
|
29
|
+
zAxis,
|
|
30
|
+
zAxisIds
|
|
31
|
+
} = React.useContext(ZAxisContext);
|
|
27
32
|
if (seriesData === undefined) {
|
|
28
33
|
return null;
|
|
29
34
|
}
|
|
@@ -39,6 +44,7 @@ function ScatterPlot(props) {
|
|
|
39
44
|
} = axisData;
|
|
40
45
|
const defaultXAxisId = xAxisIds[0];
|
|
41
46
|
const defaultYAxisId = yAxisIds[0];
|
|
47
|
+
const defaultZAxisId = zAxisIds[0];
|
|
42
48
|
const ScatterItems = slots?.scatter ?? Scatter;
|
|
43
49
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
44
50
|
children: seriesOrder.map(seriesId => {
|
|
@@ -46,10 +52,11 @@ function ScatterPlot(props) {
|
|
|
46
52
|
id,
|
|
47
53
|
xAxisKey,
|
|
48
54
|
yAxisKey,
|
|
55
|
+
zAxisKey,
|
|
49
56
|
markerSize,
|
|
50
57
|
color
|
|
51
58
|
} = series[seriesId];
|
|
52
|
-
const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId]);
|
|
59
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
|
|
53
60
|
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
54
61
|
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
55
62
|
return /*#__PURE__*/_jsx(ScatterItems, _extends({
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
export default function getColor(series, xAxis, yAxis) {
|
|
1
|
+
export default function getColor(series, xAxis, yAxis, zAxis) {
|
|
2
|
+
const zColorScale = zAxis?.colorScale;
|
|
2
3
|
const yColorScale = yAxis.colorScale;
|
|
3
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
|
+
}
|
|
4
21
|
if (yColorScale) {
|
|
5
22
|
return dataIndex => {
|
|
6
23
|
const value = series.data[dataIndex];
|
|
@@ -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,
|
|
@@ -50,7 +50,7 @@ const formatSeries = (series, colors, dataset) => {
|
|
|
50
50
|
seriesGroups[type].seriesOrder.push(id);
|
|
51
51
|
});
|
|
52
52
|
const formattedSeries = {};
|
|
53
|
-
// Apply
|
|
53
|
+
// Apply formatter on a type group
|
|
54
54
|
Object.keys(seriesTypeFormatter).forEach(type => {
|
|
55
55
|
if (seriesGroups[type] !== undefined) {
|
|
56
56
|
formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { getColorScale, getOrdinalColorScale } from '../internals/colorScale';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const ZAxisContext = /*#__PURE__*/React.createContext({
|
|
7
|
+
zAxis: {},
|
|
8
|
+
zAxisIds: []
|
|
9
|
+
});
|
|
10
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
11
|
+
ZAxisContext.displayName = 'ZAxisContext';
|
|
12
|
+
}
|
|
13
|
+
function ZAxisContextProvider(props) {
|
|
14
|
+
const {
|
|
15
|
+
zAxis: inZAxis,
|
|
16
|
+
dataset,
|
|
17
|
+
children
|
|
18
|
+
} = props;
|
|
19
|
+
const zAxis = React.useMemo(() => inZAxis?.map(axisConfig => {
|
|
20
|
+
const dataKey = axisConfig.dataKey;
|
|
21
|
+
if (dataKey === undefined || axisConfig.data !== undefined) {
|
|
22
|
+
return axisConfig;
|
|
23
|
+
}
|
|
24
|
+
if (dataset === undefined) {
|
|
25
|
+
throw Error('MUI X Charts: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
26
|
+
}
|
|
27
|
+
return _extends({}, axisConfig, {
|
|
28
|
+
data: dataset.map(d => d[dataKey])
|
|
29
|
+
});
|
|
30
|
+
}), [inZAxis, dataset]);
|
|
31
|
+
const value = React.useMemo(() => {
|
|
32
|
+
const allZAxis = zAxis?.map((axis, index) => _extends({
|
|
33
|
+
id: `defaultized-z-axis-${index}`
|
|
34
|
+
}, axis)) ?? [];
|
|
35
|
+
const completedZAxis = {};
|
|
36
|
+
allZAxis.forEach(axis => {
|
|
37
|
+
completedZAxis[axis.id] = _extends({}, axis, {
|
|
38
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' && axis.data ? getOrdinalColorScale(_extends({
|
|
39
|
+
values: axis.data
|
|
40
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
zAxis: completedZAxis,
|
|
45
|
+
zAxisIds: allZAxis.map(({
|
|
46
|
+
id
|
|
47
|
+
}) => id)
|
|
48
|
+
};
|
|
49
|
+
}, [zAxis]);
|
|
50
|
+
return /*#__PURE__*/_jsx(ZAxisContext.Provider, {
|
|
51
|
+
value: value,
|
|
52
|
+
children: children
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
56
|
+
// ----------------------------- Warning --------------------------------
|
|
57
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
58
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
59
|
+
// ----------------------------------------------------------------------
|
|
60
|
+
children: PropTypes.node,
|
|
61
|
+
/**
|
|
62
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
63
|
+
*/
|
|
64
|
+
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
65
|
+
/**
|
|
66
|
+
* The configuration of the z-axes.
|
|
67
|
+
*/
|
|
68
|
+
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
69
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
70
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
71
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
72
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
73
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
74
|
+
}), PropTypes.shape({
|
|
75
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
76
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
77
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
78
|
+
}), PropTypes.shape({
|
|
79
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
80
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
81
|
+
unknownColor: PropTypes.string,
|
|
82
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
83
|
+
})]),
|
|
84
|
+
data: PropTypes.array,
|
|
85
|
+
dataKey: PropTypes.string,
|
|
86
|
+
id: PropTypes.string
|
|
87
|
+
}))
|
|
88
|
+
} : void 0;
|
|
89
|
+
export { ZAxisContextProvider };
|
package/esm/context/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { ZAxisContextProvider } from './ZAxisContextProvider';
|
|
@@ -5,7 +5,7 @@ import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
|
|
|
5
5
|
* set skipAnimations to the value of the user's
|
|
6
6
|
* `prefers-reduced-motion` query.
|
|
7
7
|
*
|
|
8
|
-
* The return value, post-effect, is the value of their
|
|
8
|
+
* The return value, post-effect, is the value of their preferred setting
|
|
9
9
|
*/
|
|
10
10
|
export const useReducedMotion = () => {
|
|
11
11
|
// Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
|
package/esm/hooks/useScale.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
3
3
|
import { isBandScale } from '../internals/isBandScale';
|
|
4
4
|
/**
|
|
5
5
|
* For a given scale return a function that map value to their position.
|
|
6
|
-
*
|
|
6
|
+
* Useful when dealing with specific scale such as band.
|
|
7
7
|
* @param scale The scale to use
|
|
8
8
|
* @returns (value: any) => number
|
|
9
9
|
*/
|
package/esm/hooks/useTicks.js
CHANGED
|
@@ -59,6 +59,10 @@ export function useTicks(options) {
|
|
|
59
59
|
labelOffset: 0
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
62
|
+
if (scale.domain().length === 0 || scale.domain()[0] === scale.domain()[1]) {
|
|
63
|
+
// The axis should not be visible, so ticks should also be hidden.
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
62
66
|
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
63
67
|
return ticks.map(value => ({
|
|
64
68
|
value,
|
|
@@ -2,7 +2,7 @@ import getBarColor from '../BarChart/getColor';
|
|
|
2
2
|
import getLineColor from '../LineChart/getColor';
|
|
3
3
|
import getScatterColor from '../ScatterChart/getColor';
|
|
4
4
|
import getPieColor from '../PieChart/getColor';
|
|
5
|
-
function getColor(series, xAxis, yAxis) {
|
|
5
|
+
function getColor(series, xAxis, yAxis, zAxis) {
|
|
6
6
|
if (xAxis !== undefined && yAxis !== undefined) {
|
|
7
7
|
if (series.type === 'bar') {
|
|
8
8
|
return getBarColor(series, xAxis, yAxis);
|
|
@@ -11,7 +11,7 @@ function getColor(series, xAxis, yAxis) {
|
|
|
11
11
|
return getLineColor(series, xAxis, yAxis);
|
|
12
12
|
}
|
|
13
13
|
if (series.type === 'scatter') {
|
|
14
|
-
return getScatterColor(series, xAxis, yAxis);
|
|
14
|
+
return getScatterColor(series, xAxis, yAxis, zAxis);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
if (series.type === 'pie') {
|
|
@@ -4,13 +4,12 @@ import { DrawingContext } from '../../../context/DrawingProvider';
|
|
|
4
4
|
import { useDrawingArea } from '../../../hooks';
|
|
5
5
|
import ChartsPiecewiseGradient from './ChartsPiecewiseGradient';
|
|
6
6
|
import ChartsContinuousGradient from './ChartsContinuousGradient';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
8
|
export function useChartGradient() {
|
|
10
9
|
const {
|
|
11
10
|
chartId
|
|
12
11
|
} = React.useContext(DrawingContext);
|
|
13
|
-
return React.useCallback((axisId, direction) => `${chartId}-
|
|
12
|
+
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
14
13
|
}
|
|
15
14
|
export function ChartsAxesGradients() {
|
|
16
15
|
const {
|
|
@@ -41,7 +40,7 @@ export function ChartsAxesGradients() {
|
|
|
41
40
|
} = yAxis[axisId];
|
|
42
41
|
if (colorMap?.type === 'piecewise') {
|
|
43
42
|
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
44
|
-
|
|
43
|
+
isReversed: !reverse,
|
|
45
44
|
scale: scale,
|
|
46
45
|
colorMap: colorMap,
|
|
47
46
|
size: svgHeight,
|
|
@@ -51,7 +50,7 @@ export function ChartsAxesGradients() {
|
|
|
51
50
|
}
|
|
52
51
|
if (colorMap?.type === 'continuous') {
|
|
53
52
|
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
54
|
-
|
|
53
|
+
isReversed: !reverse,
|
|
55
54
|
scale: scale,
|
|
56
55
|
colorScale: colorScale,
|
|
57
56
|
colorMap: colorMap,
|
|
@@ -71,7 +70,7 @@ export function ChartsAxesGradients() {
|
|
|
71
70
|
} = xAxis[axisId];
|
|
72
71
|
if (colorMap?.type === 'piecewise') {
|
|
73
72
|
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
74
|
-
|
|
73
|
+
isReversed: reverse,
|
|
75
74
|
scale: scale,
|
|
76
75
|
colorMap: colorMap,
|
|
77
76
|
size: svgWidth,
|
|
@@ -81,7 +80,7 @@ export function ChartsAxesGradients() {
|
|
|
81
80
|
}
|
|
82
81
|
if (colorMap?.type === 'continuous') {
|
|
83
82
|
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
84
|
-
|
|
83
|
+
isReversed: reverse,
|
|
85
84
|
scale: scale,
|
|
86
85
|
colorScale: colorScale,
|
|
87
86
|
colorMap: colorMap,
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
const PX_PRECISION = 10;
|
|
5
5
|
export default function ChartsContinuousGradient(props) {
|
|
6
6
|
const {
|
|
7
|
-
|
|
7
|
+
isReversed,
|
|
8
8
|
gradientId,
|
|
9
9
|
size,
|
|
10
10
|
direction,
|
|
@@ -26,7 +26,7 @@ export default function ChartsContinuousGradient(props) {
|
|
|
26
26
|
x2: "0",
|
|
27
27
|
y1: "0",
|
|
28
28
|
y2: "0",
|
|
29
|
-
[`${direction}${
|
|
29
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
30
30
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
31
31
|
,
|
|
32
32
|
children: Array.from({
|
|
@@ -40,7 +40,7 @@ export default function ChartsContinuousGradient(props) {
|
|
|
40
40
|
if (x === undefined) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
const offset =
|
|
43
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
44
44
|
const color = colorScale(value);
|
|
45
45
|
if (color === null) {
|
|
46
46
|
return null;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
3
|
export default function ChartsPiecewiseGradient(props) {
|
|
5
4
|
const {
|
|
6
|
-
|
|
5
|
+
isReversed,
|
|
7
6
|
gradientId,
|
|
8
7
|
size,
|
|
9
8
|
direction,
|
|
@@ -16,7 +15,7 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
16
15
|
x2: "0",
|
|
17
16
|
y1: "0",
|
|
18
17
|
y2: "0",
|
|
19
|
-
[`${direction}${
|
|
18
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
20
19
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
21
20
|
,
|
|
22
21
|
children: colorMap.thresholds.map((threshold, index) => {
|
|
@@ -24,7 +23,7 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
24
23
|
if (x === undefined) {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
27
|
-
const offset =
|
|
26
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
28
27
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
29
28
|
children: [/*#__PURE__*/_jsx("stop", {
|
|
30
29
|
offset: offset,
|
package/esm/internals/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ export function getSymbol(shape) {
|
|
|
4
4
|
return symbolNames.indexOf(shape) || 0;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Transform mouse event position to
|
|
7
|
+
* Transform mouse event position to coordinates inside the SVG.
|
|
8
8
|
* @param svg The SVG element
|
|
9
9
|
* @param event The mouseEvent to transform
|
|
10
10
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/hooks/useAxisEvents.js
CHANGED
|
@@ -12,7 +12,7 @@ var _utils = require("../internals/utils");
|
|
|
12
12
|
var _useSvgRef = require("./useSvgRef");
|
|
13
13
|
var _useDrawingArea = require("./useDrawingArea");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
function getAsANumber(value) {
|
|
17
17
|
return value instanceof Date ? value.getTime() : value;
|
|
18
18
|
}
|
|
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _constants = require("../constants");
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
const useChartDimensions = (width, height, margin) => {
|
|
14
14
|
const defaultizedMargin = (0, _extends2.default)({}, _constants.DEFAULT_MARGINS, margin);
|
|
15
15
|
const drawingArea = React.useMemo(() => ({
|