@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
|
@@ -12,7 +12,8 @@ var getAxisId = function getAxisId(propsValue) {
|
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
if (_typeof(propsValue) === 'object') {
|
|
15
|
-
|
|
15
|
+
var _propsValue$axisId;
|
|
16
|
+
return (_propsValue$axisId = propsValue.axisId) != null ? _propsValue$axisId : null;
|
|
16
17
|
}
|
|
17
18
|
return propsValue;
|
|
18
19
|
};
|
|
@@ -98,7 +99,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
98
99
|
* @default xAxisIds[0] The id of the first provided axis
|
|
99
100
|
*/
|
|
100
101
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
101
|
-
axisId: PropTypes.string
|
|
102
|
+
axisId: PropTypes.string,
|
|
102
103
|
classes: PropTypes.object,
|
|
103
104
|
disableLine: PropTypes.bool,
|
|
104
105
|
disableTicks: PropTypes.bool,
|
|
@@ -125,7 +126,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
125
126
|
* @default yAxisIds[0] The id of the first provided axis
|
|
126
127
|
*/
|
|
127
128
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
128
|
-
axisId: PropTypes.string
|
|
129
|
+
axisId: PropTypes.string,
|
|
129
130
|
classes: PropTypes.object,
|
|
130
131
|
disableLine: PropTypes.bool,
|
|
131
132
|
disableTicks: PropTypes.bool,
|
|
@@ -152,7 +153,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
152
153
|
* @default null
|
|
153
154
|
*/
|
|
154
155
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
155
|
-
axisId: PropTypes.string
|
|
156
|
+
axisId: PropTypes.string,
|
|
156
157
|
classes: PropTypes.object,
|
|
157
158
|
disableLine: PropTypes.bool,
|
|
158
159
|
disableTicks: PropTypes.bool,
|
|
@@ -189,7 +190,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
189
190
|
* @default null
|
|
190
191
|
*/
|
|
191
192
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
192
|
-
axisId: PropTypes.string
|
|
193
|
+
axisId: PropTypes.string,
|
|
193
194
|
classes: PropTypes.object,
|
|
194
195
|
disableLine: PropTypes.bool,
|
|
195
196
|
disableTicks: PropTypes.bool,
|
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
var _excluded = ["rotate", "dominantBaseline"],
|
|
5
5
|
_excluded2 = ["label"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
7
8
|
import { useSlotProps } from '@mui/base/utils';
|
|
8
9
|
import { NoSsr } from '@mui/base/NoSsr';
|
|
9
10
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
@@ -11,7 +12,7 @@ import { useThemeProps, useTheme, styled } from '@mui/material/styles';
|
|
|
11
12
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
12
13
|
import { getSeriesToDisplay } from './utils';
|
|
13
14
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
14
|
-
import {
|
|
15
|
+
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
15
16
|
import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
|
|
16
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -24,7 +25,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
24
25
|
label: ['label'],
|
|
25
26
|
series: ['series']
|
|
26
27
|
};
|
|
27
|
-
return composeClasses(slots,
|
|
28
|
+
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
28
29
|
};
|
|
29
30
|
export var ChartsLegendRoot = styled('g', {
|
|
30
31
|
name: 'MuiChartsLegend',
|
|
@@ -247,7 +248,107 @@ function DefaultChartsLegend(props) {
|
|
|
247
248
|
})
|
|
248
249
|
});
|
|
249
250
|
}
|
|
250
|
-
|
|
251
|
+
process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
252
|
+
// ----------------------------- Warning --------------------------------
|
|
253
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
254
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
255
|
+
// ----------------------------------------------------------------------
|
|
256
|
+
/**
|
|
257
|
+
* Override or extend the styles applied to the component.
|
|
258
|
+
*/
|
|
259
|
+
classes: PropTypes.object.isRequired,
|
|
260
|
+
/**
|
|
261
|
+
* The direction of the legend layout.
|
|
262
|
+
* The default depends on the chart.
|
|
263
|
+
*/
|
|
264
|
+
direction: PropTypes.oneOf(['column', 'row']).isRequired,
|
|
265
|
+
drawingArea: PropTypes.shape({
|
|
266
|
+
bottom: PropTypes.number.isRequired,
|
|
267
|
+
height: PropTypes.number.isRequired,
|
|
268
|
+
left: PropTypes.number.isRequired,
|
|
269
|
+
right: PropTypes.number.isRequired,
|
|
270
|
+
top: PropTypes.number.isRequired,
|
|
271
|
+
width: PropTypes.number.isRequired
|
|
272
|
+
}).isRequired,
|
|
273
|
+
/**
|
|
274
|
+
* Set to true to hide the legend.
|
|
275
|
+
*/
|
|
276
|
+
hidden: PropTypes.bool,
|
|
277
|
+
/**
|
|
278
|
+
* Space between two legend items (in px).
|
|
279
|
+
* @default 10
|
|
280
|
+
*/
|
|
281
|
+
itemGap: PropTypes.number,
|
|
282
|
+
/**
|
|
283
|
+
* Height of the item mark (in px).
|
|
284
|
+
* @default 20
|
|
285
|
+
*/
|
|
286
|
+
itemMarkHeight: PropTypes.number,
|
|
287
|
+
/**
|
|
288
|
+
* Width of the item mark (in px).
|
|
289
|
+
* @default 20
|
|
290
|
+
*/
|
|
291
|
+
itemMarkWidth: PropTypes.number,
|
|
292
|
+
/**
|
|
293
|
+
* Style applied to legend labels.
|
|
294
|
+
* @default theme.typography.subtitle1
|
|
295
|
+
*/
|
|
296
|
+
labelStyle: PropTypes.object,
|
|
297
|
+
/**
|
|
298
|
+
* Space between the mark and the label (in px).
|
|
299
|
+
* @default 5
|
|
300
|
+
*/
|
|
301
|
+
markGap: PropTypes.number,
|
|
302
|
+
/**
|
|
303
|
+
* Legend padding (in px).
|
|
304
|
+
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
305
|
+
* @default 0
|
|
306
|
+
*/
|
|
307
|
+
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
308
|
+
bottom: PropTypes.number,
|
|
309
|
+
left: PropTypes.number,
|
|
310
|
+
right: PropTypes.number,
|
|
311
|
+
top: PropTypes.number
|
|
312
|
+
})]),
|
|
313
|
+
position: PropTypes.shape({
|
|
314
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
315
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
316
|
+
}).isRequired,
|
|
317
|
+
series: PropTypes.shape({
|
|
318
|
+
bar: PropTypes.shape({
|
|
319
|
+
series: PropTypes.object.isRequired,
|
|
320
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
321
|
+
stackingGroups: PropTypes.arrayOf(PropTypes.shape({
|
|
322
|
+
ids: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
323
|
+
stackingOffset: PropTypes.func.isRequired,
|
|
324
|
+
stackingOrder: PropTypes.func.isRequired
|
|
325
|
+
})).isRequired
|
|
326
|
+
}),
|
|
327
|
+
line: PropTypes.shape({
|
|
328
|
+
series: PropTypes.object.isRequired,
|
|
329
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
330
|
+
stackingGroups: PropTypes.arrayOf(PropTypes.shape({
|
|
331
|
+
ids: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
332
|
+
stackingOffset: PropTypes.func.isRequired,
|
|
333
|
+
stackingOrder: PropTypes.func.isRequired
|
|
334
|
+
})).isRequired
|
|
335
|
+
}),
|
|
336
|
+
pie: PropTypes.shape({
|
|
337
|
+
series: PropTypes.object.isRequired,
|
|
338
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
339
|
+
}),
|
|
340
|
+
scatter: PropTypes.shape({
|
|
341
|
+
series: PropTypes.object.isRequired,
|
|
342
|
+
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
343
|
+
})
|
|
344
|
+
}).isRequired,
|
|
345
|
+
seriesToDisplay: PropTypes.arrayOf(PropTypes.shape({
|
|
346
|
+
color: PropTypes.string.isRequired,
|
|
347
|
+
id: PropTypes.string.isRequired,
|
|
348
|
+
label: PropTypes.string.isRequired
|
|
349
|
+
})).isRequired
|
|
350
|
+
} : void 0;
|
|
351
|
+
function ChartsLegend(inProps) {
|
|
251
352
|
var _slots$legend;
|
|
252
353
|
var props = useThemeProps({
|
|
253
354
|
props: _extends({}, defaultProps, inProps),
|
|
@@ -281,4 +382,39 @@ export function ChartsLegend(inProps) {
|
|
|
281
382
|
ownerState: {}
|
|
282
383
|
});
|
|
283
384
|
return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
|
|
284
|
-
}
|
|
385
|
+
}
|
|
386
|
+
process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
387
|
+
// ----------------------------- Warning --------------------------------
|
|
388
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
389
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
390
|
+
// ----------------------------------------------------------------------
|
|
391
|
+
/**
|
|
392
|
+
* Override or extend the styles applied to the component.
|
|
393
|
+
*/
|
|
394
|
+
classes: PropTypes.object,
|
|
395
|
+
/**
|
|
396
|
+
* The direction of the legend layout.
|
|
397
|
+
* The default depends on the chart.
|
|
398
|
+
*/
|
|
399
|
+
direction: PropTypes.oneOf(['column', 'row']),
|
|
400
|
+
/**
|
|
401
|
+
* Set to true to hide the legend.
|
|
402
|
+
* @default false
|
|
403
|
+
*/
|
|
404
|
+
hidden: PropTypes.bool,
|
|
405
|
+
position: PropTypes.shape({
|
|
406
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
407
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
408
|
+
}),
|
|
409
|
+
/**
|
|
410
|
+
* The props used for each component slot.
|
|
411
|
+
* @default {}
|
|
412
|
+
*/
|
|
413
|
+
slotProps: PropTypes.object,
|
|
414
|
+
/**
|
|
415
|
+
* Overridable component slots.
|
|
416
|
+
* @default {}
|
|
417
|
+
*/
|
|
418
|
+
slots: PropTypes.object
|
|
419
|
+
} : void 0;
|
|
420
|
+
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 var 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,105 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
5
|
+
import { useDrawingArea, useXScale } from '../hooks';
|
|
6
|
+
import { ReferenceLineRoot } from './common';
|
|
7
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
8
|
+
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var getTextParams = function getTextParams(_ref) {
|
|
12
|
+
var top = _ref.top,
|
|
13
|
+
height = _ref.height,
|
|
14
|
+
spacingY = _ref.spacingY,
|
|
15
|
+
_ref$labelAlign = _ref.labelAlign,
|
|
16
|
+
labelAlign = _ref$labelAlign === void 0 ? 'middle' : _ref$labelAlign;
|
|
17
|
+
switch (labelAlign) {
|
|
18
|
+
case 'start':
|
|
19
|
+
return {
|
|
20
|
+
y: top + spacingY,
|
|
21
|
+
style: {
|
|
22
|
+
dominantBaseline: 'hanging',
|
|
23
|
+
textAnchor: 'start'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
case 'end':
|
|
27
|
+
return {
|
|
28
|
+
y: top + height - spacingY,
|
|
29
|
+
style: {
|
|
30
|
+
dominantBaseline: 'auto',
|
|
31
|
+
textAnchor: 'start'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
return {
|
|
36
|
+
y: top + height / 2,
|
|
37
|
+
style: {
|
|
38
|
+
dominantBaseline: 'central',
|
|
39
|
+
textAnchor: 'start'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export function getXReferenceLineClasses(classes) {
|
|
45
|
+
return composeClasses({
|
|
46
|
+
root: ['root', 'vertical'],
|
|
47
|
+
line: ['line'],
|
|
48
|
+
label: ['label']
|
|
49
|
+
}, getReferenceLineUtilityClass, classes);
|
|
50
|
+
}
|
|
51
|
+
var warnedOnce = false;
|
|
52
|
+
function ChartsXReferenceLine(props) {
|
|
53
|
+
var _spacing$x, _spacing$y;
|
|
54
|
+
var x = props.x,
|
|
55
|
+
_props$label = props.label,
|
|
56
|
+
label = _props$label === void 0 ? '' : _props$label,
|
|
57
|
+
_props$spacing = props.spacing,
|
|
58
|
+
spacing = _props$spacing === void 0 ? 5 : _props$spacing,
|
|
59
|
+
inClasses = props.classes,
|
|
60
|
+
labelAlign = props.labelAlign,
|
|
61
|
+
lineStyle = props.lineStyle,
|
|
62
|
+
labelStyle = props.labelStyle,
|
|
63
|
+
axisId = props.axisId;
|
|
64
|
+
var _useDrawingArea = useDrawingArea(),
|
|
65
|
+
top = _useDrawingArea.top,
|
|
66
|
+
height = _useDrawingArea.height;
|
|
67
|
+
var xAxisScale = useXScale(axisId);
|
|
68
|
+
var xPosition = xAxisScale(x);
|
|
69
|
+
if (xPosition === undefined) {
|
|
70
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
71
|
+
if (!warnedOnce) {
|
|
72
|
+
warnedOnce = true;
|
|
73
|
+
console.error("MUI X: the value ".concat(x, " does not exist in the data of x axis with id ").concat(axisId, "."));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
var d = "M ".concat(xPosition, " ").concat(top, " l 0 ").concat(height);
|
|
79
|
+
var classes = getXReferenceLineClasses(inClasses);
|
|
80
|
+
var spacingX = _typeof(spacing) === 'object' ? (_spacing$x = spacing.x) != null ? _spacing$x : 0 : spacing;
|
|
81
|
+
var spacingY = _typeof(spacing) === 'object' ? (_spacing$y = spacing.y) != null ? _spacing$y : 0 : spacing;
|
|
82
|
+
var textParams = _extends({
|
|
83
|
+
x: xPosition + spacingX,
|
|
84
|
+
text: label,
|
|
85
|
+
fontSize: 12
|
|
86
|
+
}, getTextParams({
|
|
87
|
+
top: top,
|
|
88
|
+
height: height,
|
|
89
|
+
spacingY: spacingY,
|
|
90
|
+
labelAlign: labelAlign
|
|
91
|
+
}), {
|
|
92
|
+
className: classes.label
|
|
93
|
+
});
|
|
94
|
+
return /*#__PURE__*/_jsxs(ReferenceLineRoot, {
|
|
95
|
+
className: classes.root,
|
|
96
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
97
|
+
d: d,
|
|
98
|
+
className: classes.line,
|
|
99
|
+
style: lineStyle
|
|
100
|
+
}), /*#__PURE__*/_jsx(ChartsText, _extends({}, textParams, {
|
|
101
|
+
style: _extends({}, textParams.style, labelStyle)
|
|
102
|
+
}))]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export { ChartsXReferenceLine };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
5
|
+
import { useDrawingArea, useYScale } from '../hooks';
|
|
6
|
+
import { ReferenceLineRoot } from './common';
|
|
7
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
8
|
+
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var getTextParams = function getTextParams(_ref) {
|
|
12
|
+
var left = _ref.left,
|
|
13
|
+
width = _ref.width,
|
|
14
|
+
spacingX = _ref.spacingX,
|
|
15
|
+
_ref$labelAlign = _ref.labelAlign,
|
|
16
|
+
labelAlign = _ref$labelAlign === void 0 ? 'middle' : _ref$labelAlign;
|
|
17
|
+
switch (labelAlign) {
|
|
18
|
+
case 'start':
|
|
19
|
+
return {
|
|
20
|
+
x: left + spacingX,
|
|
21
|
+
style: {
|
|
22
|
+
dominantBaseline: 'auto',
|
|
23
|
+
textAnchor: 'start'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
case 'end':
|
|
27
|
+
return {
|
|
28
|
+
x: left + width - spacingX,
|
|
29
|
+
style: {
|
|
30
|
+
dominantBaseline: 'auto',
|
|
31
|
+
textAnchor: 'end'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
return {
|
|
36
|
+
x: left + width / 2,
|
|
37
|
+
style: {
|
|
38
|
+
dominantBaseline: 'auto',
|
|
39
|
+
textAnchor: 'middle'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var warnedOnce = false;
|
|
45
|
+
export function getYReferenceLineClasses(classes) {
|
|
46
|
+
return composeClasses({
|
|
47
|
+
root: ['root', 'horizontal'],
|
|
48
|
+
line: ['line'],
|
|
49
|
+
label: ['label']
|
|
50
|
+
}, getReferenceLineUtilityClass, classes);
|
|
51
|
+
}
|
|
52
|
+
function ChartsYReferenceLine(props) {
|
|
53
|
+
var _spacing$x, _spacing$y;
|
|
54
|
+
var y = props.y,
|
|
55
|
+
_props$label = props.label,
|
|
56
|
+
label = _props$label === void 0 ? '' : _props$label,
|
|
57
|
+
_props$spacing = props.spacing,
|
|
58
|
+
spacing = _props$spacing === void 0 ? 5 : _props$spacing,
|
|
59
|
+
inClasses = props.classes,
|
|
60
|
+
labelAlign = props.labelAlign,
|
|
61
|
+
lineStyle = props.lineStyle,
|
|
62
|
+
labelStyle = props.labelStyle,
|
|
63
|
+
axisId = props.axisId;
|
|
64
|
+
var _useDrawingArea = useDrawingArea(),
|
|
65
|
+
left = _useDrawingArea.left,
|
|
66
|
+
width = _useDrawingArea.width;
|
|
67
|
+
var yAxisScale = useYScale(axisId);
|
|
68
|
+
var yPosition = yAxisScale(y);
|
|
69
|
+
if (yPosition === undefined) {
|
|
70
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
71
|
+
if (!warnedOnce) {
|
|
72
|
+
warnedOnce = true;
|
|
73
|
+
console.error("MUI X: the value ".concat(y, " does not exist in the data of y axis with id ").concat(axisId, "."));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
var d = "M ".concat(left, " ").concat(yPosition, " l ").concat(width, " 0");
|
|
79
|
+
var classes = getYReferenceLineClasses(inClasses);
|
|
80
|
+
var spacingX = _typeof(spacing) === 'object' ? (_spacing$x = spacing.x) != null ? _spacing$x : 0 : spacing;
|
|
81
|
+
var spacingY = _typeof(spacing) === 'object' ? (_spacing$y = spacing.y) != null ? _spacing$y : 0 : spacing;
|
|
82
|
+
var textParams = _extends({
|
|
83
|
+
y: yPosition - spacingY,
|
|
84
|
+
text: label,
|
|
85
|
+
fontSize: 12
|
|
86
|
+
}, getTextParams({
|
|
87
|
+
left: left,
|
|
88
|
+
width: width,
|
|
89
|
+
spacingX: spacingX,
|
|
90
|
+
labelAlign: labelAlign
|
|
91
|
+
}), {
|
|
92
|
+
className: classes.label
|
|
93
|
+
});
|
|
94
|
+
return /*#__PURE__*/_jsxs(ReferenceLineRoot, {
|
|
95
|
+
className: classes.root,
|
|
96
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
97
|
+
d: d,
|
|
98
|
+
className: classes.line,
|
|
99
|
+
style: lineStyle
|
|
100
|
+
}), /*#__PURE__*/_jsx(ChartsText, _extends({}, textParams, {
|
|
101
|
+
style: _extends({}, textParams.style, labelStyle)
|
|
102
|
+
}))]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
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 var referenceLineClasses = generateUtilityClasses('MuiChartsReferenceLine', ['root', 'vertical', 'horizontal', 'line', 'label']);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { referenceLineClasses } from './chartsReferenceLineClasses';
|
|
5
|
+
export var ReferenceLineRoot = styled('g')(function (_ref) {
|
|
6
|
+
var _ref2;
|
|
7
|
+
var theme = _ref.theme;
|
|
8
|
+
return _ref2 = {}, _defineProperty(_ref2, "& .".concat(referenceLineClasses.line), {
|
|
9
|
+
fill: 'none',
|
|
10
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
11
|
+
shapeRendering: 'crispEdges',
|
|
12
|
+
strokeWidth: 1,
|
|
13
|
+
pointerEvents: 'none'
|
|
14
|
+
}), _defineProperty(_ref2, "& .".concat(referenceLineClasses.label), _extends({
|
|
15
|
+
fill: (theme.vars || theme).palette.text.primary,
|
|
16
|
+
stroke: 'none',
|
|
17
|
+
pointerEvents: 'none',
|
|
18
|
+
fontSize: 12
|
|
19
|
+
}, theme.typography.body1)), _ref2;
|
|
20
|
+
});
|
|
@@ -102,16 +102,18 @@ var defaultProps = {
|
|
|
102
102
|
* - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
|
|
103
103
|
*/
|
|
104
104
|
function ChartsXAxis(inProps) {
|
|
105
|
-
var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
105
|
+
var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
106
106
|
var props = useThemeProps({
|
|
107
107
|
props: _extends({}, defaultProps, inProps),
|
|
108
108
|
name: 'MuiChartsXAxis'
|
|
109
109
|
});
|
|
110
110
|
var _React$useContext = React.useContext(CartesianContext),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
xAxisIds = _React$useContext.xAxisIds;
|
|
112
|
+
var _React$useContext2 = React.useContext(CartesianContext),
|
|
113
|
+
_React$useContext2$xA = _React$useContext2.xAxis[(_props$axisId = props.axisId) != null ? _props$axisId : xAxisIds[0]],
|
|
114
|
+
xScale = _React$useContext2$xA.scale,
|
|
115
|
+
tickNumber = _React$useContext2$xA.tickNumber,
|
|
116
|
+
settings = _objectWithoutProperties(_React$useContext2$xA, _excluded);
|
|
115
117
|
var isMounted = useMounted();
|
|
116
118
|
var defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
117
119
|
var position = defaultizedProps.position,
|
|
@@ -132,11 +134,11 @@ function ChartsXAxis(inProps) {
|
|
|
132
134
|
var classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
133
135
|
theme: theme
|
|
134
136
|
}));
|
|
135
|
-
var _React$
|
|
136
|
-
left = _React$
|
|
137
|
-
top = _React$
|
|
138
|
-
width = _React$
|
|
139
|
-
height = _React$
|
|
137
|
+
var _React$useContext3 = React.useContext(DrawingContext),
|
|
138
|
+
left = _React$useContext3.left,
|
|
139
|
+
top = _React$useContext3.top,
|
|
140
|
+
width = _React$useContext3.width,
|
|
141
|
+
height = _React$useContext3.height;
|
|
140
142
|
var tickSize = disableTicks ? 4 : tickSizeProp;
|
|
141
143
|
var positionSign = position === 'bottom' ? 1 : -1;
|
|
142
144
|
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
@@ -225,9 +227,10 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
225
227
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
226
228
|
// ----------------------------------------------------------------------
|
|
227
229
|
/**
|
|
228
|
-
*
|
|
230
|
+
* The id of the axis to render.
|
|
231
|
+
* If undefined, it will be the first defined axis.
|
|
229
232
|
*/
|
|
230
|
-
axisId: PropTypes.string
|
|
233
|
+
axisId: PropTypes.string,
|
|
231
234
|
/**
|
|
232
235
|
* Override or extend the styles applied to the component.
|
|
233
236
|
*/
|
|
@@ -46,16 +46,18 @@ var defaultProps = {
|
|
|
46
46
|
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
47
47
|
*/
|
|
48
48
|
function ChartsYAxis(inProps) {
|
|
49
|
-
var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
49
|
+
var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
50
50
|
var props = useThemeProps({
|
|
51
51
|
props: _extends({}, defaultProps, inProps),
|
|
52
52
|
name: 'MuiChartsYAxis'
|
|
53
53
|
});
|
|
54
54
|
var _React$useContext = React.useContext(CartesianContext),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
yAxisIds = _React$useContext.yAxisIds;
|
|
56
|
+
var _React$useContext2 = React.useContext(CartesianContext),
|
|
57
|
+
_React$useContext2$yA = _React$useContext2.yAxis[(_props$axisId = props.axisId) != null ? _props$axisId : yAxisIds[0]],
|
|
58
|
+
yScale = _React$useContext2$yA.scale,
|
|
59
|
+
tickNumber = _React$useContext2$yA.tickNumber,
|
|
60
|
+
settings = _objectWithoutProperties(_React$useContext2$yA, _excluded);
|
|
59
61
|
var defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
60
62
|
var position = defaultizedProps.position,
|
|
61
63
|
disableLine = defaultizedProps.disableLine,
|
|
@@ -71,11 +73,11 @@ function ChartsYAxis(inProps) {
|
|
|
71
73
|
var classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
72
74
|
theme: theme
|
|
73
75
|
}));
|
|
74
|
-
var _React$
|
|
75
|
-
left = _React$
|
|
76
|
-
top = _React$
|
|
77
|
-
width = _React$
|
|
78
|
-
height = _React$
|
|
76
|
+
var _React$useContext3 = React.useContext(DrawingContext),
|
|
77
|
+
left = _React$useContext3.left,
|
|
78
|
+
top = _React$useContext3.top,
|
|
79
|
+
width = _React$useContext3.width,
|
|
80
|
+
height = _React$useContext3.height;
|
|
79
81
|
var tickSize = disableTicks ? 4 : tickSizeProp;
|
|
80
82
|
var yTicks = useTicks({
|
|
81
83
|
scale: yScale,
|
|
@@ -156,9 +158,10 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
156
158
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
157
159
|
// ----------------------------------------------------------------------
|
|
158
160
|
/**
|
|
159
|
-
*
|
|
161
|
+
* The id of the axis to render.
|
|
162
|
+
* If undefined, it will be the first defined axis.
|
|
160
163
|
*/
|
|
161
|
-
axisId: PropTypes.string
|
|
164
|
+
axisId: PropTypes.string,
|
|
162
165
|
/**
|
|
163
166
|
* Override or extend the styles applied to the component.
|
|
164
167
|
*/
|