@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
@@ -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
  }));
@@ -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;
@@ -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,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,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/modern/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
@@ -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
+ };
@@ -26,7 +26,7 @@ useChartId.getInitialState = ({
26
26
  id
27
27
  }) => ({
28
28
  id: {
29
- chartId: createChartDefaultId(),
29
+ chartId: id,
30
30
  providedChartId: id
31
31
  }
32
32
  });
@@ -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 pluginParams = {}; // To generate when plugins use params.
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);
@@ -57,10 +57,6 @@ function ChartsAxis(props) {
57
57
  yAxis,
58
58
  yAxisIds
59
59
  } = (0, _CartesianProvider.useCartesianContext)();
60
-
61
- // TODO: use for plotting line without ticks or any thing
62
- // const drawingArea = React.useContext(DrawingContext);
63
-
64
60
  const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis, yAxisIds[0]);
65
61
  const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis, xAxisIds[0]);
66
62
  const topId = getAxisId(topAxis, xAxisIds[0]);
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsLabel = void 0;
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _clsx = _interopRequireDefault(require("clsx"));
16
+ var _labelClasses = require("./labelClasses");
17
+ var _consumeThemeProps = require("../internals/consumeThemeProps");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const _excluded = ["children", "className", "classes"];
20
+ const Root = (0, _styles.styled)('span', {
21
+ name: 'MuiChartsLabel',
22
+ slot: 'Root',
23
+ overridesResolver: (props, styles) => styles.root
24
+ })(({
25
+ theme
26
+ }) => (0, _extends2.default)({}, theme.typography.caption, {
27
+ color: (theme.vars || theme).palette.text.primary,
28
+ lineHeight: undefined,
29
+ display: 'flex'
30
+ }));
31
+
32
+ /**
33
+ * @ignore - internal component.
34
+ *
35
+ * Generates the label mark for the tooltip and legend.
36
+ */
37
+ const ChartsLabel = exports.ChartsLabel = (0, _consumeThemeProps.consumeThemeProps)('MuiChartsLabel', {
38
+ classesResolver: _labelClasses.useUtilityClasses
39
+ }, function ChartsLabel(props, ref) {
40
+ const {
41
+ children,
42
+ className,
43
+ classes
44
+ } = props,
45
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
46
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({
47
+ className: (0, _clsx.default)(classes?.root, className),
48
+ ownerState: props,
49
+ ref: ref
50
+ }, other, {
51
+ children: children
52
+ }));
53
+ });
54
+ process.env.NODE_ENV !== "production" ? ChartsLabel.propTypes = {
55
+ // ----------------------------- Warning --------------------------------
56
+ // | These PropTypes are generated from the TypeScript type definitions |
57
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
58
+ // ----------------------------------------------------------------------
59
+ children: _propTypes.default.node,
60
+ /**
61
+ * Override or extend the styles applied to the component.
62
+ */
63
+ classes: _propTypes.default.object
64
+ } : void 0;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsLabelGradient = void 0;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _clsx = _interopRequireDefault(require("clsx"));
16
+ var _labelGradientClasses = require("./labelGradientClasses");
17
+ var _consumeThemeProps = require("../internals/consumeThemeProps");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const _excluded = ["gradientId", "direction", "classes", "className"];
20
+ const getRotation = (direction, reverse, rotate) => {
21
+ if (!rotate && reverse) {
22
+ return direction === 'column' ? 90 : 180;
23
+ }
24
+ if (rotate && !reverse) {
25
+ return direction === 'column' ? 0 : 90;
26
+ }
27
+ if (rotate && reverse) {
28
+ return direction === 'column' ? 180 : -90;
29
+ }
30
+ return direction === 'column' ? -90 : 0;
31
+ };
32
+ const Root = (0, _styles.styled)('div', {
33
+ name: 'MuiChartsLabelGradient',
34
+ slot: 'Root',
35
+ overridesResolver: (props, styles) => styles.root
36
+ })(({
37
+ ownerState
38
+ }) => {
39
+ const rotation = getRotation(ownerState.direction, ownerState.reverse, ownerState.rotate);
40
+ return {
41
+ display: 'flex',
42
+ alignItems: 'center',
43
+ justifyContent: 'center',
44
+ [`.${_labelGradientClasses.labelGradientClasses.mask}`]: {
45
+ borderRadius: 2,
46
+ overflow: 'hidden'
47
+ },
48
+ [`&.${_labelGradientClasses.labelGradientClasses.row}`]: {
49
+ width: '100%',
50
+ [`.${_labelGradientClasses.labelGradientClasses.mask}`]: {
51
+ height: 12,
52
+ width: '100%'
53
+ }
54
+ },
55
+ [`&.${_labelGradientClasses.labelGradientClasses.column}`]: {
56
+ height: '100%',
57
+ [`.${_labelGradientClasses.labelGradientClasses.mask}`]: {
58
+ width: 12,
59
+ height: '100%',
60
+ '> svg': {
61
+ height: '100%'
62
+ }
63
+ }
64
+ },
65
+ svg: {
66
+ transform: `rotate(${rotation}deg)`,
67
+ display: 'block'
68
+ }
69
+ };
70
+ });
71
+
72
+ /**
73
+ * @ignore - internal component.
74
+ *
75
+ * Generates the label Gradient for the tooltip and legend.
76
+ */
77
+ const ChartsLabelGradient = exports.ChartsLabelGradient = (0, _consumeThemeProps.consumeThemeProps)('MuiChartsLabelGradient', {
78
+ defaultProps: {
79
+ direction: 'row'
80
+ },
81
+ classesResolver: _labelGradientClasses.useUtilityClasses
82
+ }, function ChartsLabelGradient(props, ref) {
83
+ const {
84
+ gradientId,
85
+ classes,
86
+ className
87
+ } = props,
88
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
89
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({
90
+ className: (0, _clsx.default)(classes?.root, className),
91
+ ownerState: props,
92
+ "aria-hidden": "true",
93
+ ref: ref
94
+ }, other, {
95
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
96
+ className: classes?.mask,
97
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
98
+ viewBox: "0 0 24 24",
99
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
100
+ width: "24",
101
+ height: "24",
102
+ fill: `url(#${gradientId})`
103
+ })
104
+ })
105
+ })
106
+ }));
107
+ });
108
+ process.env.NODE_ENV !== "production" ? ChartsLabelGradient.propTypes = {
109
+ // ----------------------------- Warning --------------------------------
110
+ // | These PropTypes are generated from the TypeScript type definitions |
111
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
112
+ // ----------------------------------------------------------------------
113
+ /**
114
+ * Override or extend the styles applied to the component.
115
+ */
116
+ classes: _propTypes.default.object,
117
+ /**
118
+ * The direction of the gradient.
119
+ *
120
+ * @default 'row'
121
+ */
122
+ direction: _propTypes.default.oneOf(['column', 'row']),
123
+ /**
124
+ * A unique identifier for the gradient.
125
+ *
126
+ * The `gradientId` will be used as `fill="url(#gradientId)"`.
127
+ */
128
+ gradientId: _propTypes.default.string.isRequired,
129
+ /**
130
+ * If `true`, the gradient will be reversed.
131
+ */
132
+ reverse: _propTypes.default.bool,
133
+ /**
134
+ * If provided, the gradient will be rotated by 90deg.
135
+ *
136
+ * Useful for linear gradients that are not in the correct orientation.
137
+ */
138
+ rotate: _propTypes.default.bool
139
+ } : void 0;