@mui/x-charts 6.18.0 → 7.0.0-alpha.0
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 +15 -8
- package/BarChart/BarChart.js +41 -4
- package/BarChart/BarPlot.d.ts +2 -2
- package/CHANGELOG.md +212 -5
- package/ChartsAxis/ChartsAxis.d.ts +3 -3
- package/ChartsAxis/ChartsAxis.js +5 -5
- package/ChartsAxis/axisClasses.d.ts +2 -2
- package/ChartsLegend/ChartsLegend.d.ts +10 -6
- package/ChartsLegend/ChartsLegend.js +137 -2
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/chartsLegendClasses.js +2 -2
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
- package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
- package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
- package/ChartsReferenceLine/common.d.ts +41 -0
- package/ChartsReferenceLine/common.js +27 -0
- package/ChartsReferenceLine/index.d.ts +2 -0
- package/ChartsReferenceLine/index.js +27 -0
- package/ChartsReferenceLine/package.json +6 -0
- package/ChartsSurface.d.ts +11 -0
- package/ChartsTooltip/ChartsTooltip.d.ts +4 -4
- package/ChartsXAxis/ChartsXAxis.js +9 -5
- package/ChartsYAxis/ChartsYAxis.js +9 -5
- package/LineChart/AreaPlot.d.ts +2 -2
- package/LineChart/LineChart.d.ts +18 -11
- package/LineChart/LineChart.js +41 -4
- package/LineChart/LineHighlightPlot.d.ts +4 -4
- package/LineChart/LineHighlightPlot.js +1 -1
- package/LineChart/LinePlot.d.ts +2 -2
- package/LineChart/MarkPlot.d.ts +4 -4
- package/LineChart/MarkPlot.js +2 -1
- package/PieChart/PieArcLabelPlot.d.ts +4 -4
- package/PieChart/PieArcPlot.d.ts +4 -4
- package/PieChart/PieChart.d.ts +8 -8
- package/PieChart/PieChart.js +34 -4
- package/PieChart/PiePlot.d.ts +6 -6
- package/ResponsiveChartContainer/index.d.ts +13 -3
- package/ScatterChart/ScatterChart.d.ts +8 -8
- package/ScatterChart/ScatterChart.js +34 -4
- package/ScatterChart/ScatterPlot.d.ts +4 -4
- package/SparkLineChart/SparkLineChart.d.ts +10 -10
- package/SparkLineChart/SparkLineChart.js +22 -0
- package/context/CartesianContextProvider.d.ts +21 -1
- package/context/CartesianContextProvider.js +11 -0
- package/context/DrawingProvider.d.ts +18 -0
- package/context/DrawingProvider.js +6 -0
- package/context/HighlightProvider.d.ts +17 -0
- package/context/InteractionProvider.d.ts +6 -0
- package/context/SeriesContextProvider.d.ts +5 -0
- package/esm/BarChart/BarChart.js +41 -4
- package/esm/ChartsAxis/ChartsAxis.js +6 -5
- package/esm/ChartsLegend/ChartsLegend.js +140 -4
- package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
- package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/esm/ChartsReferenceLine/common.js +20 -0
- package/esm/ChartsReferenceLine/index.js +2 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +10 -6
- package/esm/ChartsYAxis/ChartsYAxis.js +10 -6
- package/esm/LineChart/LineChart.js +41 -4
- package/esm/LineChart/LineHighlightPlot.js +1 -1
- package/esm/LineChart/MarkPlot.js +2 -1
- package/esm/PieChart/PieChart.js +34 -4
- package/esm/ScatterChart/ScatterChart.js +34 -4
- package/esm/SparkLineChart/SparkLineChart.js +22 -0
- package/esm/context/CartesianContextProvider.js +11 -0
- package/esm/context/DrawingProvider.js +6 -0
- package/esm/index.js +2 -0
- package/esm/internals/geometry.js +2 -2
- package/hooks/useScale.d.ts +2 -2
- package/index.d.ts +2 -0
- package/index.js +23 -1
- package/internals/components/ChartsText.d.ts +1 -1
- package/internals/geometry.d.ts +2 -2
- package/internals/geometry.js +2 -2
- package/internals/isBandScale.d.ts +3 -1
- package/internals/utils.d.ts +5 -0
- package/legacy/BarChart/BarChart.js +41 -4
- package/legacy/ChartsAxis/ChartsAxis.js +6 -5
- package/legacy/ChartsLegend/ChartsLegend.js +140 -4
- package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
- package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/legacy/ChartsReferenceLine/common.js +20 -0
- package/legacy/ChartsReferenceLine/index.js +2 -0
- package/legacy/ChartsXAxis/ChartsXAxis.js +15 -12
- package/legacy/ChartsYAxis/ChartsYAxis.js +15 -12
- package/legacy/LineChart/LineChart.js +41 -4
- package/legacy/LineChart/LineHighlightPlot.js +1 -1
- package/legacy/LineChart/MarkPlot.js +2 -1
- package/legacy/PieChart/PieChart.js +34 -4
- package/legacy/ScatterChart/ScatterChart.js +34 -4
- package/legacy/SparkLineChart/SparkLineChart.js +22 -0
- package/legacy/context/CartesianContextProvider.js +11 -0
- package/legacy/context/DrawingProvider.js +6 -0
- package/legacy/index.js +3 -1
- package/legacy/internals/geometry.js +2 -2
- package/models/axis.d.ts +37 -17
- package/models/layout.d.ts +6 -0
- package/models/seriesType/common.d.ts +16 -0
- package/modern/BarChart/BarChart.js +41 -4
- package/modern/ChartsAxis/ChartsAxis.js +5 -5
- package/modern/ChartsLegend/ChartsLegend.js +140 -4
- package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
- package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/modern/ChartsReferenceLine/common.js +20 -0
- package/modern/ChartsReferenceLine/index.js +2 -0
- package/modern/ChartsXAxis/ChartsXAxis.js +9 -5
- package/modern/ChartsYAxis/ChartsYAxis.js +9 -5
- package/modern/LineChart/LineChart.js +41 -4
- package/modern/LineChart/LineHighlightPlot.js +1 -1
- package/modern/LineChart/MarkPlot.js +2 -1
- package/modern/PieChart/PieChart.js +34 -4
- package/modern/ScatterChart/ScatterChart.js +34 -4
- package/modern/SparkLineChart/SparkLineChart.js +22 -0
- package/modern/context/CartesianContextProvider.js +11 -0
- package/modern/context/DrawingProvider.js +6 -0
- package/modern/index.js +3 -1
- package/modern/internals/geometry.js +2 -2
- package/package.json +1 -1
|
@@ -111,6 +111,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
111
111
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
112
112
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
113
113
|
// ----------------------------------------------------------------------
|
|
114
|
+
/**
|
|
115
|
+
* Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
|
|
116
|
+
* The two properties accept the following values:
|
|
117
|
+
* - 'none': display nothing.
|
|
118
|
+
* - 'line': display a line at the current mouse position.
|
|
119
|
+
* - 'band': display a band at the current mouse position. Only available with band scale.
|
|
120
|
+
*/
|
|
114
121
|
axisHighlight: PropTypes.shape({
|
|
115
122
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
116
123
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
@@ -121,7 +128,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
121
128
|
* @default xAxisIds[0] The id of the first provided axis
|
|
122
129
|
*/
|
|
123
130
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
124
|
-
axisId: PropTypes.string
|
|
131
|
+
axisId: PropTypes.string,
|
|
125
132
|
classes: PropTypes.object,
|
|
126
133
|
disableLine: PropTypes.bool,
|
|
127
134
|
disableTicks: PropTypes.bool,
|
|
@@ -148,9 +155,21 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
148
155
|
* Color palette used to colorize multiple series.
|
|
149
156
|
*/
|
|
150
157
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
158
|
+
/**
|
|
159
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
160
|
+
*/
|
|
151
161
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
152
162
|
desc: PropTypes.string,
|
|
163
|
+
/**
|
|
164
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
165
|
+
* It might break interactive features, but will improve performance.
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
153
168
|
disableAxisListener: PropTypes.bool,
|
|
169
|
+
/**
|
|
170
|
+
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
171
|
+
* @default undefined
|
|
172
|
+
*/
|
|
154
173
|
height: PropTypes.number,
|
|
155
174
|
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
156
175
|
/**
|
|
@@ -159,7 +178,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
159
178
|
* @default yAxisIds[0] The id of the first provided axis
|
|
160
179
|
*/
|
|
161
180
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
162
|
-
axisId: PropTypes.string
|
|
181
|
+
axisId: PropTypes.string,
|
|
163
182
|
classes: PropTypes.object,
|
|
164
183
|
disableLine: PropTypes.bool,
|
|
165
184
|
disableTicks: PropTypes.bool,
|
|
@@ -194,6 +213,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
194
213
|
slotProps: PropTypes.object,
|
|
195
214
|
slots: PropTypes.object
|
|
196
215
|
}),
|
|
216
|
+
/**
|
|
217
|
+
* The margin between the SVG and the drawing area.
|
|
218
|
+
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
219
|
+
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
220
|
+
* @default object Depends on the charts type.
|
|
221
|
+
*/
|
|
197
222
|
margin: PropTypes.shape({
|
|
198
223
|
bottom: PropTypes.number,
|
|
199
224
|
left: PropTypes.number,
|
|
@@ -206,7 +231,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
206
231
|
* @default null
|
|
207
232
|
*/
|
|
208
233
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
209
|
-
axisId: PropTypes.string
|
|
234
|
+
axisId: PropTypes.string,
|
|
210
235
|
classes: PropTypes.object,
|
|
211
236
|
disableLine: PropTypes.bool,
|
|
212
237
|
disableTicks: PropTypes.bool,
|
|
@@ -277,7 +302,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
277
302
|
* @default null
|
|
278
303
|
*/
|
|
279
304
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
280
|
-
axisId: PropTypes.string
|
|
305
|
+
axisId: PropTypes.string,
|
|
281
306
|
classes: PropTypes.object,
|
|
282
307
|
disableLine: PropTypes.bool,
|
|
283
308
|
disableTicks: PropTypes.bool,
|
|
@@ -304,7 +329,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
304
329
|
x: PropTypes.number,
|
|
305
330
|
y: PropTypes.number
|
|
306
331
|
}),
|
|
332
|
+
/**
|
|
333
|
+
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
334
|
+
* @default undefined
|
|
335
|
+
*/
|
|
307
336
|
width: PropTypes.number,
|
|
337
|
+
/**
|
|
338
|
+
* The configuration of the x-axes.
|
|
339
|
+
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
340
|
+
*/
|
|
308
341
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
309
342
|
axisId: PropTypes.string,
|
|
310
343
|
classes: PropTypes.object,
|
|
@@ -335,6 +368,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
335
368
|
tickSize: PropTypes.number,
|
|
336
369
|
valueFormatter: PropTypes.func
|
|
337
370
|
})),
|
|
371
|
+
/**
|
|
372
|
+
* The configuration of the y-axes.
|
|
373
|
+
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
374
|
+
*/
|
|
338
375
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
339
376
|
axisId: PropTypes.string,
|
|
340
377
|
classes: PropTypes.object,
|
|
@@ -11,7 +11,7 @@ const getAxisId = propsValue => {
|
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
13
|
if (typeof propsValue === 'object') {
|
|
14
|
-
return propsValue.axisId;
|
|
14
|
+
return propsValue.axisId ?? null;
|
|
15
15
|
}
|
|
16
16
|
return propsValue;
|
|
17
17
|
};
|
|
@@ -100,7 +100,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
100
100
|
* @default xAxisIds[0] The id of the first provided axis
|
|
101
101
|
*/
|
|
102
102
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
103
|
-
axisId: PropTypes.string
|
|
103
|
+
axisId: PropTypes.string,
|
|
104
104
|
classes: PropTypes.object,
|
|
105
105
|
disableLine: PropTypes.bool,
|
|
106
106
|
disableTicks: PropTypes.bool,
|
|
@@ -127,7 +127,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
127
127
|
* @default yAxisIds[0] The id of the first provided axis
|
|
128
128
|
*/
|
|
129
129
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
130
|
-
axisId: PropTypes.string
|
|
130
|
+
axisId: PropTypes.string,
|
|
131
131
|
classes: PropTypes.object,
|
|
132
132
|
disableLine: PropTypes.bool,
|
|
133
133
|
disableTicks: PropTypes.bool,
|
|
@@ -154,7 +154,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
154
154
|
* @default null
|
|
155
155
|
*/
|
|
156
156
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
157
|
-
axisId: PropTypes.string
|
|
157
|
+
axisId: PropTypes.string,
|
|
158
158
|
classes: PropTypes.object,
|
|
159
159
|
disableLine: PropTypes.bool,
|
|
160
160
|
disableTicks: PropTypes.bool,
|
|
@@ -191,7 +191,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
191
191
|
* @default null
|
|
192
192
|
*/
|
|
193
193
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
194
|
-
axisId: PropTypes.string
|
|
194
|
+
axisId: PropTypes.string,
|
|
195
195
|
classes: PropTypes.object,
|
|
196
196
|
disableLine: PropTypes.bool,
|
|
197
197
|
disableTicks: PropTypes.bool,
|
|
@@ -3,6 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["rotate", "dominantBaseline"],
|
|
4
4
|
_excluded2 = ["label"];
|
|
5
5
|
import * as React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
6
7
|
import { useSlotProps } from '@mui/base/utils';
|
|
7
8
|
import { NoSsr } from '@mui/base/NoSsr';
|
|
8
9
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
@@ -10,7 +11,7 @@ import { useThemeProps, useTheme, styled } from '@mui/material/styles';
|
|
|
10
11
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
12
|
import { getSeriesToDisplay } from './utils';
|
|
12
13
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
13
|
-
import {
|
|
14
|
+
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
14
15
|
import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -25,7 +26,7 @@ const useUtilityClasses = ownerState => {
|
|
|
25
26
|
label: ['label'],
|
|
26
27
|
series: ['series']
|
|
27
28
|
};
|
|
28
|
-
return composeClasses(slots,
|
|
29
|
+
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
29
30
|
};
|
|
30
31
|
export const ChartsLegendRoot = styled('g', {
|
|
31
32
|
name: 'MuiChartsLegend',
|
|
@@ -233,7 +234,107 @@ function DefaultChartsLegend(props) {
|
|
|
233
234
|
})
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
|
-
|
|
237
|
+
process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
238
|
+
// ----------------------------- Warning --------------------------------
|
|
239
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
240
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
241
|
+
// ----------------------------------------------------------------------
|
|
242
|
+
/**
|
|
243
|
+
* Override or extend the styles applied to the component.
|
|
244
|
+
*/
|
|
245
|
+
classes: PropTypes.object.isRequired,
|
|
246
|
+
/**
|
|
247
|
+
* The direction of the legend layout.
|
|
248
|
+
* The default depends on the chart.
|
|
249
|
+
*/
|
|
250
|
+
direction: PropTypes.oneOf(['column', 'row']).isRequired,
|
|
251
|
+
drawingArea: PropTypes.shape({
|
|
252
|
+
bottom: PropTypes.number.isRequired,
|
|
253
|
+
height: PropTypes.number.isRequired,
|
|
254
|
+
left: PropTypes.number.isRequired,
|
|
255
|
+
right: PropTypes.number.isRequired,
|
|
256
|
+
top: PropTypes.number.isRequired,
|
|
257
|
+
width: PropTypes.number.isRequired
|
|
258
|
+
}).isRequired,
|
|
259
|
+
/**
|
|
260
|
+
* Set to true to hide the legend.
|
|
261
|
+
*/
|
|
262
|
+
hidden: PropTypes.bool,
|
|
263
|
+
/**
|
|
264
|
+
* Space between two legend items (in px).
|
|
265
|
+
* @default 10
|
|
266
|
+
*/
|
|
267
|
+
itemGap: PropTypes.number,
|
|
268
|
+
/**
|
|
269
|
+
* Height of the item mark (in px).
|
|
270
|
+
* @default 20
|
|
271
|
+
*/
|
|
272
|
+
itemMarkHeight: PropTypes.number,
|
|
273
|
+
/**
|
|
274
|
+
* Width of the item mark (in px).
|
|
275
|
+
* @default 20
|
|
276
|
+
*/
|
|
277
|
+
itemMarkWidth: PropTypes.number,
|
|
278
|
+
/**
|
|
279
|
+
* Style applied to legend labels.
|
|
280
|
+
* @default theme.typography.subtitle1
|
|
281
|
+
*/
|
|
282
|
+
labelStyle: PropTypes.object,
|
|
283
|
+
/**
|
|
284
|
+
* Space between the mark and the label (in px).
|
|
285
|
+
* @default 5
|
|
286
|
+
*/
|
|
287
|
+
markGap: PropTypes.number,
|
|
288
|
+
/**
|
|
289
|
+
* Legend padding (in px).
|
|
290
|
+
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
291
|
+
* @default 0
|
|
292
|
+
*/
|
|
293
|
+
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
294
|
+
bottom: PropTypes.number,
|
|
295
|
+
left: PropTypes.number,
|
|
296
|
+
right: PropTypes.number,
|
|
297
|
+
top: PropTypes.number
|
|
298
|
+
})]),
|
|
299
|
+
position: PropTypes.shape({
|
|
300
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
301
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
302
|
+
}).isRequired,
|
|
303
|
+
series: PropTypes.shape({
|
|
304
|
+
bar: PropTypes.shape({
|
|
305
|
+
series: PropTypes.object.isRequired,
|
|
306
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
307
|
+
stackingGroups: PropTypes.arrayOf(PropTypes.shape({
|
|
308
|
+
ids: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
309
|
+
stackingOffset: PropTypes.func.isRequired,
|
|
310
|
+
stackingOrder: PropTypes.func.isRequired
|
|
311
|
+
})).isRequired
|
|
312
|
+
}),
|
|
313
|
+
line: PropTypes.shape({
|
|
314
|
+
series: PropTypes.object.isRequired,
|
|
315
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
316
|
+
stackingGroups: PropTypes.arrayOf(PropTypes.shape({
|
|
317
|
+
ids: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
318
|
+
stackingOffset: PropTypes.func.isRequired,
|
|
319
|
+
stackingOrder: PropTypes.func.isRequired
|
|
320
|
+
})).isRequired
|
|
321
|
+
}),
|
|
322
|
+
pie: PropTypes.shape({
|
|
323
|
+
series: PropTypes.object.isRequired,
|
|
324
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
325
|
+
}),
|
|
326
|
+
scatter: PropTypes.shape({
|
|
327
|
+
series: PropTypes.object.isRequired,
|
|
328
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
329
|
+
})
|
|
330
|
+
}).isRequired,
|
|
331
|
+
seriesToDisplay: PropTypes.arrayOf(PropTypes.shape({
|
|
332
|
+
color: PropTypes.string.isRequired,
|
|
333
|
+
id: PropTypes.string.isRequired,
|
|
334
|
+
label: PropTypes.string.isRequired
|
|
335
|
+
})).isRequired
|
|
336
|
+
} : void 0;
|
|
337
|
+
function ChartsLegend(inProps) {
|
|
237
338
|
const props = useThemeProps({
|
|
238
339
|
props: _extends({}, defaultProps, inProps),
|
|
239
340
|
name: 'MuiChartsLegend'
|
|
@@ -268,4 +369,39 @@ export function ChartsLegend(inProps) {
|
|
|
268
369
|
ownerState: {}
|
|
269
370
|
});
|
|
270
371
|
return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
|
|
271
|
-
}
|
|
372
|
+
}
|
|
373
|
+
process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
374
|
+
// ----------------------------- Warning --------------------------------
|
|
375
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
376
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
377
|
+
// ----------------------------------------------------------------------
|
|
378
|
+
/**
|
|
379
|
+
* Override or extend the styles applied to the component.
|
|
380
|
+
*/
|
|
381
|
+
classes: PropTypes.object,
|
|
382
|
+
/**
|
|
383
|
+
* The direction of the legend layout.
|
|
384
|
+
* The default depends on the chart.
|
|
385
|
+
*/
|
|
386
|
+
direction: PropTypes.oneOf(['column', 'row']),
|
|
387
|
+
/**
|
|
388
|
+
* Set to true to hide the legend.
|
|
389
|
+
* @default false
|
|
390
|
+
*/
|
|
391
|
+
hidden: PropTypes.bool,
|
|
392
|
+
position: PropTypes.shape({
|
|
393
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
394
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
395
|
+
}),
|
|
396
|
+
/**
|
|
397
|
+
* The props used for each component slot.
|
|
398
|
+
* @default {}
|
|
399
|
+
*/
|
|
400
|
+
slotProps: PropTypes.object,
|
|
401
|
+
/**
|
|
402
|
+
* Overridable component slots.
|
|
403
|
+
* @default {}
|
|
404
|
+
*/
|
|
405
|
+
slots: PropTypes.object
|
|
406
|
+
} : void 0;
|
|
407
|
+
export { ChartsLegend };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
2
|
-
export function
|
|
2
|
+
export function getLegendUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiChartsLegend', slot);
|
|
4
4
|
}
|
|
5
5
|
export const legendClasses = generateUtilityClasses('MuiChartsLegend', ['root', 'series', 'mark', 'label', 'column', 'row']);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { ChartsXReferenceLine } from './ChartsXReferenceLine';
|
|
5
|
+
import { ChartsYReferenceLine } from './ChartsYReferenceLine';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
function ChartsReferenceLine(props) {
|
|
8
|
+
if (props.x !== undefined && props.y !== undefined) {
|
|
9
|
+
throw new Error('MUI-X: The ChartsReferenceLine can not have both `x` and `y` props set.');
|
|
10
|
+
}
|
|
11
|
+
if (props.x === undefined && props.y === undefined) {
|
|
12
|
+
throw new Error('MUI-X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
13
|
+
}
|
|
14
|
+
if (props.x !== undefined) {
|
|
15
|
+
return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/_jsx(ChartsYReferenceLine, _extends({}, props));
|
|
18
|
+
}
|
|
19
|
+
process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
|
|
20
|
+
// ----------------------------- Warning --------------------------------
|
|
21
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
22
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
23
|
+
// ----------------------------------------------------------------------
|
|
24
|
+
/**
|
|
25
|
+
* The id of the axis used for the reference value.
|
|
26
|
+
* @default The `id` of the first defined axis.
|
|
27
|
+
*/
|
|
28
|
+
axisId: PropTypes.string,
|
|
29
|
+
/**
|
|
30
|
+
* Override or extend the styles applied to the component.
|
|
31
|
+
*/
|
|
32
|
+
classes: PropTypes.object,
|
|
33
|
+
/**
|
|
34
|
+
* The label to display along the reference line.
|
|
35
|
+
*/
|
|
36
|
+
label: PropTypes.string,
|
|
37
|
+
/**
|
|
38
|
+
* The alignment if the label is in the chart drawing area.
|
|
39
|
+
* @default 'middle'
|
|
40
|
+
*/
|
|
41
|
+
labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
42
|
+
/**
|
|
43
|
+
* The style applied to the label.
|
|
44
|
+
*/
|
|
45
|
+
labelStyle: PropTypes.object,
|
|
46
|
+
/**
|
|
47
|
+
* The style applied to the line.
|
|
48
|
+
*/
|
|
49
|
+
lineStyle: PropTypes.object,
|
|
50
|
+
/**
|
|
51
|
+
* Additional space arround the label in px.
|
|
52
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
53
|
+
* @default 5
|
|
54
|
+
*/
|
|
55
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
56
|
+
x: PropTypes.number,
|
|
57
|
+
y: PropTypes.number
|
|
58
|
+
})]),
|
|
59
|
+
/**
|
|
60
|
+
* The x value associated with the reference line.
|
|
61
|
+
* If defined the reference line will be vertical.
|
|
62
|
+
*/
|
|
63
|
+
x: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]),
|
|
64
|
+
/**
|
|
65
|
+
* The y value associated with the reference line.
|
|
66
|
+
* If defined the reference line will be horizontal.
|
|
67
|
+
*/
|
|
68
|
+
y: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string])
|
|
69
|
+
} : void 0;
|
|
70
|
+
export { ChartsReferenceLine };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
import { useDrawingArea, useXScale } from '../hooks';
|
|
5
|
+
import { ReferenceLineRoot } from './common';
|
|
6
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
7
|
+
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const getTextParams = ({
|
|
11
|
+
top,
|
|
12
|
+
height,
|
|
13
|
+
spacingY,
|
|
14
|
+
labelAlign = 'middle'
|
|
15
|
+
}) => {
|
|
16
|
+
switch (labelAlign) {
|
|
17
|
+
case 'start':
|
|
18
|
+
return {
|
|
19
|
+
y: top + spacingY,
|
|
20
|
+
style: {
|
|
21
|
+
dominantBaseline: 'hanging',
|
|
22
|
+
textAnchor: 'start'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
case 'end':
|
|
26
|
+
return {
|
|
27
|
+
y: top + height - spacingY,
|
|
28
|
+
style: {
|
|
29
|
+
dominantBaseline: 'auto',
|
|
30
|
+
textAnchor: 'start'
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
default:
|
|
34
|
+
return {
|
|
35
|
+
y: top + height / 2,
|
|
36
|
+
style: {
|
|
37
|
+
dominantBaseline: 'central',
|
|
38
|
+
textAnchor: 'start'
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export function getXReferenceLineClasses(classes) {
|
|
44
|
+
return composeClasses({
|
|
45
|
+
root: ['root', 'vertical'],
|
|
46
|
+
line: ['line'],
|
|
47
|
+
label: ['label']
|
|
48
|
+
}, getReferenceLineUtilityClass, classes);
|
|
49
|
+
}
|
|
50
|
+
let warnedOnce = false;
|
|
51
|
+
function ChartsXReferenceLine(props) {
|
|
52
|
+
const {
|
|
53
|
+
x,
|
|
54
|
+
label = '',
|
|
55
|
+
spacing = 5,
|
|
56
|
+
classes: inClasses,
|
|
57
|
+
labelAlign,
|
|
58
|
+
lineStyle,
|
|
59
|
+
labelStyle,
|
|
60
|
+
axisId
|
|
61
|
+
} = props;
|
|
62
|
+
const {
|
|
63
|
+
top,
|
|
64
|
+
height
|
|
65
|
+
} = useDrawingArea();
|
|
66
|
+
const xAxisScale = useXScale(axisId);
|
|
67
|
+
const xPosition = xAxisScale(x);
|
|
68
|
+
if (xPosition === undefined) {
|
|
69
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
+
if (!warnedOnce) {
|
|
71
|
+
warnedOnce = true;
|
|
72
|
+
console.error(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const d = `M ${xPosition} ${top} l 0 ${height}`;
|
|
78
|
+
const classes = getXReferenceLineClasses(inClasses);
|
|
79
|
+
const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
|
|
80
|
+
const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
|
|
81
|
+
const textParams = _extends({
|
|
82
|
+
x: xPosition + spacingX,
|
|
83
|
+
text: label,
|
|
84
|
+
fontSize: 12
|
|
85
|
+
}, getTextParams({
|
|
86
|
+
top,
|
|
87
|
+
height,
|
|
88
|
+
spacingY,
|
|
89
|
+
labelAlign
|
|
90
|
+
}), {
|
|
91
|
+
className: classes.label
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/_jsxs(ReferenceLineRoot, {
|
|
94
|
+
className: classes.root,
|
|
95
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
96
|
+
d: d,
|
|
97
|
+
className: classes.line,
|
|
98
|
+
style: lineStyle
|
|
99
|
+
}), /*#__PURE__*/_jsx(ChartsText, _extends({}, textParams, {
|
|
100
|
+
style: _extends({}, textParams.style, labelStyle)
|
|
101
|
+
}))]
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export { ChartsXReferenceLine };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
import { useDrawingArea, useYScale } from '../hooks';
|
|
5
|
+
import { ReferenceLineRoot } from './common';
|
|
6
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
7
|
+
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const getTextParams = ({
|
|
11
|
+
left,
|
|
12
|
+
width,
|
|
13
|
+
spacingX,
|
|
14
|
+
labelAlign = 'middle'
|
|
15
|
+
}) => {
|
|
16
|
+
switch (labelAlign) {
|
|
17
|
+
case 'start':
|
|
18
|
+
return {
|
|
19
|
+
x: left + spacingX,
|
|
20
|
+
style: {
|
|
21
|
+
dominantBaseline: 'auto',
|
|
22
|
+
textAnchor: 'start'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
case 'end':
|
|
26
|
+
return {
|
|
27
|
+
x: left + width - spacingX,
|
|
28
|
+
style: {
|
|
29
|
+
dominantBaseline: 'auto',
|
|
30
|
+
textAnchor: 'end'
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
default:
|
|
34
|
+
return {
|
|
35
|
+
x: left + width / 2,
|
|
36
|
+
style: {
|
|
37
|
+
dominantBaseline: 'auto',
|
|
38
|
+
textAnchor: 'middle'
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
let warnedOnce = false;
|
|
44
|
+
export function getYReferenceLineClasses(classes) {
|
|
45
|
+
return composeClasses({
|
|
46
|
+
root: ['root', 'horizontal'],
|
|
47
|
+
line: ['line'],
|
|
48
|
+
label: ['label']
|
|
49
|
+
}, getReferenceLineUtilityClass, classes);
|
|
50
|
+
}
|
|
51
|
+
function ChartsYReferenceLine(props) {
|
|
52
|
+
const {
|
|
53
|
+
y,
|
|
54
|
+
label = '',
|
|
55
|
+
spacing = 5,
|
|
56
|
+
classes: inClasses,
|
|
57
|
+
labelAlign,
|
|
58
|
+
lineStyle,
|
|
59
|
+
labelStyle,
|
|
60
|
+
axisId
|
|
61
|
+
} = props;
|
|
62
|
+
const {
|
|
63
|
+
left,
|
|
64
|
+
width
|
|
65
|
+
} = useDrawingArea();
|
|
66
|
+
const yAxisScale = useYScale(axisId);
|
|
67
|
+
const yPosition = yAxisScale(y);
|
|
68
|
+
if (yPosition === undefined) {
|
|
69
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
+
if (!warnedOnce) {
|
|
71
|
+
warnedOnce = true;
|
|
72
|
+
console.error(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const d = `M ${left} ${yPosition} l ${width} 0`;
|
|
78
|
+
const classes = getYReferenceLineClasses(inClasses);
|
|
79
|
+
const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
|
|
80
|
+
const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
|
|
81
|
+
const textParams = _extends({
|
|
82
|
+
y: yPosition - spacingY,
|
|
83
|
+
text: label,
|
|
84
|
+
fontSize: 12
|
|
85
|
+
}, getTextParams({
|
|
86
|
+
left,
|
|
87
|
+
width,
|
|
88
|
+
spacingX,
|
|
89
|
+
labelAlign
|
|
90
|
+
}), {
|
|
91
|
+
className: classes.label
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/_jsxs(ReferenceLineRoot, {
|
|
94
|
+
className: classes.root,
|
|
95
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
96
|
+
d: d,
|
|
97
|
+
className: classes.line,
|
|
98
|
+
style: lineStyle
|
|
99
|
+
}), /*#__PURE__*/_jsx(ChartsText, _extends({}, textParams, {
|
|
100
|
+
style: _extends({}, textParams.style, labelStyle)
|
|
101
|
+
}))]
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export { ChartsYReferenceLine };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
export function getReferenceLineUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiChartsReferenceLine', slot);
|
|
5
|
+
}
|
|
6
|
+
export const referenceLineClasses = generateUtilityClasses('MuiChartsReferenceLine', ['root', 'vertical', 'horizontal', 'line', 'label']);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { referenceLineClasses } from './chartsReferenceLineClasses';
|
|
4
|
+
export const ReferenceLineRoot = styled('g')(({
|
|
5
|
+
theme
|
|
6
|
+
}) => ({
|
|
7
|
+
[`& .${referenceLineClasses.line}`]: {
|
|
8
|
+
fill: 'none',
|
|
9
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
10
|
+
shapeRendering: 'crispEdges',
|
|
11
|
+
strokeWidth: 1,
|
|
12
|
+
pointerEvents: 'none'
|
|
13
|
+
},
|
|
14
|
+
[`& .${referenceLineClasses.label}`]: _extends({
|
|
15
|
+
fill: (theme.vars || theme).palette.text.primary,
|
|
16
|
+
stroke: 'none',
|
|
17
|
+
pointerEvents: 'none',
|
|
18
|
+
fontSize: 12
|
|
19
|
+
}, theme.typography.body1)
|
|
20
|
+
}));
|
|
@@ -106,17 +106,20 @@ function ChartsXAxis(inProps) {
|
|
|
106
106
|
props: _extends({}, defaultProps, inProps),
|
|
107
107
|
name: 'MuiChartsXAxis'
|
|
108
108
|
});
|
|
109
|
+
const {
|
|
110
|
+
xAxisIds
|
|
111
|
+
} = React.useContext(CartesianContext);
|
|
109
112
|
const _React$useContext = React.useContext(CartesianContext),
|
|
110
|
-
|
|
113
|
+
_ref = props.axisId ?? xAxisIds[0],
|
|
111
114
|
{
|
|
112
115
|
xAxis: {
|
|
113
|
-
[
|
|
116
|
+
[_ref]: {
|
|
114
117
|
scale: xScale,
|
|
115
118
|
tickNumber
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
} = _React$useContext,
|
|
119
|
-
settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[
|
|
122
|
+
settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[_ref], _excluded);
|
|
120
123
|
const isMounted = useMounted();
|
|
121
124
|
const defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
122
125
|
const {
|
|
@@ -234,9 +237,10 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
234
237
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
235
238
|
// ----------------------------------------------------------------------
|
|
236
239
|
/**
|
|
237
|
-
*
|
|
240
|
+
* The id of the axis to render.
|
|
241
|
+
* If undefined, it will be the first defined axis.
|
|
238
242
|
*/
|
|
239
|
-
axisId: PropTypes.string
|
|
243
|
+
axisId: PropTypes.string,
|
|
240
244
|
/**
|
|
241
245
|
* Override or extend the styles applied to the component.
|
|
242
246
|
*/
|