@mui/x-charts 8.0.0-alpha.2 → 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.
Files changed (90) hide show
  1. package/CHANGELOG.md +376 -0
  2. package/ChartsAxis/ChartsAxis.js +0 -4
  3. package/ChartsLabel/ChartsLabel.d.ts +19 -0
  4. package/ChartsLabel/ChartsLabel.js +58 -0
  5. package/ChartsLabel/ChartsLabelGradient.d.ts +40 -0
  6. package/ChartsLabel/ChartsLabelGradient.js +133 -0
  7. package/ChartsLabel/ChartsLabelMark.d.ts +27 -0
  8. package/ChartsLabel/ChartsLabelMark.js +108 -0
  9. package/ChartsLabel/labelClasses.d.ts +9 -0
  10. package/ChartsLabel/labelClasses.js +13 -0
  11. package/ChartsLabel/labelGradientClasses.d.ts +15 -0
  12. package/ChartsLabel/labelGradientClasses.js +17 -0
  13. package/ChartsLabel/labelMarkClasses.d.ts +17 -0
  14. package/ChartsLabel/labelMarkClasses.js +17 -0
  15. package/ChartsLegend/useAxis.js +3 -3
  16. package/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
  17. package/ChartsTooltip/ChartsTooltipTable.js +16 -14
  18. package/ChartsTooltip/chartsTooltipClasses.d.ts +3 -1
  19. package/ChartsTooltip/chartsTooltipClasses.js +3 -2
  20. package/ChartsTooltip/useAxisTooltip.js +2 -3
  21. package/ChartsTooltip/useItemTooltip.js +2 -3
  22. package/PieChart/PieArc.js +11 -5
  23. package/PieChart/PieArcPlot.js +9 -13
  24. package/PieChart/PiePlot.js +2 -2
  25. package/README.md +1 -1
  26. package/ScatterChart/ScatterPlot.js +2 -2
  27. package/ScatterChart/extremums.js +1 -3
  28. package/ScatterChart/formatter.js +2 -2
  29. package/hooks/useChartId.d.ts +1 -1
  30. package/hooks/useColorScale.js +2 -3
  31. package/hooks/useZAxis.d.ts +6 -0
  32. package/hooks/useZAxis.js +8 -0
  33. package/index.js +1 -1
  34. package/internals/consumeThemeProps.d.ts +54 -0
  35. package/internals/consumeThemeProps.js +79 -0
  36. package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
  37. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +6 -6
  38. package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +3 -3
  39. package/internals/store/useCharts.js +8 -2
  40. package/modern/ChartsAxis/ChartsAxis.js +0 -4
  41. package/modern/ChartsLabel/ChartsLabel.js +58 -0
  42. package/modern/ChartsLabel/ChartsLabelGradient.js +133 -0
  43. package/modern/ChartsLabel/ChartsLabelMark.js +108 -0
  44. package/modern/ChartsLabel/labelClasses.js +13 -0
  45. package/modern/ChartsLabel/labelGradientClasses.js +17 -0
  46. package/modern/ChartsLabel/labelMarkClasses.js +17 -0
  47. package/modern/ChartsLegend/useAxis.js +3 -3
  48. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
  49. package/modern/ChartsTooltip/ChartsTooltipTable.js +16 -14
  50. package/modern/ChartsTooltip/chartsTooltipClasses.js +3 -2
  51. package/modern/ChartsTooltip/useAxisTooltip.js +2 -3
  52. package/modern/ChartsTooltip/useItemTooltip.js +2 -3
  53. package/modern/PieChart/PieArc.js +11 -5
  54. package/modern/PieChart/PieArcPlot.js +9 -13
  55. package/modern/PieChart/PiePlot.js +2 -2
  56. package/modern/ScatterChart/ScatterPlot.js +2 -2
  57. package/modern/ScatterChart/extremums.js +1 -3
  58. package/modern/ScatterChart/formatter.js +2 -2
  59. package/modern/hooks/useColorScale.js +2 -3
  60. package/modern/hooks/useZAxis.js +8 -0
  61. package/modern/index.js +1 -1
  62. package/modern/internals/consumeThemeProps.js +79 -0
  63. package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
  64. package/modern/internals/store/useCharts.js +8 -2
  65. package/node/ChartsAxis/ChartsAxis.js +0 -4
  66. package/node/ChartsLabel/ChartsLabel.js +64 -0
  67. package/node/ChartsLabel/ChartsLabelGradient.js +139 -0
  68. package/node/ChartsLabel/ChartsLabelMark.js +114 -0
  69. package/node/ChartsLabel/labelClasses.js +22 -0
  70. package/node/ChartsLabel/labelGradientClasses.js +26 -0
  71. package/node/ChartsLabel/labelMarkClasses.js +26 -0
  72. package/node/ChartsLegend/useAxis.js +2 -4
  73. package/node/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
  74. package/node/ChartsTooltip/ChartsTooltipTable.js +16 -14
  75. package/node/ChartsTooltip/chartsTooltipClasses.js +3 -2
  76. package/node/ChartsTooltip/useAxisTooltip.js +2 -4
  77. package/node/ChartsTooltip/useItemTooltip.js +2 -4
  78. package/node/PieChart/PieArc.js +11 -5
  79. package/node/PieChart/PieArcPlot.js +9 -13
  80. package/node/PieChart/PiePlot.js +2 -2
  81. package/node/ScatterChart/ScatterPlot.js +2 -2
  82. package/node/ScatterChart/extremums.js +1 -3
  83. package/node/ScatterChart/formatter.js +2 -2
  84. package/node/hooks/useColorScale.js +2 -4
  85. package/node/hooks/useZAxis.js +15 -0
  86. package/node/index.js +1 -1
  87. package/node/internals/consumeThemeProps.js +87 -0
  88. package/node/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
  89. package/node/internals/store/useCharts.js +9 -2
  90. package/package.json +5 -4
