@mui/x-charts 8.0.0-alpha.10 → 8.0.0-alpha.11
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 +1 -2
- package/BarChart/BarChart.js +2 -4
- package/BarChart/BarChart.plugins.d.ts +12 -0
- package/BarChart/BarChart.plugins.js +5 -0
- package/BarChart/useBarChartProps.d.ts +2 -3
- package/BarChart/useBarChartProps.js +5 -8
- package/CHANGELOG.md +107 -2
- package/ChartContainer/ChartContainer.d.ts +2 -2
- package/ChartContainer/ChartContainer.js +8 -1
- package/ChartContainer/useChartContainerProps.d.ts +4 -3
- package/ChartContainer/useChartContainerProps.js +11 -7
- package/ChartDataProvider/ChartDataProvider.js +4 -1
- package/ChartsSurface/ChartsSurface.d.ts +0 -6
- package/ChartsSurface/ChartsSurface.js +1 -10
- package/ChartsTooltip/ChartsTooltipContainer.js +2 -2
- package/Gauge/Gauge.js +0 -6
- package/Gauge/GaugeContainer.js +0 -6
- package/LineChart/LineChart.d.ts +1 -2
- package/LineChart/LineChart.js +2 -4
- package/LineChart/LineChart.plugins.d.ts +12 -0
- package/LineChart/LineChart.plugins.js +5 -0
- package/LineChart/useLineChartProps.d.ts +2 -3
- package/LineChart/useLineChartProps.js +5 -8
- package/PieChart/PieChart.d.ts +3 -1
- package/PieChart/PieChart.js +8 -115
- package/PieChart/PieChart.plugins.d.ts +5 -0
- package/PieChart/PieChart.plugins.js +3 -0
- package/ScatterChart/ScatterChart.js +8 -1
- package/ScatterChart/ScatterChart.plugins.d.ts +12 -0
- package/ScatterChart/ScatterChart.plugins.js +5 -0
- package/ScatterChart/useScatterChartProps.d.ts +2 -1
- package/ScatterChart/useScatterChartProps.js +3 -1
- package/SparkLineChart/SparkLineChart.d.ts +12 -0
- package/SparkLineChart/SparkLineChart.js +24 -4
- package/colorPalettes/colorPalettes.d.ts +2 -0
- package/context/ChartProvider/ChartProvider.types.d.ts +2 -1
- package/hooks/useAxisEvents.d.ts +0 -1
- package/hooks/useAxisEvents.js +0 -165
- package/index.d.ts +0 -1
- package/index.js +1 -2
- package/internals/plugins/allPlugins.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +5 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +9 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +59 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.d.ts +1 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +142 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +19 -2
- package/models/axis.d.ts +17 -0
- package/models/axis.js +5 -1
- package/models/index.d.ts +1 -1
- package/modern/BarChart/BarChart.js +2 -4
- package/modern/BarChart/BarChart.plugins.js +5 -0
- package/modern/BarChart/useBarChartProps.js +5 -8
- package/modern/ChartContainer/ChartContainer.js +8 -1
- package/modern/ChartContainer/useChartContainerProps.js +11 -7
- package/modern/ChartDataProvider/ChartDataProvider.js +4 -1
- package/modern/ChartsSurface/ChartsSurface.js +1 -10
- package/modern/ChartsTooltip/ChartsTooltipContainer.js +2 -2
- package/modern/Gauge/Gauge.js +0 -6
- package/modern/Gauge/GaugeContainer.js +0 -6
- package/modern/LineChart/LineChart.js +2 -4
- package/modern/LineChart/LineChart.plugins.js +5 -0
- package/modern/LineChart/useLineChartProps.js +5 -8
- package/modern/PieChart/PieChart.js +8 -115
- package/modern/PieChart/PieChart.plugins.js +3 -0
- package/modern/ScatterChart/ScatterChart.js +8 -1
- package/modern/ScatterChart/ScatterChart.plugins.js +5 -0
- package/modern/ScatterChart/useScatterChartProps.js +3 -1
- package/modern/SparkLineChart/SparkLineChart.js +24 -4
- package/modern/hooks/useAxisEvents.js +0 -165
- package/modern/index.js +1 -2
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +59 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +142 -5
- package/modern/models/axis.js +5 -1
- package/node/BarChart/BarChart.js +2 -4
- package/node/BarChart/BarChart.plugins.js +11 -0
- package/node/BarChart/useBarChartProps.js +5 -8
- package/node/ChartContainer/ChartContainer.js +8 -1
- package/node/ChartContainer/useChartContainerProps.js +11 -7
- package/node/ChartDataProvider/ChartDataProvider.js +4 -1
- package/node/ChartsSurface/ChartsSurface.js +1 -10
- package/node/ChartsTooltip/ChartsTooltipContainer.js +2 -2
- package/node/Gauge/Gauge.js +0 -6
- package/node/Gauge/GaugeContainer.js +0 -6
- package/node/LineChart/LineChart.js +2 -4
- package/node/LineChart/LineChart.plugins.js +11 -0
- package/node/LineChart/useLineChartProps.js +5 -8
- package/node/PieChart/PieChart.js +8 -115
- package/node/PieChart/PieChart.plugins.js +9 -0
- package/node/ScatterChart/ScatterChart.js +8 -1
- package/node/ScatterChart/ScatterChart.plugins.js +11 -0
- package/node/ScatterChart/useScatterChartProps.js +3 -1
- package/node/SparkLineChart/SparkLineChart.js +24 -4
- package/node/hooks/useAxisEvents.js +1 -173
- package/node/index.js +1 -12
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +65 -0
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +141 -4
- package/node/models/axis.js +5 -1
- package/package.json +2 -2
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +0 -20
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -82
- package/ChartsOnAxisClickHandler/index.d.ts +0 -1
- package/ChartsOnAxisClickHandler/index.js +0 -1
- package/ChartsOnAxisClickHandler/package.json +0 -6
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -82
- package/modern/ChartsOnAxisClickHandler/index.js +0 -1
- package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -88
- package/node/ChartsOnAxisClickHandler/index.js +0 -16
|
@@ -20,8 +20,11 @@ var _ChartsSurface = require("../ChartsSurface");
|
|
|
20
20
|
var _ChartDataProvider = require("../ChartDataProvider");
|
|
21
21
|
var _useChartContainerProps = require("../ChartContainer/useChartContainerProps");
|
|
22
22
|
var _ChartsWrapper = require("../internals/components/ChartsWrapper");
|
|
23
|
+
var _useChartInteraction = require("../internals/plugins/featurePlugins/useChartInteraction");
|
|
24
|
+
var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
|
|
23
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
|
-
const _excluded = ["
|
|
26
|
+
const _excluded = ["series", "width", "height", "margin", "colors", "sx", "skipAnimation", "hideLegend", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
27
|
+
const PIE_CHART_PLUGGINS = [_useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight];
|
|
25
28
|
const defaultMargin = {
|
|
26
29
|
top: 5,
|
|
27
30
|
bottom: 5,
|
|
@@ -75,11 +78,11 @@ const PieChart = exports.PieChart = /*#__PURE__*/React.forwardRef(function PieCh
|
|
|
75
78
|
height,
|
|
76
79
|
margin,
|
|
77
80
|
colors,
|
|
78
|
-
disableAxisListener: true,
|
|
79
81
|
highlightedItem,
|
|
80
82
|
onHighlightChange,
|
|
81
83
|
className,
|
|
82
|
-
skipAnimation
|
|
84
|
+
skipAnimation,
|
|
85
|
+
plugins: PIE_CHART_PLUGGINS
|
|
83
86
|
}), ref);
|
|
84
87
|
const Tooltip = slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
|
|
85
88
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartDataProvider.ChartDataProvider, (0, _extends2.default)({}, chartDataProviderProps, {
|
|
@@ -119,7 +122,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
119
122
|
className: _propTypes.default.string,
|
|
120
123
|
/**
|
|
121
124
|
* Color palette used to colorize multiple series.
|
|
122
|
-
* @default
|
|
125
|
+
* @default rainbowSurgePalette
|
|
123
126
|
*/
|
|
124
127
|
colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
|
|
125
128
|
/**
|
|
@@ -127,12 +130,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
127
130
|
*/
|
|
128
131
|
dataset: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
129
132
|
desc: _propTypes.default.string,
|
|
130
|
-
/**
|
|
131
|
-
* If `true`, the charts will not listen to the mouse move event.
|
|
132
|
-
* It might break interactive features, but will improve performance.
|
|
133
|
-
* @default false
|
|
134
|
-
*/
|
|
135
|
-
disableAxisListener: _propTypes.default.bool,
|
|
136
133
|
/**
|
|
137
134
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
138
135
|
*/
|
|
@@ -206,109 +203,5 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
206
203
|
/**
|
|
207
204
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
208
205
|
*/
|
|
209
|
-
width: _propTypes.default.number
|
|
210
|
-
/**
|
|
211
|
-
* The configuration of the x-axes.
|
|
212
|
-
* If not provided, a default axis config is used.
|
|
213
|
-
* An array of [[AxisConfig]] objects.
|
|
214
|
-
*/
|
|
215
|
-
xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
216
|
-
classes: _propTypes.default.object,
|
|
217
|
-
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
218
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
219
|
-
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
220
|
-
unknownColor: _propTypes.default.string,
|
|
221
|
-
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
222
|
-
}), _propTypes.default.shape({
|
|
223
|
-
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
224
|
-
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
225
|
-
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
226
|
-
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
227
|
-
}), _propTypes.default.shape({
|
|
228
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
229
|
-
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
230
|
-
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
231
|
-
})]),
|
|
232
|
-
data: _propTypes.default.array,
|
|
233
|
-
dataKey: _propTypes.default.string,
|
|
234
|
-
disableLine: _propTypes.default.bool,
|
|
235
|
-
disableTicks: _propTypes.default.bool,
|
|
236
|
-
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
237
|
-
fill: _propTypes.default.string,
|
|
238
|
-
hideTooltip: _propTypes.default.bool,
|
|
239
|
-
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
240
|
-
label: _propTypes.default.string,
|
|
241
|
-
labelStyle: _propTypes.default.object,
|
|
242
|
-
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
243
|
-
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
244
|
-
position: _propTypes.default.oneOf(['bottom', 'top']),
|
|
245
|
-
reverse: _propTypes.default.bool,
|
|
246
|
-
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
247
|
-
slotProps: _propTypes.default.object,
|
|
248
|
-
slots: _propTypes.default.object,
|
|
249
|
-
stroke: _propTypes.default.string,
|
|
250
|
-
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]),
|
|
251
|
-
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
252
|
-
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
253
|
-
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
254
|
-
tickLabelStyle: _propTypes.default.object,
|
|
255
|
-
tickMaxStep: _propTypes.default.number,
|
|
256
|
-
tickMinStep: _propTypes.default.number,
|
|
257
|
-
tickNumber: _propTypes.default.number,
|
|
258
|
-
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
259
|
-
tickSize: _propTypes.default.number,
|
|
260
|
-
valueFormatter: _propTypes.default.func
|
|
261
|
-
})),
|
|
262
|
-
/**
|
|
263
|
-
* The configuration of the y-axes.
|
|
264
|
-
* If not provided, a default axis config is used.
|
|
265
|
-
* An array of [[AxisConfig]] objects.
|
|
266
|
-
*/
|
|
267
|
-
yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
268
|
-
classes: _propTypes.default.object,
|
|
269
|
-
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
270
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
271
|
-
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
272
|
-
unknownColor: _propTypes.default.string,
|
|
273
|
-
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
274
|
-
}), _propTypes.default.shape({
|
|
275
|
-
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
276
|
-
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
277
|
-
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
278
|
-
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
279
|
-
}), _propTypes.default.shape({
|
|
280
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
281
|
-
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
282
|
-
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
283
|
-
})]),
|
|
284
|
-
data: _propTypes.default.array,
|
|
285
|
-
dataKey: _propTypes.default.string,
|
|
286
|
-
disableLine: _propTypes.default.bool,
|
|
287
|
-
disableTicks: _propTypes.default.bool,
|
|
288
|
-
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
289
|
-
fill: _propTypes.default.string,
|
|
290
|
-
hideTooltip: _propTypes.default.bool,
|
|
291
|
-
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
292
|
-
label: _propTypes.default.string,
|
|
293
|
-
labelStyle: _propTypes.default.object,
|
|
294
|
-
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
295
|
-
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
296
|
-
position: _propTypes.default.oneOf(['left', 'right']),
|
|
297
|
-
reverse: _propTypes.default.bool,
|
|
298
|
-
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
299
|
-
slotProps: _propTypes.default.object,
|
|
300
|
-
slots: _propTypes.default.object,
|
|
301
|
-
stroke: _propTypes.default.string,
|
|
302
|
-
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]),
|
|
303
|
-
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
304
|
-
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
305
|
-
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
306
|
-
tickLabelStyle: _propTypes.default.object,
|
|
307
|
-
tickMaxStep: _propTypes.default.number,
|
|
308
|
-
tickMinStep: _propTypes.default.number,
|
|
309
|
-
tickNumber: _propTypes.default.number,
|
|
310
|
-
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
311
|
-
tickSize: _propTypes.default.number,
|
|
312
|
-
valueFormatter: _propTypes.default.func
|
|
313
|
-
}))
|
|
206
|
+
width: _propTypes.default.number
|
|
314
207
|
} : void 0;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PIE_CHART_PLUGINS = void 0;
|
|
7
|
+
var _useChartInteraction = require("../internals/plugins/featurePlugins/useChartInteraction");
|
|
8
|
+
var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
|
|
9
|
+
const PIE_CHART_PLUGINS = exports.PIE_CHART_PLUGINS = [_useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight];
|
|
@@ -97,7 +97,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
97
97
|
className: _propTypes.default.string,
|
|
98
98
|
/**
|
|
99
99
|
* Color palette used to colorize multiple series.
|
|
100
|
-
* @default
|
|
100
|
+
* @default rainbowSurgePalette
|
|
101
101
|
*/
|
|
102
102
|
colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
|
|
103
103
|
/**
|
|
@@ -166,6 +166,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
166
166
|
right: _propTypes.default.number,
|
|
167
167
|
top: _propTypes.default.number
|
|
168
168
|
}),
|
|
169
|
+
/**
|
|
170
|
+
* The function called for onClick events.
|
|
171
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
172
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
173
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
174
|
+
*/
|
|
175
|
+
onAxisClick: _propTypes.default.func,
|
|
169
176
|
/**
|
|
170
177
|
* The callback fired when the highlighted item changes.
|
|
171
178
|
*
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SCATTER_CHART_PLUGINS = void 0;
|
|
7
|
+
var _useChartZAxis = require("../internals/plugins/featurePlugins/useChartZAxis");
|
|
8
|
+
var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
|
|
9
|
+
var _useChartInteraction = require("../internals/plugins/featurePlugins/useChartInteraction");
|
|
10
|
+
var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
|
|
11
|
+
const SCATTER_CHART_PLUGINS = exports.SCATTER_CHART_PLUGINS = [_useChartZAxis.useChartZAxis, _useChartCartesianAxis.useChartCartesianAxis, _useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight];
|
|
@@ -9,6 +9,7 @@ exports.useScatterChartProps = void 0;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
var _calculateMargins = require("../internals/calculateMargins");
|
|
12
|
+
var _ScatterChart = require("./ScatterChart.plugins");
|
|
12
13
|
const _excluded = ["xAxis", "yAxis", "zAxis", "series", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "hideLegend", "width", "height", "margin", "colors", "sx", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
13
14
|
/**
|
|
14
15
|
* A helper function that extracts ScatterChartProps from the input props
|
|
@@ -65,7 +66,8 @@ const useScatterChartProps = props => {
|
|
|
65
66
|
zAxis,
|
|
66
67
|
highlightedItem,
|
|
67
68
|
onHighlightChange,
|
|
68
|
-
className
|
|
69
|
+
className,
|
|
70
|
+
plugins: _ScatterChart.SCATTER_CHART_PLUGINS
|
|
69
71
|
});
|
|
70
72
|
const voronoiHandlerProps = {
|
|
71
73
|
voronoiMaxRadius,
|
|
@@ -18,7 +18,7 @@ var _constants = require("../constants");
|
|
|
18
18
|
var _ChartsTooltip = require("../ChartsTooltip");
|
|
19
19
|
var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "colors", "sx", "showTooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className"];
|
|
21
|
+
const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "color", "colors", "sx", "showTooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className"];
|
|
22
22
|
const SPARKLINE_DEFAULT_MARGIN = {
|
|
23
23
|
top: 5,
|
|
24
24
|
bottom: 5,
|
|
@@ -42,7 +42,8 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
42
42
|
width,
|
|
43
43
|
height,
|
|
44
44
|
margin = SPARKLINE_DEFAULT_MARGIN,
|
|
45
|
-
|
|
45
|
+
color,
|
|
46
|
+
colors: deprecatedColors,
|
|
46
47
|
sx,
|
|
47
48
|
showTooltip,
|
|
48
49
|
showHighlight,
|
|
@@ -65,6 +66,12 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
65
66
|
};
|
|
66
67
|
const axisHighlight = (0, _extends2.default)({}, defaultXHighlight, inAxisHighlight);
|
|
67
68
|
const Tooltip = props.slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
|
|
69
|
+
const colors = React.useMemo(() => {
|
|
70
|
+
if (color == null) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return typeof color === 'function' ? mode => [color(mode)] : [color];
|
|
74
|
+
}, [color]);
|
|
68
75
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartContainer.ChartContainer, (0, _extends2.default)({}, other, {
|
|
69
76
|
ref: ref,
|
|
70
77
|
series: [(0, _extends2.default)({
|
|
@@ -91,7 +98,7 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
91
98
|
yAxis: [(0, _extends2.default)({
|
|
92
99
|
id: _constants.DEFAULT_Y_AXIS_KEY
|
|
93
100
|
}, yAxis)],
|
|
94
|
-
colors: colors,
|
|
101
|
+
colors: colors ?? deprecatedColors,
|
|
95
102
|
sx: sx,
|
|
96
103
|
disableAxisListener: (!showTooltip || slotProps?.tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
97
104
|
children: [plotType === 'bar' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarChart.BarPlot, {
|
|
@@ -134,9 +141,15 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
134
141
|
}),
|
|
135
142
|
children: _propTypes.default.node,
|
|
136
143
|
className: _propTypes.default.string,
|
|
144
|
+
/**
|
|
145
|
+
* Color used to colorize the sparkline.
|
|
146
|
+
* @default rainbowSurgePalette[0]
|
|
147
|
+
*/
|
|
148
|
+
color: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
|
137
149
|
/**
|
|
138
150
|
* Color palette used to colorize multiple series.
|
|
139
|
-
* @default
|
|
151
|
+
* @default rainbowSurgePalette
|
|
152
|
+
* @deprecated use the `color` prop instead
|
|
140
153
|
*/
|
|
141
154
|
colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
|
|
142
155
|
/**
|
|
@@ -192,6 +205,13 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
192
205
|
right: _propTypes.default.number,
|
|
193
206
|
top: _propTypes.default.number
|
|
194
207
|
}),
|
|
208
|
+
/**
|
|
209
|
+
* The function called for onClick events.
|
|
210
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
211
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
212
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
213
|
+
*/
|
|
214
|
+
onAxisClick: _propTypes.default.func,
|
|
195
215
|
/**
|
|
196
216
|
* The callback fired when the highlighted item changes.
|
|
197
217
|
*
|
|
@@ -1,173 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
exports.useAxisEvents = void 0;
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
var React = _interopRequireWildcard(require("react"));
|
|
12
|
-
var _isBandScale = require("../internals/isBandScale");
|
|
13
|
-
var _getSVGPoint = require("../internals/getSVGPoint");
|
|
14
|
-
var _useSvgRef = require("./useSvgRef");
|
|
15
|
-
var _useStore = require("../internals/store/useStore");
|
|
16
|
-
var _ChartProvider = require("../context/ChartProvider");
|
|
17
|
-
var _useAxis = require("./useAxis");
|
|
18
|
-
function getAsANumber(value) {
|
|
19
|
-
return value instanceof Date ? value.getTime() : value;
|
|
20
|
-
}
|
|
21
|
-
const useAxisEvents = disableAxisListener => {
|
|
22
|
-
const svgRef = (0, _useSvgRef.useSvgRef)();
|
|
23
|
-
const {
|
|
24
|
-
instance
|
|
25
|
-
} = (0, _ChartProvider.useChartContext)();
|
|
26
|
-
const {
|
|
27
|
-
xAxis,
|
|
28
|
-
xAxisIds
|
|
29
|
-
} = (0, _useAxis.useXAxes)();
|
|
30
|
-
const {
|
|
31
|
-
yAxis,
|
|
32
|
-
yAxisIds
|
|
33
|
-
} = (0, _useAxis.useYAxes)();
|
|
34
|
-
const store = (0, _useStore.useStore)();
|
|
35
|
-
const usedXAxis = xAxisIds[0];
|
|
36
|
-
const usedYAxis = yAxisIds[0];
|
|
37
|
-
|
|
38
|
-
// Use a ref to avoid rerendering on every mousemove event.
|
|
39
|
-
const mousePosition = React.useRef({
|
|
40
|
-
isInChart: false,
|
|
41
|
-
x: -1,
|
|
42
|
-
y: -1
|
|
43
|
-
});
|
|
44
|
-
React.useEffect(() => {
|
|
45
|
-
const element = svgRef.current;
|
|
46
|
-
if (element === null || disableAxisListener || !store) {
|
|
47
|
-
return () => {};
|
|
48
|
-
}
|
|
49
|
-
function getNewAxisState(axisConfig, mouseValue) {
|
|
50
|
-
const {
|
|
51
|
-
scale,
|
|
52
|
-
data: axisData,
|
|
53
|
-
reverse
|
|
54
|
-
} = axisConfig;
|
|
55
|
-
if (!(0, _isBandScale.isBandScale)(scale)) {
|
|
56
|
-
const value = scale.invert(mouseValue);
|
|
57
|
-
if (axisData === undefined) {
|
|
58
|
-
return {
|
|
59
|
-
value,
|
|
60
|
-
index: -1
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const valueAsNumber = getAsANumber(value);
|
|
64
|
-
const closestIndex = axisData?.findIndex((pointValue, index) => {
|
|
65
|
-
const v = getAsANumber(pointValue);
|
|
66
|
-
if (v > valueAsNumber) {
|
|
67
|
-
if (index === 0 || Math.abs(valueAsNumber - v) <= Math.abs(valueAsNumber - getAsANumber(axisData[index - 1]))) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (v <= valueAsNumber) {
|
|
72
|
-
if (index === axisData.length - 1 || Math.abs(getAsANumber(value) - v) < Math.abs(getAsANumber(value) - getAsANumber(axisData[index + 1]))) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
value: closestIndex !== undefined && closestIndex >= 0 ? axisData[closestIndex] : value,
|
|
80
|
-
index: closestIndex
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const dataIndex = scale.bandwidth() === 0 ? Math.floor((mouseValue - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((mouseValue - Math.min(...scale.range())) / scale.step());
|
|
84
|
-
if (dataIndex < 0 || dataIndex >= axisData.length) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
if (reverse) {
|
|
88
|
-
const reverseIndex = axisData.length - 1 - dataIndex;
|
|
89
|
-
return {
|
|
90
|
-
index: reverseIndex,
|
|
91
|
-
value: axisData[reverseIndex]
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
index: dataIndex,
|
|
96
|
-
value: axisData[dataIndex]
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const handleOut = () => {
|
|
100
|
-
mousePosition.current = {
|
|
101
|
-
isInChart: false,
|
|
102
|
-
x: -1,
|
|
103
|
-
y: -1
|
|
104
|
-
};
|
|
105
|
-
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
106
|
-
interaction: {
|
|
107
|
-
item: null,
|
|
108
|
-
axis: {
|
|
109
|
-
x: null,
|
|
110
|
-
y: null
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
114
|
-
};
|
|
115
|
-
const handleMove = event => {
|
|
116
|
-
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
117
|
-
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, target);
|
|
118
|
-
mousePosition.current.x = svgPoint.x;
|
|
119
|
-
mousePosition.current.y = svgPoint.y;
|
|
120
|
-
if (!instance.isPointInside(svgPoint, {
|
|
121
|
-
targetElement: event.target
|
|
122
|
-
})) {
|
|
123
|
-
if (mousePosition.current.isInChart) {
|
|
124
|
-
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
125
|
-
interaction: {
|
|
126
|
-
item: null,
|
|
127
|
-
axis: {
|
|
128
|
-
x: null,
|
|
129
|
-
y: null
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}));
|
|
133
|
-
mousePosition.current.isInChart = false;
|
|
134
|
-
}
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
mousePosition.current.isInChart = true;
|
|
138
|
-
const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
|
|
139
|
-
const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
|
|
140
|
-
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
141
|
-
interaction: (0, _extends2.default)({}, prev.interaction, {
|
|
142
|
-
axis: (0, _extends2.default)({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
|
|
143
|
-
x: newStateX
|
|
144
|
-
} : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
|
|
145
|
-
y: newStateY
|
|
146
|
-
} : {})
|
|
147
|
-
})
|
|
148
|
-
}));
|
|
149
|
-
};
|
|
150
|
-
const handleDown = event => {
|
|
151
|
-
const target = event.currentTarget;
|
|
152
|
-
if (!target) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (target.hasPointerCapture(event.pointerId)) {
|
|
156
|
-
target.releasePointerCapture(event.pointerId);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
element.addEventListener('pointerdown', handleDown);
|
|
160
|
-
element.addEventListener('pointermove', handleMove);
|
|
161
|
-
element.addEventListener('pointerout', handleOut);
|
|
162
|
-
element.addEventListener('pointercancel', handleOut);
|
|
163
|
-
element.addEventListener('pointerleave', handleOut);
|
|
164
|
-
return () => {
|
|
165
|
-
element.removeEventListener('pointerdown', handleDown);
|
|
166
|
-
element.removeEventListener('pointermove', handleMove);
|
|
167
|
-
element.removeEventListener('pointerout', handleOut);
|
|
168
|
-
element.removeEventListener('pointercancel', handleOut);
|
|
169
|
-
element.removeEventListener('pointerleave', handleOut);
|
|
170
|
-
};
|
|
171
|
-
}, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, instance]);
|
|
172
|
-
};
|
|
173
|
-
exports.useAxisEvents = useAxisEvents;
|
|
1
|
+
"use strict";
|
package/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v8.0.0-alpha.
|
|
2
|
+
* @mui/x-charts v8.0.0-alpha.11
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -197,17 +197,6 @@ Object.keys(_ChartsVoronoiHandler).forEach(function (key) {
|
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
|
-
var _ChartsOnAxisClickHandler = require("./ChartsOnAxisClickHandler");
|
|
201
|
-
Object.keys(_ChartsOnAxisClickHandler).forEach(function (key) {
|
|
202
|
-
if (key === "default" || key === "__esModule") return;
|
|
203
|
-
if (key in exports && exports[key] === _ChartsOnAxisClickHandler[key]) return;
|
|
204
|
-
Object.defineProperty(exports, key, {
|
|
205
|
-
enumerable: true,
|
|
206
|
-
get: function () {
|
|
207
|
-
return _ChartsOnAxisClickHandler[key];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
200
|
var _BarChart = require("./BarChart");
|
|
212
201
|
Object.keys(_BarChart).forEach(function (key) {
|
|
213
202
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAxisValue = getAxisValue;
|
|
7
|
+
var _isBandScale = require("../../../isBandScale");
|
|
8
|
+
function getAsANumber(value) {
|
|
9
|
+
return value instanceof Date ? value.getTime() : value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* For a pointer coordinate, this function returns the value and dataIndex associated.
|
|
14
|
+
* Returns `null` if the coordinate is outside of values.
|
|
15
|
+
*/
|
|
16
|
+
function getAxisValue(axisConfig, pointerValue) {
|
|
17
|
+
const {
|
|
18
|
+
scale,
|
|
19
|
+
data: axisData,
|
|
20
|
+
reverse
|
|
21
|
+
} = axisConfig;
|
|
22
|
+
if (!(0, _isBandScale.isBandScale)(scale)) {
|
|
23
|
+
const value = scale.invert(pointerValue);
|
|
24
|
+
if (axisData === undefined) {
|
|
25
|
+
return {
|
|
26
|
+
value,
|
|
27
|
+
index: -1
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const valueAsNumber = getAsANumber(value);
|
|
31
|
+
const closestIndex = axisData?.findIndex((pointValue, index) => {
|
|
32
|
+
const v = getAsANumber(pointValue);
|
|
33
|
+
if (v > valueAsNumber) {
|
|
34
|
+
if (index === 0 || Math.abs(valueAsNumber - v) <= Math.abs(valueAsNumber - getAsANumber(axisData[index - 1]))) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (v <= valueAsNumber) {
|
|
39
|
+
if (index === axisData.length - 1 || Math.abs(getAsANumber(value) - v) < Math.abs(getAsANumber(value) - getAsANumber(axisData[index + 1]))) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
value: closestIndex !== undefined && closestIndex >= 0 ? axisData[closestIndex] : value,
|
|
47
|
+
index: closestIndex
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const dataIndex = scale.bandwidth() === 0 ? Math.floor((pointerValue - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((pointerValue - Math.min(...scale.range())) / scale.step());
|
|
51
|
+
if (dataIndex < 0 || dataIndex >= axisData.length) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (reverse) {
|
|
55
|
+
const reverseIndex = axisData.length - 1 - dataIndex;
|
|
56
|
+
return {
|
|
57
|
+
index: reverseIndex,
|
|
58
|
+
value: axisData[reverseIndex]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
index: dataIndex,
|
|
63
|
+
value: axisData[dataIndex]
|
|
64
|
+
};
|
|
65
|
+
}
|