@mui/x-charts 7.0.0-alpha.5 → 7.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +1 -0
- package/BarChart/BarElement.d.ts +37 -20
- package/BarChart/BarPlot.js +4 -4
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +357 -49
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsReferenceLine/ChartsReferenceLine.js +9 -5
- package/ChartsSurface.d.ts +2 -2
- package/ChartsSurface.js +33 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/ChartsTooltip/ChartsTooltipTable.js +2 -0
- package/LineChart/AreaPlot.js +2 -2
- package/LineChart/LineChart.d.ts +1 -0
- package/LineChart/LineChart.js +2 -0
- package/LineChart/LineHighlightPlot.js +1 -1
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/MarkPlot.js +1 -1
- package/LineChart/formatter.js +2 -2
- package/PieChart/PieArcLabel.d.ts +1 -0
- package/PieChart/PieArcLabel.js +7 -8
- package/PieChart/PieArcLabelPlot.d.ts +5 -0
- package/PieChart/PieArcLabelPlot.js +16 -3
- package/PieChart/PieArcPlot.d.ts +5 -0
- package/PieChart/PieArcPlot.js +9 -1
- package/PieChart/PieChart.d.ts +14 -2
- package/PieChart/PieChart.js +6 -2
- package/PieChart/PiePlot.js +3 -0
- package/PieChart/dataTransform/transition.js +9 -2
- package/PieChart/dataTransform/useTransformData.d.ts +1 -0
- package/PieChart/dataTransform/useTransformData.js +11 -8
- package/ResponsiveChartContainer/index.js +2 -2
- package/ScatterChart/ScatterChart.js +1 -0
- package/SparkLineChart/SparkLineChart.d.ts +15 -1
- package/SparkLineChart/SparkLineChart.js +8 -1
- package/context/CartesianContextProvider.d.ts +1 -1
- package/context/CartesianContextProvider.js +9 -8
- package/context/DrawingProvider.d.ts +1 -1
- package/context/DrawingProvider.js +8 -7
- package/context/HighlightProvider.d.ts +2 -2
- package/context/HighlightProvider.js +4 -3
- package/context/InteractionProvider.d.ts +2 -2
- package/context/InteractionProvider.js +4 -3
- package/context/SeriesContextProvider.d.ts +3 -1
- package/context/SeriesContextProvider.js +8 -7
- package/esm/BarChart/BarChart.js +1 -0
- package/esm/BarChart/BarPlot.js +4 -4
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +9 -5
- package/esm/ChartsSurface.js +35 -2
- package/esm/ChartsTooltip/ChartsTooltipTable.js +2 -0
- package/esm/LineChart/AreaPlot.js +2 -2
- package/esm/LineChart/LineChart.js +2 -0
- package/esm/LineChart/LineHighlightPlot.js +1 -1
- package/esm/LineChart/LinePlot.js +2 -2
- package/esm/LineChart/MarkPlot.js +1 -1
- package/esm/LineChart/formatter.js +2 -2
- package/esm/PieChart/PieArcLabel.js +7 -8
- package/esm/PieChart/PieArcLabelPlot.js +16 -3
- package/esm/PieChart/PieArcPlot.js +9 -1
- package/esm/PieChart/PieChart.js +6 -2
- package/esm/PieChart/PiePlot.js +3 -0
- package/esm/PieChart/dataTransform/transition.js +9 -2
- package/esm/PieChart/dataTransform/useTransformData.js +12 -9
- package/esm/ResponsiveChartContainer/index.js +2 -2
- package/esm/ScatterChart/ScatterChart.js +1 -0
- package/esm/SparkLineChart/SparkLineChart.js +8 -1
- package/esm/context/CartesianContextProvider.js +9 -8
- package/esm/context/DrawingProvider.js +8 -7
- package/esm/context/HighlightProvider.js +6 -4
- package/esm/context/InteractionProvider.js +6 -4
- package/esm/context/SeriesContextProvider.js +10 -8
- package/esm/index.js +1 -0
- package/esm/internals/domUtils.js +3 -1
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +3 -0
- package/internals/domUtils.js +3 -1
- package/legacy/BarChart/BarChart.js +1 -0
- package/legacy/BarChart/BarPlot.js +4 -4
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +7 -5
- package/legacy/ChartsSurface.js +35 -2
- package/legacy/ChartsTooltip/ChartsTooltipTable.js +2 -0
- package/legacy/LineChart/AreaPlot.js +2 -2
- package/legacy/LineChart/LineChart.js +2 -0
- package/legacy/LineChart/LineHighlightPlot.js +1 -1
- package/legacy/LineChart/LinePlot.js +2 -2
- package/legacy/LineChart/MarkPlot.js +1 -1
- package/legacy/LineChart/formatter.js +2 -2
- package/legacy/PieChart/PieArcLabel.js +7 -8
- package/legacy/PieChart/PieArcLabelPlot.js +16 -4
- package/legacy/PieChart/PieArcPlot.js +10 -1
- package/legacy/PieChart/PieChart.js +6 -2
- package/legacy/PieChart/PiePlot.js +3 -0
- package/legacy/PieChart/dataTransform/transition.js +9 -2
- package/legacy/PieChart/dataTransform/useTransformData.js +12 -9
- package/legacy/ResponsiveChartContainer/index.js +2 -2
- package/legacy/ScatterChart/ScatterChart.js +1 -0
- package/legacy/SparkLineChart/SparkLineChart.js +8 -1
- package/legacy/context/CartesianContextProvider.js +17 -17
- package/legacy/context/DrawingProvider.js +6 -6
- package/legacy/context/HighlightProvider.js +4 -3
- package/legacy/context/InteractionProvider.js +4 -3
- package/legacy/context/SeriesContextProvider.js +9 -8
- package/legacy/index.js +2 -1
- package/legacy/internals/domUtils.js +3 -3
- package/models/seriesType/pie.d.ts +15 -0
- package/modern/BarChart/BarChart.js +1 -0
- package/modern/BarChart/BarPlot.js +4 -4
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +9 -5
- package/modern/ChartsSurface.js +35 -2
- package/modern/ChartsTooltip/ChartsTooltipTable.js +2 -0
- package/modern/LineChart/AreaPlot.js +2 -2
- package/modern/LineChart/LineChart.js +2 -0
- package/modern/LineChart/LineHighlightPlot.js +1 -1
- package/modern/LineChart/LinePlot.js +2 -2
- package/modern/LineChart/MarkPlot.js +1 -1
- package/modern/LineChart/formatter.js +2 -2
- package/modern/PieChart/PieArcLabel.js +7 -8
- package/modern/PieChart/PieArcLabelPlot.js +16 -3
- package/modern/PieChart/PieArcPlot.js +9 -1
- package/modern/PieChart/PieChart.js +6 -2
- package/modern/PieChart/PiePlot.js +3 -0
- package/modern/PieChart/dataTransform/transition.js +9 -2
- package/modern/PieChart/dataTransform/useTransformData.js +11 -8
- package/modern/ResponsiveChartContainer/index.js +2 -2
- package/modern/ScatterChart/ScatterChart.js +1 -0
- package/modern/SparkLineChart/SparkLineChart.js +8 -1
- package/modern/context/CartesianContextProvider.js +9 -8
- package/modern/context/DrawingProvider.js +8 -7
- package/modern/context/HighlightProvider.js +6 -4
- package/modern/context/InteractionProvider.js +6 -4
- package/modern/context/SeriesContextProvider.js +10 -8
- package/modern/index.js +2 -1
- package/modern/internals/domUtils.js +3 -1
- package/package.json +5 -5
|
@@ -34,13 +34,14 @@ const SVGContext = exports.SVGContext = /*#__PURE__*/React.createContext({
|
|
|
34
34
|
*
|
|
35
35
|
* - [DrawingProvider API](https://mui.com/x/api/charts/drawing-provider/)
|
|
36
36
|
*/
|
|
37
|
-
function DrawingProvider({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
function DrawingProvider(props) {
|
|
38
|
+
const {
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
margin,
|
|
42
|
+
svgRef,
|
|
43
|
+
children
|
|
44
|
+
} = props;
|
|
44
45
|
const drawingArea = (0, _useChartDimensions.default)(width, height, margin);
|
|
45
46
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SVGContext.Provider, {
|
|
46
47
|
value: svgRef,
|
|
@@ -41,5 +41,5 @@ type HighlighState = {
|
|
|
41
41
|
dispatch: React.Dispatch<HighlighActions>;
|
|
42
42
|
};
|
|
43
43
|
export declare const HighlighContext: React.Context<HighlighState>;
|
|
44
|
-
|
|
45
|
-
export {};
|
|
44
|
+
declare function HighlightProvider(props: HighlightProviderProps): React.JSX.Element;
|
|
45
|
+
export { HighlightProvider };
|
|
@@ -39,9 +39,10 @@ const dataReducer = (prevState, action) => {
|
|
|
39
39
|
return prevState;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
function HighlightProvider({
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
function HighlightProvider(props) {
|
|
43
|
+
const {
|
|
44
|
+
children
|
|
45
|
+
} = props;
|
|
45
46
|
const [data, dispatch] = React.useReducer(dataReducer, {
|
|
46
47
|
item: null,
|
|
47
48
|
scope: defaultScope
|
|
@@ -46,5 +46,5 @@ type InteractionState = {
|
|
|
46
46
|
dispatch: React.Dispatch<InteractionActions>;
|
|
47
47
|
};
|
|
48
48
|
export declare const InteractionContext: React.Context<InteractionState>;
|
|
49
|
-
|
|
50
|
-
export {};
|
|
49
|
+
declare function InteractionProvider(props: InteractionProviderProps): React.JSX.Element;
|
|
50
|
+
export { InteractionProvider };
|
|
@@ -60,9 +60,10 @@ const dataReducer = (prevState, action) => {
|
|
|
60
60
|
return prevState;
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
function InteractionProvider({
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
function InteractionProvider(props) {
|
|
64
|
+
const {
|
|
65
|
+
children
|
|
66
|
+
} = props;
|
|
66
67
|
const [data, dispatch] = React.useReducer(dataReducer, {
|
|
67
68
|
item: null,
|
|
68
69
|
axis: {
|
|
@@ -12,6 +12,7 @@ export type SeriesContextProviderProps = {
|
|
|
12
12
|
series: AllSeriesType[];
|
|
13
13
|
/**
|
|
14
14
|
* Color palette used to colorize multiple series.
|
|
15
|
+
* @default blueberryTwilightPalette
|
|
15
16
|
*/
|
|
16
17
|
colors?: ChartsColorPalette;
|
|
17
18
|
children: React.ReactNode;
|
|
@@ -20,4 +21,5 @@ export type FormattedSeries = {
|
|
|
20
21
|
[type in ChartSeriesType]?: FormatterResult<type>;
|
|
21
22
|
};
|
|
22
23
|
export declare const SeriesContext: React.Context<FormattedSeries>;
|
|
23
|
-
|
|
24
|
+
declare function SeriesContextProvider(props: SeriesContextProviderProps): React.JSX.Element;
|
|
25
|
+
export { SeriesContextProvider };
|
|
@@ -49,7 +49,7 @@ const formatSeries = (series, colors, dataset) => {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
if (seriesGroups[type]?.series[id] !== undefined) {
|
|
52
|
-
throw new Error(`MUI
|
|
52
|
+
throw new Error(`MUI X Charts: series' id "${id}" is not unique.`);
|
|
53
53
|
}
|
|
54
54
|
seriesGroups[type].series[id] = (0, _extends2.default)({
|
|
55
55
|
id
|
|
@@ -65,12 +65,13 @@ const formatSeries = (series, colors, dataset) => {
|
|
|
65
65
|
});
|
|
66
66
|
return formattedSeries;
|
|
67
67
|
};
|
|
68
|
-
function SeriesContextProvider({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
function SeriesContextProvider(props) {
|
|
69
|
+
const {
|
|
70
|
+
series,
|
|
71
|
+
dataset,
|
|
72
|
+
colors = _colorPalettes.blueberryTwilightPalette,
|
|
73
|
+
children
|
|
74
|
+
} = props;
|
|
74
75
|
const theme = (0, _styles.useTheme)();
|
|
75
76
|
const formattedSeries = React.useMemo(() => formatSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, dataset), [series, colors, theme.palette.mode, dataset]);
|
|
76
77
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SeriesContext.Provider, {
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -156,6 +156,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
156
156
|
className: PropTypes.string,
|
|
157
157
|
/**
|
|
158
158
|
* Color palette used to colorize multiple series.
|
|
159
|
+
* @default blueberryTwilightPalette
|
|
159
160
|
*/
|
|
160
161
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
161
162
|
/**
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -71,18 +71,18 @@ const useCompletedData = () => {
|
|
|
71
71
|
let baseScaleConfig;
|
|
72
72
|
if (verticalLayout) {
|
|
73
73
|
if (!isBandScaleConfig(xAxisConfig)) {
|
|
74
|
-
throw new Error(`MUI
|
|
74
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}".`);
|
|
75
75
|
}
|
|
76
76
|
if (xAxis[xAxisKey].data === undefined) {
|
|
77
|
-
throw new Error(`MUI
|
|
77
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud have data property.`);
|
|
78
78
|
}
|
|
79
79
|
baseScaleConfig = xAxisConfig;
|
|
80
80
|
} else {
|
|
81
81
|
if (!isBandScaleConfig(yAxisConfig)) {
|
|
82
|
-
throw new Error(`MUI
|
|
82
|
+
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}".`);
|
|
83
83
|
}
|
|
84
84
|
if (yAxis[yAxisKey].data === undefined) {
|
|
85
|
-
throw new Error(`MUI
|
|
85
|
+
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud have data property.`);
|
|
86
86
|
}
|
|
87
87
|
baseScaleConfig = yAxisConfig;
|
|
88
88
|
}
|
|
@@ -26,7 +26,7 @@ const formatter = (params, dataset) => {
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
} else if (dataset === undefined) {
|
|
29
|
-
throw new Error([`MUI
|
|
29
|
+
throw new Error([`MUI X Charts: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
const completedSeries = {};
|
|
@@ -59,16 +59,16 @@ function ChartsAxis(props) {
|
|
|
59
59
|
const topId = getAxisId(topAxis);
|
|
60
60
|
const rightId = getAxisId(rightAxis);
|
|
61
61
|
if (topId !== null && !xAxis[topId]) {
|
|
62
|
-
throw Error([`MUI
|
|
62
|
+
throw Error([`MUI X Charts: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
63
63
|
}
|
|
64
64
|
if (leftId !== null && !yAxis[leftId]) {
|
|
65
|
-
throw Error([`MUI
|
|
65
|
+
throw Error([`MUI X Charts: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
66
66
|
}
|
|
67
67
|
if (rightId !== null && !yAxis[rightId]) {
|
|
68
|
-
throw Error([`MUI
|
|
68
|
+
throw Error([`MUI X Charts: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
69
69
|
}
|
|
70
70
|
if (bottomId !== null && !xAxis[bottomId]) {
|
|
71
|
-
throw Error([`MUI
|
|
71
|
+
throw Error([`MUI X Charts: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
72
72
|
}
|
|
73
73
|
const topAxisProps = mergeProps(topAxis, slots, slotProps);
|
|
74
74
|
const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
|
|
@@ -5,13 +5,17 @@ import { ChartsXReferenceLine } from './ChartsXReferenceLine';
|
|
|
5
5
|
import { ChartsYReferenceLine } from './ChartsYReferenceLine';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
function ChartsReferenceLine(props) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const {
|
|
9
|
+
x,
|
|
10
|
+
y
|
|
11
|
+
} = props;
|
|
12
|
+
if (x !== undefined && y !== undefined) {
|
|
13
|
+
throw new Error('MUI X Charts: The ChartsReferenceLine can not have both `x` and `y` props set.');
|
|
10
14
|
}
|
|
11
|
-
if (
|
|
12
|
-
throw new Error('MUI
|
|
15
|
+
if (x === undefined && y === undefined) {
|
|
16
|
+
throw new Error('MUI X Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
13
17
|
}
|
|
14
|
-
if (
|
|
18
|
+
if (x !== undefined) {
|
|
15
19
|
return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
|
|
16
20
|
}
|
|
17
21
|
return /*#__PURE__*/_jsx(ChartsYReferenceLine, _extends({}, props));
|
package/esm/ChartsSurface.js
CHANGED
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import * as React from 'react';
|
|
6
7
|
import { useAxisEvents } from './hooks/useAxisEvents';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -10,7 +11,7 @@ const ChartChartsSurfaceStyles = styled('svg', {
|
|
|
10
11
|
name: 'MuiChartsSurface',
|
|
11
12
|
slot: 'Root'
|
|
12
13
|
})(() => ({}));
|
|
13
|
-
|
|
14
|
+
const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
|
|
14
15
|
const {
|
|
15
16
|
children,
|
|
16
17
|
width,
|
|
@@ -38,4 +39,36 @@ export const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurfac
|
|
|
38
39
|
children: props.desc
|
|
39
40
|
}), children]
|
|
40
41
|
}));
|
|
41
|
-
});
|
|
42
|
+
});
|
|
43
|
+
process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
|
|
44
|
+
// ----------------------------- Warning --------------------------------
|
|
45
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
46
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
47
|
+
// ----------------------------------------------------------------------
|
|
48
|
+
children: PropTypes.node,
|
|
49
|
+
className: PropTypes.string,
|
|
50
|
+
desc: PropTypes.string,
|
|
51
|
+
/**
|
|
52
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
53
|
+
* It might break interactive features, but will improve performance.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
disableAxisListener: PropTypes.bool,
|
|
57
|
+
/**
|
|
58
|
+
* The height of the chart in px.
|
|
59
|
+
*/
|
|
60
|
+
height: PropTypes.number.isRequired,
|
|
61
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
62
|
+
title: PropTypes.string,
|
|
63
|
+
viewBox: PropTypes.shape({
|
|
64
|
+
height: PropTypes.number,
|
|
65
|
+
width: PropTypes.number,
|
|
66
|
+
x: PropTypes.number,
|
|
67
|
+
y: PropTypes.number
|
|
68
|
+
}),
|
|
69
|
+
/**
|
|
70
|
+
* The width of the chart in px.
|
|
71
|
+
*/
|
|
72
|
+
width: PropTypes.number.isRequired
|
|
73
|
+
} : void 0;
|
|
74
|
+
export { ChartsSurface };
|
|
@@ -63,10 +63,10 @@ function AreaPlot(props) {
|
|
|
63
63
|
const xData = xAxis[xAxisKey].data;
|
|
64
64
|
if (process.env.NODE_ENV !== 'production') {
|
|
65
65
|
if (xData === undefined) {
|
|
66
|
-
throw new Error(`MUI
|
|
66
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
67
67
|
}
|
|
68
68
|
if (xData.length < stackedData.length) {
|
|
69
|
-
throw new Error(`MUI
|
|
69
|
+
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
@@ -120,6 +120,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
120
120
|
* - 'none': display nothing.
|
|
121
121
|
* - 'line': display a line at the current mouse position.
|
|
122
122
|
* - 'band': display a band at the current mouse position. Only available with band scale.
|
|
123
|
+
* @default { x: 'line' }
|
|
123
124
|
*/
|
|
124
125
|
axisHighlight: PropTypes.shape({
|
|
125
126
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
@@ -156,6 +157,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
156
157
|
className: PropTypes.string,
|
|
157
158
|
/**
|
|
158
159
|
* Color palette used to colorize multiple series.
|
|
160
|
+
* @default blueberryTwilightPalette
|
|
159
161
|
*/
|
|
160
162
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
161
163
|
/**
|
|
@@ -71,7 +71,7 @@ function LineHighlightPlot(props) {
|
|
|
71
71
|
const yScale = yAxis[yAxisKey].scale;
|
|
72
72
|
const xData = xAxis[xAxisKey].data;
|
|
73
73
|
if (xData === undefined) {
|
|
74
|
-
throw new Error(`MUI
|
|
74
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
75
75
|
}
|
|
76
76
|
const x = xScale(xData[highlightedIndex]);
|
|
77
77
|
const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
|
|
@@ -62,10 +62,10 @@ function LinePlot(props) {
|
|
|
62
62
|
const xData = xAxis[xAxisKey].data;
|
|
63
63
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
64
|
if (xData === undefined) {
|
|
65
|
-
throw new Error(`MUI
|
|
65
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
66
66
|
}
|
|
67
67
|
if (xData.length < stackedData.length) {
|
|
68
|
-
throw new Error(`MUI
|
|
68
|
+
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
@@ -77,7 +77,7 @@ function MarkPlot(props) {
|
|
|
77
77
|
return true;
|
|
78
78
|
};
|
|
79
79
|
if (xData === undefined) {
|
|
80
|
-
throw new Error(`MUI
|
|
80
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
81
81
|
}
|
|
82
82
|
return xData == null ? void 0 : xData.map((x, index) => {
|
|
83
83
|
const value = data[index] == null ? null : stackedData[index][1];
|
|
@@ -28,7 +28,7 @@ const formatter = (params, dataset) => {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
31
|
-
throw new Error([`MUI
|
|
31
|
+
throw new Error([`MUI X Charts: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const completedSeries = {};
|
|
@@ -58,7 +58,7 @@ const formatter = (params, dataset) => {
|
|
|
58
58
|
warnedOnce = true;
|
|
59
59
|
console.error([`MUI-X charts: your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return null;
|
|
62
62
|
}
|
|
63
63
|
return value;
|
|
64
64
|
}) : series[id].data,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "
|
|
3
|
+
const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "arcLabelRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { animated, to } from '@react-spring/web';
|
|
@@ -41,7 +41,7 @@ const PieArcLabelRoot = styled(animated.text, {
|
|
|
41
41
|
* Helper to compute label position.
|
|
42
42
|
* It's not an inline function because we need it in inerpolation.
|
|
43
43
|
*/
|
|
44
|
-
const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle,
|
|
44
|
+
const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, arcLabelRadius, cornerRadius) => {
|
|
45
45
|
if (!formattedArcLabel) {
|
|
46
46
|
return 0;
|
|
47
47
|
}
|
|
@@ -49,8 +49,8 @@ const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle,
|
|
|
49
49
|
padAngle,
|
|
50
50
|
startAngle,
|
|
51
51
|
endAngle,
|
|
52
|
-
innerRadius,
|
|
53
|
-
outerRadius
|
|
52
|
+
innerRadius: arcLabelRadius,
|
|
53
|
+
outerRadius: arcLabelRadius
|
|
54
54
|
});
|
|
55
55
|
if (variable === 'x') {
|
|
56
56
|
return x;
|
|
@@ -65,8 +65,7 @@ function PieArcLabel(props) {
|
|
|
65
65
|
startAngle,
|
|
66
66
|
endAngle,
|
|
67
67
|
paddingAngle,
|
|
68
|
-
|
|
69
|
-
outerRadius,
|
|
68
|
+
arcLabelRadius,
|
|
70
69
|
cornerRadius,
|
|
71
70
|
formattedArcLabel,
|
|
72
71
|
isHighlighted,
|
|
@@ -86,8 +85,8 @@ function PieArcLabel(props) {
|
|
|
86
85
|
className: classes.root
|
|
87
86
|
}, other, {
|
|
88
87
|
style: _extends({
|
|
89
|
-
x: to([startAngle, endAngle, paddingAngle,
|
|
90
|
-
y: to([startAngle, endAngle, paddingAngle,
|
|
88
|
+
x: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
|
|
89
|
+
y: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
|
|
91
90
|
}, style),
|
|
92
91
|
children: formattedArcLabel
|
|
93
92
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
|
|
4
|
-
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
|
|
3
|
+
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
|
|
4
|
+
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { useTransition } from '@react-spring/web';
|
|
@@ -29,8 +29,9 @@ function PieArcLabelPlot(props) {
|
|
|
29
29
|
const {
|
|
30
30
|
slots,
|
|
31
31
|
slotProps,
|
|
32
|
-
innerRadius
|
|
32
|
+
innerRadius,
|
|
33
33
|
outerRadius,
|
|
34
|
+
arcLabelRadius,
|
|
34
35
|
cornerRadius = 0,
|
|
35
36
|
paddingAngle = 0,
|
|
36
37
|
id,
|
|
@@ -48,6 +49,7 @@ function PieArcLabelPlot(props) {
|
|
|
48
49
|
const transformedData = useTransformData({
|
|
49
50
|
innerRadius,
|
|
50
51
|
outerRadius,
|
|
52
|
+
arcLabelRadius,
|
|
51
53
|
cornerRadius,
|
|
52
54
|
paddingAngle,
|
|
53
55
|
id,
|
|
@@ -71,6 +73,7 @@ function PieArcLabelPlot(props) {
|
|
|
71
73
|
paddingAngle: pA,
|
|
72
74
|
innerRadius: iR,
|
|
73
75
|
outerRadius: oR,
|
|
76
|
+
arcLabelRadius: aLR,
|
|
74
77
|
cornerRadius: cR
|
|
75
78
|
} = _ref,
|
|
76
79
|
style = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
@@ -80,6 +83,7 @@ function PieArcLabelPlot(props) {
|
|
|
80
83
|
paddingAngle: pA,
|
|
81
84
|
innerRadius: iR,
|
|
82
85
|
outerRadius: oR,
|
|
86
|
+
arcLabelRadius: aLR,
|
|
83
87
|
cornerRadius: cR,
|
|
84
88
|
style: style,
|
|
85
89
|
id: id,
|
|
@@ -102,8 +106,14 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
102
106
|
arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
|
|
103
107
|
/**
|
|
104
108
|
* The minimal angle required to display the arc label.
|
|
109
|
+
* @default 0
|
|
105
110
|
*/
|
|
106
111
|
arcLabelMinAngle: PropTypes.number,
|
|
112
|
+
/**
|
|
113
|
+
* The radius between circle center and the arc label in px.
|
|
114
|
+
* @default (innerRadius - outerRadius) / 2
|
|
115
|
+
*/
|
|
116
|
+
arcLabelRadius: PropTypes.number,
|
|
107
117
|
/**
|
|
108
118
|
* The radius applied to arc corners (similar to border radius).
|
|
109
119
|
* @default 0
|
|
@@ -122,9 +132,11 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
122
132
|
})).isRequired,
|
|
123
133
|
/**
|
|
124
134
|
* Override the arc attibutes when it is faded.
|
|
135
|
+
* @default { additionalRadius: -5 }
|
|
125
136
|
*/
|
|
126
137
|
faded: PropTypes.shape({
|
|
127
138
|
additionalRadius: PropTypes.number,
|
|
139
|
+
arcLabelRadius: PropTypes.number,
|
|
128
140
|
color: PropTypes.string,
|
|
129
141
|
cornerRadius: PropTypes.number,
|
|
130
142
|
innerRadius: PropTypes.number,
|
|
@@ -136,6 +148,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
136
148
|
*/
|
|
137
149
|
highlighted: PropTypes.shape({
|
|
138
150
|
additionalRadius: PropTypes.number,
|
|
151
|
+
arcLabelRadius: PropTypes.number,
|
|
139
152
|
color: PropTypes.string,
|
|
140
153
|
cornerRadius: PropTypes.number,
|
|
141
154
|
innerRadius: PropTypes.number,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
|
|
4
|
-
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
|
|
4
|
+
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { useTransition } from '@react-spring/web';
|
|
@@ -88,6 +88,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
88
88
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
89
89
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
90
90
|
// ----------------------------------------------------------------------
|
|
91
|
+
/**
|
|
92
|
+
* The radius between circle center and the arc label in px.
|
|
93
|
+
* @default (innerRadius - outerRadius) / 2
|
|
94
|
+
*/
|
|
95
|
+
arcLabelRadius: PropTypes.number,
|
|
91
96
|
/**
|
|
92
97
|
* The radius applied to arc corners (similar to border radius).
|
|
93
98
|
* @default 0
|
|
@@ -106,9 +111,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
106
111
|
})).isRequired,
|
|
107
112
|
/**
|
|
108
113
|
* Override the arc attibutes when it is faded.
|
|
114
|
+
* @default { additionalRadius: -5 }
|
|
109
115
|
*/
|
|
110
116
|
faded: PropTypes.shape({
|
|
111
117
|
additionalRadius: PropTypes.number,
|
|
118
|
+
arcLabelRadius: PropTypes.number,
|
|
112
119
|
color: PropTypes.string,
|
|
113
120
|
cornerRadius: PropTypes.number,
|
|
114
121
|
innerRadius: PropTypes.number,
|
|
@@ -120,6 +127,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
120
127
|
*/
|
|
121
128
|
highlighted: PropTypes.shape({
|
|
122
129
|
additionalRadius: PropTypes.number,
|
|
130
|
+
arcLabelRadius: PropTypes.number,
|
|
123
131
|
color: PropTypes.string,
|
|
124
132
|
cornerRadius: PropTypes.number,
|
|
125
133
|
innerRadius: PropTypes.number,
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -108,7 +108,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
108
108
|
/**
|
|
109
109
|
* Indicate which axis to display the bottom of the charts.
|
|
110
110
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
111
|
-
* @default
|
|
111
|
+
* @default null
|
|
112
112
|
*/
|
|
113
113
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
114
114
|
axisId: PropTypes.string,
|
|
@@ -136,6 +136,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
136
136
|
className: PropTypes.string,
|
|
137
137
|
/**
|
|
138
138
|
* Color palette used to colorize multiple series.
|
|
139
|
+
* @default blueberryTwilightPalette
|
|
139
140
|
*/
|
|
140
141
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
141
142
|
/**
|
|
@@ -157,7 +158,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
157
158
|
/**
|
|
158
159
|
* Indicate which axis to display the left of the charts.
|
|
159
160
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
160
|
-
* @default
|
|
161
|
+
* @default null
|
|
161
162
|
*/
|
|
162
163
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
163
164
|
axisId: PropTypes.string,
|
|
@@ -238,6 +239,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
238
239
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
239
240
|
arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
|
|
240
241
|
arcLabelMinAngle: PropTypes.number,
|
|
242
|
+
arcLabelRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
241
243
|
color: PropTypes.string,
|
|
242
244
|
cornerRadius: PropTypes.number,
|
|
243
245
|
cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -251,6 +253,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
251
253
|
endAngle: PropTypes.number,
|
|
252
254
|
faded: PropTypes.shape({
|
|
253
255
|
additionalRadius: PropTypes.number,
|
|
256
|
+
arcLabelRadius: PropTypes.number,
|
|
254
257
|
color: PropTypes.string,
|
|
255
258
|
cornerRadius: PropTypes.number,
|
|
256
259
|
innerRadius: PropTypes.number,
|
|
@@ -259,6 +262,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
259
262
|
}),
|
|
260
263
|
highlighted: PropTypes.shape({
|
|
261
264
|
additionalRadius: PropTypes.number,
|
|
265
|
+
arcLabelRadius: PropTypes.number,
|
|
262
266
|
color: PropTypes.string,
|
|
263
267
|
cornerRadius: PropTypes.number,
|
|
264
268
|
innerRadius: PropTypes.number,
|
package/esm/PieChart/PiePlot.js
CHANGED
|
@@ -79,6 +79,7 @@ function PiePlot(props) {
|
|
|
79
79
|
const {
|
|
80
80
|
innerRadius: innerRadiusParam,
|
|
81
81
|
outerRadius: outerRadiusParam,
|
|
82
|
+
arcLabelRadius: arcLabelRadiusParam,
|
|
82
83
|
cornerRadius,
|
|
83
84
|
paddingAngle,
|
|
84
85
|
arcLabel,
|
|
@@ -90,6 +91,7 @@ function PiePlot(props) {
|
|
|
90
91
|
} = series[seriesId];
|
|
91
92
|
const outerRadius = getPercentageValue(outerRadiusParam != null ? outerRadiusParam : availableRadius, availableRadius);
|
|
92
93
|
const innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : 0, availableRadius);
|
|
94
|
+
const arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : getPercentageValue(arcLabelRadiusParam, availableRadius);
|
|
93
95
|
const cx = getPercentageValue(cxParam != null ? cxParam : '50%', width);
|
|
94
96
|
const cy = getPercentageValue(cyParam != null ? cyParam : '50%', height);
|
|
95
97
|
return /*#__PURE__*/_jsx("g", {
|
|
@@ -97,6 +99,7 @@ function PiePlot(props) {
|
|
|
97
99
|
children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
|
|
98
100
|
innerRadius: innerRadius,
|
|
99
101
|
outerRadius: outerRadius != null ? outerRadius : availableRadius,
|
|
102
|
+
arcLabelRadius: arcLabelRadius,
|
|
100
103
|
cornerRadius: cornerRadius,
|
|
101
104
|
paddingAngle: paddingAngle,
|
|
102
105
|
id: seriesId,
|