@@ -0,0 +1,108 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["type", "color", "className", "classes"];
6
+ import * as React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { styled } from '@mui/material/styles';
9
+ import clsx from 'clsx';
10
+ import { labelMarkClasses, useUtilityClasses } from "./labelMarkClasses.js";
11
+ import { consumeThemeProps } from "../internals/consumeThemeProps.js";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const Root = styled('div', {
14
+ name: 'MuiChartsLabelMark',
15
+ slot: 'Root',
16
+ overridesResolver: (props, styles) => styles.root
17
+ })(() => {
18
+ return {
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ flexShrink: 0,
23
+ [`&.${labelMarkClasses.line}`]: {
24
+ width: 16,
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ [`.${labelMarkClasses.mask}`]: {
28
+ height: 4,
29
+ width: '100%',
30
+ borderRadius: 1,
31
+ overflow: 'hidden'
32
+ }
33
+ },
34
+ [`&.${labelMarkClasses.square}`]: {
35
+ height: 13,
36
+ width: 13,
37
+ borderRadius: 2,
38
+ overflow: 'hidden'
39
+ },
40
+ [`&.${labelMarkClasses.circle}`]: {
41
+ height: 15,
42
+ width: 15,
43
+ borderRadius: '50%',
44
+ overflow: 'hidden'
45
+ },
46
+ svg: {
47
+ display: 'block',
48
+ height: '100%',
49
+ width: '100%'
50
+ }
51
+ };
52
+ });
53
+
54
+ /**
55
+ * @ignore - internal component.
56
+ *
57
+ * Generates the label mark for the tooltip and legend.
58
+ */
59
+ const ChartsLabelMark = consumeThemeProps('MuiChartsLabelMark', {
60
+ classesResolver: useUtilityClasses
61
+ }, function ChartsLabelMark(props, ref) {
62
+ const {
63
+ type,
64
+ color,
65
+ className,
66
+ classes
67
+ } = props,
68
+ other = _objectWithoutPropertiesLoose(props, _excluded);
69
+ return /*#__PURE__*/_jsx(Root, _extends({
70
+ className: clsx(classes?.root, className),
71
+ ownerState: props,
72
+ "aria-hidden": "true",
73
+ ref: ref
74
+ }, other, {
75
+ children: /*#__PURE__*/_jsx("div", {
76
+ className: classes?.mask,
77
+ children: /*#__PURE__*/_jsx("svg", {
78
+ viewBox: "0 0 24 24",
79
+ preserveAspectRatio: type === 'line' ? 'none' : undefined,
80
+ children: /*#__PURE__*/_jsx("rect", {
81
+ width: "24",
82
+ height: "24",
83
+ fill: color
84
+ })
85
+ })
86
+ })
87
+ }));
88
+ });
89
+ process.env.NODE_ENV !== "production" ? ChartsLabelMark.propTypes = {
90
+ // ----------------------------- Warning --------------------------------
91
+ // | These PropTypes are generated from the TypeScript type definitions |
92
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
93
+ // ----------------------------------------------------------------------
94
+ /**
95
+ * Override or extend the styles applied to the component.
96
+ */
97
+ classes: PropTypes.object,
98
+ /**
99
+ * The color of the mark.
100
+ */
101
+ color: PropTypes.string,
102
+ /**
103
+ * The type of the mark.
104
+ * @default 'square'
105
+ */
106
+ type: PropTypes.oneOf(['circle', 'line', 'square'])
107
+ } : void 0;
108
+ export { ChartsLabelMark };
@@ -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
+ };
@@ -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
- } = React.useContext(ZAxisContext);
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 tootlipData = useAxisTooltip();
17
+ const tooltipData = useAxisTooltip();
18
18
  const xAxis = useXAxis();
