@mui/x-charts 7.0.0-beta.0 → 7.0.0-beta.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 +2 -1
- package/BarChart/BarChart.js +23 -4
- package/BarChart/BarElement.d.ts +1 -1
- package/BarChart/BarElement.js +6 -3
- package/BarChart/BarPlot.d.ts +8 -1
- package/BarChart/BarPlot.js +19 -5
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +247 -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/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -4
- package/ChartsTooltip/utils.d.ts +3 -1
- package/ChartsTooltip/utils.js +8 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- 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 +17 -17
- 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 +35 -6
- package/LineChart/LineElement.d.ts +17 -17
- package/LineChart/LineElement.js +16 -36
- package/LineChart/LineHighlightElement.js +3 -2
- package/LineChart/LinePlot.d.ts +12 -7
- package/LineChart/LinePlot.js +89 -56
- package/LineChart/MarkElement.d.ts +5 -2
- package/LineChart/MarkElement.js +26 -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/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.d.ts +2 -2
- package/PieChart/PieArcPlot.js +6 -6
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +4 -4
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -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 +11 -2
- package/ScatterChart/ScatterPlot.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +10 -2
- package/SparkLineChart/SparkLineChart.js +2 -0
- 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 +23 -4
- package/esm/BarChart/BarElement.js +6 -3
- package/esm/BarChart/BarPlot.js +19 -5
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
- package/esm/ChartsOnAxisClickHandler/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -4
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- 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 +35 -6
- package/esm/LineChart/LineElement.js +16 -35
- package/esm/LineChart/LineHighlightElement.js +3 -2
- package/esm/LineChart/LinePlot.js +90 -57
- package/esm/LineChart/MarkElement.js +26 -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/PieArcLabelPlot.js +1 -1
- package/esm/PieChart/PieArcPlot.js +6 -6
- package/esm/PieChart/PieChart.js +4 -4
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ScatterChart/Scatter.js +17 -3
- package/esm/ScatterChart/ScatterChart.js +11 -2
- package/esm/ScatterChart/ScatterPlot.js +10 -2
- package/esm/SparkLineChart/SparkLineChart.js +2 -0
- 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/geometry.js +1 -1
- 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 +23 -4
- package/legacy/BarChart/BarElement.js +5 -2
- package/legacy/BarChart/BarPlot.js +18 -4
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +6 -7
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -4
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
- 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 +35 -6
- package/legacy/LineChart/LineElement.js +15 -37
- package/legacy/LineChart/LineHighlightElement.js +3 -2
- package/legacy/LineChart/LinePlot.js +97 -63
- package/legacy/LineChart/MarkElement.js +29 -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/PieArcLabelPlot.js +1 -1
- package/legacy/PieChart/PieArcPlot.js +6 -6
- package/legacy/PieChart/PieChart.js +4 -4
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ScatterChart/Scatter.js +19 -3
- package/legacy/ScatterChart/ScatterChart.js +11 -2
- package/legacy/ScatterChart/ScatterPlot.js +10 -2
- package/legacy/SparkLineChart/SparkLineChart.js +2 -0
- 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/modern/BarChart/BarChart.js +23 -4
- package/modern/BarChart/BarElement.js +6 -3
- package/modern/BarChart/BarPlot.js +19 -5
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/modern/ChartsOnAxisClickHandler/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -4
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- 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 +35 -6
- package/modern/LineChart/LineElement.js +16 -35
- package/modern/LineChart/LineHighlightElement.js +3 -2
- package/modern/LineChart/LinePlot.js +89 -56
- package/modern/LineChart/MarkElement.js +26 -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/PieArcLabelPlot.js +1 -1
- package/modern/PieChart/PieArcPlot.js +6 -6
- package/modern/PieChart/PieChart.js +4 -4
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ScatterChart/Scatter.js +17 -3
- package/modern/ScatterChart/ScatterChart.js +11 -2
- package/modern/ScatterChart/ScatterPlot.js +10 -2
- package/modern/SparkLineChart/SparkLineChart.js +2 -0
- 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
|
@@ -69,7 +69,7 @@ const formatter = (params, dataset) => {
|
|
|
69
69
|
return {
|
|
70
70
|
seriesOrder,
|
|
71
71
|
stackingGroups,
|
|
72
|
-
series: defaultizeValueFormatter(completedSeries, v => v
|
|
72
|
+
series: defaultizeValueFormatter(completedSeries, v => v == null ? '' : v.toLocaleString())
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
export default formatter;
|
|
@@ -4,6 +4,8 @@ export * from './AreaPlot';
|
|
|
4
4
|
export * from './MarkPlot';
|
|
5
5
|
export * from './LineHighlightPlot';
|
|
6
6
|
export * from './AreaElement';
|
|
7
|
+
export * from './AnimatedArea';
|
|
7
8
|
export * from './LineElement';
|
|
9
|
+
export * from './AnimatedLine';
|
|
8
10
|
export * from './MarkElement';
|
|
9
11
|
export * from './LineHighlightElement';
|
|
@@ -173,7 +173,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
173
173
|
*/
|
|
174
174
|
paddingAngle: PropTypes.number,
|
|
175
175
|
/**
|
|
176
|
-
* If `true`, animations are
|
|
176
|
+
* If `true`, animations are skipped.
|
|
177
177
|
* @default false
|
|
178
178
|
*/
|
|
179
179
|
skipAnimation: PropTypes.bool,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "
|
|
3
|
+
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
|
|
4
4
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -24,7 +24,7 @@ function PieArcPlot(props) {
|
|
|
24
24
|
additionalRadius: -5
|
|
25
25
|
},
|
|
26
26
|
data,
|
|
27
|
-
|
|
27
|
+
onItemClick,
|
|
28
28
|
skipAnimation
|
|
29
29
|
} = props,
|
|
30
30
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
@@ -71,8 +71,8 @@ function PieArcPlot(props) {
|
|
|
71
71
|
highlightScope: highlightScope,
|
|
72
72
|
isFaded: item.isFaded,
|
|
73
73
|
isHighlighted: item.isHighlighted,
|
|
74
|
-
onClick:
|
|
75
|
-
|
|
74
|
+
onClick: onItemClick && (event => {
|
|
75
|
+
onItemClick(event, {
|
|
76
76
|
type: 'pie',
|
|
77
77
|
seriesId: id,
|
|
78
78
|
dataIndex: index
|
|
@@ -149,7 +149,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
149
149
|
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
150
150
|
* @param {DefaultizedPieValueType} item The pie item.
|
|
151
151
|
*/
|
|
152
|
-
|
|
152
|
+
onItemClick: PropTypes.func,
|
|
153
153
|
/**
|
|
154
154
|
* The radius between circle center and the end of the arc.
|
|
155
155
|
*/
|
|
@@ -160,7 +160,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
160
160
|
*/
|
|
161
161
|
paddingAngle: PropTypes.number,
|
|
162
162
|
/**
|
|
163
|
-
* If `true`, animations are
|
|
163
|
+
* If `true`, animations are skipped.
|
|
164
164
|
* @default false
|
|
165
165
|
*/
|
|
166
166
|
skipAnimation: PropTypes.bool,
|
|
@@ -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,
|
|
@@ -208,7 +208,7 @@ 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`.
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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
|
|
@@ -195,6 +198,12 @@ 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`.
|
|
@@ -18,7 +18,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
18
|
function ScatterPlot(props) {
|
|
19
19
|
const {
|
|
20
20
|
slots,
|
|
21
|
-
slotProps
|
|
21
|
+
slotProps,
|
|
22
|
+
onItemClick
|
|
22
23
|
} = props;
|
|
23
24
|
const seriesData = React.useContext(SeriesContext).scatter;
|
|
24
25
|
const axisData = React.useContext(CartesianContext);
|
|
@@ -54,7 +55,8 @@ function ScatterPlot(props) {
|
|
|
54
55
|
yScale: yScale,
|
|
55
56
|
color: color,
|
|
56
57
|
markerSize: markerSize ?? 4,
|
|
57
|
-
series: series[seriesId]
|
|
58
|
+
series: series[seriesId],
|
|
59
|
+
onItemClick: onItemClick
|
|
58
60
|
}, slotProps?.scatter), id);
|
|
59
61
|
})
|
|
60
62
|
});
|
|
@@ -64,6 +66,12 @@ process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
|
|
|
64
66
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
67
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
66
68
|
// ----------------------------------------------------------------------
|
|
69
|
+
/**
|
|
70
|
+
* Callback fired when clicking on a scatter item.
|
|
71
|
+
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
|
|
72
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
73
|
+
*/
|
|
74
|
+
onItemClick: PropTypes.func,
|
|
67
75
|
/**
|
|
68
76
|
* The props used for each component slot.
|
|
69
77
|
* @default {}
|
|
@@ -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, {
|
|
@@ -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 ?? ''
|
|
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/modern/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v7.0.0-beta.
|
|
2
|
+
* @mui/x-charts v7.0.0-beta.1
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -20,6 +20,7 @@ export * from './ChartsTooltip';
|
|
|
20
20
|
export * from './ChartsLegend';
|
|
21
21
|
export * from './ChartsAxisHighlight';
|
|
22
22
|
export * from './ChartsVoronoiHandler';
|
|
23
|
+
export * from './ChartsOnAxisClickHandler';
|
|
23
24
|
export * from './BarChart';
|
|
24
25
|
export * from './LineChart';
|
|
25
26
|
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
|
+
};
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.1",
|
|
4
4
|
"description": "The community edition of the charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -28,15 +28,16 @@
|
|
|
28
28
|
"directory": "packages/x-charts"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@babel/runtime": "^7.23.
|
|
32
|
-
"@mui/base": "^5.0.0-beta.
|
|
33
|
-
"@mui/system": "^5.15.
|
|
34
|
-
"@mui/utils": "^5.15.
|
|
31
|
+
"@babel/runtime": "^7.23.9",
|
|
32
|
+
"@mui/base": "^5.0.0-beta.34",
|
|
33
|
+
"@mui/system": "^5.15.7",
|
|
34
|
+
"@mui/utils": "^5.15.7",
|
|
35
35
|
"@react-spring/rafz": "^9.7.3",
|
|
36
36
|
"@react-spring/web": "^9.7.3",
|
|
37
37
|
"clsx": "^2.1.0",
|
|
38
38
|
"d3-color": "^3.1.0",
|
|
39
39
|
"d3-delaunay": "^6.0.4",
|
|
40
|
+
"d3-interpolate": "^3.0.1",
|
|
40
41
|
"d3-scale": "^4.0.2",
|
|
41
42
|
"d3-shape": "^3.2.0",
|
|
42
43
|
"prop-types": "^15.8.1"
|