@mui/x-charts 7.0.0-beta.0 → 7.0.0-beta.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 +2 -1
- package/BarChart/BarChart.js +33 -12
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +7 -3
- package/BarChart/BarPlot.d.ts +11 -6
- package/BarChart/BarPlot.js +28 -15
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +406 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +20 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +83 -0
- package/ChartsOnAxisClickHandler/index.d.ts +1 -0
- package/ChartsOnAxisClickHandler/index.js +16 -0
- package/ChartsOnAxisClickHandler/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 +2 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -5
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +4 -1
- package/ChartsTooltip/utils.js +15 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/ChartsXAxis/ChartsXAxis.js +13 -9
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- package/LineChart/AnimatedArea.d.ts +1361 -0
- package/LineChart/AnimatedArea.js +111 -0
- package/LineChart/AnimatedLine.d.ts +1361 -0
- package/LineChart/AnimatedLine.js +113 -0
- package/LineChart/AreaElement.d.ts +19 -18
- package/LineChart/AreaElement.js +17 -34
- package/LineChart/AreaPlot.d.ts +12 -7
- package/LineChart/AreaPlot.js +91 -58
- package/LineChart/LineChart.d.ts +13 -4
- package/LineChart/LineChart.js +45 -14
- package/LineChart/LineElement.d.ts +19 -18
- package/LineChart/LineElement.js +16 -36
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +5 -3
- package/LineChart/LinePlot.d.ts +12 -7
- package/LineChart/LinePlot.js +89 -56
- package/LineChart/MarkElement.d.ts +8 -4
- package/LineChart/MarkElement.js +27 -13
- package/LineChart/MarkPlot.d.ts +8 -1
- package/LineChart/MarkPlot.js +80 -51
- package/LineChart/formatter.js +1 -1
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +22 -0
- package/PieChart/PieArc.d.ts +3 -2
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +2 -2
- package/PieChart/PieArcPlot.d.ts +2 -2
- package/PieChart/PieArcPlot.js +7 -7
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +14 -12
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -4
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/ScatterChart/Scatter.d.ts +7 -1
- package/ScatterChart/Scatter.js +17 -3
- package/ScatterChart/ScatterChart.d.ts +8 -2
- package/ScatterChart/ScatterChart.js +21 -10
- package/ScatterChart/ScatterPlot.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +10 -2
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +7 -4
- package/context/CartesianContextProvider.js +8 -6
- package/context/DrawingProvider.d.ts +6 -1
- package/context/DrawingProvider.js +9 -2
- package/context/InteractionProvider.d.ts +3 -3
- package/esm/BarChart/BarChart.js +33 -12
- package/esm/BarChart/BarElement.js +7 -3
- package/esm/BarChart/BarPlot.js +27 -15
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
- package/esm/ChartsOnAxisClickHandler/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -5
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +12 -0
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- package/esm/LineChart/AnimatedArea.js +103 -0
- package/esm/LineChart/AnimatedLine.js +105 -0
- package/esm/LineChart/AreaElement.js +16 -33
- package/esm/LineChart/AreaPlot.js +92 -59
- package/esm/LineChart/LineChart.js +45 -14
- package/esm/LineChart/LineElement.js +16 -35
- package/esm/LineChart/LineHighlightElement.js +5 -3
- package/esm/LineChart/LinePlot.js +90 -57
- package/esm/LineChart/MarkElement.js +27 -13
- package/esm/LineChart/MarkPlot.js +80 -51
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/index.js +2 -0
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +2 -2
- package/esm/PieChart/PieArcPlot.js +7 -7
- package/esm/PieChart/PieChart.js +14 -12
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/esm/ScatterChart/Scatter.js +17 -3
- package/esm/ScatterChart/ScatterChart.js +21 -10
- package/esm/ScatterChart/ScatterPlot.js +10 -2
- package/esm/SparkLineChart/SparkLineChart.js +7 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/hooks/useDrawingArea.js +7 -3
- package/esm/index.js +1 -0
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/useAnimatedPath.js +29 -0
- package/esm/internals/utils.js +7 -0
- package/hooks/useDrawingArea.d.ts +2 -0
- package/hooks/useDrawingArea.js +7 -3
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/geometry.js +1 -1
- package/internals/stackSeries.d.ts +4 -7
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +38 -0
- package/internals/utils.d.ts +4 -0
- package/internals/utils.js +8 -0
- package/legacy/BarChart/BarChart.js +33 -12
- package/legacy/BarChart/BarElement.js +6 -2
- package/legacy/BarChart/BarPlot.js +28 -14
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +6 -7
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -5
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +12 -0
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
- package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
- package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
- package/legacy/LineChart/AnimatedArea.js +102 -0
- package/legacy/LineChart/AnimatedLine.js +104 -0
- package/legacy/LineChart/AreaElement.js +15 -35
- package/legacy/LineChart/AreaPlot.js +102 -66
- package/legacy/LineChart/LineChart.js +45 -14
- package/legacy/LineChart/LineElement.js +15 -37
- package/legacy/LineChart/LineHighlightElement.js +5 -3
- package/legacy/LineChart/LinePlot.js +97 -63
- package/legacy/LineChart/MarkElement.js +30 -12
- package/legacy/LineChart/MarkPlot.js +83 -53
- package/legacy/LineChart/formatter.js +1 -1
- package/legacy/LineChart/index.js +2 -0
- package/legacy/PieChart/PieArc.js +1 -0
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +2 -2
- package/legacy/PieChart/PieArcPlot.js +7 -7
- package/legacy/PieChart/PieChart.js +14 -12
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/legacy/ScatterChart/Scatter.js +19 -3
- package/legacy/ScatterChart/ScatterChart.js +21 -10
- package/legacy/ScatterChart/ScatterPlot.js +10 -2
- package/legacy/SparkLineChart/SparkLineChart.js +8 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- package/legacy/context/DrawingProvider.js +11 -2
- package/legacy/hooks/useDrawingArea.js +7 -3
- package/legacy/index.js +2 -1
- package/legacy/internals/geometry.js +1 -1
- package/legacy/internals/useAnimatedPath.js +32 -0
- package/legacy/internals/utils.js +7 -0
- package/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +33 -12
- package/modern/BarChart/BarElement.js +7 -3
- package/modern/BarChart/BarPlot.js +27 -15
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/modern/ChartsOnAxisClickHandler/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -5
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +12 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- package/modern/LineChart/AnimatedArea.js +103 -0
- package/modern/LineChart/AnimatedLine.js +105 -0
- package/modern/LineChart/AreaElement.js +16 -33
- package/modern/LineChart/AreaPlot.js +91 -58
- package/modern/LineChart/LineChart.js +45 -14
- package/modern/LineChart/LineElement.js +16 -35
- package/modern/LineChart/LineHighlightElement.js +5 -3
- package/modern/LineChart/LinePlot.js +89 -56
- package/modern/LineChart/MarkElement.js +27 -13
- package/modern/LineChart/MarkPlot.js +80 -51
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/index.js +2 -0
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +2 -2
- package/modern/PieChart/PieArcPlot.js +7 -7
- package/modern/PieChart/PieChart.js +14 -12
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/modern/ScatterChart/Scatter.js +17 -3
- package/modern/ScatterChart/ScatterChart.js +21 -10
- package/modern/ScatterChart/ScatterPlot.js +10 -2
- package/modern/SparkLineChart/SparkLineChart.js +7 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/hooks/useDrawingArea.js +7 -3
- package/modern/index.js +2 -1
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/useAnimatedPath.js +29 -0
- package/modern/internals/utils.js +7 -0
- package/package.json +6 -5
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -59,7 +59,7 @@ function PieChart(props) {
|
|
|
59
59
|
children,
|
|
60
60
|
slots,
|
|
61
61
|
slotProps,
|
|
62
|
-
|
|
62
|
+
onItemClick
|
|
63
63
|
} = props;
|
|
64
64
|
const margin = _extends({}, defaultMargin, marginProps);
|
|
65
65
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
@@ -88,7 +88,7 @@ function PieChart(props) {
|
|
|
88
88
|
}), /*#__PURE__*/_jsx(PiePlot, {
|
|
89
89
|
slots: slots,
|
|
90
90
|
slotProps: slotProps,
|
|
91
|
-
|
|
91
|
+
onItemClick: onItemClick,
|
|
92
92
|
skipAnimation: skipAnimation
|
|
93
93
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
94
94
|
slots: slots,
|
|
@@ -111,7 +111,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
111
111
|
* @default null
|
|
112
112
|
*/
|
|
113
113
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
114
|
-
axisId: PropTypes.string,
|
|
114
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
115
115
|
classes: PropTypes.object,
|
|
116
116
|
disableLine: PropTypes.bool,
|
|
117
117
|
disableTicks: PropTypes.bool,
|
|
@@ -161,7 +161,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
161
161
|
* @default null
|
|
162
162
|
*/
|
|
163
163
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
164
|
-
axisId: PropTypes.string,
|
|
164
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
165
165
|
classes: PropTypes.object,
|
|
166
166
|
disableLine: PropTypes.bool,
|
|
167
167
|
disableTicks: PropTypes.bool,
|
|
@@ -208,14 +208,14 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
208
208
|
right: PropTypes.number,
|
|
209
209
|
top: PropTypes.number
|
|
210
210
|
}),
|
|
211
|
-
|
|
211
|
+
onItemClick: PropTypes.func,
|
|
212
212
|
/**
|
|
213
213
|
* Indicate which axis to display the right of the charts.
|
|
214
214
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
215
215
|
* @default null
|
|
216
216
|
*/
|
|
217
217
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
218
|
-
axisId: PropTypes.string,
|
|
218
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
219
219
|
classes: PropTypes.object,
|
|
220
220
|
disableLine: PropTypes.bool,
|
|
221
221
|
disableTicks: PropTypes.bool,
|
|
@@ -238,7 +238,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
238
238
|
}), PropTypes.string]),
|
|
239
239
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
240
240
|
/**
|
|
241
|
-
* If `true`, animations are
|
|
241
|
+
* If `true`, animations are skipped.
|
|
242
242
|
* @default false
|
|
243
243
|
*/
|
|
244
244
|
skipAnimation: PropTypes.bool,
|
|
@@ -264,7 +264,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
264
264
|
* @default null
|
|
265
265
|
*/
|
|
266
266
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
267
|
-
axisId: PropTypes.string,
|
|
267
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
268
268
|
classes: PropTypes.object,
|
|
269
269
|
disableLine: PropTypes.bool,
|
|
270
270
|
disableTicks: PropTypes.bool,
|
|
@@ -301,7 +301,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
301
301
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
302
302
|
*/
|
|
303
303
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
304
|
-
axisId: PropTypes.string,
|
|
304
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
305
305
|
classes: PropTypes.object,
|
|
306
306
|
data: PropTypes.array,
|
|
307
307
|
dataKey: PropTypes.string,
|
|
@@ -309,13 +309,14 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
309
309
|
disableTicks: PropTypes.bool,
|
|
310
310
|
fill: PropTypes.string,
|
|
311
311
|
hideTooltip: PropTypes.bool,
|
|
312
|
-
id: PropTypes.string,
|
|
312
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
313
313
|
label: PropTypes.string,
|
|
314
314
|
labelFontSize: PropTypes.number,
|
|
315
315
|
labelStyle: PropTypes.object,
|
|
316
316
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
317
317
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
318
318
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
319
|
+
reverse: PropTypes.bool,
|
|
319
320
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
320
321
|
slotProps: PropTypes.object,
|
|
321
322
|
slots: PropTypes.object,
|
|
@@ -335,7 +336,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
335
336
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
336
337
|
*/
|
|
337
338
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
338
|
-
axisId: PropTypes.string,
|
|
339
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
339
340
|
classes: PropTypes.object,
|
|
340
341
|
data: PropTypes.array,
|
|
341
342
|
dataKey: PropTypes.string,
|
|
@@ -343,13 +344,14 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
343
344
|
disableTicks: PropTypes.bool,
|
|
344
345
|
fill: PropTypes.string,
|
|
345
346
|
hideTooltip: PropTypes.bool,
|
|
346
|
-
id: PropTypes.string,
|
|
347
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
347
348
|
label: PropTypes.string,
|
|
348
349
|
labelFontSize: PropTypes.number,
|
|
349
350
|
labelStyle: PropTypes.object,
|
|
350
351
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
351
352
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
352
353
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
354
|
+
reverse: PropTypes.bool,
|
|
353
355
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
354
356
|
slotProps: PropTypes.object,
|
|
355
357
|
slots: PropTypes.object,
|
package/esm/PieChart/PiePlot.js
CHANGED
|
@@ -22,7 +22,7 @@ function PiePlot(props) {
|
|
|
22
22
|
skipAnimation,
|
|
23
23
|
slots,
|
|
24
24
|
slotProps,
|
|
25
|
-
|
|
25
|
+
onItemClick
|
|
26
26
|
} = props;
|
|
27
27
|
const seriesData = React.useContext(SeriesContext).pie;
|
|
28
28
|
const {
|
|
@@ -70,7 +70,7 @@ function PiePlot(props) {
|
|
|
70
70
|
highlightScope: highlightScope,
|
|
71
71
|
highlighted: highlighted,
|
|
72
72
|
faded: faded,
|
|
73
|
-
|
|
73
|
+
onItemClick: onItemClick,
|
|
74
74
|
slots: slots,
|
|
75
75
|
slotProps: slotProps
|
|
76
76
|
})
|
|
@@ -124,9 +124,9 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
|
124
124
|
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
125
125
|
* @param {DefaultizedPieValueType} item The pie item.
|
|
126
126
|
*/
|
|
127
|
-
|
|
127
|
+
onItemClick: PropTypes.func,
|
|
128
128
|
/**
|
|
129
|
-
* If `true`, animations are
|
|
129
|
+
* If `true`, animations are skipped.
|
|
130
130
|
* @default false
|
|
131
131
|
*/
|
|
132
132
|
skipAnimation: PropTypes.bool,
|
|
@@ -178,7 +178,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
178
178
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
179
179
|
*/
|
|
180
180
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
181
|
-
axisId: PropTypes.string,
|
|
181
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
182
182
|
classes: PropTypes.object,
|
|
183
183
|
data: PropTypes.array,
|
|
184
184
|
dataKey: PropTypes.string,
|
|
@@ -186,13 +186,14 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
186
186
|
disableTicks: PropTypes.bool,
|
|
187
187
|
fill: PropTypes.string,
|
|
188
188
|
hideTooltip: PropTypes.bool,
|
|
189
|
-
id: PropTypes.string,
|
|
189
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
190
190
|
label: PropTypes.string,
|
|
191
191
|
labelFontSize: PropTypes.number,
|
|
192
192
|
labelStyle: PropTypes.object,
|
|
193
193
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
194
194
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
195
195
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
196
|
+
reverse: PropTypes.bool,
|
|
196
197
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
197
198
|
slotProps: PropTypes.object,
|
|
198
199
|
slots: PropTypes.object,
|
|
@@ -212,7 +213,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
212
213
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
213
214
|
*/
|
|
214
215
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
215
|
-
axisId: PropTypes.string,
|
|
216
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
216
217
|
classes: PropTypes.object,
|
|
217
218
|
data: PropTypes.array,
|
|
218
219
|
dataKey: PropTypes.string,
|
|
@@ -220,13 +221,14 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
220
221
|
disableTicks: PropTypes.bool,
|
|
221
222
|
fill: PropTypes.string,
|
|
222
223
|
hideTooltip: PropTypes.bool,
|
|
223
|
-
id: PropTypes.string,
|
|
224
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
224
225
|
label: PropTypes.string,
|
|
225
226
|
labelFontSize: PropTypes.number,
|
|
226
227
|
labelStyle: PropTypes.object,
|
|
227
228
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
228
229
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
229
230
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
231
|
+
reverse: PropTypes.bool,
|
|
230
232
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
231
233
|
slotProps: PropTypes.object,
|
|
232
234
|
slots: PropTypes.object,
|
|
@@ -21,7 +21,8 @@ function Scatter(props) {
|
|
|
21
21
|
xScale,
|
|
22
22
|
yScale,
|
|
23
23
|
color,
|
|
24
|
-
markerSize
|
|
24
|
+
markerSize,
|
|
25
|
+
onItemClick
|
|
25
26
|
} = props;
|
|
26
27
|
const highlightScope = React.useMemo(() => _extends({
|
|
27
28
|
highlighted: 'item',
|
|
@@ -61,7 +62,8 @@ function Scatter(props) {
|
|
|
61
62
|
isHighlighted,
|
|
62
63
|
isFaded: !isHighlighted && getIsFaded(item, pointCtx, highlightScope),
|
|
63
64
|
interactionProps: getInteractionItemProps(pointCtx),
|
|
64
|
-
id: scatterPoint.id
|
|
65
|
+
id: scatterPoint.id,
|
|
66
|
+
dataIndex: i
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -74,7 +76,13 @@ function Scatter(props) {
|
|
|
74
76
|
r: (dataPoint.isHighlighted ? 1.2 : 1) * markerSize,
|
|
75
77
|
transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
|
|
76
78
|
fill: color,
|
|
77
|
-
opacity: dataPoint.isFaded && 0.3 || 1
|
|
79
|
+
opacity: dataPoint.isFaded && 0.3 || 1,
|
|
80
|
+
onClick: onItemClick && (event => onItemClick(event, {
|
|
81
|
+
type: 'scatter',
|
|
82
|
+
seriesId: series.id,
|
|
83
|
+
dataIndex: dataPoint.dataIndex
|
|
84
|
+
})),
|
|
85
|
+
cursor: onItemClick ? 'pointer' : 'unset'
|
|
78
86
|
}, dataPoint.interactionProps), dataPoint.id))
|
|
79
87
|
});
|
|
80
88
|
}
|
|
@@ -85,6 +93,12 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
|
|
|
85
93
|
// ----------------------------------------------------------------------
|
|
86
94
|
color: PropTypes.string.isRequired,
|
|
87
95
|
markerSize: PropTypes.number.isRequired,
|
|
96
|
+
/**
|
|
97
|
+
* Callback fired when clicking on a scatter item.
|
|
98
|
+
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
|
|
99
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
100
|
+
*/
|
|
101
|
+
onItemClick: PropTypes.func,
|
|
88
102
|
series: PropTypes.object.isRequired,
|
|
89
103
|
xScale: PropTypes.func.isRequired,
|
|
90
104
|
yScale: PropTypes.func.isRequired
|
|
@@ -39,6 +39,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
39
39
|
leftAxis,
|
|
40
40
|
rightAxis,
|
|
41
41
|
bottomAxis,
|
|
42
|
+
onItemClick,
|
|
42
43
|
children,
|
|
43
44
|
slots,
|
|
44
45
|
slotProps
|
|
@@ -56,7 +57,8 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
56
57
|
yAxis: yAxis,
|
|
57
58
|
sx: sx,
|
|
58
59
|
children: [!disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, {
|
|
59
|
-
voronoiMaxRadius: voronoiMaxRadius
|
|
60
|
+
voronoiMaxRadius: voronoiMaxRadius,
|
|
61
|
+
onItemClick: onItemClick
|
|
60
62
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
61
63
|
topAxis: topAxis,
|
|
62
64
|
leftAxis: leftAxis,
|
|
@@ -66,7 +68,8 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
66
68
|
slotProps: slotProps
|
|
67
69
|
}), /*#__PURE__*/_jsx(ScatterPlot, {
|
|
68
70
|
slots: slots,
|
|
69
|
-
slotProps: slotProps
|
|
71
|
+
slotProps: slotProps,
|
|
72
|
+
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
70
73
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
71
74
|
slots: slots,
|
|
72
75
|
slotProps: slotProps
|
|
@@ -93,7 +96,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
93
96
|
* @default xAxisIds[0] The id of the first provided axis
|
|
94
97
|
*/
|
|
95
98
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
96
|
-
axisId: PropTypes.string,
|
|
99
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
97
100
|
classes: PropTypes.object,
|
|
98
101
|
disableLine: PropTypes.bool,
|
|
99
102
|
disableTicks: PropTypes.bool,
|
|
@@ -148,7 +151,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
148
151
|
* @default yAxisIds[0] The id of the first provided axis
|
|
149
152
|
*/
|
|
150
153
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
151
|
-
axisId: PropTypes.string,
|
|
154
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
152
155
|
classes: PropTypes.object,
|
|
153
156
|
disableLine: PropTypes.bool,
|
|
154
157
|
disableTicks: PropTypes.bool,
|
|
@@ -195,13 +198,19 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
195
198
|
right: PropTypes.number,
|
|
196
199
|
top: PropTypes.number
|
|
197
200
|
}),
|
|
201
|
+
/**
|
|
202
|
+
* Callback fired when clicking on a scatter item.
|
|
203
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element if using Voronoi cells. Or the Mouse event from the scatter element, when `disableVoronoi=true`.
|
|
204
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
205
|
+
*/
|
|
206
|
+
onItemClick: PropTypes.func,
|
|
198
207
|
/**
|
|
199
208
|
* Indicate which axis to display the right of the charts.
|
|
200
209
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
201
210
|
* @default null
|
|
202
211
|
*/
|
|
203
212
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
204
|
-
axisId: PropTypes.string,
|
|
213
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
205
214
|
classes: PropTypes.object,
|
|
206
215
|
disableLine: PropTypes.bool,
|
|
207
216
|
disableTicks: PropTypes.bool,
|
|
@@ -249,7 +258,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
249
258
|
* @default null
|
|
250
259
|
*/
|
|
251
260
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
252
|
-
axisId: PropTypes.string,
|
|
261
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
253
262
|
classes: PropTypes.object,
|
|
254
263
|
disableLine: PropTypes.bool,
|
|
255
264
|
disableTicks: PropTypes.bool,
|
|
@@ -292,7 +301,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
292
301
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
293
302
|
*/
|
|
294
303
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
295
|
-
axisId: PropTypes.string,
|
|
304
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
296
305
|
classes: PropTypes.object,
|
|
297
306
|
data: PropTypes.array,
|
|
298
307
|
dataKey: PropTypes.string,
|
|
@@ -300,13 +309,14 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
300
309
|
disableTicks: PropTypes.bool,
|
|
301
310
|
fill: PropTypes.string,
|
|
302
311
|
hideTooltip: PropTypes.bool,
|
|
303
|
-
id: PropTypes.string,
|
|
312
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
304
313
|
label: PropTypes.string,
|
|
305
314
|
labelFontSize: PropTypes.number,
|
|
306
315
|
labelStyle: PropTypes.object,
|
|
307
316
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
308
317
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
309
318
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
319
|
+
reverse: PropTypes.bool,
|
|
310
320
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
311
321
|
slotProps: PropTypes.object,
|
|
312
322
|
slots: PropTypes.object,
|
|
@@ -326,7 +336,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
326
336
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
327
337
|
*/
|
|
328
338
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
329
|
-
axisId: PropTypes.string,
|
|
339
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
330
340
|
classes: PropTypes.object,
|
|
331
341
|
data: PropTypes.array,
|
|
332
342
|
dataKey: PropTypes.string,
|
|
@@ -334,13 +344,14 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
334
344
|
disableTicks: PropTypes.bool,
|
|
335
345
|
fill: PropTypes.string,
|
|
336
346
|
hideTooltip: PropTypes.bool,
|
|
337
|
-
id: PropTypes.string,
|
|
347
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
338
348
|
label: PropTypes.string,
|
|
339
349
|
labelFontSize: PropTypes.number,
|
|
340
350
|
labelStyle: PropTypes.object,
|
|
341
351
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
342
352
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
343
353
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
354
|
+
reverse: PropTypes.bool,
|
|
344
355
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
345
356
|
slotProps: PropTypes.object,
|
|
346
357
|
slots: PropTypes.object,
|
|
@@ -19,7 +19,8 @@ function ScatterPlot(props) {
|
|
|
19
19
|
var _slots$scatter;
|
|
20
20
|
const {
|
|
21
21
|
slots,
|
|
22
|
-
slotProps
|
|
22
|
+
slotProps,
|
|
23
|
+
onItemClick
|
|
23
24
|
} = props;
|
|
24
25
|
const seriesData = React.useContext(SeriesContext).scatter;
|
|
25
26
|
const axisData = React.useContext(CartesianContext);
|
|
@@ -55,7 +56,8 @@ function ScatterPlot(props) {
|
|
|
55
56
|
yScale: yScale,
|
|
56
57
|
color: color,
|
|
57
58
|
markerSize: markerSize != null ? markerSize : 4,
|
|
58
|
-
series: series[seriesId]
|
|
59
|
+
series: series[seriesId],
|
|
60
|
+
onItemClick: onItemClick
|
|
59
61
|
}, slotProps == null ? void 0 : slotProps.scatter), id);
|
|
60
62
|
})
|
|
61
63
|
});
|
|
@@ -65,6 +67,12 @@ process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
|
|
|
65
67
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
66
68
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
67
69
|
// ----------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Callback fired when clicking on a scatter item.
|
|
72
|
+
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
|
|
73
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
74
|
+
*/
|
|
75
|
+
onItemClick: PropTypes.func,
|
|
68
76
|
/**
|
|
69
77
|
* The props used for each component slot.
|
|
70
78
|
* @default {}
|
|
@@ -42,7 +42,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
42
42
|
slotProps,
|
|
43
43
|
data,
|
|
44
44
|
plotType = 'line',
|
|
45
|
-
valueFormatter =
|
|
45
|
+
valueFormatter = value => value === null ? '' : value.toString(),
|
|
46
46
|
area,
|
|
47
47
|
curve = 'linear'
|
|
48
48
|
} = props;
|
|
@@ -86,9 +86,11 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
86
86
|
}
|
|
87
87
|
}), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
88
88
|
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
89
|
+
skipAnimation: true,
|
|
89
90
|
slots: slots,
|
|
90
91
|
slotProps: slotProps
|
|
91
92
|
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
93
|
+
skipAnimation: true,
|
|
92
94
|
slots: slots,
|
|
93
95
|
slotProps: slotProps
|
|
94
96
|
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
@@ -205,7 +207,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
205
207
|
* Formatter used by the tooltip.
|
|
206
208
|
* @param {number} value The value to format.
|
|
207
209
|
* @returns {string} the formatted value.
|
|
208
|
-
* @default (
|
|
210
|
+
* @default (value: number | null) => (value === null ? '' : value.toString())
|
|
209
211
|
*/
|
|
210
212
|
valueFormatter: PropTypes.func,
|
|
211
213
|
viewBox: PropTypes.shape({
|
|
@@ -224,7 +226,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
224
226
|
* Notice it is a single configuration object, not an array of configuration.
|
|
225
227
|
*/
|
|
226
228
|
xAxis: PropTypes.shape({
|
|
227
|
-
axisId: PropTypes.string,
|
|
229
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
228
230
|
classes: PropTypes.object,
|
|
229
231
|
data: PropTypes.array,
|
|
230
232
|
dataKey: PropTypes.string,
|
|
@@ -232,13 +234,14 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
232
234
|
disableTicks: PropTypes.bool,
|
|
233
235
|
fill: PropTypes.string,
|
|
234
236
|
hideTooltip: PropTypes.bool,
|
|
235
|
-
id: PropTypes.string,
|
|
237
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
236
238
|
label: PropTypes.string,
|
|
237
239
|
labelFontSize: PropTypes.number,
|
|
238
240
|
labelStyle: PropTypes.object,
|
|
239
241
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
240
242
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
241
243
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
244
|
+
reverse: PropTypes.bool,
|
|
242
245
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
243
246
|
slotProps: PropTypes.object,
|
|
244
247
|
slots: PropTypes.object,
|
|
@@ -110,7 +110,7 @@ function CartesianContextProvider(props) {
|
|
|
110
110
|
var _axis$scaleType, _axis$min, _axis$max, _axis$min2, _axis$max2;
|
|
111
111
|
const isDefaultAxis = axisIndex === 0;
|
|
112
112
|
const [minData, maxData] = getAxisExtremum(axis, xExtremumGetters, isDefaultAxis);
|
|
113
|
-
const range = [drawingArea.left, drawingArea.left + drawingArea.width];
|
|
113
|
+
const range = axis.reverse ? [drawingArea.left + drawingArea.width, drawingArea.left] : [drawingArea.left, drawingArea.left + drawingArea.width];
|
|
114
114
|
if (isBandScaleConfig(axis)) {
|
|
115
115
|
var _axis$categoryGapRati, _axis$barGapRatio;
|
|
116
116
|
const categoryGapRatio = (_axis$categoryGapRati = axis.categoryGapRatio) != null ? _axis$categoryGapRati : DEFAULT_CATEGORY_GAP_RATIO;
|
|
@@ -161,7 +161,7 @@ function CartesianContextProvider(props) {
|
|
|
161
161
|
var _axis$scaleType2, _axis$min3, _axis$max3, _axis$min4, _axis$max4;
|
|
162
162
|
const isDefaultAxis = axisIndex === 0;
|
|
163
163
|
const [minData, maxData] = getAxisExtremum(axis, yExtremumGetters, isDefaultAxis);
|
|
164
|
-
const range = [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
164
|
+
const range = axis.reverse ? [drawingArea.top, drawingArea.top + drawingArea.height] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
165
165
|
if (isBandScaleConfig(axis)) {
|
|
166
166
|
var _axis$categoryGapRati2;
|
|
167
167
|
const categoryGapRatio = (_axis$categoryGapRati2 = axis.categoryGapRatio) != null ? _axis$categoryGapRati2 : DEFAULT_CATEGORY_GAP_RATIO;
|
|
@@ -231,7 +231,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
231
231
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
232
232
|
*/
|
|
233
233
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
234
|
-
axisId: PropTypes.string,
|
|
234
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
235
235
|
classes: PropTypes.object,
|
|
236
236
|
data: PropTypes.array,
|
|
237
237
|
dataKey: PropTypes.string,
|
|
@@ -239,13 +239,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
239
239
|
disableTicks: PropTypes.bool,
|
|
240
240
|
fill: PropTypes.string,
|
|
241
241
|
hideTooltip: PropTypes.bool,
|
|
242
|
-
id: PropTypes.string,
|
|
242
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
243
243
|
label: PropTypes.string,
|
|
244
244
|
labelFontSize: PropTypes.number,
|
|
245
245
|
labelStyle: PropTypes.object,
|
|
246
246
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
247
247
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
248
248
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
249
|
+
reverse: PropTypes.bool,
|
|
249
250
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
250
251
|
slotProps: PropTypes.object,
|
|
251
252
|
slots: PropTypes.object,
|
|
@@ -265,7 +266,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
265
266
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
266
267
|
*/
|
|
267
268
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
268
|
-
axisId: PropTypes.string,
|
|
269
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
269
270
|
classes: PropTypes.object,
|
|
270
271
|
data: PropTypes.array,
|
|
271
272
|
dataKey: PropTypes.string,
|
|
@@ -273,13 +274,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
273
274
|
disableTicks: PropTypes.bool,
|
|
274
275
|
fill: PropTypes.string,
|
|
275
276
|
hideTooltip: PropTypes.bool,
|
|
276
|
-
id: PropTypes.string,
|
|
277
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
277
278
|
label: PropTypes.string,
|
|
278
279
|
labelFontSize: PropTypes.number,
|
|
279
280
|
labelStyle: PropTypes.object,
|
|
280
281
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
281
282
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
282
283
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
284
|
+
reverse: PropTypes.bool,
|
|
283
285
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
284
286
|
slotProps: PropTypes.object,
|
|
285
287
|
slots: PropTypes.object,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import useId from '@mui/utils/useId';
|
|
3
5
|
import useChartDimensions from '../hooks/useChartDimensions';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -12,7 +14,8 @@ export const DrawingContext = /*#__PURE__*/React.createContext({
|
|
|
12
14
|
bottom: 0,
|
|
13
15
|
right: 0,
|
|
14
16
|
height: 300,
|
|
15
|
-
width: 400
|
|
17
|
+
width: 400,
|
|
18
|
+
chartId: ''
|
|
16
19
|
});
|
|
17
20
|
export const SVGContext = /*#__PURE__*/React.createContext({
|
|
18
21
|
current: null
|
|
@@ -32,10 +35,14 @@ function DrawingProvider(props) {
|
|
|
32
35
|
children
|
|
33
36
|
} = props;
|
|
34
37
|
const drawingArea = useChartDimensions(width, height, margin);
|
|
38
|
+
const chartId = useId();
|
|
39
|
+
const value = React.useMemo(() => _extends({
|
|
40
|
+
chartId: chartId != null ? chartId : ''
|
|
41
|
+
}, drawingArea), [chartId, drawingArea]);
|
|
35
42
|
return /*#__PURE__*/_jsx(SVGContext.Provider, {
|
|
36
43
|
value: svgRef,
|
|
37
44
|
children: /*#__PURE__*/_jsx(DrawingContext.Provider, {
|
|
38
|
-
value:
|
|
45
|
+
value: value,
|
|
39
46
|
children: children
|
|
40
47
|
})
|
|
41
48
|
});
|
|
@@ -5,12 +5,16 @@ export function useDrawingArea() {
|
|
|
5
5
|
left,
|
|
6
6
|
top,
|
|
7
7
|
width,
|
|
8
|
-
height
|
|
8
|
+
height,
|
|
9
|
+
bottom,
|
|
10
|
+
right
|
|
9
11
|
} = React.useContext(DrawingContext);
|
|
10
12
|
return React.useMemo(() => ({
|
|
11
13
|
left,
|
|
12
14
|
top,
|
|
13
15
|
width,
|
|
14
|
-
height
|
|
15
|
-
|
|
16
|
+
height,
|
|
17
|
+
bottom,
|
|
18
|
+
right
|
|
19
|
+
}), [height, left, top, width, bottom, right]);
|
|
16
20
|
}
|
package/esm/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from './ChartsTooltip';
|
|
|
13
13
|
export * from './ChartsLegend';
|
|
14
14
|
export * from './ChartsAxisHighlight';
|
|
15
15
|
export * from './ChartsVoronoiHandler';
|
|
16
|
+
export * from './ChartsOnAxisClickHandler';
|
|
16
17
|
export * from './BarChart';
|
|
17
18
|
export * from './LineChart';
|
|
18
19
|
export * from './PieChart';
|
|
@@ -14,7 +14,7 @@ export function getMinXTranslation(width, height, angle = 0) {
|
|
|
14
14
|
if (process.env.NODE_ENV !== 'production') {
|
|
15
15
|
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
16
16
|
warnedOnce = true;
|
|
17
|
-
console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
|
|
17
|
+
console.warn([`MUI X Charts: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { interpolateString } from 'd3-interpolate';
|
|
3
|
+
import { useSpring, to } from '@react-spring/web';
|
|
4
|
+
function usePrevious(value) {
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
ref.current = value;
|
|
8
|
+
}, [value]);
|
|
9
|
+
return ref.current;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Taken from Nivo
|
|
13
|
+
export const useAnimatedPath = (path, skipAnimation) => {
|
|
14
|
+
const previousPath = usePrevious(path);
|
|
15
|
+
const interpolator = React.useMemo(() => previousPath ? interpolateString(previousPath, path) : () => path, [previousPath, path]);
|
|
16
|
+
const {
|
|
17
|
+
value
|
|
18
|
+
} = useSpring({
|
|
19
|
+
from: {
|
|
20
|
+
value: 0
|
|
21
|
+
},
|
|
22
|
+
to: {
|
|
23
|
+
value: 1
|
|
24
|
+
},
|
|
25
|
+
reset: true,
|
|
26
|
+
immediate: skipAnimation
|
|
27
|
+
});
|
|
28
|
+
return to([value], interpolator);
|
|
29
|
+
};
|
package/esm/internals/utils.js
CHANGED
|
@@ -42,4 +42,11 @@ export function getPercentageValue(value, refValue) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
throw Error(`MUI-Charts: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Remove spaces to have viable ids
|
|
49
|
+
*/
|
|
50
|
+
export function cleanId(id) {
|
|
51
|
+
return id.replace(' ', '_');
|
|
45
52
|
}
|
package/hooks/useDrawingArea.js
CHANGED
|
@@ -13,12 +13,16 @@ function useDrawingArea() {
|
|
|
13
13
|
left,
|
|
14
14
|
top,
|
|
15
15
|
width,
|
|
16
|
-
height
|
|
16
|
+
height,
|
|
17
|
+
bottom,
|
|
18
|
+
right
|
|
17
19
|
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
18
20
|
return React.useMemo(() => ({
|
|
19
21
|
left,
|
|
20
22
|
top,
|
|
21
23
|
width,
|
|
22
|
-
height
|
|
23
|
-
|
|
24
|
+
height,
|
|
25
|
+
bottom,
|
|
26
|
+
right
|
|
27
|
+
}), [height, left, top, width, bottom, right]);
|
|
24
28
|
}
|