19
19
  const yAxis = useYAxis();
20
20
  const classes = useUtilityClasses(propClasses);
21
- if (tootlipData === null) {
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
- } = tootlipData;
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
- transition: theme.transitions.create('box-shadow'),
19
- borderRadius: theme.shape.borderRadius
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(1)
48
+ paddingTop: theme.spacing(0.5)
50
49
  },
51
50
  'tr:last-of-type& td': {
52
- paddingBottom: theme.spacing(1)
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(4),
73
- color: (theme.vars || theme).palette.text.primary
77
+ paddingLeft: theme.spacing(1.5),
78
+ paddingRight: theme.spacing(1.5)
74
79
  },
75
80
  'td:first-of-type&': {
76
- paddingLeft: theme.spacing(2)
81
+ paddingLeft: theme.spacing(1.5)
77
82
  },
78
83
  'td:last-of-type&': {
79
- paddingRight: theme.spacing(2)
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
- backgroundColor: color,
100
- borderColor: (theme.vars || theme).palette.background.paper,
101
- border: `solid ${(theme.vars || theme).palette.background.paper} ${theme.spacing(0.25)}`,
103
+ background: color,
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
- } = React.useContext(ZAxisContext);
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
- } = React.useContext(ZAxisContext);
25
+ } = useZAxis();
27
26
  const colorProcessors = useColorProcessor();
28
27
  const xAxisId = series.xAxisId ?? xAxisIds[0];
29
28
  const yAxisId = series.yAxisId ?? yAxisIds[0];
@@ -22,10 +22,11 @@ const useUtilityClasses = ownerState => {
22
22
  classes,
23
23
  id,
24
24
  isFaded,
25
- isHighlighted
25
+ isHighlighted,
26
+ dataIndex
26
27
  } = ownerState;
27
28
  const slots = {
28
- root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
29
+ root: ['root', `series-${id}`, `data-index-${dataIndex}`, isHighlighted && 'highlighted', isFaded && 'faded']
29
30
  };
30
31
  return composeClasses(slots, getPieArcUtilityClass, classes);
31
32
  };
