@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/LineChart/LineChart.js
CHANGED
|
@@ -20,6 +20,7 @@ var _ChartsLegend = require("../ChartsLegend");
|
|
|
20
20
|
var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
|
|
21
21
|
var _ChartsClipPath = require("../ChartsClipPath");
|
|
22
22
|
var _LineHighlightPlot = require("./LineHighlightPlot");
|
|
23
|
+
var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
|
|
23
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
25
|
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); }
|
|
25
26
|
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 && Object.prototype.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; }
|
|
@@ -45,6 +46,10 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
|
|
|
45
46
|
dataset,
|
|
46
47
|
sx,
|
|
47
48
|
tooltip,
|
|
49
|
+
onAxisClick,
|
|
50
|
+
onAreaClick,
|
|
51
|
+
onLineClick,
|
|
52
|
+
onMarkClick,
|
|
48
53
|
axisHighlight = {
|
|
49
54
|
x: 'line'
|
|
50
55
|
},
|
|
@@ -56,7 +61,8 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
|
|
|
56
61
|
bottomAxis,
|
|
57
62
|
children,
|
|
58
63
|
slots,
|
|
59
|
-
slotProps
|
|
64
|
+
slotProps,
|
|
65
|
+
skipAnimation
|
|
60
66
|
} = props;
|
|
61
67
|
const id = (0, _useId.default)();
|
|
62
68
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -80,15 +86,21 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
|
|
|
80
86
|
colors: colors,
|
|
81
87
|
dataset: dataset,
|
|
82
88
|
sx: sx,
|
|
83
|
-
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
84
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
89
|
+
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
90
|
+
children: [onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, {
|
|
91
|
+
onAxisClick: onAxisClick
|
|
92
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
85
93
|
clipPath: `url(#${clipPathId})`,
|
|
86
94
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaPlot.AreaPlot, {
|
|
87
95
|
slots: slots,
|
|
88
|
-
slotProps: slotProps
|
|
96
|
+
slotProps: slotProps,
|
|
97
|
+
onItemClick: onAreaClick,
|
|
98
|
+
skipAnimation: skipAnimation
|
|
89
99
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinePlot.LinePlot, {
|
|
90
100
|
slots: slots,
|
|
91
|
-
slotProps: slotProps
|
|
101
|
+
slotProps: slotProps,
|
|
102
|
+
onItemClick: onLineClick,
|
|
103
|
+
skipAnimation: skipAnimation
|
|
92
104
|
})]
|
|
93
105
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
|
|
94
106
|
topAxis: topAxis,
|
|
@@ -99,7 +111,9 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
|
|
|
99
111
|
slotProps: slotProps
|
|
100
112
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlight)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MarkPlot.MarkPlot, {
|
|
101
113
|
slots: slots,
|
|
102
|
-
slotProps: slotProps
|
|
114
|
+
slotProps: slotProps,
|
|
115
|
+
onItemClick: onMarkClick,
|
|
116
|
+
skipAnimation: skipAnimation
|
|
103
117
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineHighlightPlot.LineHighlightPlot, {
|
|
104
118
|
slots: slots,
|
|
105
119
|
slotProps: slotProps
|
|
@@ -137,7 +151,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
137
151
|
* @default xAxisIds[0] The id of the first provided axis
|
|
138
152
|
*/
|
|
139
153
|
bottomAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
140
|
-
axisId: _propTypes.default.string,
|
|
154
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
141
155
|
classes: _propTypes.default.object,
|
|
142
156
|
disableLine: _propTypes.default.bool,
|
|
143
157
|
disableTicks: _propTypes.default.bool,
|
|
@@ -191,7 +205,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
191
205
|
* @default yAxisIds[0] The id of the first provided axis
|
|
192
206
|
*/
|
|
193
207
|
leftAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
194
|
-
axisId: _propTypes.default.string,
|
|
208
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
195
209
|
classes: _propTypes.default.object,
|
|
196
210
|
disableLine: _propTypes.default.bool,
|
|
197
211
|
disableTicks: _propTypes.default.bool,
|
|
@@ -238,13 +252,23 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
238
252
|
right: _propTypes.default.number,
|
|
239
253
|
top: _propTypes.default.number
|
|
240
254
|
}),
|
|
255
|
+
onAreaClick: _propTypes.default.func,
|
|
256
|
+
/**
|
|
257
|
+
* The function called for onClick events.
|
|
258
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
259
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
260
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
261
|
+
*/
|
|
262
|
+
onAxisClick: _propTypes.default.func,
|
|
263
|
+
onLineClick: _propTypes.default.func,
|
|
264
|
+
onMarkClick: _propTypes.default.func,
|
|
241
265
|
/**
|
|
242
266
|
* Indicate which axis to display the right of the charts.
|
|
243
267
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
244
268
|
* @default null
|
|
245
269
|
*/
|
|
246
270
|
rightAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
247
|
-
axisId: _propTypes.default.string,
|
|
271
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
248
272
|
classes: _propTypes.default.object,
|
|
249
273
|
disableLine: _propTypes.default.bool,
|
|
250
274
|
disableTicks: _propTypes.default.bool,
|
|
@@ -266,6 +290,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
266
290
|
tickSize: _propTypes.default.number
|
|
267
291
|
}), _propTypes.default.string]),
|
|
268
292
|
series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
293
|
+
/**
|
|
294
|
+
* If `true`, animations are skipped.
|
|
295
|
+
* @default false
|
|
296
|
+
*/
|
|
297
|
+
skipAnimation: _propTypes.default.bool,
|
|
269
298
|
/**
|
|
270
299
|
* The props used for each component slot.
|
|
271
300
|
* @default {}
|
|
@@ -292,7 +321,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
292
321
|
* @default null
|
|
293
322
|
*/
|
|
294
323
|
topAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
295
|
-
axisId: _propTypes.default.string,
|
|
324
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
296
325
|
classes: _propTypes.default.object,
|
|
297
326
|
disableLine: _propTypes.default.bool,
|
|
298
327
|
disableTicks: _propTypes.default.bool,
|
|
@@ -329,7 +358,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
329
358
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
330
359
|
*/
|
|
331
360
|
xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
332
|
-
axisId: _propTypes.default.string,
|
|
361
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
333
362
|
classes: _propTypes.default.object,
|
|
334
363
|
data: _propTypes.default.array,
|
|
335
364
|
dataKey: _propTypes.default.string,
|
|
@@ -337,13 +366,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
337
366
|
disableTicks: _propTypes.default.bool,
|
|
338
367
|
fill: _propTypes.default.string,
|
|
339
368
|
hideTooltip: _propTypes.default.bool,
|
|
340
|
-
id: _propTypes.default.string,
|
|
369
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
341
370
|
label: _propTypes.default.string,
|
|
342
371
|
labelFontSize: _propTypes.default.number,
|
|
343
372
|
labelStyle: _propTypes.default.object,
|
|
344
373
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
345
374
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
346
375
|
position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
|
|
376
|
+
reverse: _propTypes.default.bool,
|
|
347
377
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
348
378
|
slotProps: _propTypes.default.object,
|
|
349
379
|
slots: _propTypes.default.object,
|
|
@@ -363,7 +393,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
363
393
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
364
394
|
*/
|
|
365
395
|
yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
366
|
-
axisId: _propTypes.default.string,
|
|
396
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
367
397
|
classes: _propTypes.default.object,
|
|
368
398
|
data: _propTypes.default.array,
|
|
369
399
|
dataKey: _propTypes.default.string,
|
|
@@ -371,13 +401,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
371
401
|
disableTicks: _propTypes.default.bool,
|
|
372
402
|
fill: _propTypes.default.string,
|
|
373
403
|
hideTooltip: _propTypes.default.bool,
|
|
374
|
-
id: _propTypes.default.string,
|
|
404
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
375
405
|
label: _propTypes.default.string,
|
|
376
406
|
labelFontSize: _propTypes.default.number,
|
|
377
407
|
labelStyle: _propTypes.default.object,
|
|
378
408
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
379
409
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
380
410
|
position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
|
|
411
|
+
reverse: _propTypes.default.bool,
|
|
381
412
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
382
413
|
slotProps: _propTypes.default.object,
|
|
383
414
|
slots: _propTypes.default.object,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SlotComponentProps } from '@mui/base/utils';
|
|
3
2
|
import { HighlightScope } from '../context/HighlightProvider';
|
|
3
|
+
import { AnimatedLineProps } from './AnimatedLine';
|
|
4
|
+
import { SeriesId } from '../models/seriesType/common';
|
|
4
5
|
export interface LineElementClasses {
|
|
5
6
|
/** Styles applied to the root element. */
|
|
6
7
|
root: string;
|
|
@@ -10,8 +11,8 @@ export interface LineElementClasses {
|
|
|
10
11
|
faded: string;
|
|
11
12
|
}
|
|
12
13
|
export type LineElementClassKey = keyof LineElementClasses;
|
|
13
|
-
interface LineElementOwnerState {
|
|
14
|
-
id:
|
|
14
|
+
export interface LineElementOwnerState {
|
|
15
|
+
id: SeriesId;
|
|
15
16
|
color: string;
|
|
16
17
|
isFaded: boolean;
|
|
17
18
|
isHighlighted: boolean;
|
|
@@ -19,30 +20,30 @@ interface LineElementOwnerState {
|
|
|
19
20
|
}
|
|
20
21
|
export declare function getLineElementUtilityClass(slot: string): string;
|
|
21
22
|
export declare const lineElementClasses: LineElementClasses;
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export interface LineElementSlots {
|
|
24
|
+
/**
|
|
25
|
+
* The component that renders the line.
|
|
26
|
+
* @default LineElementPath
|
|
27
|
+
*/
|
|
28
|
+
line?: React.JSXElementConstructor<AnimatedLineProps>;
|
|
29
|
+
}
|
|
30
|
+
export interface LineElementSlotProps {
|
|
31
|
+
line?: AnimatedLineProps;
|
|
32
|
+
}
|
|
33
|
+
export interface LineElementProps extends Omit<LineElementOwnerState, 'isFaded' | 'isHighlighted'>, Pick<AnimatedLineProps, 'skipAnimation'>, Omit<React.ComponentPropsWithoutRef<'path'>, 'color' | 'id'> {
|
|
34
|
+
d: string;
|
|
26
35
|
highlightScope?: Partial<HighlightScope>;
|
|
27
36
|
/**
|
|
28
37
|
* The props used for each component slot.
|
|
29
38
|
* @default {}
|
|
30
39
|
*/
|
|
31
|
-
slotProps?:
|
|
32
|
-
line?: SlotComponentProps<'path', {}, LineElementOwnerState>;
|
|
33
|
-
};
|
|
40
|
+
slotProps?: LineElementSlotProps;
|
|
34
41
|
/**
|
|
35
42
|
* Overridable component slots.
|
|
36
43
|
* @default {}
|
|
37
44
|
*/
|
|
38
|
-
slots?:
|
|
39
|
-
|
|
40
|
-
* The component that renders the root.
|
|
41
|
-
* @default LineElementPath
|
|
42
|
-
*/
|
|
43
|
-
line?: React.ElementType;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
45
|
+
slots?: LineElementSlots;
|
|
46
|
+
}
|
|
46
47
|
/**
|
|
47
48
|
* Demos:
|
|
48
49
|
*
|
package/LineChart/LineElement.js
CHANGED
|
@@ -5,23 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.LineElement = LineElement;
|
|
8
|
-
exports.LineElementPath = void 0;
|
|
9
8
|
exports.getLineElementUtilityClass = getLineElementUtilityClass;
|
|
10
9
|
exports.lineElementClasses = void 0;
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
12
|
var React = _interopRequireWildcard(require("react"));
|
|
14
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
var _d3Color = require("d3-color");
|
|
16
14
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
17
15
|
var _utils = require("@mui/base/utils");
|
|
18
16
|
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
19
|
-
var _styles = require("@mui/material/styles");
|
|
20
17
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
21
18
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
22
19
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
20
|
+
var _AnimatedLine = require("./AnimatedLine");
|
|
23
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
|
-
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
22
|
+
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
|
|
25
23
|
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); }
|
|
26
24
|
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 && Object.prototype.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; }
|
|
27
25
|
function getLineElementUtilityClass(slot) {
|
|
@@ -40,35 +38,6 @@ const useUtilityClasses = ownerState => {
|
|
|
40
38
|
};
|
|
41
39
|
return (0, _composeClasses.default)(slots, getLineElementUtilityClass, classes);
|
|
42
40
|
};
|
|
43
|
-
const LineElementPath = exports.LineElementPath = (0, _styles.styled)('path', {
|
|
44
|
-
name: 'MuiLineElement',
|
|
45
|
-
slot: 'Root',
|
|
46
|
-
overridesResolver: (_, styles) => styles.root
|
|
47
|
-
})(({
|
|
48
|
-
ownerState
|
|
49
|
-
}) => ({
|
|
50
|
-
strokeWidth: 2,
|
|
51
|
-
strokeLinejoin: 'round',
|
|
52
|
-
fill: 'none',
|
|
53
|
-
stroke: ownerState.isHighlighted ? (0, _d3Color.color)(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
|
|
54
|
-
transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
|
|
55
|
-
opacity: ownerState.isFaded ? 0.3 : 1
|
|
56
|
-
}));
|
|
57
|
-
LineElementPath.propTypes = {
|
|
58
|
-
// ----------------------------- Warning --------------------------------
|
|
59
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
60
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
61
|
-
// ----------------------------------------------------------------------
|
|
62
|
-
as: _propTypes.default.elementType,
|
|
63
|
-
ownerState: _propTypes.default.shape({
|
|
64
|
-
classes: _propTypes.default.object,
|
|
65
|
-
color: _propTypes.default.string.isRequired,
|
|
66
|
-
id: _propTypes.default.string.isRequired,
|
|
67
|
-
isFaded: _propTypes.default.bool.isRequired,
|
|
68
|
-
isHighlighted: _propTypes.default.bool.isRequired
|
|
69
|
-
}).isRequired,
|
|
70
|
-
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
|
|
71
|
-
};
|
|
72
41
|
/**
|
|
73
42
|
* Demos:
|
|
74
43
|
*
|
|
@@ -86,7 +55,8 @@ function LineElement(props) {
|
|
|
86
55
|
color,
|
|
87
56
|
highlightScope,
|
|
88
57
|
slots,
|
|
89
|
-
slotProps
|
|
58
|
+
slotProps,
|
|
59
|
+
onClick
|
|
90
60
|
} = props,
|
|
91
61
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
92
62
|
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
|
|
@@ -109,7 +79,7 @@ function LineElement(props) {
|
|
|
109
79
|
isHighlighted
|
|
110
80
|
};
|
|
111
81
|
const classes = useUtilityClasses(ownerState);
|
|
112
|
-
const Line = slots?.line ??
|
|
82
|
+
const Line = slots?.line ?? _AnimatedLine.AnimatedLine;
|
|
113
83
|
const lineProps = (0, _utils.useSlotProps)({
|
|
114
84
|
elementType: Line,
|
|
115
85
|
externalSlotProps: slotProps?.line,
|
|
@@ -117,7 +87,9 @@ function LineElement(props) {
|
|
|
117
87
|
type: 'line',
|
|
118
88
|
seriesId: id
|
|
119
89
|
}), {
|
|
120
|
-
className: classes.root
|
|
90
|
+
className: classes.root,
|
|
91
|
+
onClick,
|
|
92
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
121
93
|
}),
|
|
122
94
|
ownerState
|
|
123
95
|
});
|
|
@@ -129,10 +101,18 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
|
129
101
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
130
102
|
// ----------------------------------------------------------------------
|
|
131
103
|
classes: _propTypes.default.object,
|
|
104
|
+
color: _propTypes.default.string.isRequired,
|
|
105
|
+
d: _propTypes.default.string.isRequired,
|
|
132
106
|
highlightScope: _propTypes.default.shape({
|
|
133
107
|
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
134
108
|
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
135
109
|
}),
|
|
110
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
111
|
+
/**
|
|
112
|
+
* If `true`, animations are skipped.
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
skipAnimation: _propTypes.default.bool,
|
|
136
116
|
/**
|
|
137
117
|
* The props used for each component slot.
|
|
138
118
|
* @default {}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { SeriesId } from '../models/seriesType/common';
|
|
2
3
|
export interface LineHighlightElementClasses {
|
|
3
4
|
/** Styles applied to the root element. */
|
|
4
5
|
root: string;
|
|
5
6
|
}
|
|
6
7
|
export type HighlightElementClassKey = keyof LineHighlightElementClasses;
|
|
7
8
|
interface LineHighlightElementOwnerState {
|
|
8
|
-
id:
|
|
9
|
+
id: SeriesId;
|
|
9
10
|
color: string;
|
|
10
11
|
x: number;
|
|
11
12
|
y: number;
|
|
@@ -13,7 +14,7 @@ interface LineHighlightElementOwnerState {
|
|
|
13
14
|
}
|
|
14
15
|
export declare function getHighlightElementUtilityClass(slot: string): string;
|
|
15
16
|
export declare const lineHighlightElementClasses: LineHighlightElementClasses;
|
|
16
|
-
export type LineHighlightElementProps = LineHighlightElementOwnerState & React.ComponentPropsWithoutRef<'circle'> & {};
|
|
17
|
+
export type LineHighlightElementProps = LineHighlightElementOwnerState & Omit<React.ComponentPropsWithoutRef<'circle'>, 'id'> & {};
|
|
17
18
|
/**
|
|
18
19
|
* Demos:
|
|
19
20
|
*
|
|
@@ -71,18 +71,20 @@ function LineHighlightElement(props) {
|
|
|
71
71
|
y
|
|
72
72
|
};
|
|
73
73
|
const classes = useUtilityClasses(ownerState);
|
|
74
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HighlightElement, (0, _extends2.default)({
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HighlightElement, (0, _extends2.default)({
|
|
75
|
+
pointerEvents: "none",
|
|
75
76
|
ownerState: ownerState,
|
|
76
77
|
className: classes.root,
|
|
77
78
|
cx: 0,
|
|
78
79
|
cy: 0,
|
|
79
80
|
r: other.r === undefined ? 5 : other.r
|
|
80
|
-
}));
|
|
81
|
+
}, other));
|
|
81
82
|
}
|
|
82
83
|
process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
83
84
|
// ----------------------------- Warning --------------------------------
|
|
84
85
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
85
86
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
86
87
|
// ----------------------------------------------------------------------
|
|
87
|
-
classes: _propTypes.default.object
|
|
88
|
+
classes: _propTypes.default.object,
|
|
89
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired
|
|
88
90
|
} : void 0;
|
package/LineChart/LinePlot.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { LineElementProps } from './LineElement';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { LineElementProps, LineElementSlotProps, LineElementSlots } from './LineElement';
|
|
3
|
+
import { LineItemIdentifier } from '../models/seriesType/line';
|
|
4
|
+
export interface LinePlotSlots extends LineElementSlots {
|
|
5
5
|
}
|
|
6
|
-
export interface LinePlotSlotProps {
|
|
7
|
-
line?: Partial<LineElementProps>;
|
|
6
|
+
export interface LinePlotSlotProps extends LineElementSlotProps {
|
|
8
7
|
}
|
|
9
|
-
export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<LineElementProps, 'slots' | 'slotProps'> {
|
|
8
|
+
export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<LineElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
|
|
9
|
+
/**
|
|
10
|
+
* Callback fired when a line item is clicked.
|
|
11
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
12
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
|
|
13
|
+
*/
|
|
14
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemIdentifier) => void;
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* Demos:
|
|
@@ -18,7 +23,7 @@ export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<
|
|
|
18
23
|
*
|
|
19
24
|
* - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
|
|
20
25
|
*/
|
|
21
|
-
declare function LinePlot(props: LinePlotProps): React.JSX.Element
|
|
26
|
+
declare function LinePlot(props: LinePlotProps): React.JSX.Element;
|
|
22
27
|
declare namespace LinePlot {
|
|
23
28
|
var propTypes: any;
|
|
24
29
|
}
|
package/LineChart/LinePlot.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.LinePlot = LinePlot;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
8
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _d3Shape = require("d3-shape");
|
|
@@ -17,29 +17,14 @@ var _useScale = require("../hooks/useScale");
|
|
|
17
17
|
var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
|
|
18
18
|
var _constants = require("../constants");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["slots", "slotProps"];
|
|
20
|
+
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
21
21
|
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); }
|
|
22
22
|
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 && Object.prototype.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; }
|
|
23
|
-
|
|
24
|
-
* Demos:
|
|
25
|
-
*
|
|
26
|
-
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
27
|
-
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
28
|
-
*
|
|
29
|
-
* API:
|
|
30
|
-
*
|
|
31
|
-
* - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
|
|
32
|
-
*/
|
|
33
|
-
function LinePlot(props) {
|
|
34
|
-
const {
|
|
35
|
-
slots,
|
|
36
|
-
slotProps
|
|
37
|
-
} = props,
|
|
38
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
23
|
+
const useAggregatedData = () => {
|
|
39
24
|
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).line;
|
|
40
25
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
41
26
|
if (seriesData === undefined) {
|
|
42
|
-
return
|
|
27
|
+
return [];
|
|
43
28
|
}
|
|
44
29
|
const {
|
|
45
30
|
series,
|
|
@@ -53,45 +38,82 @@ function LinePlot(props) {
|
|
|
53
38
|
} = axisData;
|
|
54
39
|
const defaultXAxisId = xAxisIds[0];
|
|
55
40
|
const defaultYAxisId = yAxisIds[0];
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
throw new Error(`MUI X Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
74
|
-
}
|
|
75
|
-
if (xData.length < stackedData.length) {
|
|
76
|
-
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
77
|
-
}
|
|
41
|
+
return stackingGroups.flatMap(({
|
|
42
|
+
ids: groupIds
|
|
43
|
+
}) => {
|
|
44
|
+
return groupIds.flatMap(seriesId => {
|
|
45
|
+
const {
|
|
46
|
+
xAxisKey = defaultXAxisId,
|
|
47
|
+
yAxisKey = defaultYAxisId,
|
|
48
|
+
stackedData,
|
|
49
|
+
data,
|
|
50
|
+
connectNulls
|
|
51
|
+
} = series[seriesId];
|
|
52
|
+
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
53
|
+
const yScale = yAxis[yAxisKey].scale;
|
|
54
|
+
const xData = xAxis[xAxisKey].data;
|
|
55
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
+
if (xData === undefined) {
|
|
57
|
+
throw new Error(`MUI X Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
78
58
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, seriesId);
|
|
59
|
+
if (xData.length < stackedData.length) {
|
|
60
|
+
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const linePath = (0, _d3Shape.line)().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
64
|
+
const formattedData = xData?.map((x, index) => ({
|
|
65
|
+
x,
|
|
66
|
+
y: stackedData[index]
|
|
67
|
+
})) ?? [];
|
|
68
|
+
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
69
|
+
const d = linePath.curve((0, _getCurve.default)(series[seriesId].curve))(d3Data) || '';
|
|
70
|
+
return (0, _extends2.default)({}, series[seriesId], {
|
|
71
|
+
d,
|
|
72
|
+
seriesId
|
|
94
73
|
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Demos:
|
|
80
|
+
*
|
|
81
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
82
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
83
|
+
*
|
|
84
|
+
* API:
|
|
85
|
+
*
|
|
86
|
+
* - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
|
|
87
|
+
*/
|
|
88
|
+
function LinePlot(props) {
|
|
89
|
+
const {
|
|
90
|
+
slots,
|
|
91
|
+
slotProps,
|
|
92
|
+
skipAnimation,
|
|
93
|
+
onItemClick
|
|
94
|
+
} = props,
|
|
95
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
96
|
+
const completedData = useAggregatedData();
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
|
|
98
|
+
children: completedData.map(({
|
|
99
|
+
d,
|
|
100
|
+
seriesId,
|
|
101
|
+
color,
|
|
102
|
+
highlightScope
|
|
103
|
+
}) => {
|
|
104
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineElement.LineElement, {
|
|
105
|
+
id: seriesId,
|
|
106
|
+
d: d,
|
|
107
|
+
color: color,
|
|
108
|
+
highlightScope: highlightScope,
|
|
109
|
+
skipAnimation: skipAnimation,
|
|
110
|
+
slots: slots,
|
|
111
|
+
slotProps: slotProps,
|
|
112
|
+
onClick: onItemClick && (event => onItemClick(event, {
|
|
113
|
+
type: 'line',
|
|
114
|
+
seriesId
|
|
115
|
+
}))
|
|
116
|
+
}, seriesId);
|
|
95
117
|
})
|
|
96
118
|
}));
|
|
97
119
|
}
|
|
@@ -100,6 +122,17 @@ process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
|
|
|
100
122
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
101
123
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
102
124
|
// ----------------------------------------------------------------------
|
|
125
|
+
/**
|
|
126
|
+
* Callback fired when a line item is clicked.
|
|
127
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
128
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
|
|
129
|
+
*/
|
|
130
|
+
onItemClick: _propTypes.default.func,
|
|
131
|
+
/**
|
|
132
|
+
* If `true`, animations are skipped.
|
|
133
|
+
* @default false
|
|
134
|
+
*/
|
|
135
|
+
skipAnimation: _propTypes.default.bool,
|
|
103
136
|
/**
|
|
104
137
|
* The props used for each component slot.
|
|
105
138
|
* @default {}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { HighlightScope } from '../context/HighlightProvider';
|
|
3
|
+
import { SeriesId } from '../models/seriesType/common';
|
|
3
4
|
export interface MarkElementClasses {
|
|
4
5
|
/** Styles applied to the root element. */
|
|
5
6
|
root: string;
|
|
@@ -10,17 +11,20 @@ export interface MarkElementClasses {
|
|
|
10
11
|
}
|
|
11
12
|
export type MarkElementClassKey = keyof MarkElementClasses;
|
|
12
13
|
interface MarkElementOwnerState {
|
|
13
|
-
id:
|
|
14
|
+
id: SeriesId;
|
|
14
15
|
color: string;
|
|
15
16
|
isFaded: boolean;
|
|
16
17
|
isHighlighted: boolean;
|
|
17
|
-
x: number;
|
|
18
|
-
y: number;
|
|
19
18
|
classes?: Partial<MarkElementClasses>;
|
|
20
19
|
}
|
|
21
20
|
export declare function getMarkElementUtilityClass(slot: string): string;
|
|
22
21
|
export declare const markElementClasses: MarkElementClasses;
|
|
23
|
-
export type MarkElementProps = Omit<MarkElementOwnerState, 'isFaded' | 'isHighlighted'> & React.ComponentPropsWithoutRef<'path'> & {
|
|
22
|
+
export type MarkElementProps = Omit<MarkElementOwnerState, 'isFaded' | 'isHighlighted'> & Omit<React.ComponentPropsWithoutRef<'path'>, 'id'> & {
|
|
23
|
+
/**
|
|
24
|
+
* If `true`, animations are skipped.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
skipAnimation?: boolean;
|
|
24
28
|
/**
|
|
25
29
|
* The shape of the marker.
|
|
26
30
|
*/
|