@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
package/LineChart/MarkPlot.js
CHANGED
|
@@ -14,8 +14,10 @@ var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
|
14
14
|
var _MarkElement = require("./MarkElement");
|
|
15
15
|
var _useScale = require("../hooks/useScale");
|
|
16
16
|
var _constants = require("../constants");
|
|
17
|
+
var _DrawingProvider = require("../context/DrawingProvider");
|
|
18
|
+
var _utils = require("../internals/utils");
|
|
17
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _excluded = ["slots", "slotProps"];
|
|
20
|
+
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
19
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); }
|
|
20
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; }
|
|
21
23
|
/**
|
|
@@ -31,11 +33,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
31
33
|
function MarkPlot(props) {
|
|
32
34
|
const {
|
|
33
35
|
slots,
|
|
34
|
-
slotProps
|
|
36
|
+
slotProps,
|
|
37
|
+
skipAnimation,
|
|
38
|
+
onItemClick
|
|
35
39
|
} = props,
|
|
36
40
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
37
41
|
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).line;
|
|
38
42
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
43
|
+
const {
|
|
44
|
+
chartId
|
|
45
|
+
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
39
46
|
const Mark = slots?.mark ?? _MarkElement.MarkElement;
|
|
40
47
|
if (seriesData === undefined) {
|
|
41
48
|
return null;
|
|
@@ -56,7 +63,7 @@ function MarkPlot(props) {
|
|
|
56
63
|
children: stackingGroups.flatMap(({
|
|
57
64
|
ids: groupIds
|
|
58
65
|
}) => {
|
|
59
|
-
return groupIds.
|
|
66
|
+
return groupIds.map(seriesId => {
|
|
60
67
|
const {
|
|
61
68
|
xAxisKey = defaultXAxisId,
|
|
62
69
|
yAxisKey = defaultYAxisId,
|
|
@@ -87,59 +94,70 @@ function MarkPlot(props) {
|
|
|
87
94
|
if (xData === undefined) {
|
|
88
95
|
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.`);
|
|
89
96
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
value
|
|
105
|
-
}) => {
|
|
106
|
-
if (value === null || y === null) {
|
|
107
|
-
// Remove missing data point
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
if (!isInRange({
|
|
111
|
-
x,
|
|
112
|
-
y
|
|
113
|
-
})) {
|
|
114
|
-
// Remove out of range
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (showMark === true) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
return showMark({
|
|
97
|
+
const clipId = (0, _utils.cleanId)(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
|
|
98
|
+
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
100
|
+
clipPath: `url(#${clipId})`,
|
|
101
|
+
children: xData?.map((x, index) => {
|
|
102
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
103
|
+
return {
|
|
104
|
+
x: xScale(x),
|
|
105
|
+
y: value === null ? null : yScale(value),
|
|
106
|
+
position: x,
|
|
107
|
+
value,
|
|
108
|
+
index
|
|
109
|
+
};
|
|
110
|
+
}).filter(({
|
|
121
111
|
x,
|
|
122
112
|
y,
|
|
123
113
|
index,
|
|
124
114
|
position,
|
|
125
115
|
value
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
}) => {
|
|
117
|
+
if (value === null || y === null) {
|
|
118
|
+
// Remove missing data point
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (!isInRange({
|
|
122
|
+
x,
|
|
123
|
+
y
|
|
124
|
+
})) {
|
|
125
|
+
// Remove out of range
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (showMark === true) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return showMark({
|
|
132
|
+
x,
|
|
133
|
+
y,
|
|
134
|
+
index,
|
|
135
|
+
position,
|
|
136
|
+
value
|
|
137
|
+
});
|
|
138
|
+
}).map(({
|
|
139
|
+
x,
|
|
140
|
+
y,
|
|
141
|
+
index
|
|
142
|
+
}) => {
|
|
143
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Mark, (0, _extends2.default)({
|
|
144
|
+
id: seriesId,
|
|
145
|
+
dataIndex: index,
|
|
146
|
+
shape: "circle",
|
|
147
|
+
color: series[seriesId].color,
|
|
148
|
+
x: x,
|
|
149
|
+
y: y // Don't know why TS doesn't get from the filter that y can't be null
|
|
150
|
+
,
|
|
151
|
+
highlightScope: series[seriesId].highlightScope,
|
|
152
|
+
skipAnimation: skipAnimation,
|
|
153
|
+
onClick: onItemClick && (event => onItemClick(event, {
|
|
154
|
+
type: 'line',
|
|
155
|
+
seriesId,
|
|
156
|
+
dataIndex: index
|
|
157
|
+
}))
|
|
158
|
+
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
159
|
+
})
|
|
160
|
+
}, seriesId);
|
|
143
161
|
});
|
|
144
162
|
})
|
|
145
163
|
}));
|
|
@@ -149,6 +167,17 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
|
|
|
149
167
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
150
168
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
151
169
|
// ----------------------------------------------------------------------
|
|
170
|
+
/**
|
|
171
|
+
* Callback fired when a line mark item is clicked.
|
|
172
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
173
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line mark item identifier.
|
|
174
|
+
*/
|
|
175
|
+
onItemClick: _propTypes.default.func,
|
|
176
|
+
/**
|
|
177
|
+
* If `true`, animations are skipped.
|
|
178
|
+
* @default false
|
|
179
|
+
*/
|
|
180
|
+
skipAnimation: _propTypes.default.bool,
|
|
152
181
|
/**
|
|
153
182
|
* The props used for each component slot.
|
|
154
183
|
* @default {}
|
package/LineChart/formatter.js
CHANGED
|
@@ -76,7 +76,7 @@ const formatter = (params, dataset) => {
|
|
|
76
76
|
return {
|
|
77
77
|
seriesOrder,
|
|
78
78
|
stackingGroups,
|
|
79
|
-
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v
|
|
79
|
+
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v == null ? '' : v.toLocaleString())
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
var _default = exports.default = formatter;
|
package/LineChart/index.d.ts
CHANGED
|
@@ -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';
|
package/LineChart/index.js
CHANGED
|
@@ -69,6 +69,17 @@ Object.keys(_AreaElement).forEach(function (key) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
+
var _AnimatedArea = require("./AnimatedArea");
|
|
73
|
+
Object.keys(_AnimatedArea).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _AnimatedArea[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _AnimatedArea[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
72
83
|
var _LineElement = require("./LineElement");
|
|
73
84
|
Object.keys(_LineElement).forEach(function (key) {
|
|
74
85
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -80,6 +91,17 @@ Object.keys(_LineElement).forEach(function (key) {
|
|
|
80
91
|
}
|
|
81
92
|
});
|
|
82
93
|
});
|
|
94
|
+
var _AnimatedLine = require("./AnimatedLine");
|
|
95
|
+
Object.keys(_AnimatedLine).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _AnimatedLine[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _AnimatedLine[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
83
105
|
var _MarkElement = require("./MarkElement");
|
|
84
106
|
Object.keys(_MarkElement).forEach(function (key) {
|
|
85
107
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -24,7 +24,7 @@ export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'da
|
|
|
24
24
|
*/
|
|
25
25
|
slotProps?: PieArcLabelPlotSlotProps;
|
|
26
26
|
/**
|
|
27
|
-
* If `true`, animations are
|
|
27
|
+
* If `true`, animations are skipped.
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
skipAnimation?: boolean;
|
|
@@ -182,7 +182,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
182
182
|
*/
|
|
183
183
|
paddingAngle: _propTypes.default.number,
|
|
184
184
|
/**
|
|
185
|
-
* If `true`, animations are
|
|
185
|
+
* If `true`, animations are skipped.
|
|
186
186
|
* @default false
|
|
187
187
|
*/
|
|
188
188
|
skipAnimation: _propTypes.default.bool,
|
package/PieChart/PieArcPlot.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' |
|
|
|
29
29
|
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
30
30
|
* @param {DefaultizedPieValueType} item The pie item.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
onItemClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
|
|
33
33
|
/**
|
|
34
|
-
* If `true`, animations are
|
|
34
|
+
* If `true`, animations are skipped.
|
|
35
35
|
* @default false
|
|
36
36
|
*/
|
|
37
37
|
skipAnimation?: boolean;
|
package/PieChart/PieArcPlot.js
CHANGED
|
@@ -14,7 +14,7 @@ var _PieArc = require("./PieArc");
|
|
|
14
14
|
var _transition = require("./dataTransform/transition");
|
|
15
15
|
var _useTransformData = require("./dataTransform/useTransformData");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "
|
|
17
|
+
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
|
|
18
18
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
|
|
19
19
|
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); }
|
|
20
20
|
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; }
|
|
@@ -33,7 +33,7 @@ function PieArcPlot(props) {
|
|
|
33
33
|
additionalRadius: -5
|
|
34
34
|
},
|
|
35
35
|
data,
|
|
36
|
-
|
|
36
|
+
onItemClick,
|
|
37
37
|
skipAnimation
|
|
38
38
|
} = props,
|
|
39
39
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
@@ -80,8 +80,8 @@ function PieArcPlot(props) {
|
|
|
80
80
|
highlightScope: highlightScope,
|
|
81
81
|
isFaded: item.isFaded,
|
|
82
82
|
isHighlighted: item.isHighlighted,
|
|
83
|
-
onClick:
|
|
84
|
-
|
|
83
|
+
onClick: onItemClick && (event => {
|
|
84
|
+
onItemClick(event, {
|
|
85
85
|
type: 'pie',
|
|
86
86
|
seriesId: id,
|
|
87
87
|
dataIndex: index
|
|
@@ -158,7 +158,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
158
158
|
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
159
159
|
* @param {DefaultizedPieValueType} item The pie item.
|
|
160
160
|
*/
|
|
161
|
-
|
|
161
|
+
onItemClick: _propTypes.default.func,
|
|
162
162
|
/**
|
|
163
163
|
* The radius between circle center and the end of the arc.
|
|
164
164
|
*/
|
|
@@ -169,7 +169,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
169
169
|
*/
|
|
170
170
|
paddingAngle: _propTypes.default.number,
|
|
171
171
|
/**
|
|
172
|
-
* If `true`, animations are
|
|
172
|
+
* If `true`, animations are skipped.
|
|
173
173
|
* @default false
|
|
174
174
|
*/
|
|
175
175
|
skipAnimation: _propTypes.default.bool,
|
package/PieChart/PieChart.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface PieChartProps extends Omit<ResponsiveChartContainerProps, 'seri
|
|
|
33
33
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
34
34
|
*/
|
|
35
35
|
legend?: ChartsLegendProps;
|
|
36
|
-
|
|
36
|
+
onItemClick?: PiePlotProps['onItemClick'];
|
|
37
37
|
slots?: PieChartSlots;
|
|
38
38
|
/**
|
|
39
39
|
* The props used for each component slot.
|
package/PieChart/PieChart.js
CHANGED
|
@@ -67,7 +67,7 @@ function PieChart(props) {
|
|
|
67
67
|
children,
|
|
68
68
|
slots,
|
|
69
69
|
slotProps,
|
|
70
|
-
|
|
70
|
+
onItemClick
|
|
71
71
|
} = props;
|
|
72
72
|
const margin = (0, _extends2.default)({}, defaultMargin, marginProps);
|
|
73
73
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, {
|
|
@@ -96,7 +96,7 @@ function PieChart(props) {
|
|
|
96
96
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PiePlot.PiePlot, {
|
|
97
97
|
slots: slots,
|
|
98
98
|
slotProps: slotProps,
|
|
99
|
-
|
|
99
|
+
onItemClick: onItemClick,
|
|
100
100
|
skipAnimation: skipAnimation
|
|
101
101
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
|
|
102
102
|
slots: slots,
|
|
@@ -216,7 +216,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
216
216
|
right: _propTypes.default.number,
|
|
217
217
|
top: _propTypes.default.number
|
|
218
218
|
}),
|
|
219
|
-
|
|
219
|
+
onItemClick: _propTypes.default.func,
|
|
220
220
|
/**
|
|
221
221
|
* Indicate which axis to display the right of the charts.
|
|
222
222
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -246,7 +246,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
246
246
|
}), _propTypes.default.string]),
|
|
247
247
|
series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
248
248
|
/**
|
|
249
|
-
* If `true`, animations are
|
|
249
|
+
* If `true`, animations are skipped.
|
|
250
250
|
* @default false
|
|
251
251
|
*/
|
|
252
252
|
skipAnimation: _propTypes.default.bool,
|
package/PieChart/PiePlot.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface PiePlotSlots extends PieArcPlotSlots, PieArcLabelPlotSlots {
|
|
|
5
5
|
}
|
|
6
6
|
export interface PiePlotSlotProps extends PieArcPlotSlotProps, PieArcLabelPlotSlotProps {
|
|
7
7
|
}
|
|
8
|
-
export interface PiePlotProps extends Pick<PieArcPlotProps, 'skipAnimation' | '
|
|
8
|
+
export interface PiePlotProps extends Pick<PieArcPlotProps, 'skipAnimation' | 'onItemClick'> {
|
|
9
9
|
/**
|
|
10
10
|
* Overridable component slots.
|
|
11
11
|
* @default {}
|
package/PieChart/PiePlot.js
CHANGED
|
@@ -30,7 +30,7 @@ function PiePlot(props) {
|
|
|
30
30
|
skipAnimation,
|
|
31
31
|
slots,
|
|
32
32
|
slotProps,
|
|
33
|
-
|
|
33
|
+
onItemClick
|
|
34
34
|
} = props;
|
|
35
35
|
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).pie;
|
|
36
36
|
const {
|
|
@@ -78,7 +78,7 @@ function PiePlot(props) {
|
|
|
78
78
|
highlightScope: highlightScope,
|
|
79
79
|
highlighted: highlighted,
|
|
80
80
|
faded: faded,
|
|
81
|
-
|
|
81
|
+
onItemClick: onItemClick,
|
|
82
82
|
slots: slots,
|
|
83
83
|
slotProps: slotProps
|
|
84
84
|
})
|
|
@@ -132,9 +132,9 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
|
132
132
|
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
133
133
|
* @param {DefaultizedPieValueType} item The pie item.
|
|
134
134
|
*/
|
|
135
|
-
|
|
135
|
+
onItemClick: _propTypes.default.func,
|
|
136
136
|
/**
|
|
137
|
-
* If `true`, animations are
|
|
137
|
+
* If `true`, animations are skipped.
|
|
138
138
|
* @default false
|
|
139
139
|
*/
|
|
140
140
|
skipAnimation: _propTypes.default.bool,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { DefaultizedScatterSeriesType } from '../models/seriesType/scatter';
|
|
2
|
+
import { DefaultizedScatterSeriesType, ScatterItemIdentifier } from '../models/seriesType/scatter';
|
|
3
3
|
import { D3Scale } from '../models/axis';
|
|
4
4
|
export interface ScatterProps {
|
|
5
5
|
series: DefaultizedScatterSeriesType;
|
|
@@ -7,6 +7,12 @@ export interface ScatterProps {
|
|
|
7
7
|
yScale: D3Scale;
|
|
8
8
|
markerSize: number;
|
|
9
9
|
color: string;
|
|
10
|
+
/**
|
|
11
|
+
* Callback fired when clicking on a scatter item.
|
|
12
|
+
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
|
|
13
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
14
|
+
*/
|
|
15
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, scatterItemIdentifier: ScatterItemIdentifier) => void;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* Demos:
|
package/ScatterChart/Scatter.js
CHANGED
|
@@ -30,7 +30,8 @@ function Scatter(props) {
|
|
|
30
30
|
xScale,
|
|
31
31
|
yScale,
|
|
32
32
|
color,
|
|
33
|
-
markerSize
|
|
33
|
+
markerSize,
|
|
34
|
+
onItemClick
|
|
34
35
|
} = props;
|
|
35
36
|
const highlightScope = React.useMemo(() => (0, _extends2.default)({
|
|
36
37
|
highlighted: 'item',
|
|
@@ -70,7 +71,8 @@ function Scatter(props) {
|
|
|
70
71
|
isHighlighted,
|
|
71
72
|
isFaded: !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, pointCtx, highlightScope),
|
|
72
73
|
interactionProps: getInteractionItemProps(pointCtx),
|
|
73
|
-
id: scatterPoint.id
|
|
74
|
+
id: scatterPoint.id,
|
|
75
|
+
dataIndex: i
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
}
|
|
@@ -83,7 +85,13 @@ function Scatter(props) {
|
|
|
83
85
|
r: (dataPoint.isHighlighted ? 1.2 : 1) * markerSize,
|
|
84
86
|
transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
|
|
85
87
|
fill: color,
|
|
86
|
-
opacity: dataPoint.isFaded && 0.3 || 1
|
|
88
|
+
opacity: dataPoint.isFaded && 0.3 || 1,
|
|
89
|
+
onClick: onItemClick && (event => onItemClick(event, {
|
|
90
|
+
type: 'scatter',
|
|
91
|
+
seriesId: series.id,
|
|
92
|
+
dataIndex: dataPoint.dataIndex
|
|
93
|
+
})),
|
|
94
|
+
cursor: onItemClick ? 'pointer' : 'unset'
|
|
87
95
|
}, dataPoint.interactionProps), dataPoint.id))
|
|
88
96
|
});
|
|
89
97
|
}
|
|
@@ -94,6 +102,12 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
|
|
|
94
102
|
// ----------------------------------------------------------------------
|
|
95
103
|
color: _propTypes.default.string.isRequired,
|
|
96
104
|
markerSize: _propTypes.default.number.isRequired,
|
|
105
|
+
/**
|
|
106
|
+
* Callback fired when clicking on a scatter item.
|
|
107
|
+
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
|
|
108
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
109
|
+
*/
|
|
110
|
+
onItemClick: _propTypes.default.func,
|
|
97
111
|
series: _propTypes.default.object.isRequired,
|
|
98
112
|
xScale: _propTypes.default.func.isRequired,
|
|
99
113
|
yScale: _propTypes.default.func.isRequired
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ScatterPlotSlotProps, ScatterPlotSlots } from './ScatterPlot';
|
|
2
|
+
import { ScatterPlotProps, ScatterPlotSlotProps, ScatterPlotSlots } from './ScatterPlot';
|
|
3
3
|
import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
|
|
4
4
|
import { ChartsAxisProps } from '../ChartsAxis';
|
|
5
5
|
import { ScatterSeriesType } from '../models/seriesType/scatter';
|
|
@@ -13,7 +13,7 @@ export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, Ch
|
|
|
13
13
|
}
|
|
14
14
|
export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps {
|
|
15
15
|
}
|
|
16
|
-
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, ChartsVoronoiHandlerProps {
|
|
16
|
+
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsVoronoiHandlerProps, 'onItemClick'> {
|
|
17
17
|
series: MakeOptional<ScatterSeriesType, 'type'>[];
|
|
18
18
|
tooltip?: ChartsTooltipProps;
|
|
19
19
|
axisHighlight?: ChartsAxisHighlightProps;
|
|
@@ -36,6 +36,12 @@ export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, '
|
|
|
36
36
|
* @default {}
|
|
37
37
|
*/
|
|
38
38
|
slotProps?: ScatterChartSlotProps;
|
|
39
|
+
/**
|
|
40
|
+
* Callback fired when clicking on a scatter item.
|
|
41
|
+
* @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`.
|
|
42
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
43
|
+
*/
|
|
44
|
+
onItemClick?: ScatterPlotProps['onItemClick'] | ChartsVoronoiHandlerProps['onItemClick'];
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* Demos:
|
|
@@ -47,6 +47,7 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
47
47
|
leftAxis,
|
|
48
48
|
rightAxis,
|
|
49
49
|
bottomAxis,
|
|
50
|
+
onItemClick,
|
|
50
51
|
children,
|
|
51
52
|
slots,
|
|
52
53
|
slotProps
|
|
@@ -64,7 +65,8 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
64
65
|
yAxis: yAxis,
|
|
65
66
|
sx: sx,
|
|
66
67
|
children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, {
|
|
67
|
-
voronoiMaxRadius: voronoiMaxRadius
|
|
68
|
+
voronoiMaxRadius: voronoiMaxRadius,
|
|
69
|
+
onItemClick: onItemClick
|
|
68
70
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
|
|
69
71
|
topAxis: topAxis,
|
|
70
72
|
leftAxis: leftAxis,
|
|
@@ -74,7 +76,8 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
74
76
|
slotProps: slotProps
|
|
75
77
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, {
|
|
76
78
|
slots: slots,
|
|
77
|
-
slotProps: slotProps
|
|
79
|
+
slotProps: slotProps,
|
|
80
|
+
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
78
81
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
|
|
79
82
|
slots: slots,
|
|
80
83
|
slotProps: slotProps
|
|
@@ -203,6 +206,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
203
206
|
right: _propTypes.default.number,
|
|
204
207
|
top: _propTypes.default.number
|
|
205
208
|
}),
|
|
209
|
+
/**
|
|
210
|
+
* Callback fired when clicking on a scatter item.
|
|
211
|
+
* @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`.
|
|
212
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
213
|
+
*/
|
|
214
|
+
onItemClick: _propTypes.default.func,
|
|
206
215
|
/**
|
|
207
216
|
* Indicate which axis to display the right of the charts.
|
|
208
217
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -6,7 +6,7 @@ export interface ScatterPlotSlots {
|
|
|
6
6
|
export interface ScatterPlotSlotProps {
|
|
7
7
|
scatter?: Partial<ScatterProps>;
|
|
8
8
|
}
|
|
9
|
-
export interface ScatterPlotProps {
|
|
9
|
+
export interface ScatterPlotProps extends Pick<ScatterProps, 'onItemClick'> {
|
|
10
10
|
/**
|
|
11
11
|
* Overridable component slots.
|
|
12
12
|
* @default {}
|
|
@@ -27,7 +27,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
27
27
|
function ScatterPlot(props) {
|
|
28
28
|
const {
|
|
29
29
|
slots,
|
|
30
|
-
slotProps
|
|
30
|
+
slotProps,
|
|
31
|
+
onItemClick
|
|
31
32
|
} = props;
|
|
32
33
|
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).scatter;
|
|
33
34
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
@@ -63,7 +64,8 @@ function ScatterPlot(props) {
|
|
|
63
64
|
yScale: yScale,
|
|
64
65
|
color: color,
|
|
65
66
|
markerSize: markerSize ?? 4,
|
|
66
|
-
series: series[seriesId]
|
|
67
|
+
series: series[seriesId],
|
|
68
|
+
onItemClick: onItemClick
|
|
67
69
|
}, slotProps?.scatter), id);
|
|
68
70
|
})
|
|
69
71
|
});
|
|
@@ -73,6 +75,12 @@ process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
|
|
|
73
75
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
74
76
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
75
77
|
// ----------------------------------------------------------------------
|
|
78
|
+
/**
|
|
79
|
+
* Callback fired when clicking on a scatter item.
|
|
80
|
+
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
|
|
81
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
82
|
+
*/
|
|
83
|
+
onItemClick: _propTypes.default.func,
|
|
76
84
|
/**
|
|
77
85
|
* The props used for each component slot.
|
|
78
86
|
* @default {}
|
|
@@ -94,9 +94,11 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
94
94
|
}
|
|
95
95
|
}), plotType === 'line' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
96
96
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.AreaPlot, {
|
|
97
|
+
skipAnimation: true,
|
|
97
98
|
slots: slots,
|
|
98
99
|
slotProps: slotProps
|
|
99
100
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.LinePlot, {
|
|
101
|
+
skipAnimation: true,
|
|
100
102
|
slots: slots,
|
|
101
103
|
slotProps: slotProps
|
|
102
104
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.LineHighlightPlot, {
|
|
@@ -33,7 +33,12 @@ export type DrawingArea = {
|
|
|
33
33
|
*/
|
|
34
34
|
height: number;
|
|
35
35
|
};
|
|
36
|
-
export declare const DrawingContext: React.Context<DrawingArea
|
|
36
|
+
export declare const DrawingContext: React.Context<DrawingArea & {
|
|
37
|
+
/**
|
|
38
|
+
* A random id used to distinguish each chart on the same page.
|
|
39
|
+
*/
|
|
40
|
+
chartId: string;
|
|
41
|
+
}>;
|
|
37
42
|
export declare const SVGContext: React.Context<React.RefObject<SVGSVGElement>>;
|
|
38
43
|
/**
|
|
39
44
|
* API:
|
|
@@ -7,8 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.DrawingContext = void 0;
|
|
8
8
|
exports.DrawingProvider = DrawingProvider;
|
|
9
9
|
exports.SVGContext = void 0;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
11
|
var React = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
12
14
|
var _useChartDimensions = _interopRequireDefault(require("../hooks/useChartDimensions"));
|
|
13
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
16
|
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); }
|
|
@@ -23,7 +25,8 @@ const DrawingContext = exports.DrawingContext = /*#__PURE__*/React.createContext
|
|
|
23
25
|
bottom: 0,
|
|
24
26
|
right: 0,
|
|
25
27
|
height: 300,
|
|
26
|
-
width: 400
|
|
28
|
+
width: 400,
|
|
29
|
+
chartId: ''
|
|
27
30
|
});
|
|
28
31
|
const SVGContext = exports.SVGContext = /*#__PURE__*/React.createContext({
|
|
29
32
|
current: null
|
|
@@ -43,10 +46,14 @@ function DrawingProvider(props) {
|
|
|
43
46
|
children
|
|
44
47
|
} = props;
|
|
45
48
|
const drawingArea = (0, _useChartDimensions.default)(width, height, margin);
|
|
49
|
+
const chartId = (0, _useId.default)();
|
|
50
|
+
const value = React.useMemo(() => (0, _extends2.default)({
|
|
51
|
+
chartId: chartId ?? ''
|
|
52
|
+
}, drawingArea), [chartId, drawingArea]);
|
|
46
53
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SVGContext.Provider, {
|
|
47
54
|
value: svgRef,
|
|
48
55
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DrawingContext.Provider, {
|
|
49
|
-
value:
|
|
56
|
+
value: value,
|
|
50
57
|
children: children
|
|
51
58
|
})
|
|
52
59
|
});
|