@@ -36,9 +37,9 @@ const PieArcRoot = styled(animated.path, {
36
37
  })(({
37
38
  theme
38
39
  }) => ({
40
+ // Got to move stroke to an element prop instead of style.
39
41
  stroke: (theme.vars || theme).palette.background.paper,
40
- strokeWidth: 1,
41
- strokeLinejoin: 'round'
42
+ transition: 'opacity 0.2s ease-in, fill 0.2s ease-in, filter 0.2s ease-in'
42
43
  }));
43
44
  function PieArc(props) {
44
45
  const {
@@ -79,7 +80,12 @@ function PieArc(props) {
79
80
  onClick: onClick,
80
81
  cursor: onClick ? 'pointer' : 'unset',
81
82
  ownerState: ownerState,
82
- className: classes.root
83
+ className: classes.root,
84
+ fill: ownerState.color,
85
+ opacity: ownerState.isFaded ? 0.3 : 1,
86
+ filter: ownerState.isHighlighted ? 'brightness(120%)' : 'none',
87
+ strokeWidth: 1,
88
+ strokeLinejoin: "round"
83
89
  }, other, getInteractionItemProps({
84
90
  type: 'pie',
85
91
  seriesId: id,
@@ -2,8 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
6
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
5
+ const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlighted", "faded", "data", "onItemClick", "skipAnimation"];
7
6
  import * as React from 'react';
8
7
  import PropTypes from 'prop-types';
9
8
  import { useTransition } from '@react-spring/web';
@@ -47,16 +46,14 @@ function PieArcPlot(props) {
47
46
  }
48
47
  const Arc = slots?.pieArc ?? PieArc;
49
48
  return /*#__PURE__*/_jsx("g", _extends({}, other, {
50
- children: transition((_ref, item, _, index) => {
51
- let {
52
- startAngle,
53
- endAngle,
54
- paddingAngle: pA,
55
- innerRadius: iR,
56
- outerRadius: oR,
57
- cornerRadius: cR
58
- } = _ref,
59
- style = _objectWithoutPropertiesLoose(_ref, _excluded2);
49
+ children: transition(({
50
+ startAngle,
51
+ endAngle,
52
+ paddingAngle: pA,
53
+ innerRadius: iR,
54
+ outerRadius: oR,
55
+ cornerRadius: cR
56
+ }, item, _, index) => {
60
57
  return /*#__PURE__*/_jsx(Arc, _extends({
61
58
  startAngle: startAngle,
62
59
  endAngle: endAngle,
@@ -64,7 +61,6 @@ function PieArcPlot(props) {
64
61
  innerRadius: iR,
65
62
  outerRadius: oR,
66
63
  cornerRadius: cR,
67
- style: style,
68
64
  id: id,
69
65
  color: item.color,
70
66
  dataIndex: index,
@@ -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
- } = React.useContext(DrawingAreaContext);
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 MUI Core, with advanced components.
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
- } = React.useContext(ZAxisContext);
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
  };
@@ -1 +1 @@
1
- export declare function useChartId(): string;
1
+ export declare function useChartId(): string | undefined;
@@ -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 { ZAxisContext } from "../context/ZAxisContextProvider.js";
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
- } = React.useContext(ZAxisContext);
25
+ } = useZAxis();
27
26
  const id = typeof identifier === 'string' ? identifier : zAxisIds[identifier ?? 0];
28
27
  return zAxis[id]?.colorScale;
29
28
  }
@@ -0,0 +1,6 @@
1
+ export declare const useZAxis: () => {
2
+ zAxis: {
3
+ [axisId: string]: import("../internals").ZAxisDefaultized;
4
+ };
5
+ zAxisIds: string[];
6
+ };
@@ -0,0 +1,8 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { ZAxisContext } from "../context/ZAxisContextProvider.js";
5
+ export const useZAxis = () => {
6
+ const data = React.useContext(ZAxisContext);
7
+ return data;
8
+ };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.0.0-alpha.2
2
+ * @mui/x-charts v8.0.0-alpha.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the