@mui/x-charts 8.0.0-alpha.3 → 8.0.0-alpha.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/CHANGELOG.md +274 -0
- package/ChartsAxis/ChartsAxis.js +0 -4
- package/ChartsLabel/ChartsLabel.d.ts +19 -0
- package/ChartsLabel/ChartsLabel.js +58 -0
- package/ChartsLabel/ChartsLabelGradient.d.ts +40 -0
- package/ChartsLabel/ChartsLabelGradient.js +133 -0
- package/ChartsLabel/ChartsLabelMark.d.ts +27 -0
- package/ChartsLabel/ChartsLabelMark.js +108 -0
- package/ChartsLabel/labelClasses.d.ts +9 -0
- package/ChartsLabel/labelClasses.js +13 -0
- package/ChartsLabel/labelGradientClasses.d.ts +15 -0
- package/ChartsLabel/labelGradientClasses.js +17 -0
- package/ChartsLabel/labelMarkClasses.d.ts +17 -0
- package/ChartsLabel/labelMarkClasses.js +17 -0
- package/ChartsLegend/useAxis.js +3 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
- package/ChartsTooltip/ChartsTooltipTable.js +15 -13
- package/ChartsTooltip/chartsTooltipClasses.d.ts +3 -1
- package/ChartsTooltip/chartsTooltipClasses.js +3 -2
- package/ChartsTooltip/useAxisTooltip.js +2 -3
- package/ChartsTooltip/useItemTooltip.js +2 -3
- package/PieChart/PiePlot.js +2 -2
- package/README.md +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/extremums.js +1 -3
- package/ScatterChart/formatter.js +2 -2
- package/hooks/useChartId.d.ts +1 -1
- package/hooks/useColorScale.js +2 -3
- package/hooks/useZAxis.d.ts +6 -0
- package/hooks/useZAxis.js +8 -0
- package/index.js +1 -1
- package/internals/consumeThemeProps.d.ts +54 -0
- package/internals/consumeThemeProps.js +79 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +6 -6
- package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +3 -3
- package/internals/store/useCharts.js +8 -2
- package/modern/ChartsAxis/ChartsAxis.js +0 -4
- package/modern/ChartsLabel/ChartsLabel.js +58 -0
- package/modern/ChartsLabel/ChartsLabelGradient.js +133 -0
- package/modern/ChartsLabel/ChartsLabelMark.js +108 -0
- package/modern/ChartsLabel/labelClasses.js +13 -0
- package/modern/ChartsLabel/labelGradientClasses.js +17 -0
- package/modern/ChartsLabel/labelMarkClasses.js +17 -0
- package/modern/ChartsLegend/useAxis.js +3 -3
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
- package/modern/ChartsTooltip/ChartsTooltipTable.js +15 -13
- package/modern/ChartsTooltip/chartsTooltipClasses.js +3 -2
- package/modern/ChartsTooltip/useAxisTooltip.js +2 -3
- package/modern/ChartsTooltip/useItemTooltip.js +2 -3
- package/modern/PieChart/PiePlot.js +2 -2
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/extremums.js +1 -3
- package/modern/ScatterChart/formatter.js +2 -2
- package/modern/hooks/useColorScale.js +2 -3
- package/modern/hooks/useZAxis.js +8 -0
- package/modern/index.js +1 -1
- package/modern/internals/consumeThemeProps.js +79 -0
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/modern/internals/store/useCharts.js +8 -2
- package/node/ChartsAxis/ChartsAxis.js +0 -4
- package/node/ChartsLabel/ChartsLabel.js +64 -0
- package/node/ChartsLabel/ChartsLabelGradient.js +139 -0
- package/node/ChartsLabel/ChartsLabelMark.js +114 -0
- package/node/ChartsLabel/labelClasses.js +22 -0
- package/node/ChartsLabel/labelGradientClasses.js +26 -0
- package/node/ChartsLabel/labelMarkClasses.js +26 -0
- package/node/ChartsLegend/useAxis.js +2 -4
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
- package/node/ChartsTooltip/ChartsTooltipTable.js +15 -13
- package/node/ChartsTooltip/chartsTooltipClasses.js +3 -2
- package/node/ChartsTooltip/useAxisTooltip.js +2 -4
- package/node/ChartsTooltip/useItemTooltip.js +2 -4
- package/node/PieChart/PiePlot.js +2 -2
- package/node/ScatterChart/ScatterPlot.js +2 -2
- package/node/ScatterChart/extremums.js +1 -3
- package/node/ScatterChart/formatter.js +2 -2
- package/node/hooks/useColorScale.js +2 -4
- package/node/hooks/useZAxis.js +15 -0
- package/node/index.js +1 -1
- package/node/internals/consumeThemeProps.js +87 -0
- package/node/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/node/internals/store/useCharts.js +9 -2
- package/package.json +4 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChartsLabelProps } from './ChartsLabel';
|
|
2
|
+
export interface ChartsLabelClasses {
|
|
3
|
+
/** Styles applied to the root element. */
|
|
4
|
+
root: string;
|
|
5
|
+
}
|
|
6
|
+
export type ChartsLabelClassKey = keyof ChartsLabelClasses;
|
|
7
|
+
export declare function getLabelUtilityClass(slot: string): string;
|
|
8
|
+
export declare const labelClasses: ChartsLabelClasses;
|
|
9
|
+
export declare const useUtilityClasses: (props: ChartsLabelProps) => Record<"root", string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getLabelUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiChartsLabel', slot);
|
|
6
|
+
}
|
|
7
|
+
export const labelClasses = generateUtilityClasses('MuiChartsLabel', ['root']);
|
|
8
|
+
export const useUtilityClasses = props => {
|
|
9
|
+
const slots = {
|
|
10
|
+
root: ['root']
|
|
11
|
+
};
|
|
12
|
+
return composeClasses(slots, getLabelUtilityClass, props.classes);
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChartsLabelGradientProps } from './ChartsLabelGradient';
|
|
2
|
+
export interface ChartsLabelGradientClasses {
|
|
3
|
+
/** Styles applied to the root element. */
|
|
4
|
+
root: string;
|
|
5
|
+
/** Styles applied to the "mask" that gives shape to the gradient. */
|
|
6
|
+
mask: string;
|
|
7
|
+
/** Styles applied when direction is "column". */
|
|
8
|
+
column: string;
|
|
9
|
+
/** Styles applied when direction is "row". */
|
|
10
|
+
row: string;
|
|
11
|
+
}
|
|
12
|
+
export type ChartsLabelGradientClassKey = keyof ChartsLabelGradientClasses;
|
|
13
|
+
export declare function getLabelGradientUtilityClass(slot: string): string;
|
|
14
|
+
export declare const labelGradientClasses: ChartsLabelGradientClasses;
|
|
15
|
+
export declare const useUtilityClasses: (props: ChartsLabelGradientProps) => Record<"mask" | "root", string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getLabelGradientUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiChartsLabelGradient', slot);
|
|
6
|
+
}
|
|
7
|
+
export const labelGradientClasses = generateUtilityClasses('MuiChartsLabelGradient', ['root', 'column', 'row', 'mask']);
|
|
8
|
+
export const useUtilityClasses = props => {
|
|
9
|
+
const {
|
|
10
|
+
direction
|
|
11
|
+
} = props;
|
|
12
|
+
const slots = {
|
|
13
|
+
root: ['root', direction],
|
|
14
|
+
mask: ['mask']
|
|
15
|
+
};
|
|
16
|
+
return composeClasses(slots, getLabelGradientUtilityClass, props.classes);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChartsLabelMarkProps } from './ChartsLabelMark';
|
|
2
|
+
export interface ChartsLabelMarkClasses {
|
|
3
|
+
/** Styles applied to the root element. */
|
|
4
|
+
root: string;
|
|
5
|
+
/** Styles applied to the "mask" that gives shape to the marks. */
|
|
6
|
+
mask: string;
|
|
7
|
+
/** Styles applied to the mark type "line". */
|
|
8
|
+
line: string;
|
|
9
|
+
/** Styles applied to the mark type "square". */
|
|
10
|
+
square: string;
|
|
11
|
+
/** Styles applied to the mark type "circle". */
|
|
12
|
+
circle: string;
|
|
13
|
+
}
|
|
14
|
+
export type ChartsLabelMarkClassKey = keyof ChartsLabelMarkClasses;
|
|
15
|
+
export declare function getLabelMarkUtilityClass(slot: string): string;
|
|
16
|
+
export declare const labelMarkClasses: ChartsLabelMarkClasses;
|
|
17
|
+
export declare const useUtilityClasses: (props: ChartsLabelMarkProps) => Record<"mask" | "root", string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getLabelMarkUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiChartsLabelMark', slot);
|
|
6
|
+
}
|
|
7
|
+
export const labelMarkClasses = generateUtilityClasses('MuiChartsLabelMark', ['root', 'line', 'square', 'circle', 'mask']);
|
|
8
|
+
export const useUtilityClasses = props => {
|
|
9
|
+
const {
|
|
10
|
+
type
|
|
11
|
+
} = props;
|
|
12
|
+
const slots = {
|
|
13
|
+
root: ['root', type],
|
|
14
|
+
mask: ['mask']
|
|
15
|
+
};
|
|
16
|
+
return composeClasses(slots, getLabelMarkUtilityClass, props.classes);
|
|
17
|
+
};
|
package/ChartsLegend/useAxis.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
5
3
|
import { useCartesianContext } from "../context/CartesianProvider/useCartesianContext.js";
|
|
4
|
+
import { useZAxis } from "../hooks/useZAxis.js";
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* Helper to select an axis definition according to its direction and id.
|
|
8
8
|
*/
|
|
@@ -19,7 +19,7 @@ export function useAxis({
|
|
|
19
19
|
const {
|
|
20
20
|
zAxis,
|
|
21
21
|
zAxisIds
|
|
22
|
-
} =
|
|
22
|
+
} = useZAxis();
|
|
23
23
|
switch (axisDirection) {
|
|
24
24
|
case 'x':
|
|
25
25
|
{
|
|
@@ -14,11 +14,11 @@ function ChartsAxisTooltipContent(props) {
|
|
|
14
14
|
classes: propClasses,
|
|
15
15
|
sx
|
|
16
16
|
} = props;
|
|
17
|
-
const
|
|
17
|
+
const tooltipData = useAxisTooltip();
|
|
18
18
|
const xAxis = useXAxis();
|
|
19
19
|
const yAxis = useYAxis();
|
|
20
20
|
const classes = useUtilityClasses(propClasses);
|
|
21
|
-
if (
|
|
21
|
+
if (tooltipData === null) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
const {
|
|
@@ -26,7 +26,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
26
26
|
axisValue,
|
|
27
27
|
axisFormattedValue,
|
|
28
28
|
seriesItems
|
|
29
|
-
} =
|
|
29
|
+
} = tooltipData;
|
|
30
30
|
const axis = axisDirection === 'x' ? xAxis : yAxis;
|
|
31
31
|
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
32
32
|
sx: sx,
|
|
@@ -35,8 +35,10 @@ function ChartsAxisTooltipContent(props) {
|
|
|
35
35
|
className: classes.table,
|
|
36
36
|
children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
|
|
37
37
|
children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
|
|
38
|
+
className: classes.row,
|
|
38
39
|
children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
39
40
|
colSpan: 3,
|
|
41
|
+
className: clsx(classes.cell, classes.axisValueCell),
|
|
40
42
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
41
43
|
children: axisFormattedValue
|
|
42
44
|
})
|
|
@@ -12,11 +12,10 @@ export const ChartsTooltipPaper = styled('div', {
|
|
|
12
12
|
})(({
|
|
13
13
|
theme
|
|
14
14
|
}) => ({
|
|
15
|
-
boxShadow: theme.shadows[1],
|
|
16
15
|
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
17
16
|
color: (theme.vars || theme).palette.text.primary,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
borderRadius: theme.shape.borderRadius,
|
|
18
|
+
border: `solid ${(theme.vars || theme).palette.divider} 1px`
|
|
20
19
|
}));
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -46,10 +45,10 @@ export const ChartsTooltipRow = styled('tr', {
|
|
|
46
45
|
theme
|
|
47
46
|
}) => ({
|
|
48
47
|
'tr:first-of-type& td': {
|
|
49
|
-
paddingTop: theme.spacing(
|
|
48
|
+
paddingTop: theme.spacing(0.5)
|
|
50
49
|
},
|
|
51
50
|
'tr:last-of-type& td': {
|
|
52
|
-
paddingBottom: theme.spacing(
|
|
51
|
+
paddingBottom: theme.spacing(0.5)
|
|
53
52
|
}
|
|
54
53
|
}));
|
|
55
54
|
|
|
@@ -66,17 +65,23 @@ export const ChartsTooltipCell = styled('td', {
|
|
|
66
65
|
verticalAlign: 'middle',
|
|
67
66
|
color: (theme.vars || theme).palette.text.secondary,
|
|
68
67
|
[`&.${chartsTooltipClasses.labelCell}`]: {
|
|
69
|
-
paddingLeft: theme.spacing(1)
|
|
68
|
+
paddingLeft: theme.spacing(1),
|
|
69
|
+
paddingRight: theme.spacing(1.5),
|
|
70
|
+
fontWeight: theme.typography.fontWeightRegular
|
|
71
|
+
},
|
|
72
|
+
[`&.${chartsTooltipClasses.valueCell}, &.${chartsTooltipClasses.axisValueCell}`]: {
|
|
73
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
74
|
+
fontWeight: theme.typography.fontWeightMedium
|
|
70
75
|
},
|
|
71
76
|
[`&.${chartsTooltipClasses.valueCell}`]: {
|
|
72
|
-
paddingLeft: theme.spacing(
|
|
73
|
-
|
|
77
|
+
paddingLeft: theme.spacing(1.5),
|
|
78
|
+
paddingRight: theme.spacing(1.5)
|
|
74
79
|
},
|
|
75
80
|
'td:first-of-type&': {
|
|
76
|
-
paddingLeft: theme.spacing(
|
|
81
|
+
paddingLeft: theme.spacing(1.5)
|
|
77
82
|
},
|
|
78
83
|
'td:last-of-type&': {
|
|
79
|
-
paddingRight: theme.spacing(
|
|
84
|
+
paddingRight: theme.spacing(1.5)
|
|
80
85
|
}
|
|
81
86
|
}));
|
|
82
87
|
|
|
@@ -95,9 +100,6 @@ export const ChartsTooltipMark = styled('div', {
|
|
|
95
100
|
width: theme.spacing(1),
|
|
96
101
|
height: theme.spacing(1),
|
|
97
102
|
borderRadius: '50%',
|
|
98
|
-
boxShadow: theme.shadows[1],
|
|
99
103
|
background: color,
|
|
100
|
-
borderColor: (theme.vars || theme).palette.background.paper,
|
|
101
|
-
border: `solid ${(theme.vars || theme).palette.background.paper} ${theme.spacing(0.25)}`,
|
|
102
104
|
boxSizing: 'content-box'
|
|
103
105
|
}));
|
|
@@ -17,8 +17,10 @@ export interface ChartsTooltipClasses {
|
|
|
17
17
|
labelCell: string;
|
|
18
18
|
/** Styles applied to the valueCell element. */
|
|
19
19
|
valueCell: string;
|
|
20
|
+
/** Styles applied to the axisValueCell element. Only available for axis tooltip. */
|
|
21
|
+
axisValueCell: string;
|
|
20
22
|
}
|
|
21
23
|
export type ChartsTooltipClassKey = keyof Omit<ChartsTooltipClasses, 'markCell' | 'labelCell' | 'valueCell'>;
|
|
22
24
|
export declare function getChartsTooltipUtilityClass(slot: string): string;
|
|
23
25
|
export declare const chartsTooltipClasses: ChartsTooltipClasses;
|
|
24
|
-
export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"cell" | "table" | "row" | "mark" | "root" | "paper" | "markCell" | "labelCell" | "valueCell", string>;
|
|
26
|
+
export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"cell" | "table" | "row" | "mark" | "root" | "paper" | "markCell" | "labelCell" | "valueCell" | "axisValueCell", string>;
|
|
@@ -4,7 +4,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
4
4
|
export function getChartsTooltipUtilityClass(slot) {
|
|
5
5
|
return generateUtilityClass('MuiChartsTooltip', slot);
|
|
6
6
|
}
|
|
7
|
-
export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
|
|
7
|
+
export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell', 'axisValueCell']);
|
|
8
8
|
export const useUtilityClasses = classes => {
|
|
9
9
|
const slots = {
|
|
10
10
|
root: ['root'],
|
|
@@ -15,7 +15,8 @@ export const useUtilityClasses = classes => {
|
|
|
15
15
|
mark: ['mark'],
|
|
16
16
|
markCell: ['markCell'],
|
|
17
17
|
labelCell: ['labelCell'],
|
|
18
|
-
valueCell: ['valueCell']
|
|
18
|
+
valueCell: ['valueCell'],
|
|
19
|
+
axisValueCell: ['axisValueCell']
|
|
19
20
|
};
|
|
20
21
|
return composeClasses(slots, getChartsTooltipUtilityClass, classes);
|
|
21
22
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { useSeries } from "../hooks/useSeries.js";
|
|
5
4
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
6
|
-
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
7
5
|
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
8
6
|
import { useStore } from "../internals/store/useStore.js";
|
|
9
7
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
@@ -11,6 +9,7 @@ import { getLabel } from "../internals/getLabel.js";
|
|
|
11
9
|
import { isCartesianSeriesType } from "../internals/isCartesian.js";
|
|
12
10
|
import { utcFormatter } from "./utils.js";
|
|
13
11
|
import { useXAxis, useYAxis } from "../hooks/useAxis.js";
|
|
12
|
+
import { useZAxis } from "../hooks/useZAxis.js";
|
|
14
13
|
import { selectorChartsInteractionXAxis, selectorChartsInteractionYAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
15
14
|
export function useAxisTooltip() {
|
|
16
15
|
const defaultXAxis = useXAxis();
|
|
@@ -26,7 +25,7 @@ export function useAxisTooltip() {
|
|
|
26
25
|
const {
|
|
27
26
|
zAxis,
|
|
28
27
|
zAxisIds
|
|
29
|
-
} =
|
|
28
|
+
} = useZAxis();
|
|
30
29
|
const colorProcessors = useColorProcessor();
|
|
31
30
|
if (axisData === null) {
|
|
32
31
|
return null;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import * as React from 'react';
|
|
5
4
|
import { useSeries } from "../hooks/useSeries.js";
|
|
6
5
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
7
|
-
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
8
6
|
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
9
7
|
import { getLabel } from "../internals/getLabel.js";
|
|
10
8
|
import { selectorChartsInteractionItem } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
11
9
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
12
10
|
import { useStore } from "../internals/store/useStore.js";
|
|
11
|
+
import { useZAxis } from "../hooks/useZAxis.js";
|
|
13
12
|
export function useItemTooltip() {
|
|
14
13
|
const store = useStore();
|
|
15
14
|
const item = useSelector(store, selectorChartsInteractionItem);
|
|
@@ -23,7 +22,7 @@ export function useItemTooltip() {
|
|
|
23
22
|
const {
|
|
24
23
|
zAxis,
|
|
25
24
|
zAxisIds
|
|
26
|
-
} =
|
|
25
|
+
} = useZAxis();
|
|
27
26
|
const colorProcessors = useColorProcessor();
|
|
28
27
|
const xAxisId = series.xAxisId ?? xAxisIds[0];
|
|
29
28
|
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
package/PieChart/PiePlot.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
|
|
6
5
|
import { PieArcPlot } from "./PieArcPlot.js";
|
|
7
6
|
import { PieArcLabelPlot } from "./PieArcLabelPlot.js";
|
|
8
7
|
import { getPercentageValue } from "../internals/getPercentageValue.js";
|
|
9
8
|
import { getPieCoordinates } from "./getPieCoordinates.js";
|
|
10
9
|
import { usePieSeries } from "../hooks/useSeries.js";
|
|
11
10
|
import { useSkipAnimation } from "../context/AnimationProvider/index.js";
|
|
11
|
+
import { useDrawingArea } from "../hooks/index.js";
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
/**
|
|
14
14
|
* Demos:
|
|
@@ -33,7 +33,7 @@ function PiePlot(props) {
|
|
|
33
33
|
top,
|
|
34
34
|
width,
|
|
35
35
|
height
|
|
36
|
-
} =
|
|
36
|
+
} = useDrawingArea();
|
|
37
37
|
const skipAnimation = useSkipAnimation(inSkipAnimation);
|
|
38
38
|
if (seriesData === undefined) {
|
|
39
39
|
return null;
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# MUI X Charts
|
|
2
2
|
|
|
3
3
|
This package is the community edition of the chart components.
|
|
4
|
-
It's part of [MUI X](https://mui.com/x/), an open-core extension of
|
|
4
|
+
It's part of [MUI X](https://mui.com/x/), an open-core extension of our Core libraries, with advanced components.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
@@ -6,8 +6,8 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { Scatter } from "./Scatter.js";
|
|
7
7
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
8
8
|
import getColor from "./getColor.js";
|
|
9
|
-
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
10
9
|
import { useScatterSeries } from "../hooks/useSeries.js";
|
|
10
|
+
import { useZAxis } from "../hooks/useZAxis.js";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
/**
|
|
13
13
|
* Demos:
|
|
@@ -30,7 +30,7 @@ function ScatterPlot(props) {
|
|
|
30
30
|
const {
|
|
31
31
|
zAxis,
|
|
32
32
|
zAxisIds
|
|
33
|
-
} =
|
|
33
|
+
} = useZAxis();
|
|
34
34
|
if (seriesData === undefined) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const mergeMinMax = (acc, val) =>
|
|
2
|
-
return [Math.min(acc[0], val[0]), Math.max(acc[1], val[1])];
|
|
3
|
-
};
|
|
1
|
+
const mergeMinMax = (acc, val) => [val[0] === null ? acc[0] : Math.min(acc[0], val[0]), val[1] === null ? acc[1] : Math.max(acc[1], val[1])];
|
|
4
2
|
export const getExtremumX = params => {
|
|
5
3
|
const {
|
|
6
4
|
series,
|
|
@@ -11,8 +11,8 @@ const formatter = ({
|
|
|
11
11
|
}
|
|
12
12
|
const data = !datasetKeys ? seriesData.data ?? [] : dataset?.map(d => {
|
|
13
13
|
return {
|
|
14
|
-
x: d[datasetKeys.x],
|
|
15
|
-
y: d[datasetKeys.y],
|
|
14
|
+
x: d[datasetKeys.x] ?? null,
|
|
15
|
+
y: d[datasetKeys.y] ?? null,
|
|
16
16
|
z: datasetKeys.z && d[datasetKeys.z],
|
|
17
17
|
id: d[datasetKeys.id]
|
|
18
18
|
};
|
package/hooks/useChartId.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useChartId(): string;
|
|
1
|
+
export declare function useChartId(): string | undefined;
|
package/hooks/useColorScale.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
5
|
-
import {
|
|
4
|
+
import { useZAxis } from "./useZAxis.js";
|
|
6
5
|
export function useXColorScale(identifier) {
|
|
7
6
|
const {
|
|
8
7
|
xAxis,
|
|
@@ -23,7 +22,7 @@ export function useZColorScale(identifier) {
|
|
|
23
22
|
const {
|
|
24
23
|
zAxis,
|
|
25
24
|
zAxisIds
|
|
26
|
-
} =
|
|
25
|
+
} = useZAxis();
|
|
27
26
|
const id = typeof identifier === 'string' ? identifier : zAxisIds[identifier ?? 0];
|
|
28
27
|
return zAxis[id]?.colorScale;
|
|
29
28
|
}
|
package/index.js
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A higher order component that consumes and merges the theme `defaultProps` and handles the `classes` and renders the component.
|
|
4
|
+
*
|
|
5
|
+
* This HOC will wrap a single component.
|
|
6
|
+
* If you need to render multiple components, you can manually consume the theme and render them in your component instead of using this HOC.
|
|
7
|
+
*
|
|
8
|
+
* In the example below, `MyComponent` will render the `DefaultComponent` with the `direction` prop set to `'row'` and the className set to `'my-custom-root'`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* createTheme({
|
|
13
|
+
* components: {
|
|
14
|
+
* MuiMyComponent: {
|
|
15
|
+
* defaultProps: {
|
|
16
|
+
* direction: 'row',
|
|
17
|
+
* },
|
|
18
|
+
* },
|
|
19
|
+
* },
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* type MyComponentProps = {
|
|
23
|
+
* direction: 'row' | 'column';
|
|
24
|
+
* classes?: Record<'root', string>;
|
|
25
|
+
* };
|
|
26
|
+
*
|
|
27
|
+
* const MyComponent = consumeThemeProps(
|
|
28
|
+
* 'MuiMyComponent',
|
|
29
|
+
* function DefaultComponent(props: MyComponentProps) {
|
|
30
|
+
* return (
|
|
31
|
+
* <div className={props.classes.root}>
|
|
32
|
+
* {props.direction}
|
|
33
|
+
* </div>
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* render(<MyComponent classes={{ root: 'my-custom-root' }} />);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param {string} name The mui component name.
|
|
42
|
+
* @param {object} options Options for the HOC.
|
|
43
|
+
* @param {Record<string, any>} options.defaultProps A set of defaults for the component, will be deep merged with the props.
|
|
44
|
+
* @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
|
|
45
|
+
* @param InComponent The component to render if the slot is not provided.
|
|
46
|
+
*/
|
|
47
|
+
export declare const consumeThemeProps: <Props extends {
|
|
48
|
+
slots?: Record<string, any>;
|
|
49
|
+
slotProps?: Record<string, any>;
|
|
50
|
+
classes?: Record<string, any>;
|
|
51
|
+
}>(name: string, options: {
|
|
52
|
+
defaultProps?: Omit<Partial<Props>, "slots" | "slotProps"> | ((props: Props) => Omit<Partial<Props>, "slots" | "slotProps">);
|
|
53
|
+
classesResolver?: (props: Props, theme: any) => Record<string, string>;
|
|
54
|
+
}, InComponent: React.JSXElementConstructor<Props>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Props> & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { useTheme, useThemeProps } from '@mui/material/styles';
|
|
3
|
+
import resolveProps from '@mui/utils/resolveProps';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import * as ReactIs from 'react-is';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A higher order component that consumes and merges the theme `defaultProps` and handles the `classes` and renders the component.
|
|
9
|
+
*
|
|
10
|
+
* This HOC will wrap a single component.
|
|
11
|
+
* If you need to render multiple components, you can manually consume the theme and render them in your component instead of using this HOC.
|
|
12
|
+
*
|
|
13
|
+
* In the example below, `MyComponent` will render the `DefaultComponent` with the `direction` prop set to `'row'` and the className set to `'my-custom-root'`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* createTheme({
|
|
18
|
+
* components: {
|
|
19
|
+
* MuiMyComponent: {
|
|
20
|
+
* defaultProps: {
|
|
21
|
+
* direction: 'row',
|
|
22
|
+
* },
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* type MyComponentProps = {
|
|
28
|
+
* direction: 'row' | 'column';
|
|
29
|
+
* classes?: Record<'root', string>;
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* const MyComponent = consumeThemeProps(
|
|
33
|
+
* 'MuiMyComponent',
|
|
34
|
+
* function DefaultComponent(props: MyComponentProps) {
|
|
35
|
+
* return (
|
|
36
|
+
* <div className={props.classes.root}>
|
|
37
|
+
* {props.direction}
|
|
38
|
+
* </div>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* render(<MyComponent classes={{ root: 'my-custom-root' }} />);
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param {string} name The mui component name.
|
|
47
|
+
* @param {object} options Options for the HOC.
|
|
48
|
+
* @param {Record<string, any>} options.defaultProps A set of defaults for the component, will be deep merged with the props.
|
|
49
|
+
* @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
|
|
50
|
+
* @param InComponent The component to render if the slot is not provided.
|
|
51
|
+
*/
|
|
52
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
53
|
+
export const consumeThemeProps = (name, options, InComponent) => {
|
|
54
|
+
function InternalComponent(props, ref) {
|
|
55
|
+
const themedProps = useThemeProps({
|
|
56
|
+
props,
|
|
57
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
58
|
+
name
|
|
59
|
+
});
|
|
60
|
+
const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
|
|
61
|
+
const outProps = resolveProps(defaultProps, themedProps);
|
|
62
|
+
const theme = useTheme();
|
|
63
|
+
const classes = options.classesResolver?.(outProps, theme);
|
|
64
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
65
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
66
|
+
InComponent.displayName = name;
|
|
67
|
+
}
|
|
68
|
+
const OutComponent = ReactIs.isForwardRef(InComponent) ? InComponent :
|
|
69
|
+
/*#__PURE__*/
|
|
70
|
+
// InComponent needs to be a function that accepts `(props, ref)`
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
React.forwardRef(InComponent);
|
|
73
|
+
return /*#__PURE__*/_jsx(OutComponent, _extends({}, outProps, {
|
|
74
|
+
classes: classes,
|
|
75
|
+
ref: ref
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return /*#__PURE__*/React.forwardRef(InternalComponent);
|
|
79
|
+
};
|
|
@@ -7,24 +7,24 @@ import { UseChartIdSignature } from './useChartId.types';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const selectorChartId: ((state: import("./useChartId.types").UseChartIdState & Partial<{}> & {
|
|
9
9
|
cacheKey: import("../../models").ChartStateCacheKey;
|
|
10
|
-
}) => string) & {
|
|
10
|
+
}) => string | undefined) & {
|
|
11
11
|
clearCache: () => void;
|
|
12
12
|
resultsCount: () => number;
|
|
13
13
|
resetResultsCount: () => void;
|
|
14
14
|
} & {
|
|
15
15
|
resultFunc: (resultFuncArgs_0: {
|
|
16
|
-
chartId: string;
|
|
16
|
+
chartId: string | undefined;
|
|
17
17
|
providedChartId: string | undefined;
|
|
18
|
-
}) => string;
|
|
18
|
+
}) => string | undefined;
|
|
19
19
|
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
20
|
-
chartId: string;
|
|
20
|
+
chartId: string | undefined;
|
|
21
21
|
providedChartId: string | undefined;
|
|
22
|
-
}) => string) & {
|
|
22
|
+
}) => string | undefined) & {
|
|
23
23
|
clearCache: () => void;
|
|
24
24
|
resultsCount: () => number;
|
|
25
25
|
resetResultsCount: () => void;
|
|
26
26
|
};
|
|
27
|
-
lastResult: () => string;
|
|
27
|
+
lastResult: () => string | undefined;
|
|
28
28
|
dependencies: [ChartRootSelector<UseChartIdSignature>];
|
|
29
29
|
recomputations: () => number;
|
|
30
30
|
resetRecomputations: () => void;
|
|
@@ -4,12 +4,12 @@ export interface UseChartIdParameters {
|
|
|
4
4
|
* This prop is used to help implement the accessibility logic.
|
|
5
5
|
* If you don't provide this prop. It falls back to a randomly generated id.
|
|
6
6
|
*/
|
|
7
|
-
id
|
|
7
|
+
id: string | undefined;
|
|
8
8
|
}
|
|
9
|
-
export type UseChartIdDefaultizedParameters = UseChartIdParameters
|
|
9
|
+
export type UseChartIdDefaultizedParameters = Required<UseChartIdParameters>;
|
|
10
10
|
export interface UseChartIdState {
|
|
11
11
|
id: {
|
|
12
|
-
chartId: string;
|
|
12
|
+
chartId: string | undefined;
|
|
13
13
|
providedChartId: string | undefined;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import useId from '@mui/utils/useId';
|
|
2
3
|
import { ChartStore } from "../plugins/utils/ChartStore.js";
|
|
3
4
|
import { CHART_CORE_PLUGINS } from "../plugins/corePlugins/index.js";
|
|
4
5
|
export function useChartApiInitialization(inputApiRef) {
|
|
@@ -15,7 +16,10 @@ export function useChartApiInitialization(inputApiRef) {
|
|
|
15
16
|
let globalId = 0;
|
|
16
17
|
export function useCharts(inPlugins, props) {
|
|
17
18
|
const plugins = React.useMemo(() => [...CHART_CORE_PLUGINS, ...inPlugins], [inPlugins]);
|
|
18
|
-
const
|
|
19
|
+
const defaultChartId = useId();
|
|
20
|
+
const pluginParams = {
|
|
21
|
+
id: defaultChartId
|
|
22
|
+
}; // To generate when plugins use params.
|
|
19
23
|
const instanceRef = React.useRef({});
|
|
20
24
|
const instance = instanceRef.current;
|
|
21
25
|
const publicAPI = useChartApiInitialization(props.apiRef);
|
|
@@ -39,7 +43,9 @@ export function useCharts(inPlugins, props) {
|
|
|
39
43
|
};
|
|
40
44
|
plugins.forEach(plugin => {
|
|
41
45
|
if (plugin.getInitialState) {
|
|
42
|
-
Object.assign(initialState, plugin.getInitialState({
|
|
46
|
+
Object.assign(initialState, plugin.getInitialState({
|
|
47
|
+
id: defaultChartId
|
|
48
|
+
}));
|
|
43
49
|
}
|
|
44
50
|
});
|
|
45
51
|
storeRef.current = new ChartStore(initialState);
|