@mui/x-charts 6.0.0-alpha.14 → 6.0.0-alpha.16
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 +16 -2
- package/BarChart/BarChart.js +49 -11
- package/BarChart/BarElement.d.ts +1318 -3
- package/BarChart/BarElement.js +10 -8
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/CHANGELOG.md +169 -0
- package/ChartContainer/index.js +5 -2
- package/ChartsAxis/ChartsAxis.js +18 -2
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/ChartsClipPath/ChartsClipPath.js +2 -2
- package/ChartsLegend/ChartsLegend.d.ts +44 -24
- package/ChartsLegend/ChartsLegend.js +191 -145
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.js +5 -13
- package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsTooltip.js +2 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +151 -40
- package/ChartsYAxis/ChartsYAxis.js +76 -33
- package/LineChart/AreaElement.d.ts +10 -0
- package/LineChart/AreaElement.js +12 -2
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +13 -2
- package/LineChart/LineChart.d.ts +13 -0
- package/LineChart/LineChart.js +40 -10
- package/LineChart/LineElement.d.ts +10 -0
- package/LineChart/LineElement.js +12 -2
- package/LineChart/LineHighlightElement.d.ts +10 -0
- package/LineChart/LineHighlightElement.js +12 -2
- package/LineChart/LineHighlightPlot.d.ts +10 -0
- package/LineChart/LineHighlightPlot.js +12 -2
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +12 -2
- package/LineChart/MarkElement.d.ts +10 -0
- package/LineChart/MarkElement.js +12 -2
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +12 -2
- package/PieChart/PieArc.js +2 -2
- package/PieChart/PieArcLabel.js +2 -2
- package/PieChart/PieChart.d.ts +13 -0
- package/PieChart/PieChart.js +41 -10
- package/PieChart/PiePlot.d.ts +10 -0
- package/PieChart/PiePlot.js +12 -2
- package/ResponsiveChartContainer/index.js +4 -4
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +13 -0
- package/ScatterChart/ScatterChart.js +40 -10
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/SparkLineChart/SparkLineChart.d.ts +9 -0
- package/SparkLineChart/SparkLineChart.js +16 -2
- package/constants.js +1 -1
- package/context/CartesianContextProvider.js +20 -12
- package/context/DrawingProvider.d.ts +2 -0
- package/context/DrawingProvider.js +4 -2
- package/context/HighlightProvider.js +2 -2
- package/context/InteractionProvider.js +2 -2
- package/context/SeriesContextProvider.js +2 -2
- package/esm/BarChart/BarChart.js +47 -9
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +16 -0
- package/esm/ChartsLegend/ChartsLegend.js +188 -142
- package/esm/ChartsSurface.js +3 -11
- package/esm/ChartsXAxis/ChartsXAxis.js +148 -37
- package/esm/ChartsYAxis/ChartsYAxis.js +73 -30
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +11 -0
- package/esm/LineChart/LineChart.js +38 -8
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +10 -0
- package/esm/LineChart/LineHighlightPlot.js +10 -0
- package/esm/LineChart/LinePlot.js +10 -0
- package/esm/LineChart/MarkElement.js +10 -0
- package/esm/LineChart/MarkPlot.js +10 -0
- package/esm/PieChart/PieChart.js +39 -8
- package/esm/PieChart/PiePlot.js +10 -0
- package/esm/ResponsiveChartContainer/index.js +2 -2
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +38 -8
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +14 -0
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +19 -11
- package/esm/context/DrawingProvider.js +2 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +15 -9
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +75 -0
- package/esm/internals/domUtils.js +113 -0
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +4 -2
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +19 -11
- package/hooks/useTicks.js +18 -12
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +16 -71
- package/internals/components/ChartsText.d.ts +35 -0
- package/internals/components/ChartsText.js +85 -0
- package/internals/defaultizeColor.d.ts +1 -1
- package/internals/domUtils.d.ts +13 -0
- package/internals/domUtils.js +122 -0
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/legacy/BarChart/BarChart.js +47 -9
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +16 -0
- package/legacy/ChartsLegend/ChartsLegend.js +203 -140
- package/legacy/ChartsSurface.js +2 -11
- package/legacy/ChartsXAxis/ChartsXAxis.js +152 -39
- package/legacy/ChartsYAxis/ChartsYAxis.js +73 -30
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +11 -0
- package/legacy/LineChart/LineChart.js +38 -8
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +10 -0
- package/legacy/LineChart/LineHighlightPlot.js +10 -0
- package/legacy/LineChart/LinePlot.js +10 -0
- package/legacy/LineChart/MarkElement.js +10 -0
- package/legacy/LineChart/MarkPlot.js +10 -0
- package/legacy/PieChart/PieChart.js +39 -8
- package/legacy/PieChart/PiePlot.js +10 -0
- package/legacy/ResponsiveChartContainer/index.js +2 -2
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +38 -8
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +14 -0
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +19 -11
- package/legacy/context/DrawingProvider.js +2 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +16 -9
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +9 -63
- package/legacy/internals/components/ChartsText.js +77 -0
- package/legacy/internals/domUtils.js +121 -0
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +25 -7
- package/models/layout.d.ts +7 -6
- package/models/seriesType/line.d.ts +2 -2
- package/modern/BarChart/BarChart.js +47 -9
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +16 -0
- package/modern/ChartsLegend/ChartsLegend.js +188 -142
- package/modern/ChartsSurface.js +3 -11
- package/modern/ChartsXAxis/ChartsXAxis.js +148 -37
- package/modern/ChartsYAxis/ChartsYAxis.js +73 -30
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +11 -0
- package/modern/LineChart/LineChart.js +38 -8
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +10 -0
- package/modern/LineChart/LineHighlightPlot.js +10 -0
- package/modern/LineChart/LinePlot.js +10 -0
- package/modern/LineChart/MarkElement.js +10 -0
- package/modern/LineChart/MarkPlot.js +10 -0
- package/modern/PieChart/PieChart.js +39 -8
- package/modern/PieChart/PiePlot.js +10 -0
- package/modern/ResponsiveChartContainer/index.js +2 -2
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +38 -8
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +14 -0
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +19 -11
- package/modern/context/DrawingProvider.js +2 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +15 -9
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +75 -0
- package/modern/internals/domUtils.js +113 -0
- package/modern/internals/geometry.js +36 -0
- package/package.json +5 -3
|
@@ -13,6 +13,17 @@ import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
|
13
13
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
/**
|
|
17
|
+
* Demos:
|
|
18
|
+
*
|
|
19
|
+
* - [Bars](https://mui.com/x/react-charts/bars/)
|
|
20
|
+
* - [Bar demonstration](https://mui.com/x/react-charts/bar-demo/)
|
|
21
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
22
|
+
*
|
|
23
|
+
* API:
|
|
24
|
+
*
|
|
25
|
+
* - [BarChart API](https://mui.com/x/api/charts/bar-chart/)
|
|
26
|
+
*/
|
|
16
27
|
var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
17
28
|
var xAxis = props.xAxis,
|
|
18
29
|
yAxis = props.yAxis,
|
|
@@ -31,6 +42,7 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
31
42
|
leftAxis = props.leftAxis,
|
|
32
43
|
rightAxis = props.rightAxis,
|
|
33
44
|
bottomAxis = props.bottomAxis,
|
|
45
|
+
skipAnimation = props.skipAnimation,
|
|
34
46
|
children = props.children,
|
|
35
47
|
slots = props.slots,
|
|
36
48
|
slotProps = props.slotProps;
|
|
@@ -81,7 +93,8 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
81
93
|
clipPath: "url(#".concat(clipPathId, ")"),
|
|
82
94
|
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
83
95
|
slots: slots,
|
|
84
|
-
slotProps: slotProps
|
|
96
|
+
slotProps: slotProps,
|
|
97
|
+
skipAnimation: skipAnimation
|
|
85
98
|
})
|
|
86
99
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
87
100
|
topAxis: topAxis,
|
|
@@ -123,11 +136,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
123
136
|
fill: PropTypes.string,
|
|
124
137
|
label: PropTypes.string,
|
|
125
138
|
labelFontSize: PropTypes.number,
|
|
139
|
+
labelStyle: PropTypes.object,
|
|
126
140
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
127
141
|
slotProps: PropTypes.object,
|
|
128
142
|
slots: PropTypes.object,
|
|
129
143
|
stroke: PropTypes.string,
|
|
130
144
|
tickFontSize: PropTypes.number,
|
|
145
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
146
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
147
|
+
tickLabelStyle: PropTypes.object,
|
|
131
148
|
tickMaxStep: PropTypes.number,
|
|
132
149
|
tickMinStep: PropTypes.number,
|
|
133
150
|
tickNumber: PropTypes.number,
|
|
@@ -157,33 +174,33 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
157
174
|
fill: PropTypes.string,
|
|
158
175
|
label: PropTypes.string,
|
|
159
176
|
labelFontSize: PropTypes.number,
|
|
177
|
+
labelStyle: PropTypes.object,
|
|
160
178
|
position: PropTypes.oneOf(['left', 'right']),
|
|
161
179
|
slotProps: PropTypes.object,
|
|
162
180
|
slots: PropTypes.object,
|
|
163
181
|
stroke: PropTypes.string,
|
|
164
182
|
tickFontSize: PropTypes.number,
|
|
183
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
184
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
185
|
+
tickLabelStyle: PropTypes.object,
|
|
165
186
|
tickMaxStep: PropTypes.number,
|
|
166
187
|
tickMinStep: PropTypes.number,
|
|
167
188
|
tickNumber: PropTypes.number,
|
|
168
189
|
tickSize: PropTypes.number
|
|
169
190
|
}), PropTypes.string]),
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
193
|
+
*/
|
|
170
194
|
legend: PropTypes.shape({
|
|
171
195
|
classes: PropTypes.object,
|
|
172
196
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
173
197
|
hidden: PropTypes.bool,
|
|
174
|
-
itemWidth: PropTypes.number,
|
|
175
|
-
markSize: PropTypes.number,
|
|
176
|
-
offset: PropTypes.shape({
|
|
177
|
-
x: PropTypes.number,
|
|
178
|
-
y: PropTypes.number
|
|
179
|
-
}),
|
|
180
198
|
position: PropTypes.shape({
|
|
181
199
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
182
200
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
183
201
|
}),
|
|
184
202
|
slotProps: PropTypes.object,
|
|
185
|
-
slots: PropTypes.object
|
|
186
|
-
spacing: PropTypes.number
|
|
203
|
+
slots: PropTypes.object
|
|
187
204
|
}),
|
|
188
205
|
margin: PropTypes.shape({
|
|
189
206
|
bottom: PropTypes.number,
|
|
@@ -204,11 +221,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
204
221
|
fill: PropTypes.string,
|
|
205
222
|
label: PropTypes.string,
|
|
206
223
|
labelFontSize: PropTypes.number,
|
|
224
|
+
labelStyle: PropTypes.object,
|
|
207
225
|
position: PropTypes.oneOf(['left', 'right']),
|
|
208
226
|
slotProps: PropTypes.object,
|
|
209
227
|
slots: PropTypes.object,
|
|
210
228
|
stroke: PropTypes.string,
|
|
211
229
|
tickFontSize: PropTypes.number,
|
|
230
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
231
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
232
|
+
tickLabelStyle: PropTypes.object,
|
|
212
233
|
tickMaxStep: PropTypes.number,
|
|
213
234
|
tickMinStep: PropTypes.number,
|
|
214
235
|
tickNumber: PropTypes.number,
|
|
@@ -233,6 +254,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
233
254
|
xAxisKey: PropTypes.string,
|
|
234
255
|
yAxisKey: PropTypes.string
|
|
235
256
|
})).isRequired,
|
|
257
|
+
/**
|
|
258
|
+
* If `true`, animations are skiped.
|
|
259
|
+
* @default false
|
|
260
|
+
*/
|
|
261
|
+
skipAnimation: PropTypes.bool,
|
|
236
262
|
/**
|
|
237
263
|
* The props used for each component slot.
|
|
238
264
|
* @default {}
|
|
@@ -266,11 +292,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
266
292
|
fill: PropTypes.string,
|
|
267
293
|
label: PropTypes.string,
|
|
268
294
|
labelFontSize: PropTypes.number,
|
|
295
|
+
labelStyle: PropTypes.object,
|
|
269
296
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
270
297
|
slotProps: PropTypes.object,
|
|
271
298
|
slots: PropTypes.object,
|
|
272
299
|
stroke: PropTypes.string,
|
|
273
300
|
tickFontSize: PropTypes.number,
|
|
301
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
302
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
303
|
+
tickLabelStyle: PropTypes.object,
|
|
274
304
|
tickMaxStep: PropTypes.number,
|
|
275
305
|
tickMinStep: PropTypes.number,
|
|
276
306
|
tickNumber: PropTypes.number,
|
|
@@ -295,6 +325,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
295
325
|
id: PropTypes.string,
|
|
296
326
|
label: PropTypes.string,
|
|
297
327
|
labelFontSize: PropTypes.number,
|
|
328
|
+
labelStyle: PropTypes.object,
|
|
298
329
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
299
330
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
300
331
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -303,6 +334,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
303
334
|
slots: PropTypes.object,
|
|
304
335
|
stroke: PropTypes.string,
|
|
305
336
|
tickFontSize: PropTypes.number,
|
|
337
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
338
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
339
|
+
tickLabelStyle: PropTypes.object,
|
|
306
340
|
tickMaxStep: PropTypes.number,
|
|
307
341
|
tickMinStep: PropTypes.number,
|
|
308
342
|
tickNumber: PropTypes.number,
|
|
@@ -321,6 +355,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
321
355
|
id: PropTypes.string,
|
|
322
356
|
label: PropTypes.string,
|
|
323
357
|
labelFontSize: PropTypes.number,
|
|
358
|
+
labelStyle: PropTypes.object,
|
|
324
359
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
325
360
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
326
361
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -329,6 +364,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
329
364
|
slots: PropTypes.object,
|
|
330
365
|
stroke: PropTypes.string,
|
|
331
366
|
tickFontSize: PropTypes.number,
|
|
367
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
368
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
369
|
+
tickLabelStyle: PropTypes.object,
|
|
332
370
|
tickMaxStep: PropTypes.number,
|
|
333
371
|
tickMinStep: PropTypes.number,
|
|
334
372
|
tickNumber: PropTypes.number,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
3
|
+
var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
6
|
import { useSlotProps } from '@mui/base/utils';
|
|
@@ -8,13 +8,14 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import { color as d3Color } from 'd3-color';
|
|
10
10
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
11
|
+
import { animated } from '@react-spring/web';
|
|
11
12
|
import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
12
13
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
export function getBarElementUtilityClass(slot) {
|
|
15
16
|
return generateUtilityClass('MuiBarElement', slot);
|
|
16
17
|
}
|
|
17
|
-
export var
|
|
18
|
+
export var barElementClasses = generateUtilityClasses('MuiBarElement', ['root']);
|
|
18
19
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
19
20
|
var classes = ownerState.classes,
|
|
20
21
|
id = ownerState.id;
|
|
@@ -23,7 +24,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
23
24
|
};
|
|
24
25
|
return composeClasses(slots, getBarElementUtilityClass, classes);
|
|
25
26
|
};
|
|
26
|
-
export var BarElementPath = styled(
|
|
27
|
+
export var BarElementPath = styled(animated.rect, {
|
|
27
28
|
name: 'MuiBarElement',
|
|
28
29
|
slot: 'Root',
|
|
29
30
|
overridesResolver: function overridesResolver(_, styles) {
|
|
@@ -48,6 +49,7 @@ export function BarElement(props) {
|
|
|
48
49
|
highlightScope = props.highlightScope,
|
|
49
50
|
slots = props.slots,
|
|
50
51
|
slotProps = props.slotProps,
|
|
52
|
+
style = props.style,
|
|
51
53
|
other = _objectWithoutProperties(props, _excluded);
|
|
52
54
|
var getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
53
55
|
var _React$useContext = React.useContext(InteractionContext),
|
|
@@ -80,6 +82,7 @@ export function BarElement(props) {
|
|
|
80
82
|
seriesId: id,
|
|
81
83
|
dataIndex: dataIndex
|
|
82
84
|
}), {
|
|
85
|
+
style: style,
|
|
83
86
|
className: classes.root
|
|
84
87
|
}),
|
|
85
88
|
ownerState: ownerState
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
var _excluded = ["skipAnimation"];
|
|
3
5
|
import * as React from 'react';
|
|
4
6
|
import PropTypes from 'prop-types';
|
|
7
|
+
import { useTransition } from '@react-spring/web';
|
|
5
8
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
10
|
import { BarElement } from './BarElement';
|
|
8
11
|
import { isBandScaleConfig } from '../models/axis';
|
|
9
|
-
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
13
|
/**
|
|
11
14
|
* Solution of the equations
|
|
12
15
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -16,7 +19,6 @@ import { isBandScaleConfig } from '../models/axis';
|
|
|
16
19
|
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
17
20
|
* @returns The bar width and the offset between bars.
|
|
18
21
|
*/
|
|
19
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
22
|
function getBandSize(_ref) {
|
|
21
23
|
var W = _ref.bandWidth,
|
|
22
24
|
N = _ref.numberOfGroups,
|
|
@@ -34,12 +36,14 @@ function getBandSize(_ref) {
|
|
|
34
36
|
offset: offset
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
|
-
function
|
|
38
|
-
var
|
|
39
|
+
var useCompletedData = function useCompletedData() {
|
|
40
|
+
var _React$useContext$bar;
|
|
41
|
+
var seriesData = (_React$useContext$bar = React.useContext(SeriesContext).bar) != null ? _React$useContext$bar : {
|
|
42
|
+
series: {},
|
|
43
|
+
stackingGroups: [],
|
|
44
|
+
seriesOrder: []
|
|
45
|
+
};
|
|
39
46
|
var axisData = React.useContext(CartesianContext);
|
|
40
|
-
if (seriesData === undefined) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
47
|
var series = seriesData.series,
|
|
44
48
|
stackingGroups = seriesData.stackingGroups;
|
|
45
49
|
var xAxis = axisData.xAxis,
|
|
@@ -48,64 +52,143 @@ function BarPlot(props) {
|
|
|
48
52
|
yAxisIds = axisData.yAxisIds;
|
|
49
53
|
var defaultXAxisId = xAxisIds[0];
|
|
50
54
|
var defaultYAxisId = yAxisIds[0];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
throw new Error("Axis with id \"".concat(yAxisKey, "\" shoud be of type \"band\" to display the bar series of id \"").concat(seriesId, "\""));
|
|
73
|
-
}
|
|
74
|
-
if (yAxis[yAxisKey].data === undefined) {
|
|
75
|
-
throw new Error("Axis with id \"".concat(xAxisKey, "\" shoud have data property"));
|
|
76
|
-
}
|
|
77
|
-
baseScaleConfig = yAxisConfig;
|
|
55
|
+
var data = stackingGroups.flatMap(function (_ref2, groupIndex) {
|
|
56
|
+
var groupIds = _ref2.ids;
|
|
57
|
+
return groupIds.flatMap(function (seriesId) {
|
|
58
|
+
var _series$seriesId$xAxi, _series$seriesId$yAxi;
|
|
59
|
+
var xAxisKey = (_series$seriesId$xAxi = series[seriesId].xAxisKey) != null ? _series$seriesId$xAxi : defaultXAxisId;
|
|
60
|
+
var yAxisKey = (_series$seriesId$yAxi = series[seriesId].yAxisKey) != null ? _series$seriesId$yAxi : defaultYAxisId;
|
|
61
|
+
var xAxisConfig = xAxis[xAxisKey];
|
|
62
|
+
var yAxisConfig = yAxis[yAxisKey];
|
|
63
|
+
var verticalLayout = series[seriesId].layout === 'vertical';
|
|
64
|
+
var baseScaleConfig;
|
|
65
|
+
if (verticalLayout) {
|
|
66
|
+
if (!isBandScaleConfig(xAxisConfig)) {
|
|
67
|
+
throw new Error("Axis with id \"".concat(xAxisKey, "\" shoud be of type \"band\" to display the bar series of id \"").concat(seriesId, "\""));
|
|
68
|
+
}
|
|
69
|
+
if (xAxis[xAxisKey].data === undefined) {
|
|
70
|
+
throw new Error("Axis with id \"".concat(xAxisKey, "\" shoud have data property"));
|
|
71
|
+
}
|
|
72
|
+
baseScaleConfig = xAxisConfig;
|
|
73
|
+
} else {
|
|
74
|
+
if (!isBandScaleConfig(yAxisConfig)) {
|
|
75
|
+
throw new Error("Axis with id \"".concat(yAxisKey, "\" shoud be of type \"band\" to display the bar series of id \"").concat(seriesId, "\""));
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
77
|
+
if (yAxis[yAxisKey].data === undefined) {
|
|
78
|
+
throw new Error("Axis with id \"".concat(xAxisKey, "\" shoud have data property"));
|
|
79
|
+
}
|
|
80
|
+
baseScaleConfig = yAxisConfig;
|
|
81
|
+
}
|
|
82
|
+
var xScale = xAxisConfig.scale;
|
|
83
|
+
var yScale = yAxisConfig.scale;
|
|
84
|
+
var bandWidth = baseScaleConfig.scale.bandwidth();
|
|
85
|
+
var _getBandSize = getBandSize({
|
|
86
|
+
bandWidth: bandWidth,
|
|
87
|
+
numberOfGroups: stackingGroups.length,
|
|
88
|
+
gapRatio: baseScaleConfig.barGapRatio
|
|
89
|
+
}),
|
|
90
|
+
barWidth = _getBandSize.barWidth,
|
|
91
|
+
offset = _getBandSize.offset;
|
|
92
|
+
var barOffset = groupIndex * (barWidth + offset);
|
|
93
|
+
var _series$seriesId = series[seriesId],
|
|
94
|
+
stackedData = _series$seriesId.stackedData,
|
|
95
|
+
color = _series$seriesId.color;
|
|
96
|
+
return stackedData.map(function (values, dataIndex) {
|
|
97
|
+
var _xAxis$xAxisKey$data, _yAxis$yAxisKey$data;
|
|
98
|
+
var bottom = Math.min.apply(Math, _toConsumableArray(values));
|
|
99
|
+
var top = Math.max.apply(Math, _toConsumableArray(values));
|
|
100
|
+
return {
|
|
101
|
+
bottom: bottom,
|
|
102
|
+
top: top,
|
|
103
|
+
seriesId: seriesId,
|
|
104
|
+
dataIndex: dataIndex,
|
|
105
|
+
layout: series[seriesId].layout,
|
|
106
|
+
x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset : xScale(bottom),
|
|
107
|
+
y: verticalLayout ? yScale(top) : yScale((_yAxis$yAxisKey$data = yAxis[yAxisKey].data) == null ? void 0 : _yAxis$yAxisKey$data[dataIndex]) + barOffset,
|
|
108
|
+
xOrigin: xScale(0),
|
|
109
|
+
yOrigin: yScale(0),
|
|
110
|
+
height: verticalLayout ? Math.abs(yScale(bottom) - yScale(top)) : barWidth,
|
|
111
|
+
width: verticalLayout ? barWidth : Math.abs(xScale(bottom) - xScale(top)),
|
|
112
|
+
color: color,
|
|
113
|
+
highlightScope: series[seriesId].highlightScope
|
|
114
|
+
};
|
|
108
115
|
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
return data;
|
|
119
|
+
};
|
|
120
|
+
var getOutStyle = function getOutStyle(_ref3) {
|
|
121
|
+
var layout = _ref3.layout,
|
|
122
|
+
yOrigin = _ref3.yOrigin,
|
|
123
|
+
x = _ref3.x,
|
|
124
|
+
width = _ref3.width,
|
|
125
|
+
y = _ref3.y,
|
|
126
|
+
xOrigin = _ref3.xOrigin,
|
|
127
|
+
height = _ref3.height;
|
|
128
|
+
return _extends({}, layout === 'vertical' ? {
|
|
129
|
+
y: yOrigin,
|
|
130
|
+
x: x,
|
|
131
|
+
height: 0,
|
|
132
|
+
width: width
|
|
133
|
+
} : {
|
|
134
|
+
y: y,
|
|
135
|
+
x: xOrigin,
|
|
136
|
+
height: height,
|
|
137
|
+
width: 0
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
var getInStyle = function getInStyle(_ref4) {
|
|
141
|
+
var x = _ref4.x,
|
|
142
|
+
width = _ref4.width,
|
|
143
|
+
y = _ref4.y,
|
|
144
|
+
height = _ref4.height;
|
|
145
|
+
return {
|
|
146
|
+
y: y,
|
|
147
|
+
x: x,
|
|
148
|
+
height: height,
|
|
149
|
+
width: width
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Demos:
|
|
155
|
+
*
|
|
156
|
+
* - [Bars](https://mui.com/x/react-charts/bars/)
|
|
157
|
+
* - [Bar demonstration](https://mui.com/x/react-charts/bar-demo/)
|
|
158
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
159
|
+
*
|
|
160
|
+
* API:
|
|
161
|
+
*
|
|
162
|
+
* - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
|
|
163
|
+
*/
|
|
164
|
+
function BarPlot(props) {
|
|
165
|
+
var completedData = useCompletedData();
|
|
166
|
+
var skipAnimation = props.skipAnimation,
|
|
167
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
168
|
+
var transition = useTransition(completedData, {
|
|
169
|
+
keys: function keys(bar) {
|
|
170
|
+
return "".concat(bar.seriesId, "-").concat(bar.dataIndex);
|
|
171
|
+
},
|
|
172
|
+
from: getOutStyle,
|
|
173
|
+
leave: getOutStyle,
|
|
174
|
+
enter: getInStyle,
|
|
175
|
+
update: getInStyle,
|
|
176
|
+
immediate: skipAnimation
|
|
177
|
+
});
|
|
178
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
179
|
+
children: transition(function (style, _ref5) {
|
|
180
|
+
var seriesId = _ref5.seriesId,
|
|
181
|
+
dataIndex = _ref5.dataIndex,
|
|
182
|
+
color = _ref5.color,
|
|
183
|
+
highlightScope = _ref5.highlightScope;
|
|
184
|
+
return /*#__PURE__*/_jsx(BarElement, _extends({
|
|
185
|
+
id: seriesId,
|
|
186
|
+
dataIndex: dataIndex,
|
|
187
|
+
highlightScope: highlightScope,
|
|
188
|
+
color: color
|
|
189
|
+
}, other, {
|
|
190
|
+
style: style
|
|
191
|
+
}));
|
|
109
192
|
})
|
|
110
193
|
});
|
|
111
194
|
}
|
|
@@ -114,6 +197,11 @@ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
|
114
197
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
115
198
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
116
199
|
// ----------------------------------------------------------------------
|
|
200
|
+
/**
|
|
201
|
+
* If `true`, animations are skiped.
|
|
202
|
+
* @default false
|
|
203
|
+
*/
|
|
204
|
+
skipAnimation: PropTypes.bool,
|
|
117
205
|
/**
|
|
118
206
|
* The props used for each component slot.
|
|
119
207
|
* @default {}
|
|
@@ -3,6 +3,7 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
3
3
|
import { DrawingProvider } from '../context/DrawingProvider';
|
|
4
4
|
import { SeriesContextProvider } from '../context/SeriesContextProvider';
|
|
5
5
|
import { InteractionProvider } from '../context/InteractionProvider';
|
|
6
|
+
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
6
7
|
import { ChartsSurface } from '../ChartsSurface';
|
|
7
8
|
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
8
9
|
import { HighlightProvider } from '../context/HighlightProvider';
|
|
@@ -23,6 +24,8 @@ export var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContaine
|
|
|
23
24
|
children = props.children;
|
|
24
25
|
var svgRef = React.useRef(null);
|
|
25
26
|
var handleRef = useForkRef(ref, svgRef);
|
|
27
|
+
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
28
|
+
|
|
26
29
|
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
27
30
|
width: width,
|
|
28
31
|
height: height,
|
|
@@ -95,11 +95,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
95
95
|
fill: PropTypes.string,
|
|
96
96
|
label: PropTypes.string,
|
|
97
97
|
labelFontSize: PropTypes.number,
|
|
98
|
+
labelStyle: PropTypes.object,
|
|
98
99
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
99
100
|
slotProps: PropTypes.object,
|
|
100
101
|
slots: PropTypes.object,
|
|
101
102
|
stroke: PropTypes.string,
|
|
102
103
|
tickFontSize: PropTypes.number,
|
|
104
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
105
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
106
|
+
tickLabelStyle: PropTypes.object,
|
|
103
107
|
tickMaxStep: PropTypes.number,
|
|
104
108
|
tickMinStep: PropTypes.number,
|
|
105
109
|
tickNumber: PropTypes.number,
|
|
@@ -118,11 +122,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
118
122
|
fill: PropTypes.string,
|
|
119
123
|
label: PropTypes.string,
|
|
120
124
|
labelFontSize: PropTypes.number,
|
|
125
|
+
labelStyle: PropTypes.object,
|
|
121
126
|
position: PropTypes.oneOf(['left', 'right']),
|
|
122
127
|
slotProps: PropTypes.object,
|
|
123
128
|
slots: PropTypes.object,
|
|
124
129
|
stroke: PropTypes.string,
|
|
125
130
|
tickFontSize: PropTypes.number,
|
|
131
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
132
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
133
|
+
tickLabelStyle: PropTypes.object,
|
|
126
134
|
tickMaxStep: PropTypes.number,
|
|
127
135
|
tickMinStep: PropTypes.number,
|
|
128
136
|
tickNumber: PropTypes.number,
|
|
@@ -141,11 +149,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
141
149
|
fill: PropTypes.string,
|
|
142
150
|
label: PropTypes.string,
|
|
143
151
|
labelFontSize: PropTypes.number,
|
|
152
|
+
labelStyle: PropTypes.object,
|
|
144
153
|
position: PropTypes.oneOf(['left', 'right']),
|
|
145
154
|
slotProps: PropTypes.object,
|
|
146
155
|
slots: PropTypes.object,
|
|
147
156
|
stroke: PropTypes.string,
|
|
148
157
|
tickFontSize: PropTypes.number,
|
|
158
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
159
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
160
|
+
tickLabelStyle: PropTypes.object,
|
|
149
161
|
tickMaxStep: PropTypes.number,
|
|
150
162
|
tickMinStep: PropTypes.number,
|
|
151
163
|
tickNumber: PropTypes.number,
|
|
@@ -174,11 +186,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
174
186
|
fill: PropTypes.string,
|
|
175
187
|
label: PropTypes.string,
|
|
176
188
|
labelFontSize: PropTypes.number,
|
|
189
|
+
labelStyle: PropTypes.object,
|
|
177
190
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
178
191
|
slotProps: PropTypes.object,
|
|
179
192
|
slots: PropTypes.object,
|
|
180
193
|
stroke: PropTypes.string,
|
|
181
194
|
tickFontSize: PropTypes.number,
|
|
195
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
196
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
197
|
+
tickLabelStyle: PropTypes.object,
|
|
182
198
|
tickMaxStep: PropTypes.number,
|
|
183
199
|
tickMinStep: PropTypes.number,
|
|
184
200
|
tickNumber: PropTypes.number,
|