@mui/x-charts 6.18.2 → 6.18.4
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/BarElement.d.ts +5 -1
- package/BarChart/BarElement.js +24 -1
- package/BarChart/BarPlot.js +7 -6
- package/BarChart/formatter.js +15 -3
- package/BarChart/index.d.ts +3 -2
- package/BarChart/index.js +31 -12
- package/CHANGELOG.md +192 -1
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsLegend/ChartsLegend.d.ts +1 -1
- package/ChartsLegend/ChartsLegend.js +3 -2
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsText/ChartsText.d.ts +17 -0
- package/{internals/components → ChartsText}/ChartsText.js +32 -17
- package/ChartsText/index.d.ts +3 -0
- package/ChartsText/index.js +12 -0
- package/ChartsText/package.json +6 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
- package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
- package/ChartsTooltip/index.d.ts +4 -0
- package/ChartsTooltip/index.js +44 -0
- package/ChartsXAxis/ChartsXAxis.js +3 -2
- package/ChartsYAxis/ChartsYAxis.js +7 -5
- package/LineChart/AreaPlot.js +3 -2
- package/LineChart/LineHighlightPlot.js +2 -1
- package/LineChart/LinePlot.js +3 -2
- package/LineChart/MarkPlot.js +2 -1
- package/LineChart/extremums.js +25 -8
- package/LineChart/formatter.js +14 -2
- package/LineChart/index.d.ts +5 -5
- package/LineChart/index.js +50 -41
- package/PieChart/PieArcLabelPlot.d.ts +7 -4
- package/PieChart/PieArcLabelPlot.js +88 -1
- package/PieChart/PieArcPlot.d.ts +7 -4
- package/PieChart/PieArcPlot.js +87 -1
- package/PieChart/PieChart.js +4 -4
- package/PieChart/PiePlot.js +20 -15
- package/PieChart/dataTransform/useTransformData.d.ts +2 -3
- package/PieChart/index.d.ts +6 -6
- package/PieChart/index.js +60 -46
- package/ResponsiveChartContainer/index.js +2 -2
- package/ScatterChart/Scatter.js +1 -1
- package/ScatterChart/index.d.ts +3 -3
- package/ScatterChart/index.js +31 -19
- package/context/CartesianContextProvider.js +2 -2
- package/context/SeriesContextProvider.js +1 -1
- package/esm/BarChart/BarElement.js +26 -2
- package/esm/BarChart/BarPlot.js +7 -5
- package/esm/BarChart/formatter.js +20 -4
- package/esm/BarChart/index.js +3 -2
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -1
- package/esm/ChartsLegend/index.js +2 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/{internals/components → ChartsText}/ChartsText.js +33 -16
- package/esm/ChartsText/index.js +1 -0
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
- package/esm/ChartsTooltip/index.js +5 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +7 -5
- package/esm/LineChart/AreaPlot.js +3 -2
- package/esm/LineChart/LineHighlightPlot.js +2 -1
- package/esm/LineChart/LinePlot.js +3 -2
- package/esm/LineChart/MarkPlot.js +2 -1
- package/esm/LineChart/extremums.js +25 -8
- package/esm/LineChart/formatter.js +16 -3
- package/esm/LineChart/index.js +5 -5
- package/esm/PieChart/PieArcLabelPlot.js +90 -2
- package/esm/PieChart/PieArcPlot.js +89 -2
- package/esm/PieChart/PieChart.js +4 -4
- package/esm/PieChart/PiePlot.js +20 -15
- package/esm/PieChart/index.js +6 -4
- package/esm/ResponsiveChartContainer/index.js +2 -2
- package/esm/ScatterChart/Scatter.js +1 -1
- package/esm/ScatterChart/index.js +3 -3
- package/esm/context/CartesianContextProvider.js +2 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/index.js +1 -0
- package/esm/internals/defaultizeValueFormatter.js +4 -3
- package/esm/internals/getWordsByLines.js +14 -0
- package/esm/internals/utils.js +40 -0
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +4 -4
- package/internals/defaultizeValueFormatter.d.ts +3 -1
- package/internals/defaultizeValueFormatter.js +3 -3
- package/internals/{components/ChartsText.d.ts → getWordsByLines.d.ts} +2 -11
- package/internals/getWordsByLines.js +21 -0
- package/internals/utils.d.ts +13 -0
- package/internals/utils.js +42 -0
- package/legacy/BarChart/BarElement.js +26 -2
- package/legacy/BarChart/BarPlot.js +7 -5
- package/legacy/BarChart/formatter.js +23 -9
- package/legacy/BarChart/index.js +3 -2
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsLegend/ChartsLegend.js +2 -1
- package/legacy/ChartsLegend/index.js +2 -1
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/{internals/components → ChartsText}/ChartsText.js +38 -22
- package/legacy/ChartsText/index.js +1 -0
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
- package/legacy/ChartsTooltip/index.js +5 -1
- package/legacy/ChartsXAxis/ChartsXAxis.js +2 -1
- package/legacy/ChartsYAxis/ChartsYAxis.js +7 -5
- package/legacy/LineChart/AreaPlot.js +3 -2
- package/legacy/LineChart/LineHighlightPlot.js +2 -1
- package/legacy/LineChart/LinePlot.js +3 -2
- package/legacy/LineChart/MarkPlot.js +2 -1
- package/legacy/LineChart/extremums.js +29 -14
- package/legacy/LineChart/formatter.js +19 -8
- package/legacy/LineChart/index.js +5 -5
- package/legacy/PieChart/PieArcLabelPlot.js +90 -2
- package/legacy/PieChart/PieArcPlot.js +89 -2
- package/legacy/PieChart/PieChart.js +4 -4
- package/legacy/PieChart/PiePlot.js +20 -15
- package/legacy/PieChart/index.js +6 -4
- package/legacy/ResponsiveChartContainer/index.js +2 -2
- package/legacy/ScatterChart/Scatter.js +1 -1
- package/legacy/ScatterChart/index.js +3 -3
- package/legacy/context/CartesianContextProvider.js +2 -2
- package/legacy/context/SeriesContextProvider.js +1 -1
- package/legacy/index.js +2 -1
- package/legacy/internals/defaultizeValueFormatter.js +4 -3
- package/legacy/internals/getWordsByLines.js +15 -0
- package/legacy/internals/utils.js +40 -0
- package/models/axis.d.ts +1 -1
- package/models/seriesType/config.d.ts +9 -4
- package/models/seriesType/pie.d.ts +29 -7
- package/models/seriesType/scatter.d.ts +1 -1
- package/modern/BarChart/BarElement.js +26 -2
- package/modern/BarChart/BarPlot.js +7 -5
- package/modern/BarChart/formatter.js +15 -3
- package/modern/BarChart/index.js +3 -2
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/ChartsLegend.js +2 -1
- package/modern/ChartsLegend/index.js +2 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/{internals/components → ChartsText}/ChartsText.js +33 -16
- package/modern/ChartsText/index.js +1 -0
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
- package/modern/ChartsTooltip/index.js +5 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +7 -5
- package/modern/LineChart/AreaPlot.js +3 -2
- package/modern/LineChart/LineHighlightPlot.js +2 -1
- package/modern/LineChart/LinePlot.js +3 -2
- package/modern/LineChart/MarkPlot.js +2 -1
- package/modern/LineChart/extremums.js +25 -8
- package/modern/LineChart/formatter.js +14 -2
- package/modern/LineChart/index.js +5 -5
- package/modern/PieChart/PieArcLabelPlot.js +90 -2
- package/modern/PieChart/PieArcPlot.js +89 -2
- package/modern/PieChart/PieChart.js +4 -4
- package/modern/PieChart/PiePlot.js +20 -15
- package/modern/PieChart/index.js +6 -4
- package/modern/ResponsiveChartContainer/index.js +2 -2
- package/modern/ScatterChart/Scatter.js +1 -1
- package/modern/ScatterChart/index.js +3 -3
- package/modern/context/CartesianContextProvider.js +2 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/index.js +2 -1
- package/modern/internals/defaultizeValueFormatter.js +3 -3
- package/modern/internals/getWordsByLines.js +14 -0
- package/modern/internals/utils.js +40 -0
- package/package.json +1 -1
package/models/axis.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, ScalePoint } from 'd3-scale';
|
|
3
3
|
import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
|
|
4
4
|
import type { TickParams } from '../hooks/useTicks';
|
|
5
|
-
import { ChartsTextProps } from '../
|
|
5
|
+
import { ChartsTextProps } from '../ChartsText';
|
|
6
6
|
export type D3Scale<Domain extends {
|
|
7
7
|
toString(): string;
|
|
8
8
|
} = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
|
|
@@ -46,7 +46,11 @@ export type ChartSeries<T extends ChartSeriesType> = ChartsSeriesConfig[T] exten
|
|
|
46
46
|
} ? ChartsSeriesConfig[T]['seriesInput'] & {
|
|
47
47
|
stackedData: [number, number][];
|
|
48
48
|
} : ChartsSeriesConfig[T]['seriesInput'];
|
|
49
|
-
export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConfig[T]
|
|
49
|
+
export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends {
|
|
50
|
+
canBeStacked: true;
|
|
51
|
+
} ? ChartsSeriesConfig[T]['series'] & {
|
|
52
|
+
stackedData: [number, number][];
|
|
53
|
+
} : ChartsSeriesConfig[T]['series'];
|
|
50
54
|
export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
|
|
51
55
|
type ExtremumGetterParams<T extends ChartSeriesType> = {
|
|
52
56
|
series: {
|
|
@@ -73,10 +77,11 @@ export type FormatterResult<T extends ChartSeriesType> = {
|
|
|
73
77
|
} ? {
|
|
74
78
|
stackingGroups: StackingGroupsType;
|
|
75
79
|
} : {});
|
|
76
|
-
export type
|
|
80
|
+
export type DatasetElementType<T> = {
|
|
77
81
|
[key: string]: T;
|
|
78
|
-
}
|
|
79
|
-
export type
|
|
82
|
+
};
|
|
83
|
+
export type DatasetType<T = number | string | Date | null | undefined> = DatasetElementType<T>[];
|
|
84
|
+
export type Formatter<T extends ChartSeriesType> = (params: FormatterParams<T>, dataset?: DatasetType) => FormatterResult<T>;
|
|
80
85
|
export type LegendParams = {
|
|
81
86
|
/**
|
|
82
87
|
* The color used in the legend
|
|
@@ -17,14 +17,18 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
|
|
|
17
17
|
data: Tdata[];
|
|
18
18
|
/**
|
|
19
19
|
* The radius between circle center and the begining of the arc.
|
|
20
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
21
|
+
* The '100%' is the maximal radius that fit into the drawing area.
|
|
20
22
|
* @default 0
|
|
21
23
|
*/
|
|
22
|
-
innerRadius?: number;
|
|
24
|
+
innerRadius?: number | string;
|
|
23
25
|
/**
|
|
24
26
|
* The radius between circle center and the end of the arc.
|
|
25
|
-
*
|
|
27
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
28
|
+
* The '100%' is the maximal radius that fit into the drawing area.
|
|
29
|
+
* @default '100%'
|
|
26
30
|
*/
|
|
27
|
-
outerRadius?: number;
|
|
31
|
+
outerRadius?: number | string;
|
|
28
32
|
/**
|
|
29
33
|
* The radius applied to arc corners (similar to border radius).
|
|
30
34
|
* @default 0
|
|
@@ -56,14 +60,18 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
|
|
|
56
60
|
arcLabelMinAngle?: number;
|
|
57
61
|
/**
|
|
58
62
|
* The x coordinate of the pie center.
|
|
59
|
-
*
|
|
63
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
64
|
+
* The '100%' is the width the drawing area.
|
|
65
|
+
* @default '50%'
|
|
60
66
|
*/
|
|
61
|
-
cx?: number;
|
|
67
|
+
cx?: number | string;
|
|
62
68
|
/**
|
|
63
69
|
* The y coordinate of the pie center.
|
|
64
|
-
*
|
|
70
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
71
|
+
* The '100%' is the height the drawing area.
|
|
72
|
+
* @default '50%'
|
|
65
73
|
*/
|
|
66
|
-
cy?: number;
|
|
74
|
+
cy?: number | string;
|
|
67
75
|
/**
|
|
68
76
|
* Override the arc attibutes when it is highlighted.
|
|
69
77
|
*/
|
|
@@ -107,3 +115,17 @@ export type PieItemIdentifier = {
|
|
|
107
115
|
export interface DefaultizedPieSeriesType extends DefaultizedProps<PieSeriesType, CommonDefaultizedProps> {
|
|
108
116
|
data: DefaultizedPieValueType[];
|
|
109
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Props received when the parent components has done the percentage conversion.
|
|
120
|
+
*/
|
|
121
|
+
export interface ComputedPieRadius {
|
|
122
|
+
/**
|
|
123
|
+
* The radius between circle center and the begining of the arc.
|
|
124
|
+
* @default 0
|
|
125
|
+
*/
|
|
126
|
+
innerRadius?: number;
|
|
127
|
+
/**
|
|
128
|
+
* The radius between circle center and the end of the arc.
|
|
129
|
+
*/
|
|
130
|
+
outerRadius: number;
|
|
131
|
+
}
|
|
@@ -20,5 +20,5 @@ export type ScatterItemIdentifier = {
|
|
|
20
20
|
seriesId: DefaultizedScatterSeriesType['id'];
|
|
21
21
|
dataIndex: number;
|
|
22
22
|
};
|
|
23
|
-
export interface DefaultizedScatterSeriesType extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps> {
|
|
23
|
+
export interface DefaultizedScatterSeriesType extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps | 'color'> {
|
|
24
24
|
}
|
|
@@ -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 = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
7
|
import { useSlotProps } from '@mui/base/utils';
|
|
7
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
@@ -39,7 +40,7 @@ export const BarElementPath = styled(animated.rect, {
|
|
|
39
40
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
40
41
|
opacity: ownerState.isFaded && 0.3 || 1
|
|
41
42
|
}));
|
|
42
|
-
|
|
43
|
+
function BarElement(props) {
|
|
43
44
|
const {
|
|
44
45
|
id,
|
|
45
46
|
dataIndex,
|
|
@@ -89,4 +90,27 @@ export function BarElement(props) {
|
|
|
89
90
|
ownerState
|
|
90
91
|
});
|
|
91
92
|
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
92
|
-
}
|
|
93
|
+
}
|
|
94
|
+
process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
|
|
95
|
+
// ----------------------------- Warning --------------------------------
|
|
96
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
97
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
98
|
+
// ----------------------------------------------------------------------
|
|
99
|
+
classes: PropTypes.object,
|
|
100
|
+
dataIndex: PropTypes.number.isRequired,
|
|
101
|
+
highlightScope: PropTypes.shape({
|
|
102
|
+
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
103
|
+
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
104
|
+
}),
|
|
105
|
+
/**
|
|
106
|
+
* The props used for each component slot.
|
|
107
|
+
* @default {}
|
|
108
|
+
*/
|
|
109
|
+
slotProps: PropTypes.object,
|
|
110
|
+
/**
|
|
111
|
+
* Overridable component slots.
|
|
112
|
+
* @default {}
|
|
113
|
+
*/
|
|
114
|
+
slots: PropTypes.object
|
|
115
|
+
} : void 0;
|
|
116
|
+
export { BarElement };
|
|
@@ -8,7 +8,8 @@ import { SeriesContext } from '../context/SeriesContextProvider';
|
|
|
8
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
9
|
import { BarElement } from './BarElement';
|
|
10
10
|
import { isBandScaleConfig } from '../models/axis';
|
|
11
|
-
import {
|
|
11
|
+
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Solution of the equations
|
|
14
15
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -18,6 +19,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
19
|
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
19
20
|
* @returns The bar width and the offset between bars.
|
|
20
21
|
*/
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
23
|
function getBandSize({
|
|
22
24
|
bandWidth: W,
|
|
23
25
|
numberOfGroups: N,
|
|
@@ -67,18 +69,18 @@ const useCompletedData = () => {
|
|
|
67
69
|
let baseScaleConfig;
|
|
68
70
|
if (verticalLayout) {
|
|
69
71
|
if (!isBandScaleConfig(xAxisConfig)) {
|
|
70
|
-
throw new Error(`
|
|
72
|
+
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}"`);
|
|
71
73
|
}
|
|
72
74
|
if (xAxis[xAxisKey].data === undefined) {
|
|
73
|
-
throw new Error(`
|
|
75
|
+
throw new Error(`MUI-X-Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud have data property`);
|
|
74
76
|
}
|
|
75
77
|
baseScaleConfig = xAxisConfig;
|
|
76
78
|
} else {
|
|
77
79
|
if (!isBandScaleConfig(yAxisConfig)) {
|
|
78
|
-
throw new Error(`
|
|
80
|
+
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}"`);
|
|
79
81
|
}
|
|
80
82
|
if (yAxis[yAxisKey].data === undefined) {
|
|
81
|
-
throw new Error(`
|
|
83
|
+
throw new Error(`MUI-X-Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud have data property`);
|
|
82
84
|
}
|
|
83
85
|
baseScaleConfig = yAxisConfig;
|
|
84
86
|
}
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { stack as d3Stack } from 'd3-shape';
|
|
3
3
|
import { getStackingGroups } from '../internals/stackSeries';
|
|
4
4
|
import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
|
|
5
|
+
let warnOnce = false;
|
|
5
6
|
const formatter = (params, dataset) => {
|
|
6
7
|
const {
|
|
7
8
|
seriesOrder,
|
|
@@ -24,7 +25,7 @@ const formatter = (params, dataset) => {
|
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
} else if (dataset === undefined) {
|
|
27
|
-
throw new Error([`MUI: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
28
|
+
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'));
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
31
|
const completedSeries = {};
|
|
@@ -39,13 +40,24 @@ const formatter = (params, dataset) => {
|
|
|
39
40
|
// Use dataKey if needed and available
|
|
40
41
|
const dataKey = series[id].dataKey;
|
|
41
42
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
42
|
-
})).
|
|
43
|
+
})).value((d, key) => d[key] ?? 0) // defaultize null value to 0
|
|
44
|
+
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
43
45
|
ids.forEach((id, index) => {
|
|
44
46
|
const dataKey = series[id].dataKey;
|
|
45
47
|
completedSeries[id] = _extends({
|
|
46
48
|
layout: 'vertical'
|
|
47
49
|
}, series[id], {
|
|
48
|
-
data: dataKey ? dataset.map(
|
|
50
|
+
data: dataKey ? dataset.map(data => {
|
|
51
|
+
const value = data[dataKey];
|
|
52
|
+
if (typeof value !== 'number') {
|
|
53
|
+
if (process.env.NODE_ENV !== 'production' && !warnOnce && value !== null) {
|
|
54
|
+
warnOnce = true;
|
|
55
|
+
console.error([`MUI-X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.']);
|
|
56
|
+
}
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}) : series[id].data,
|
|
49
61
|
stackedData: stackedSeries[index].map(([a, b]) => [a, b])
|
|
50
62
|
});
|
|
51
63
|
});
|
package/modern/BarChart/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './BarChart';
|
|
2
|
+
export * from './BarPlot';
|
|
3
|
+
export * from './BarElement';
|
|
@@ -58,16 +58,16 @@ function ChartsAxis(props) {
|
|
|
58
58
|
const topId = getAxisId(topAxis);
|
|
59
59
|
const rightId = getAxisId(rightAxis);
|
|
60
60
|
if (topId !== null && !xAxis[topId]) {
|
|
61
|
-
throw Error(`MUI: id used for top axis "${topId}" is not defined`);
|
|
61
|
+
throw Error([`MUI-X-Charts: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
62
62
|
}
|
|
63
63
|
if (leftId !== null && !yAxis[leftId]) {
|
|
64
|
-
throw Error(`MUI: id used for left axis "${leftId}" is not defined`);
|
|
64
|
+
throw Error([`MUI-X-Charts: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
65
65
|
}
|
|
66
66
|
if (rightId !== null && !yAxis[rightId]) {
|
|
67
|
-
throw Error(`MUI: id used for right axis "${rightId}" is not defined`);
|
|
67
|
+
throw Error([`MUI-X-Charts: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
68
68
|
}
|
|
69
69
|
if (bottomId !== null && !xAxis[bottomId]) {
|
|
70
|
-
throw Error(`MUI: id used for bottom axis "${bottomId}" is not defined`);
|
|
70
|
+
throw Error([`MUI-X-Charts: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
71
71
|
}
|
|
72
72
|
const topAxisProps = mergeProps(topAxis, slots, slotProps);
|
|
73
73
|
const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
|
|
@@ -11,7 +11,8 @@ import { DrawingContext } from '../context/DrawingProvider';
|
|
|
11
11
|
import { getSeriesToDisplay } from './utils';
|
|
12
12
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
13
13
|
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
14
|
-
import { ChartsText
|
|
14
|
+
import { ChartsText } from '../ChartsText';
|
|
15
|
+
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
18
|
const useUtilityClasses = ownerState => {
|
|
@@ -6,10 +6,10 @@ import { ChartsYReferenceLine } from './ChartsYReferenceLine';
|
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
function ChartsReferenceLine(props) {
|
|
8
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.');
|
|
9
|
+
throw new Error('MUI-X-Charts: The ChartsReferenceLine can not have both `x` and `y` props set.');
|
|
10
10
|
}
|
|
11
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.');
|
|
12
|
+
throw new Error('MUI-X-Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
13
13
|
}
|
|
14
14
|
if (props.x !== undefined) {
|
|
15
15
|
return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import composeClasses from '@mui/utils/composeClasses';
|
|
4
4
|
import { useDrawingArea, useXScale } from '../hooks';
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
|
-
import { ChartsText } from '../
|
|
6
|
+
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import composeClasses from '@mui/utils/composeClasses';
|
|
4
4
|
import { useDrawingArea, useYScale } from '../hooks';
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
|
-
import { ChartsText } from '../
|
|
6
|
+
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["x", "y", "style", "text", "ownerState"],
|
|
4
4
|
_excluded2 = ["angle", "textAnchor", "dominantBaseline"];
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}) {
|
|
13
|
-
return text.split('\n').map(subText => _extends({
|
|
14
|
-
text: subText
|
|
15
|
-
}, needsComputation ? getStringSize(subText, style) : {
|
|
16
|
-
width: 0,
|
|
17
|
-
height: 0
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
export function ChartsText(props) {
|
|
9
|
+
/**
|
|
10
|
+
* Helper component to manage multiline text in SVG
|
|
11
|
+
*/
|
|
12
|
+
function ChartsText(props) {
|
|
21
13
|
const {
|
|
22
14
|
x,
|
|
23
15
|
y,
|
|
@@ -74,4 +66,29 @@ export function ChartsText(props) {
|
|
|
74
66
|
children: line.text
|
|
75
67
|
}, index))
|
|
76
68
|
}));
|
|
77
|
-
}
|
|
69
|
+
}
|
|
70
|
+
process.env.NODE_ENV !== "production" ? ChartsText.propTypes = {
|
|
71
|
+
// ----------------------------- Warning --------------------------------
|
|
72
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
73
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
74
|
+
// ----------------------------------------------------------------------
|
|
75
|
+
/**
|
|
76
|
+
* Height of a text line (in `em`).
|
|
77
|
+
*/
|
|
78
|
+
lineHeight: PropTypes.number,
|
|
79
|
+
/**
|
|
80
|
+
* If `true`, the line width is computed.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
needsComputation: PropTypes.bool,
|
|
84
|
+
ownerState: PropTypes.any,
|
|
85
|
+
/**
|
|
86
|
+
* Style applied to text elements.
|
|
87
|
+
*/
|
|
88
|
+
style: PropTypes.object,
|
|
89
|
+
/**
|
|
90
|
+
* Text displayed.
|
|
91
|
+
*/
|
|
92
|
+
text: PropTypes.string.isRequired
|
|
93
|
+
} : void 0;
|
|
94
|
+
export { ChartsText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChartsText } from './ChartsText';
|
|
@@ -1,81 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import Typography from '@mui/material/Typography';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
5
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
6
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
7
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
|
-
import {
|
|
7
|
+
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
9
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
export function DefaultChartsAxisContent(props) {
|
|
12
|
-
const {
|
|
13
|
-
series,
|
|
14
|
-
axis,
|
|
15
|
-
dataIndex,
|
|
16
|
-
axisValue,
|
|
17
|
-
sx,
|
|
18
|
-
classes
|
|
19
|
-
} = props;
|
|
20
|
-
if (dataIndex == null) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const axisFormatter = axis.valueFormatter ?? (v => v.toLocaleString());
|
|
24
|
-
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
25
|
-
sx: sx,
|
|
26
|
-
className: classes.root,
|
|
27
|
-
children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
|
|
28
|
-
className: classes.table,
|
|
29
|
-
children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
|
|
30
|
-
children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
|
|
31
|
-
children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
32
|
-
colSpan: 3,
|
|
33
|
-
children: /*#__PURE__*/_jsx(Typography, {
|
|
34
|
-
children: axisFormatter(axisValue)
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
}), /*#__PURE__*/_jsx("tbody", {
|
|
39
|
-
children: series.map(({
|
|
40
|
-
color,
|
|
41
|
-
id,
|
|
42
|
-
label,
|
|
43
|
-
valueFormatter,
|
|
44
|
-
data
|
|
45
|
-
}) => {
|
|
46
|
-
const formattedValue = valueFormatter(data[dataIndex]);
|
|
47
|
-
if (formattedValue == null) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
51
|
-
className: classes.row,
|
|
52
|
-
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
53
|
-
className: clsx(classes.markCell, classes.cell),
|
|
54
|
-
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
55
|
-
ownerState: {
|
|
56
|
-
color
|
|
57
|
-
},
|
|
58
|
-
boxShadow: 1,
|
|
59
|
-
className: classes.mark
|
|
60
|
-
})
|
|
61
|
-
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
62
|
-
className: clsx(classes.labelCell, classes.cell),
|
|
63
|
-
children: label ? /*#__PURE__*/_jsx(Typography, {
|
|
64
|
-
children: label
|
|
65
|
-
}) : null
|
|
66
|
-
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
67
|
-
className: clsx(classes.valueCell, classes.cell),
|
|
68
|
-
children: /*#__PURE__*/_jsx(Typography, {
|
|
69
|
-
children: formattedValue
|
|
70
|
-
})
|
|
71
|
-
})]
|
|
72
|
-
}, id);
|
|
73
|
-
})
|
|
74
|
-
})]
|
|
75
|
-
})
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
export function ChartsAxisTooltipContent(props) {
|
|
9
|
+
function ChartsAxisTooltipContent(props) {
|
|
79
10
|
const {
|
|
80
11
|
content,
|
|
81
12
|
contentProps,
|
|
@@ -110,7 +41,7 @@ export function ChartsAxisTooltipContent(props) {
|
|
|
110
41
|
const relevantAxis = React.useMemo(() => {
|
|
111
42
|
return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
112
43
|
}, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
|
|
113
|
-
const Content = content ??
|
|
44
|
+
const Content = content ?? DefaultChartsAxisTooltipContent;
|
|
114
45
|
const chartTooltipContentProps = useSlotProps({
|
|
115
46
|
elementType: Content,
|
|
116
47
|
externalSlotProps: contentProps,
|
|
@@ -126,4 +57,94 @@ export function ChartsAxisTooltipContent(props) {
|
|
|
126
57
|
ownerState: {}
|
|
127
58
|
});
|
|
128
59
|
return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
|
|
129
|
-
}
|
|
60
|
+
}
|
|
61
|
+
process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
|
|
62
|
+
// ----------------------------- Warning --------------------------------
|
|
63
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
64
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
65
|
+
// ----------------------------------------------------------------------
|
|
66
|
+
axisData: PropTypes.shape({
|
|
67
|
+
x: PropTypes.shape({
|
|
68
|
+
index: PropTypes.number,
|
|
69
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
70
|
+
}),
|
|
71
|
+
y: PropTypes.shape({
|
|
72
|
+
index: PropTypes.number,
|
|
73
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
74
|
+
})
|
|
75
|
+
}).isRequired,
|
|
76
|
+
classes: PropTypes.object.isRequired,
|
|
77
|
+
content: PropTypes.elementType,
|
|
78
|
+
contentProps: PropTypes.shape({
|
|
79
|
+
axis: PropTypes.shape({
|
|
80
|
+
axisId: PropTypes.string,
|
|
81
|
+
classes: PropTypes.object,
|
|
82
|
+
data: PropTypes.array,
|
|
83
|
+
dataKey: PropTypes.string,
|
|
84
|
+
disableLine: PropTypes.bool,
|
|
85
|
+
disableTicks: PropTypes.bool,
|
|
86
|
+
fill: PropTypes.string,
|
|
87
|
+
hideTooltip: PropTypes.bool,
|
|
88
|
+
id: PropTypes.string.isRequired,
|
|
89
|
+
label: PropTypes.string,
|
|
90
|
+
labelFontSize: PropTypes.number,
|
|
91
|
+
labelStyle: PropTypes.object,
|
|
92
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
93
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
94
|
+
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
95
|
+
scale: PropTypes.func.isRequired,
|
|
96
|
+
scaleType: PropTypes.oneOf(['time']).isRequired,
|
|
97
|
+
slotProps: PropTypes.object,
|
|
98
|
+
slots: PropTypes.object,
|
|
99
|
+
stroke: PropTypes.string,
|
|
100
|
+
tickFontSize: PropTypes.number,
|
|
101
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
102
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
103
|
+
tickLabelStyle: PropTypes.object,
|
|
104
|
+
tickMaxStep: PropTypes.number,
|
|
105
|
+
tickMinStep: PropTypes.number,
|
|
106
|
+
tickNumber: PropTypes.number.isRequired,
|
|
107
|
+
tickSize: PropTypes.number,
|
|
108
|
+
valueFormatter: PropTypes.func
|
|
109
|
+
}),
|
|
110
|
+
axisData: PropTypes.shape({
|
|
111
|
+
x: PropTypes.shape({
|
|
112
|
+
index: PropTypes.number,
|
|
113
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
114
|
+
}),
|
|
115
|
+
y: PropTypes.shape({
|
|
116
|
+
index: PropTypes.number,
|
|
117
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
axisValue: PropTypes.any,
|
|
121
|
+
classes: PropTypes.object,
|
|
122
|
+
dataIndex: PropTypes.number,
|
|
123
|
+
series: PropTypes.arrayOf(PropTypes.shape({
|
|
124
|
+
area: PropTypes.bool,
|
|
125
|
+
color: PropTypes.string.isRequired,
|
|
126
|
+
connectNulls: PropTypes.bool,
|
|
127
|
+
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
128
|
+
data: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
129
|
+
dataKey: PropTypes.string,
|
|
130
|
+
disableHighlight: PropTypes.bool,
|
|
131
|
+
highlightScope: PropTypes.shape({
|
|
132
|
+
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
133
|
+
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
134
|
+
}),
|
|
135
|
+
id: PropTypes.string.isRequired,
|
|
136
|
+
label: PropTypes.string,
|
|
137
|
+
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
138
|
+
stack: PropTypes.string,
|
|
139
|
+
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
|
|
140
|
+
stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
|
|
141
|
+
type: PropTypes.oneOf(['line']).isRequired,
|
|
142
|
+
valueFormatter: PropTypes.func.isRequired,
|
|
143
|
+
xAxisKey: PropTypes.string,
|
|
144
|
+
yAxisKey: PropTypes.string
|
|
145
|
+
})),
|
|
146
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
147
|
+
}),
|
|
148
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
149
|
+
} : void 0;
|
|
150
|
+
export { ChartsAxisTooltipContent };
|