@mui/x-charts 6.0.0-alpha.6 → 6.0.0-alpha.8
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 +19 -2
- package/BarChart/BarChart.js +84 -22
- package/BarChart/BarElement.d.ts +22 -0
- package/BarChart/BarElement.js +21 -10
- package/BarChart/BarPlot.d.ts +14 -1
- package/BarChart/BarPlot.js +48 -19
- package/BarChart/extremums.js +19 -3
- package/BarChart/formatter.js +3 -1
- package/CHANGELOG.md +213 -28
- package/ChartsAxis/ChartsAxis.d.ts +11 -1
- package/ChartsAxis/ChartsAxis.js +51 -6
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +3 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
- package/ChartsLegend/ChartsLegend.d.ts +25 -2
- package/ChartsLegend/ChartsLegend.js +49 -17
- package/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
- package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
- package/ChartsXAxis/ChartsXAxis.js +44 -9
- package/ChartsYAxis/ChartsYAxis.js +44 -9
- package/LineChart/AreaElement.d.ts +22 -0
- package/LineChart/AreaElement.js +31 -11
- package/LineChart/AreaPlot.d.ts +14 -1
- package/LineChart/AreaPlot.js +29 -3
- package/LineChart/LineChart.d.ts +20 -2
- package/LineChart/LineChart.js +63 -11
- package/LineChart/LineElement.d.ts +22 -0
- package/LineChart/LineElement.js +31 -10
- package/LineChart/LinePlot.d.ts +14 -1
- package/LineChart/LinePlot.js +35 -4
- package/LineChart/MarkPlot.d.ts +24 -1
- package/LineChart/MarkPlot.js +29 -4
- package/PieChart/PieArcLabel.js +0 -1
- package/PieChart/PieChart.d.ts +14 -2
- package/PieChart/PieChart.js +52 -10
- package/PieChart/PiePlot.d.ts +27 -1
- package/PieChart/PiePlot.js +29 -6
- package/ScatterChart/ScatterChart.d.ts +18 -2
- package/ScatterChart/ScatterChart.js +56 -10
- package/ScatterChart/ScatterPlot.d.ts +24 -1
- package/ScatterChart/ScatterPlot.js +28 -4
- package/SparkLineChart/SparkLineChart.d.ts +18 -0
- package/SparkLineChart/SparkLineChart.js +29 -6
- package/colorPalettes/colorPalettes.js +2 -2
- package/context/CartesianContextProvider.js +18 -12
- package/esm/BarChart/BarChart.js +88 -26
- package/esm/BarChart/BarElement.js +21 -11
- package/esm/BarChart/BarPlot.js +49 -20
- package/esm/BarChart/extremums.js +18 -2
- package/esm/BarChart/formatter.js +3 -1
- package/esm/ChartsAxis/ChartsAxis.js +51 -6
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
- package/esm/ChartsLegend/ChartsLegend.js +47 -14
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
- package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
- package/esm/LineChart/AreaElement.js +31 -11
- package/esm/LineChart/AreaPlot.js +31 -4
- package/esm/LineChart/LineChart.js +63 -11
- package/esm/LineChart/LineElement.js +31 -11
- package/esm/LineChart/LinePlot.js +43 -8
- package/esm/LineChart/MarkPlot.js +32 -5
- package/esm/PieChart/PieArcLabel.js +0 -1
- package/esm/PieChart/PieChart.js +52 -10
- package/esm/PieChart/PiePlot.js +31 -6
- package/esm/ScatterChart/ScatterChart.js +56 -10
- package/esm/ScatterChart/ScatterPlot.js +29 -4
- package/esm/SparkLineChart/SparkLineChart.js +29 -6
- package/esm/colorPalettes/colorPalettes.js +2 -2
- package/esm/context/CartesianContextProvider.js +18 -12
- package/esm/hooks/useAxisEvents.js +21 -38
- package/esm/hooks/useTicks.js +11 -8
- package/esm/internals/components/AxisSharedComponents.js +10 -10
- package/hooks/useAxisEvents.js +21 -38
- package/hooks/useTicks.d.ts +20 -5
- package/hooks/useTicks.js +11 -8
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +4 -4
- package/internals/components/AxisSharedComponents.js +15 -15
- package/internals/defaultizeColor.d.ts +1 -0
- package/legacy/BarChart/BarChart.js +93 -29
- package/legacy/BarChart/BarElement.js +20 -10
- package/legacy/BarChart/BarPlot.js +49 -20
- package/legacy/BarChart/extremums.js +22 -2
- package/legacy/BarChart/formatter.js +3 -1
- package/legacy/ChartsAxis/ChartsAxis.js +51 -6
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
- package/legacy/ChartsLegend/ChartsLegend.js +46 -15
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
- package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
- package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
- package/legacy/LineChart/AreaElement.js +30 -10
- package/legacy/LineChart/AreaPlot.js +29 -4
- package/legacy/LineChart/LineChart.js +63 -11
- package/legacy/LineChart/LineElement.js +30 -10
- package/legacy/LineChart/LinePlot.js +36 -5
- package/legacy/LineChart/MarkPlot.js +30 -5
- package/legacy/PieChart/PieArcLabel.js +0 -1
- package/legacy/PieChart/PieChart.js +52 -10
- package/legacy/PieChart/PiePlot.js +29 -6
- package/legacy/ScatterChart/ScatterChart.js +56 -10
- package/legacy/ScatterChart/ScatterPlot.js +27 -4
- package/legacy/SparkLineChart/SparkLineChart.js +29 -6
- package/legacy/colorPalettes/colorPalettes.js +2 -2
- package/legacy/context/CartesianContextProvider.js +18 -12
- package/legacy/hooks/useAxisEvents.js +21 -37
- package/legacy/hooks/useTicks.js +11 -11
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +10 -10
- package/models/axis.d.ts +24 -1
- package/models/seriesType/bar.d.ts +6 -1
- package/modern/BarChart/BarChart.js +85 -23
- package/modern/BarChart/BarElement.js +20 -11
- package/modern/BarChart/BarPlot.js +48 -19
- package/modern/BarChart/extremums.js +18 -2
- package/modern/BarChart/formatter.js +3 -1
- package/modern/ChartsAxis/ChartsAxis.js +51 -6
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
- package/modern/ChartsLegend/ChartsLegend.js +46 -14
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
- package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
- package/modern/LineChart/AreaElement.js +30 -11
- package/modern/LineChart/AreaPlot.js +31 -4
- package/modern/LineChart/LineChart.js +63 -11
- package/modern/LineChart/LineElement.js +30 -11
- package/modern/LineChart/LinePlot.js +37 -5
- package/modern/LineChart/MarkPlot.js +31 -5
- package/modern/PieChart/PieArcLabel.js +0 -1
- package/modern/PieChart/PieChart.js +52 -10
- package/modern/PieChart/PiePlot.js +30 -6
- package/modern/ScatterChart/ScatterChart.js +56 -10
- package/modern/ScatterChart/ScatterPlot.js +28 -4
- package/modern/SparkLineChart/SparkLineChart.js +29 -6
- package/modern/colorPalettes/colorPalettes.js +2 -2
- package/modern/context/CartesianContextProvider.js +18 -12
- package/modern/hooks/useAxisEvents.js +21 -38
- package/modern/hooks/useTicks.js +11 -8
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +10 -10
- package/package.json +5 -5
- package/themeAugmentation/components.d.ts +0 -10
- package/themeAugmentation/overrides.d.ts +0 -2
package/esm/PieChart/PiePlot.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
3
4
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
4
5
|
import PieArc from './PieArc';
|
|
5
6
|
import PieArcLabel from './PieArcLabel';
|
|
@@ -22,7 +23,12 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
22
23
|
}
|
|
23
24
|
return arcLabel(item);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
function PiePlot(props) {
|
|
27
|
+
var _slots$pieArc, _slots$pieArcLabel;
|
|
28
|
+
const {
|
|
29
|
+
slots,
|
|
30
|
+
slotProps
|
|
31
|
+
} = props;
|
|
26
32
|
const seriesData = React.useContext(SeriesContext).pie;
|
|
27
33
|
const {
|
|
28
34
|
left,
|
|
@@ -42,6 +48,8 @@ export function PiePlot() {
|
|
|
42
48
|
series,
|
|
43
49
|
seriesOrder
|
|
44
50
|
} = seriesData;
|
|
51
|
+
const Arc = (_slots$pieArc = slots == null ? void 0 : slots.pieArc) != null ? _slots$pieArc : PieArc;
|
|
52
|
+
const ArcLabel = (_slots$pieArcLabel = slots == null ? void 0 : slots.pieArcLabel) != null ? _slots$pieArcLabel : PieArcLabel;
|
|
45
53
|
return /*#__PURE__*/_jsx("g", {
|
|
46
54
|
children: seriesOrder.map(seriesId => {
|
|
47
55
|
const {
|
|
@@ -60,7 +68,7 @@ export function PiePlot() {
|
|
|
60
68
|
transform: `translate(${cx === undefined ? center.x : left + cx}, ${cy === undefined ? center.y : top + cy})`,
|
|
61
69
|
children: /*#__PURE__*/_jsxs("g", {
|
|
62
70
|
children: [data.map((item, index) => {
|
|
63
|
-
return /*#__PURE__*/_createElement(
|
|
71
|
+
return /*#__PURE__*/_createElement(Arc, _extends({}, item, {
|
|
64
72
|
key: item.id,
|
|
65
73
|
innerRadius: innerRadius,
|
|
66
74
|
outerRadius: outerRadius != null ? outerRadius : availableRadius,
|
|
@@ -71,9 +79,9 @@ export function PiePlot() {
|
|
|
71
79
|
highlightScope: series[seriesId].highlightScope,
|
|
72
80
|
highlighted: highlighted,
|
|
73
81
|
faded: faded
|
|
74
|
-
}));
|
|
82
|
+
}, slotProps == null ? void 0 : slotProps.pieArc));
|
|
75
83
|
}), data.map((item, index) => {
|
|
76
|
-
return /*#__PURE__*/_createElement(
|
|
84
|
+
return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
|
|
77
85
|
key: item.id,
|
|
78
86
|
innerRadius: innerRadius,
|
|
79
87
|
outerRadius: outerRadius != null ? outerRadius : availableRadius,
|
|
@@ -83,10 +91,27 @@ export function PiePlot() {
|
|
|
83
91
|
dataIndex: index,
|
|
84
92
|
highlightScope: series[seriesId].highlightScope,
|
|
85
93
|
formattedArcLabel: getItemLabel(arcLabel, arcLabelMinAngle, item)
|
|
86
|
-
}));
|
|
94
|
+
}, slotProps == null ? void 0 : slotProps.pieArcLabel));
|
|
87
95
|
})]
|
|
88
96
|
})
|
|
89
97
|
}, seriesId);
|
|
90
98
|
})
|
|
91
99
|
});
|
|
92
|
-
}
|
|
100
|
+
}
|
|
101
|
+
process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
102
|
+
// ----------------------------- Warning --------------------------------
|
|
103
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
104
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
105
|
+
// ----------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* The props used for each component slot.
|
|
108
|
+
* @default {}
|
|
109
|
+
*/
|
|
110
|
+
slotProps: PropTypes.object,
|
|
111
|
+
/**
|
|
112
|
+
* Overridable component slots.
|
|
113
|
+
* @default {}
|
|
114
|
+
*/
|
|
115
|
+
slots: PropTypes.object
|
|
116
|
+
} : void 0;
|
|
117
|
+
export { PiePlot };
|
|
@@ -26,7 +26,9 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
26
26
|
leftAxis,
|
|
27
27
|
rightAxis,
|
|
28
28
|
bottomAxis,
|
|
29
|
-
children
|
|
29
|
+
children,
|
|
30
|
+
slots,
|
|
31
|
+
slotProps
|
|
30
32
|
} = props;
|
|
31
33
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
32
34
|
ref: ref,
|
|
@@ -44,8 +46,16 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
44
46
|
topAxis: topAxis,
|
|
45
47
|
leftAxis: leftAxis,
|
|
46
48
|
rightAxis: rightAxis,
|
|
47
|
-
bottomAxis: bottomAxis
|
|
48
|
-
|
|
49
|
+
bottomAxis: bottomAxis,
|
|
50
|
+
slots: slots,
|
|
51
|
+
slotProps: slotProps
|
|
52
|
+
}), /*#__PURE__*/_jsx(ScatterPlot, {
|
|
53
|
+
slots: slots,
|
|
54
|
+
slotProps: slotProps
|
|
55
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
56
|
+
slots: slots,
|
|
57
|
+
slotProps: slotProps
|
|
58
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
49
59
|
x: "none",
|
|
50
60
|
y: "none"
|
|
51
61
|
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
@@ -60,7 +70,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
60
70
|
// ----------------------------------------------------------------------
|
|
61
71
|
axisHighlight: PropTypes.shape({
|
|
62
72
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
63
|
-
y: PropTypes.oneOf(['line', 'none'])
|
|
73
|
+
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
64
74
|
}),
|
|
65
75
|
/**
|
|
66
76
|
* Indicate which axis to display the bottom of the charts.
|
|
@@ -76,8 +86,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
76
86
|
label: PropTypes.string,
|
|
77
87
|
labelFontSize: PropTypes.number,
|
|
78
88
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
89
|
+
slotProps: PropTypes.object,
|
|
90
|
+
slots: PropTypes.object,
|
|
79
91
|
stroke: PropTypes.string,
|
|
80
92
|
tickFontSize: PropTypes.number,
|
|
93
|
+
tickMaxStep: PropTypes.number,
|
|
94
|
+
tickMinStep: PropTypes.number,
|
|
95
|
+
tickNumber: PropTypes.number,
|
|
81
96
|
tickSize: PropTypes.number
|
|
82
97
|
}), PropTypes.string]),
|
|
83
98
|
children: PropTypes.node,
|
|
@@ -104,8 +119,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
104
119
|
label: PropTypes.string,
|
|
105
120
|
labelFontSize: PropTypes.number,
|
|
106
121
|
position: PropTypes.oneOf(['left', 'right']),
|
|
122
|
+
slotProps: PropTypes.object,
|
|
123
|
+
slots: PropTypes.object,
|
|
107
124
|
stroke: PropTypes.string,
|
|
108
125
|
tickFontSize: PropTypes.number,
|
|
126
|
+
tickMaxStep: PropTypes.number,
|
|
127
|
+
tickMinStep: PropTypes.number,
|
|
128
|
+
tickNumber: PropTypes.number,
|
|
109
129
|
tickSize: PropTypes.number
|
|
110
130
|
}), PropTypes.string]),
|
|
111
131
|
legend: PropTypes.shape({
|
|
@@ -122,6 +142,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
122
142
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
123
143
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
124
144
|
}),
|
|
145
|
+
slotProps: PropTypes.object,
|
|
146
|
+
slots: PropTypes.object,
|
|
125
147
|
spacing: PropTypes.number
|
|
126
148
|
}),
|
|
127
149
|
margin: PropTypes.shape({
|
|
@@ -144,8 +166,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
144
166
|
label: PropTypes.string,
|
|
145
167
|
labelFontSize: PropTypes.number,
|
|
146
168
|
position: PropTypes.oneOf(['left', 'right']),
|
|
169
|
+
slotProps: PropTypes.object,
|
|
170
|
+
slots: PropTypes.object,
|
|
147
171
|
stroke: PropTypes.string,
|
|
148
172
|
tickFontSize: PropTypes.number,
|
|
173
|
+
tickMaxStep: PropTypes.number,
|
|
174
|
+
tickMinStep: PropTypes.number,
|
|
175
|
+
tickNumber: PropTypes.number,
|
|
149
176
|
tickSize: PropTypes.number
|
|
150
177
|
}), PropTypes.string]),
|
|
151
178
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -167,6 +194,16 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
167
194
|
xAxisKey: PropTypes.string,
|
|
168
195
|
yAxisKey: PropTypes.string
|
|
169
196
|
})).isRequired,
|
|
197
|
+
/**
|
|
198
|
+
* The props used for each component slot.
|
|
199
|
+
* @default {}
|
|
200
|
+
*/
|
|
201
|
+
slotProps: PropTypes.object,
|
|
202
|
+
/**
|
|
203
|
+
* Overridable component slots.
|
|
204
|
+
* @default {}
|
|
205
|
+
*/
|
|
206
|
+
slots: PropTypes.object,
|
|
170
207
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
171
208
|
title: PropTypes.string,
|
|
172
209
|
tooltip: PropTypes.shape({
|
|
@@ -189,8 +226,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
189
226
|
label: PropTypes.string,
|
|
190
227
|
labelFontSize: PropTypes.number,
|
|
191
228
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
229
|
+
slotProps: PropTypes.object,
|
|
230
|
+
slots: PropTypes.object,
|
|
192
231
|
stroke: PropTypes.string,
|
|
193
232
|
tickFontSize: PropTypes.number,
|
|
233
|
+
tickMaxStep: PropTypes.number,
|
|
234
|
+
tickMinStep: PropTypes.number,
|
|
235
|
+
tickNumber: PropTypes.number,
|
|
194
236
|
tickSize: PropTypes.number
|
|
195
237
|
}), PropTypes.string]),
|
|
196
238
|
viewBox: PropTypes.shape({
|
|
@@ -213,15 +255,17 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
213
255
|
label: PropTypes.string,
|
|
214
256
|
labelFontSize: PropTypes.number,
|
|
215
257
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
216
|
-
maxTicks: PropTypes.number,
|
|
217
258
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
218
|
-
minTicks: PropTypes.number,
|
|
219
259
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
220
260
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
261
|
+
slotProps: PropTypes.object,
|
|
262
|
+
slots: PropTypes.object,
|
|
221
263
|
stroke: PropTypes.string,
|
|
222
264
|
tickFontSize: PropTypes.number,
|
|
265
|
+
tickMaxStep: PropTypes.number,
|
|
266
|
+
tickMinStep: PropTypes.number,
|
|
267
|
+
tickNumber: PropTypes.number,
|
|
223
268
|
tickSize: PropTypes.number,
|
|
224
|
-
tickSpacing: PropTypes.number,
|
|
225
269
|
valueFormatter: PropTypes.func
|
|
226
270
|
})),
|
|
227
271
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -237,15 +281,17 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
237
281
|
label: PropTypes.string,
|
|
238
282
|
labelFontSize: PropTypes.number,
|
|
239
283
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
240
|
-
maxTicks: PropTypes.number,
|
|
241
284
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
242
|
-
minTicks: PropTypes.number,
|
|
243
285
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
244
286
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
287
|
+
slotProps: PropTypes.object,
|
|
288
|
+
slots: PropTypes.object,
|
|
245
289
|
stroke: PropTypes.string,
|
|
246
290
|
tickFontSize: PropTypes.number,
|
|
291
|
+
tickMaxStep: PropTypes.number,
|
|
292
|
+
tickMinStep: PropTypes.number,
|
|
293
|
+
tickNumber: PropTypes.number,
|
|
247
294
|
tickSize: PropTypes.number,
|
|
248
|
-
tickSpacing: PropTypes.number,
|
|
249
295
|
valueFormatter: PropTypes.func
|
|
250
296
|
}))
|
|
251
297
|
} : void 0;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
2
4
|
import { Scatter } from './Scatter';
|
|
3
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
4
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
5
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
8
|
+
function ScatterPlot(props) {
|
|
9
|
+
var _slots$scatter;
|
|
10
|
+
const {
|
|
11
|
+
slots,
|
|
12
|
+
slotProps
|
|
13
|
+
} = props;
|
|
7
14
|
const seriesData = React.useContext(SeriesContext).scatter;
|
|
8
15
|
const axisData = React.useContext(CartesianContext);
|
|
9
16
|
if (seriesData === undefined) {
|
|
@@ -21,6 +28,7 @@ export function ScatterPlot() {
|
|
|
21
28
|
} = axisData;
|
|
22
29
|
const defaultXAxisId = xAxisIds[0];
|
|
23
30
|
const defaultYAxisId = yAxisIds[0];
|
|
31
|
+
const ScatterItems = (_slots$scatter = slots == null ? void 0 : slots.scatter) != null ? _slots$scatter : Scatter;
|
|
24
32
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
25
33
|
children: seriesOrder.map(seriesId => {
|
|
26
34
|
const {
|
|
@@ -32,13 +40,30 @@ export function ScatterPlot() {
|
|
|
32
40
|
} = series[seriesId];
|
|
33
41
|
const xScale = xAxis[xAxisKey != null ? xAxisKey : defaultXAxisId].scale;
|
|
34
42
|
const yScale = yAxis[yAxisKey != null ? yAxisKey : defaultYAxisId].scale;
|
|
35
|
-
return /*#__PURE__*/_jsx(
|
|
43
|
+
return /*#__PURE__*/_jsx(ScatterItems, _extends({
|
|
36
44
|
xScale: xScale,
|
|
37
45
|
yScale: yScale,
|
|
38
46
|
color: color,
|
|
39
47
|
markerSize: markerSize != null ? markerSize : 4,
|
|
40
48
|
series: series[seriesId]
|
|
41
|
-
}, id);
|
|
49
|
+
}, slotProps == null ? void 0 : slotProps.scatter), id);
|
|
42
50
|
})
|
|
43
51
|
});
|
|
44
|
-
}
|
|
52
|
+
}
|
|
53
|
+
process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
|
|
54
|
+
// ----------------------------- Warning --------------------------------
|
|
55
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
56
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
57
|
+
// ----------------------------------------------------------------------
|
|
58
|
+
/**
|
|
59
|
+
* The props used for each component slot.
|
|
60
|
+
* @default {}
|
|
61
|
+
*/
|
|
62
|
+
slotProps: PropTypes.object,
|
|
63
|
+
/**
|
|
64
|
+
* Overridable component slots.
|
|
65
|
+
* @default {}
|
|
66
|
+
*/
|
|
67
|
+
slots: PropTypes.object
|
|
68
|
+
} : void 0;
|
|
69
|
+
export { ScatterPlot };
|
|
@@ -37,6 +37,8 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
37
37
|
showHighlight,
|
|
38
38
|
axisHighlight: inAxisHighlight,
|
|
39
39
|
children,
|
|
40
|
+
slots,
|
|
41
|
+
slotProps,
|
|
40
42
|
data,
|
|
41
43
|
plotType = 'line',
|
|
42
44
|
valueFormatter = v => v.toString(),
|
|
@@ -73,8 +75,17 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
73
75
|
colors: colors,
|
|
74
76
|
sx: sx,
|
|
75
77
|
disableAxisListener: (!showTooltip || (tooltip == null ? void 0 : tooltip.trigger) !== 'axis') && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
|
|
76
|
-
children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
|
|
77
|
-
|
|
78
|
+
children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
|
|
79
|
+
slots: slots,
|
|
80
|
+
slotProps: slotProps
|
|
81
|
+
}), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
82
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
83
|
+
slots: slots,
|
|
84
|
+
slotProps: slotProps
|
|
85
|
+
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
86
|
+
slots: slots,
|
|
87
|
+
slotProps: slotProps
|
|
88
|
+
}), showHighlight && /*#__PURE__*/_jsx(SparkLineMarkPlot, {})]
|
|
78
89
|
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
|
|
79
90
|
});
|
|
80
91
|
});
|
|
@@ -91,7 +102,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
91
102
|
area: PropTypes.bool,
|
|
92
103
|
axisHighlight: PropTypes.shape({
|
|
93
104
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
94
|
-
y: PropTypes.oneOf(['line', 'none'])
|
|
105
|
+
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
95
106
|
}),
|
|
96
107
|
children: PropTypes.node,
|
|
97
108
|
className: PropTypes.string,
|
|
@@ -134,6 +145,16 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
134
145
|
* @default false
|
|
135
146
|
*/
|
|
136
147
|
showTooltip: PropTypes.bool,
|
|
148
|
+
/**
|
|
149
|
+
* The props used for each component slot.
|
|
150
|
+
* @default {}
|
|
151
|
+
*/
|
|
152
|
+
slotProps: PropTypes.object,
|
|
153
|
+
/**
|
|
154
|
+
* Overridable component slots.
|
|
155
|
+
* @default {}
|
|
156
|
+
*/
|
|
157
|
+
slots: PropTypes.object,
|
|
137
158
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
138
159
|
title: PropTypes.string,
|
|
139
160
|
tooltip: PropTypes.shape({
|
|
@@ -172,15 +193,17 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
172
193
|
label: PropTypes.string,
|
|
173
194
|
labelFontSize: PropTypes.number,
|
|
174
195
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
175
|
-
maxTicks: PropTypes.number,
|
|
176
196
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
177
|
-
minTicks: PropTypes.number,
|
|
178
197
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
179
198
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
199
|
+
slotProps: PropTypes.object,
|
|
200
|
+
slots: PropTypes.object,
|
|
180
201
|
stroke: PropTypes.string,
|
|
181
202
|
tickFontSize: PropTypes.number,
|
|
203
|
+
tickMaxStep: PropTypes.number,
|
|
204
|
+
tickMinStep: PropTypes.number,
|
|
205
|
+
tickNumber: PropTypes.number,
|
|
182
206
|
tickSize: PropTypes.number,
|
|
183
|
-
tickSpacing: PropTypes.number,
|
|
184
207
|
valueFormatter: PropTypes.func
|
|
185
208
|
})
|
|
186
209
|
} : void 0;
|
|
@@ -4,6 +4,6 @@ export const blueberryTwilightPalette = mode => mode === 'dark' ? blueberryTwili
|
|
|
4
4
|
export const mangoFusionPaletteLight = ['#173A5E', '#00A3A0', '#C91B63', '#EF5350', '#FFA726', '#B800D8', '#60009B', '#2E96FF', '#2731C8', '#03008D'];
|
|
5
5
|
export const mangoFusionPaletteDark = ['#41698F', '#19D0CD', '#DE196B', '#FC5F5C', '#FFD771', '#DA00FF', '#9001CB', '#72CCFF', '#2E96FF', '#3B48E0'];
|
|
6
6
|
export const mangoFusionPalette = mode => mode === 'dark' ? mangoFusionPaletteDark : mangoFusionPaletteLight;
|
|
7
|
-
export const cheerfulFiestaPaletteDark = ['#
|
|
8
|
-
export const cheerfulFiestaPaletteLight = ['#
|
|
7
|
+
export const cheerfulFiestaPaletteDark = ['#0059B2', '#2E96FF', '#FFC24C', '#FF9F0E', '#F38200', '#2ABFDE', '#1F94AD', '#BD2C38', '#FF3143', '#FF8282'];
|
|
8
|
+
export const cheerfulFiestaPaletteLight = ['#003A75', '#007FFF', '#FFC24C', '#FF9D09', '#CA6C00', '#127D94', '#1F94AD', '#C82634', '#FF3143', '#FF7E7E'];
|
|
9
9
|
export const cheerfulFiestaPalette = mode => mode === 'dark' ? cheerfulFiestaPaletteDark : cheerfulFiestaPaletteLight;
|
|
@@ -127,7 +127,8 @@ function CartesianContextProvider({
|
|
|
127
127
|
const scaleType = (_axis$scaleType = axis.scaleType) != null ? _axis$scaleType : 'linear';
|
|
128
128
|
const extremums = [(_axis$min = axis.min) != null ? _axis$min : minData, (_axis$max = axis.max) != null ? _axis$max : maxData];
|
|
129
129
|
const ticksNumber = getTicksNumber(_extends({}, axis, {
|
|
130
|
-
range
|
|
130
|
+
range,
|
|
131
|
+
domain: extremums
|
|
131
132
|
}));
|
|
132
133
|
const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
|
|
133
134
|
const niceDomain = niceScale.domain();
|
|
@@ -155,17 +156,17 @@ function CartesianContextProvider({
|
|
|
155
156
|
if (isBandScaleConfig(axis)) {
|
|
156
157
|
var _axis$categoryGapRati2;
|
|
157
158
|
const categoryGapRatio = (_axis$categoryGapRati2 = axis.categoryGapRatio) != null ? _axis$categoryGapRati2 : DEFAULT_CATEGORY_GAP_RATIO;
|
|
158
|
-
|
|
159
|
+
completedYAxis[axis.id] = _extends({
|
|
159
160
|
categoryGapRatio,
|
|
160
161
|
barGapRatio: 0
|
|
161
162
|
}, axis, {
|
|
162
|
-
scale: scaleBand(axis.data, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
163
|
+
scale: scaleBand(axis.data, [range[1], range[0]]).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
163
164
|
ticksNumber: axis.data.length
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
167
|
if (isPointScaleConfig(axis)) {
|
|
167
|
-
|
|
168
|
-
scale: scalePoint(axis.data, range),
|
|
168
|
+
completedYAxis[axis.id] = _extends({}, axis, {
|
|
169
|
+
scale: scalePoint(axis.data, [range[1], range[0]]),
|
|
169
170
|
ticksNumber: axis.data.length
|
|
170
171
|
});
|
|
171
172
|
}
|
|
@@ -176,7 +177,8 @@ function CartesianContextProvider({
|
|
|
176
177
|
const scaleType = (_axis$scaleType2 = axis.scaleType) != null ? _axis$scaleType2 : 'linear';
|
|
177
178
|
const extremums = [(_axis$min3 = axis.min) != null ? _axis$min3 : minData, (_axis$max3 = axis.max) != null ? _axis$max3 : maxData];
|
|
178
179
|
const ticksNumber = getTicksNumber(_extends({}, axis, {
|
|
179
|
-
range
|
|
180
|
+
range,
|
|
181
|
+
domain: extremums
|
|
180
182
|
}));
|
|
181
183
|
const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
|
|
182
184
|
const niceDomain = niceScale.domain();
|
|
@@ -225,15 +227,17 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
225
227
|
label: PropTypes.string,
|
|
226
228
|
labelFontSize: PropTypes.number,
|
|
227
229
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
228
|
-
maxTicks: PropTypes.number,
|
|
229
230
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
230
|
-
minTicks: PropTypes.number,
|
|
231
231
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
232
232
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
233
|
+
slotProps: PropTypes.object,
|
|
234
|
+
slots: PropTypes.object,
|
|
233
235
|
stroke: PropTypes.string,
|
|
234
236
|
tickFontSize: PropTypes.number,
|
|
237
|
+
tickMaxStep: PropTypes.number,
|
|
238
|
+
tickMinStep: PropTypes.number,
|
|
239
|
+
tickNumber: PropTypes.number,
|
|
235
240
|
tickSize: PropTypes.number,
|
|
236
|
-
tickSpacing: PropTypes.number,
|
|
237
241
|
valueFormatter: PropTypes.func
|
|
238
242
|
})),
|
|
239
243
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -249,15 +253,17 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
249
253
|
label: PropTypes.string,
|
|
250
254
|
labelFontSize: PropTypes.number,
|
|
251
255
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
252
|
-
maxTicks: PropTypes.number,
|
|
253
256
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
254
|
-
minTicks: PropTypes.number,
|
|
255
257
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
256
258
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
259
|
+
slotProps: PropTypes.object,
|
|
260
|
+
slots: PropTypes.object,
|
|
257
261
|
stroke: PropTypes.string,
|
|
258
262
|
tickFontSize: PropTypes.number,
|
|
263
|
+
tickMaxStep: PropTypes.number,
|
|
264
|
+
tickMinStep: PropTypes.number,
|
|
265
|
+
tickNumber: PropTypes.number,
|
|
259
266
|
tickSize: PropTypes.number,
|
|
260
|
-
tickSpacing: PropTypes.number,
|
|
261
267
|
valueFormatter: PropTypes.func
|
|
262
268
|
}))
|
|
263
269
|
} : void 0;
|
|
@@ -33,66 +33,49 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
33
33
|
if (element === null || disableAxisListener) {
|
|
34
34
|
return () => {};
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
if (usedYAxis === null) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const {
|
|
41
|
-
scale: yScale,
|
|
42
|
-
data: yAxisData
|
|
43
|
-
} = yAxis[usedYAxis];
|
|
44
|
-
if (!isBandScale(yScale)) {
|
|
45
|
-
return {
|
|
46
|
-
value: yScale.invert(y)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const dataIndex = Math.floor((y - yScale.range()[0]) / yScale.step());
|
|
50
|
-
if (dataIndex < 0 || dataIndex >= yAxisData.length) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
index: dataIndex,
|
|
55
|
-
value: yAxisData[dataIndex]
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const getUpdateX = x => {
|
|
36
|
+
const getUpdate = (axisConfig, mouseValue) => {
|
|
59
37
|
if (usedXAxis === null) {
|
|
60
38
|
return null;
|
|
61
39
|
}
|
|
62
40
|
const {
|
|
63
|
-
scale
|
|
64
|
-
data:
|
|
65
|
-
} =
|
|
66
|
-
if (!isBandScale(
|
|
67
|
-
const value =
|
|
68
|
-
|
|
41
|
+
scale,
|
|
42
|
+
data: axisData
|
|
43
|
+
} = axisConfig;
|
|
44
|
+
if (!isBandScale(scale)) {
|
|
45
|
+
const value = scale.invert(mouseValue);
|
|
46
|
+
if (axisData === undefined) {
|
|
47
|
+
return {
|
|
48
|
+
value
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const closestIndex = axisData == null ? void 0 : axisData.findIndex((v, index) => {
|
|
69
52
|
if (v > value) {
|
|
70
53
|
// @ts-ignore
|
|
71
|
-
if (index === 0 || Math.abs(value - v) <= Math.abs(value -
|
|
54
|
+
if (index === 0 || Math.abs(value - v) <= Math.abs(value - axisData[index - 1])) {
|
|
72
55
|
return true;
|
|
73
56
|
}
|
|
74
57
|
}
|
|
75
58
|
if (v <= value) {
|
|
76
|
-
if (index ===
|
|
59
|
+
if (index === axisData.length - 1 ||
|
|
77
60
|
// @ts-ignore
|
|
78
|
-
Math.abs(value - v) < Math.abs(value -
|
|
61
|
+
Math.abs(value - v) < Math.abs(value - axisData[index + 1])) {
|
|
79
62
|
return true;
|
|
80
63
|
}
|
|
81
64
|
}
|
|
82
65
|
return false;
|
|
83
66
|
});
|
|
84
67
|
return {
|
|
85
|
-
value: closestIndex !== undefined && closestIndex >= 0 ?
|
|
68
|
+
value: closestIndex !== undefined && closestIndex >= 0 ? axisData[closestIndex] : value,
|
|
86
69
|
index: closestIndex
|
|
87
70
|
};
|
|
88
71
|
}
|
|
89
|
-
const dataIndex =
|
|
90
|
-
if (dataIndex < 0 || dataIndex >=
|
|
72
|
+
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());
|
|
73
|
+
if (dataIndex < 0 || dataIndex >= axisData.length) {
|
|
91
74
|
return null;
|
|
92
75
|
}
|
|
93
76
|
return {
|
|
94
77
|
index: dataIndex,
|
|
95
|
-
value:
|
|
78
|
+
value: axisData[dataIndex]
|
|
96
79
|
};
|
|
97
80
|
};
|
|
98
81
|
const handleMouseOut = () => {
|
|
@@ -130,8 +113,8 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
130
113
|
});
|
|
131
114
|
return;
|
|
132
115
|
}
|
|
133
|
-
const newStateX =
|
|
134
|
-
const newStateY =
|
|
116
|
+
const newStateX = getUpdate(xAxis[usedXAxis], svgPt.x);
|
|
117
|
+
const newStateY = getUpdate(yAxis[usedYAxis], svgPt.y);
|
|
135
118
|
dispatch({
|
|
136
119
|
type: 'updateAxis',
|
|
137
120
|
data: {
|
package/esm/hooks/useTicks.js
CHANGED
|
@@ -2,13 +2,16 @@ import * as React from 'react';
|
|
|
2
2
|
import { isBandScale } from '../internals/isBandScale';
|
|
3
3
|
export function getTicksNumber(params) {
|
|
4
4
|
const {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
range
|
|
5
|
+
tickMaxStep,
|
|
6
|
+
tickMinStep,
|
|
7
|
+
tickNumber,
|
|
8
|
+
range,
|
|
9
|
+
domain
|
|
9
10
|
} = params;
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const maxTicks = tickMinStep === undefined ? 999 : Math.floor(Math.abs(domain[1] - domain[0]) / tickMinStep);
|
|
12
|
+
const minTicks = tickMaxStep === undefined ? 2 : Math.ceil(Math.abs(domain[1] - domain[0]) / tickMaxStep);
|
|
13
|
+
const defaultizedTickNumber = tickNumber != null ? tickNumber : Math.floor(Math.abs(range[1] - range[0]) / 50);
|
|
14
|
+
return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
|
|
12
15
|
}
|
|
13
16
|
function useTicks(options) {
|
|
14
17
|
const {
|
|
@@ -22,11 +25,11 @@ function useTicks(options) {
|
|
|
22
25
|
const domain = scale.domain();
|
|
23
26
|
if (scale.bandwidth() > 0) {
|
|
24
27
|
// scale type = 'band'
|
|
25
|
-
return [...domain.map(
|
|
28
|
+
return [...domain.map(value => {
|
|
26
29
|
var _valueFormatter;
|
|
27
30
|
return {
|
|
28
31
|
formattedValue: (_valueFormatter = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter : value,
|
|
29
|
-
offset:
|
|
32
|
+
offset: scale(value) - (scale.step() - scale.bandwidth()) / 2,
|
|
30
33
|
labelOffset: scale.step() / 2
|
|
31
34
|
};
|
|
32
35
|
}), {
|