@mui/x-charts 7.4.0 → 7.5.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.js +11 -10
- package/BarChart/BarElement.d.ts +10 -5
- package/BarChart/BarElement.js +3 -2
- package/BarChart/legend.js +13 -6
- package/CHANGELOG.md +93 -0
- package/ChartContainer/ChartContainer.js +10 -10
- package/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/ChartsOverlay/ChartsOverlay.d.ts +9 -0
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/ChartsTooltip/utils.js +13 -8
- package/ChartsXAxis/ChartsXAxis.js +1 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/AreaElement.js +3 -3
- package/LineChart/AreaPlot.js +3 -2
- package/LineChart/LineChart.js +11 -10
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineElement.js +3 -3
- package/LineChart/LineHighlightElement.d.ts +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/legend.js +13 -6
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +3 -1
- package/PieChart/PieArcLabelPlot.js +14 -5
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.js +11 -10
- package/PieChart/formatter.js +4 -1
- package/PieChart/legend.js +15 -5
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/ScatterChart/ScatterChart.js +16 -15
- package/ScatterChart/legend.js +13 -6
- package/SparkLineChart/SparkLineChart.js +5 -5
- package/context/ZAxisContextProvider.js +5 -5
- package/esm/BarChart/BarChart.js +11 -10
- package/esm/BarChart/BarElement.js +3 -2
- package/esm/BarChart/legend.js +13 -6
- package/esm/ChartContainer/ChartContainer.js +10 -10
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/esm/ChartsTooltip/utils.js +13 -8
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/LineChart/AreaElement.js +3 -3
- package/esm/LineChart/AreaPlot.js +3 -2
- package/esm/LineChart/LineChart.js +11 -10
- package/esm/LineChart/LineElement.js +3 -3
- package/esm/LineChart/legend.js +13 -6
- package/esm/PieChart/PieArcLabel.js +3 -1
- package/esm/PieChart/PieArcLabelPlot.js +14 -5
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +11 -10
- package/esm/PieChart/formatter.js +4 -1
- package/esm/PieChart/legend.js +15 -5
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/esm/ScatterChart/ScatterChart.js +16 -15
- package/esm/ScatterChart/legend.js +13 -6
- package/esm/SparkLineChart/SparkLineChart.js +5 -5
- package/esm/context/ZAxisContextProvider.js +5 -5
- package/esm/hooks/useAxisEvents.js +12 -7
- package/esm/internals/getLabel.js +3 -0
- package/hooks/useAxisEvents.js +12 -7
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +7 -5
- package/internals/getLabel.d.ts +1 -0
- package/internals/getLabel.js +9 -0
- package/internals/utils.d.ts +1 -1
- package/models/seriesType/bar.d.ts +4 -1
- package/models/seriesType/line.d.ts +4 -1
- package/models/seriesType/pie.d.ts +9 -4
- package/models/seriesType/scatter.d.ts +4 -1
- package/modern/BarChart/BarChart.js +11 -10
- package/modern/BarChart/BarElement.js +3 -2
- package/modern/BarChart/legend.js +13 -6
- package/modern/ChartContainer/ChartContainer.js +10 -10
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/modern/ChartsTooltip/utils.js +13 -8
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/LineChart/AreaElement.js +3 -3
- package/modern/LineChart/AreaPlot.js +3 -2
- package/modern/LineChart/LineChart.js +11 -10
- package/modern/LineChart/LineElement.js +3 -3
- package/modern/LineChart/legend.js +13 -6
- package/modern/PieChart/PieArcLabel.js +3 -1
- package/modern/PieChart/PieArcLabelPlot.js +14 -5
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +11 -10
- package/modern/PieChart/formatter.js +4 -1
- package/modern/PieChart/legend.js +15 -5
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/modern/ScatterChart/ScatterChart.js +16 -15
- package/modern/ScatterChart/legend.js +13 -6
- package/modern/SparkLineChart/SparkLineChart.js +5 -5
- package/modern/context/ZAxisContextProvider.js +5 -5
- package/modern/hooks/useAxisEvents.js +12 -7
- package/modern/index.js +1 -1
- package/modern/internals/getLabel.js +3 -0
- package/package.json +2 -2
|
@@ -226,6 +226,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
226
226
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
227
227
|
classes: PropTypes.object,
|
|
228
228
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
229
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
230
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
231
|
+
unknownColor: PropTypes.string,
|
|
232
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
233
|
+
}), PropTypes.shape({
|
|
229
234
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
230
235
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
231
236
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -234,11 +239,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
234
239
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
235
240
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
236
241
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
237
|
-
}), PropTypes.shape({
|
|
238
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
239
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
240
|
-
unknownColor: PropTypes.string,
|
|
241
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
242
242
|
})]),
|
|
243
243
|
data: PropTypes.array,
|
|
244
244
|
dataKey: PropTypes.string,
|
|
@@ -67,6 +67,11 @@ process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
|
67
67
|
*/
|
|
68
68
|
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
69
69
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
70
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
71
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
72
|
+
unknownColor: PropTypes.string,
|
|
73
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
74
|
+
}), PropTypes.shape({
|
|
70
75
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
71
76
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
72
77
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -75,11 +80,6 @@ process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
|
75
80
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
76
81
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
77
82
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
78
|
-
}), PropTypes.shape({
|
|
79
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
80
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
81
|
-
unknownColor: PropTypes.string,
|
|
82
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
83
83
|
})]),
|
|
84
84
|
data: PropTypes.array,
|
|
85
85
|
dataKey: PropTypes.string,
|
|
@@ -90,7 +90,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
90
90
|
value: axisData[dataIndex]
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
const
|
|
93
|
+
const handleOut = () => {
|
|
94
94
|
mousePosition.current = {
|
|
95
95
|
x: -1,
|
|
96
96
|
y: -1
|
|
@@ -99,8 +99,9 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
99
99
|
type: 'exitChart'
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
|
-
const
|
|
103
|
-
const
|
|
102
|
+
const handleMove = event => {
|
|
103
|
+
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
104
|
+
const svgPoint = getSVGPoint(svgRef.current, target);
|
|
104
105
|
mousePosition.current = {
|
|
105
106
|
x: svgPoint.x,
|
|
106
107
|
y: svgPoint.y
|
|
@@ -123,11 +124,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
126
|
};
|
|
126
|
-
element.addEventListener('mouseout',
|
|
127
|
-
element.addEventListener('mousemove',
|
|
127
|
+
element.addEventListener('mouseout', handleOut);
|
|
128
|
+
element.addEventListener('mousemove', handleMove);
|
|
129
|
+
element.addEventListener('touchend', handleOut);
|
|
130
|
+
element.addEventListener('touchmove', handleMove);
|
|
128
131
|
return () => {
|
|
129
|
-
element.removeEventListener('mouseout',
|
|
130
|
-
element.removeEventListener('mousemove',
|
|
132
|
+
element.removeEventListener('mouseout', handleOut);
|
|
133
|
+
element.removeEventListener('mousemove', handleMove);
|
|
134
|
+
element.removeEventListener('touchend', handleOut);
|
|
135
|
+
element.removeEventListener('touchmove', handleMove);
|
|
131
136
|
};
|
|
132
137
|
}, [svgRef, dispatch, left, width, top, height, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener]);
|
|
133
138
|
};
|
package/hooks/useAxisEvents.js
CHANGED
|
@@ -98,7 +98,7 @@ const useAxisEvents = disableAxisListener => {
|
|
|
98
98
|
value: axisData[dataIndex]
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
|
-
const
|
|
101
|
+
const handleOut = () => {
|
|
102
102
|
mousePosition.current = {
|
|
103
103
|
x: -1,
|
|
104
104
|
y: -1
|
|
@@ -107,8 +107,9 @@ const useAxisEvents = disableAxisListener => {
|
|
|
107
107
|
type: 'exitChart'
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
|
-
const
|
|
111
|
-
const
|
|
110
|
+
const handleMove = event => {
|
|
111
|
+
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
112
|
+
const svgPoint = (0, _utils.getSVGPoint)(svgRef.current, target);
|
|
112
113
|
mousePosition.current = {
|
|
113
114
|
x: svgPoint.x,
|
|
114
115
|
y: svgPoint.y
|
|
@@ -131,11 +132,15 @@ const useAxisEvents = disableAxisListener => {
|
|
|
131
132
|
}
|
|
132
133
|
});
|
|
133
134
|
};
|
|
134
|
-
element.addEventListener('mouseout',
|
|
135
|
-
element.addEventListener('mousemove',
|
|
135
|
+
element.addEventListener('mouseout', handleOut);
|
|
136
|
+
element.addEventListener('mousemove', handleMove);
|
|
137
|
+
element.addEventListener('touchend', handleOut);
|
|
138
|
+
element.addEventListener('touchmove', handleMove);
|
|
136
139
|
return () => {
|
|
137
|
-
element.removeEventListener('mouseout',
|
|
138
|
-
element.removeEventListener('mousemove',
|
|
140
|
+
element.removeEventListener('mouseout', handleOut);
|
|
141
|
+
element.removeEventListener('mousemove', handleMove);
|
|
142
|
+
element.removeEventListener('touchend', handleOut);
|
|
143
|
+
element.removeEventListener('touchmove', handleMove);
|
|
139
144
|
};
|
|
140
145
|
}, [svgRef, dispatch, left, width, top, height, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener]);
|
|
141
146
|
};
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AllSeriesType } from '../models/seriesType';
|
|
|
2
2
|
export declare function defaultizeColor(series: AllSeriesType, seriesIndex: number, colors?: string[]): {
|
|
3
3
|
data: {
|
|
4
4
|
color: string;
|
|
5
|
-
label?: string | undefined;
|
|
5
|
+
label?: string | ((location: "tooltip" | "legend" | "arc") => string) | undefined;
|
|
6
6
|
value: number;
|
|
7
7
|
id?: import("../models/seriesType").PieItemId | undefined;
|
|
8
8
|
}[];
|
|
@@ -15,7 +15,9 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
15
15
|
endAngle?: number | undefined;
|
|
16
16
|
paddingAngle?: number | undefined;
|
|
17
17
|
sortingValues?: import("../models/seriesType").ChartsPieSorting | undefined;
|
|
18
|
-
arcLabel?: "label" | "value" | "formattedValue" | ((item: import("../models/seriesType").DefaultizedPieValueType
|
|
18
|
+
arcLabel?: "label" | "value" | "formattedValue" | ((item: Omit<import("../models/seriesType").DefaultizedPieValueType, "label"> & {
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
}) => string) | undefined;
|
|
19
21
|
arcLabelMinAngle?: number | undefined;
|
|
20
22
|
cx?: string | number | undefined;
|
|
21
23
|
cy?: string | number | undefined;
|
|
@@ -45,7 +47,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
45
47
|
type: "bar";
|
|
46
48
|
data?: (number | null)[] | undefined;
|
|
47
49
|
dataKey?: string | undefined;
|
|
48
|
-
label?: string | undefined;
|
|
50
|
+
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
49
51
|
layout?: "horizontal" | "vertical" | undefined;
|
|
50
52
|
stackOffset?: import("..").StackOffsetType | undefined;
|
|
51
53
|
id?: import("../models/seriesType/common").SeriesId | undefined;
|
|
@@ -60,7 +62,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
60
62
|
type: "scatter";
|
|
61
63
|
data: import("../models/seriesType").ScatterValueType[];
|
|
62
64
|
markerSize?: number | undefined;
|
|
63
|
-
label?: string | undefined;
|
|
65
|
+
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
64
66
|
disableHover?: boolean | undefined;
|
|
65
67
|
zAxisKey?: string | undefined;
|
|
66
68
|
id?: import("../models/seriesType/common").SeriesId | undefined;
|
|
@@ -75,7 +77,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
75
77
|
dataKey?: string | undefined;
|
|
76
78
|
stack?: string | undefined;
|
|
77
79
|
area?: boolean | undefined;
|
|
78
|
-
label?: string | undefined;
|
|
80
|
+
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
79
81
|
curve?: import("../models/seriesType").CurveType | undefined;
|
|
80
82
|
showMark?: boolean | ((params: import("../models/seriesType").ShowMarkParams<number | Date>) => boolean) | undefined;
|
|
81
83
|
disableHighlight?: boolean | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLabel<Location extends string>(value: string | ((location: Location) => string) | undefined, location: Location): string | undefined;
|
package/internals/utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U,
|
|
|
9
9
|
* @param svg The SVG element
|
|
10
10
|
* @param event The mouseEvent to transform
|
|
11
11
|
*/
|
|
12
|
-
export declare function getSVGPoint(svg: SVGSVGElement, event: MouseEvent): DOMPoint;
|
|
12
|
+
export declare function getSVGPoint(svg: SVGSVGElement, event: Pick<MouseEvent, 'clientX' | 'clientY'>): DOMPoint;
|
|
13
13
|
/**
|
|
14
14
|
* Helper that converts values and percentages into values.
|
|
15
15
|
* @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
|
|
@@ -11,7 +11,10 @@ export interface BarSeriesType extends CommonSeriesType<number | null>, Cartesia
|
|
|
11
11
|
* The key used to retrieve data from the dataset.
|
|
12
12
|
*/
|
|
13
13
|
dataKey?: string;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The label to display on the tooltip or the legend. It can be a string or a function.
|
|
16
|
+
*/
|
|
17
|
+
label?: string | ((location: 'tooltip' | 'legend') => string);
|
|
15
18
|
/**
|
|
16
19
|
* Layout of the bars. All bar should have the same layout.
|
|
17
20
|
* @default 'vertical'
|
|
@@ -36,7 +36,10 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
|
|
|
36
36
|
dataKey?: string;
|
|
37
37
|
stack?: string;
|
|
38
38
|
area?: boolean;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The label to display on the tooltip or the legend. It can be a string or a function.
|
|
41
|
+
*/
|
|
42
|
+
label?: string | ((location: 'tooltip' | 'legend') => string);
|
|
40
43
|
curve?: CurveType;
|
|
41
44
|
/**
|
|
42
45
|
* Define which items of the series should display a mark.
|
|
@@ -8,7 +8,10 @@ export type PieValueType = {
|
|
|
8
8
|
*/
|
|
9
9
|
id: PieItemId;
|
|
10
10
|
value: number;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The label to display on the tooltip, arc, or the legend. It can be a string or a function.
|
|
13
|
+
*/
|
|
14
|
+
label?: string | ((location: 'tooltip' | 'legend' | 'arc') => string);
|
|
12
15
|
color?: string;
|
|
13
16
|
};
|
|
14
17
|
export type DefaultizedPieValueType = PieValueType & Omit<D3PieArcDatum<any>, 'data'> & {
|
|
@@ -16,9 +19,9 @@ export type DefaultizedPieValueType = PieValueType & Omit<D3PieArcDatum<any>, 'd
|
|
|
16
19
|
formattedValue: string;
|
|
17
20
|
};
|
|
18
21
|
export type ChartsPieSorting = 'none' | 'asc' | 'desc' | ((a: number, b: number) => number);
|
|
19
|
-
export interface PieSeriesType<
|
|
22
|
+
export interface PieSeriesType<TData = PieValueType> extends CommonSeriesType<TData> {
|
|
20
23
|
type: 'pie';
|
|
21
|
-
data:
|
|
24
|
+
data: TData[];
|
|
22
25
|
/**
|
|
23
26
|
* The radius between circle center and the beginning of the arc.
|
|
24
27
|
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
@@ -69,7 +72,9 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
|
|
|
69
72
|
/**
|
|
70
73
|
* The label displayed into the arc.
|
|
71
74
|
*/
|
|
72
|
-
arcLabel?: 'formattedValue' | 'label' | 'value' | ((item: DefaultizedPieValueType
|
|
75
|
+
arcLabel?: 'formattedValue' | 'label' | 'value' | ((item: Omit<DefaultizedPieValueType, 'label'> & {
|
|
76
|
+
label?: string;
|
|
77
|
+
}) => string);
|
|
73
78
|
/**
|
|
74
79
|
* The minimal angle required to display the arc label.
|
|
75
80
|
* @default 0
|
|
@@ -13,7 +13,10 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, C
|
|
|
13
13
|
type: 'scatter';
|
|
14
14
|
data: ScatterValueType[];
|
|
15
15
|
markerSize?: number;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The label to display on the tooltip or the legend. It can be a string or a function.
|
|
18
|
+
*/
|
|
19
|
+
label?: string | ((location: 'tooltip' | 'legend') => string);
|
|
17
20
|
/**
|
|
18
21
|
* If true, the interaction will not use element hover for this series.
|
|
19
22
|
* @default false
|
|
@@ -205,6 +205,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
205
205
|
}),
|
|
206
206
|
/**
|
|
207
207
|
* If `true`, a loading overlay is displayed.
|
|
208
|
+
* @default false
|
|
208
209
|
*/
|
|
209
210
|
loading: PropTypes.bool,
|
|
210
211
|
/**
|
|
@@ -297,6 +298,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
297
298
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
298
299
|
classes: PropTypes.object,
|
|
299
300
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
301
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
302
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
303
|
+
unknownColor: PropTypes.string,
|
|
304
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
305
|
+
}), PropTypes.shape({
|
|
300
306
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
301
307
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
302
308
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -305,11 +311,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
305
311
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
306
312
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
307
313
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
308
|
-
}), PropTypes.shape({
|
|
309
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
310
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
311
|
-
unknownColor: PropTypes.string,
|
|
312
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
313
314
|
})]),
|
|
314
315
|
data: PropTypes.array,
|
|
315
316
|
dataKey: PropTypes.string,
|
|
@@ -350,6 +351,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
350
351
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
351
352
|
classes: PropTypes.object,
|
|
352
353
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
354
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
355
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
356
|
+
unknownColor: PropTypes.string,
|
|
357
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
358
|
+
}), PropTypes.shape({
|
|
353
359
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
354
360
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
355
361
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -358,11 +364,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
358
364
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
359
365
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
360
366
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
361
|
-
}), PropTypes.shape({
|
|
362
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
363
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
364
|
-
unknownColor: PropTypes.string,
|
|
365
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
366
367
|
})]),
|
|
367
368
|
data: PropTypes.array,
|
|
368
369
|
dataKey: PropTypes.string,
|
|
@@ -79,16 +79,17 @@ function BarElement(props) {
|
|
|
79
79
|
const barProps = useSlotProps({
|
|
80
80
|
elementType: Bar,
|
|
81
81
|
externalSlotProps: slotProps?.bar,
|
|
82
|
-
|
|
82
|
+
externalForwardedProps: other,
|
|
83
|
+
additionalProps: _extends({}, getInteractionItemProps({
|
|
83
84
|
type: 'bar',
|
|
84
85
|
seriesId: id,
|
|
85
86
|
dataIndex
|
|
86
87
|
}), {
|
|
87
88
|
style,
|
|
88
|
-
className: classes.root,
|
|
89
89
|
onClick,
|
|
90
90
|
cursor: onClick ? 'pointer' : 'unset'
|
|
91
91
|
}),
|
|
92
|
+
className: classes.root,
|
|
92
93
|
ownerState
|
|
93
94
|
});
|
|
94
95
|
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { getLabel } from '../internals/getLabel';
|
|
1
2
|
const legendGetter = params => {
|
|
2
3
|
const {
|
|
3
4
|
seriesOrder,
|
|
4
5
|
series
|
|
5
6
|
} = params;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return seriesOrder.reduce((acc, seriesId) => {
|
|
8
|
+
const formattedLabel = getLabel(series[seriesId].label, 'legend');
|
|
9
|
+
if (formattedLabel === undefined) {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
acc.push({
|
|
13
|
+
color: series[seriesId].color,
|
|
14
|
+
label: formattedLabel,
|
|
15
|
+
id: seriesId
|
|
16
|
+
});
|
|
17
|
+
return acc;
|
|
18
|
+
}, []);
|
|
12
19
|
};
|
|
13
20
|
export default legendGetter;
|
|
@@ -127,6 +127,11 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
127
127
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
128
128
|
classes: PropTypes.object,
|
|
129
129
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
130
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
131
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
132
|
+
unknownColor: PropTypes.string,
|
|
133
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
134
|
+
}), PropTypes.shape({
|
|
130
135
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
131
136
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
132
137
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -135,11 +140,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
135
140
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
136
141
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
137
142
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
138
|
-
}), PropTypes.shape({
|
|
139
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
140
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
141
|
-
unknownColor: PropTypes.string,
|
|
142
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
143
143
|
})]),
|
|
144
144
|
data: PropTypes.array,
|
|
145
145
|
dataKey: PropTypes.string,
|
|
@@ -180,6 +180,11 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
180
180
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
181
181
|
classes: PropTypes.object,
|
|
182
182
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
183
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
184
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
185
|
+
unknownColor: PropTypes.string,
|
|
186
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
187
|
+
}), PropTypes.shape({
|
|
183
188
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
184
189
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
185
190
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -188,11 +193,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
188
193
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
189
194
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
190
195
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
191
|
-
}), PropTypes.shape({
|
|
192
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
193
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
194
|
-
unknownColor: PropTypes.string,
|
|
195
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
196
196
|
})]),
|
|
197
197
|
data: PropTypes.array,
|
|
198
198
|
dataKey: PropTypes.string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["message"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
@@ -7,7 +7,7 @@ import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const StyledText = styled('text')(({
|
|
9
9
|
theme
|
|
10
|
-
}) => ({
|
|
10
|
+
}) => _extends({}, theme.typography.body2, {
|
|
11
11
|
stroke: 'none',
|
|
12
12
|
fill: theme.palette.text.primary,
|
|
13
13
|
shapeRendering: 'crispEdges',
|
|
@@ -29,6 +29,6 @@ export function ChartsLoadingOverlay(props) {
|
|
|
29
29
|
x: left + width / 2,
|
|
30
30
|
y: top + height / 2
|
|
31
31
|
}, other, {
|
|
32
|
-
children: message ?? 'Loading data
|
|
32
|
+
children: message ?? 'Loading data…'
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["message"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
@@ -7,7 +7,7 @@ import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const StyledText = styled('text')(({
|
|
9
9
|
theme
|
|
10
|
-
}) => ({
|
|
10
|
+
}) => _extends({}, theme.typography.body2, {
|
|
11
11
|
stroke: 'none',
|
|
12
12
|
fill: theme.palette.text.primary,
|
|
13
13
|
shapeRendering: 'crispEdges',
|
|
@@ -4,6 +4,7 @@ import clsx from 'clsx';
|
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
6
|
import { isCartesianSeries, utcFormatter } from './utils';
|
|
7
|
+
import { getLabel } from '../internals/getLabel';
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
function DefaultChartsAxisTooltipContent(props) {
|
|
9
10
|
const {
|
|
@@ -50,6 +51,7 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
50
51
|
if (formattedValue == null) {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
54
|
+
const formattedLabel = getLabel(label, 'tooltip');
|
|
53
55
|
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
54
56
|
className: classes.row,
|
|
55
57
|
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
@@ -60,8 +62,8 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
60
62
|
})
|
|
61
63
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
62
64
|
className: clsx(classes.labelCell, classes.cell),
|
|
63
|
-
children:
|
|
64
|
-
children:
|
|
65
|
+
children: formattedLabel ? /*#__PURE__*/_jsx(Typography, {
|
|
66
|
+
children: formattedLabel
|
|
65
67
|
}) : null
|
|
66
68
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
67
69
|
className: clsx(classes.valueCell, classes.cell),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import clsx from 'clsx';
|
|
4
5
|
import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
|
+
import { getLabel } from '../internals/getLabel';
|
|
5
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
8
|
function DefaultChartsItemTooltipContent(props) {
|
|
7
9
|
const {
|
|
@@ -19,12 +21,14 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
19
21
|
color
|
|
20
22
|
} = series.type === 'pie' ? {
|
|
21
23
|
color: getColor(itemData.dataIndex),
|
|
22
|
-
displayedLabel: series.data[itemData.dataIndex].label
|
|
24
|
+
displayedLabel: getLabel(series.data[itemData.dataIndex].label, 'tooltip')
|
|
23
25
|
} : {
|
|
24
26
|
color: getColor(itemData.dataIndex) ?? series.color,
|
|
25
|
-
displayedLabel: series.label
|
|
27
|
+
displayedLabel: getLabel(series.label, 'tooltip')
|
|
26
28
|
};
|
|
27
|
-
const value = series.data[itemData.dataIndex]
|
|
29
|
+
const value = series.type === 'pie' ? _extends({}, series.data[itemData.dataIndex], {
|
|
30
|
+
label: getLabel(series.data[itemData.dataIndex].label, 'tooltip')
|
|
31
|
+
}) : series.data[itemData.dataIndex];
|
|
28
32
|
const formattedValue = series.valueFormatter?.(value, {
|
|
29
33
|
dataIndex: itemData.dataIndex
|
|
30
34
|
});
|
|
@@ -53,20 +53,25 @@ export function useMouseTracker() {
|
|
|
53
53
|
if (element === null) {
|
|
54
54
|
return () => {};
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const handleOut = () => {
|
|
57
57
|
setMousePosition(null);
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const handleMove = event => {
|
|
60
|
+
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
60
61
|
setMousePosition({
|
|
61
|
-
x:
|
|
62
|
-
y:
|
|
62
|
+
x: target.clientX,
|
|
63
|
+
y: target.clientY
|
|
63
64
|
});
|
|
64
65
|
};
|
|
65
|
-
element.addEventListener('mouseout',
|
|
66
|
-
element.addEventListener('mousemove',
|
|
66
|
+
element.addEventListener('mouseout', handleOut);
|
|
67
|
+
element.addEventListener('mousemove', handleMove);
|
|
68
|
+
element.addEventListener('touchend', handleOut);
|
|
69
|
+
element.addEventListener('touchmove', handleMove);
|
|
67
70
|
return () => {
|
|
68
|
-
element.removeEventListener('mouseout',
|
|
69
|
-
element.removeEventListener('mousemove',
|
|
71
|
+
element.removeEventListener('mouseout', handleOut);
|
|
72
|
+
element.removeEventListener('mousemove', handleMove);
|
|
73
|
+
element.addEventListener('touchend', handleOut);
|
|
74
|
+
element.addEventListener('touchmove', handleMove);
|
|
70
75
|
};
|
|
71
76
|
}, [svgRef]);
|
|
72
77
|
return mousePosition;
|
|
@@ -167,8 +167,7 @@ function ChartsXAxis(inProps) {
|
|
|
167
167
|
textAnchor: 'middle',
|
|
168
168
|
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
169
169
|
fontSize: tickFontSize ?? 12
|
|
170
|
-
}, tickLabelStyle)
|
|
171
|
-
className: classes.tickLabel
|
|
170
|
+
}, tickLabelStyle)
|
|
172
171
|
},
|
|
173
172
|
className: classes.tickLabel,
|
|
174
173
|
ownerState: {}
|
|
@@ -120,9 +120,9 @@ function ChartsYAxis(inProps) {
|
|
|
120
120
|
fontSize: tickFontSize,
|
|
121
121
|
textAnchor: position === 'right' ? 'start' : 'end',
|
|
122
122
|
dominantBaseline: 'central'
|
|
123
|
-
}, tickLabelStyle)
|
|
124
|
-
className: classes.tickLabel
|
|
123
|
+
}, tickLabelStyle)
|
|
125
124
|
},
|
|
125
|
+
className: classes.tickLabel,
|
|
126
126
|
ownerState: {}
|
|
127
127
|
});
|
|
128
128
|
const axisLabelProps = useSlotProps({
|
|
@@ -74,17 +74,17 @@ function AreaElement(props) {
|
|
|
74
74
|
const areaProps = useSlotProps({
|
|
75
75
|
elementType: Area,
|
|
76
76
|
externalSlotProps: slotProps?.area,
|
|
77
|
-
additionalProps: _extends({},
|
|
77
|
+
additionalProps: _extends({}, getInteractionItemProps({
|
|
78
78
|
type: 'line',
|
|
79
79
|
seriesId: id
|
|
80
80
|
}), {
|
|
81
|
-
className: classes.root,
|
|
82
81
|
onClick,
|
|
83
82
|
cursor: onClick ? 'pointer' : 'unset'
|
|
84
83
|
}),
|
|
84
|
+
className: classes.root,
|
|
85
85
|
ownerState
|
|
86
86
|
});
|
|
87
|
-
return /*#__PURE__*/_jsx(Area, _extends({}, areaProps));
|
|
87
|
+
return /*#__PURE__*/_jsx(Area, _extends({}, other, areaProps));
|
|
88
88
|
}
|
|
89
89
|
process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
90
90
|
// ----------------------------- Warning --------------------------------
|
|
@@ -33,7 +33,8 @@ const useAggregatedData = () => {
|
|
|
33
33
|
return stackingGroups.flatMap(({
|
|
34
34
|
ids: groupIds
|
|
35
35
|
}) => {
|
|
36
|
-
return groupIds.
|
|
36
|
+
return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
|
|
37
|
+
.map(seriesId => {
|
|
37
38
|
const {
|
|
38
39
|
xAxisKey = defaultXAxisId,
|
|
39
40
|
yAxisKey = defaultYAxisId,
|
|
@@ -92,7 +93,7 @@ function AreaPlot(props) {
|
|
|
92
93
|
const getGradientId = useChartGradient();
|
|
93
94
|
const completedData = useAggregatedData();
|
|
94
95
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
95
|
-
children: completedData.
|
|
96
|
+
children: completedData.map(({
|
|
96
97
|
d,
|
|
97
98
|
seriesId,
|
|
98
99
|
color,
|