@mui/x-charts 8.9.2 → 8.10.1

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 (120) hide show
  1. package/BarChart/BarChart.js +20 -0
  2. package/CHANGELOG.md +217 -6
  3. package/ChartContainer/ChartContainer.js +30 -0
  4. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  5. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -3
  6. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -3
  7. package/ChartsLabel/labelGradientClasses.d.ts +1 -1
  8. package/ChartsLabel/labelMarkClasses.d.ts +1 -1
  9. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  10. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  11. package/ChartsTooltip/ChartsTooltip.d.ts +2 -1
  12. package/ChartsTooltip/ChartsTooltip.js +3 -3
  13. package/ChartsTooltip/ChartsTooltipContainer.d.ts +5 -5
  14. package/ChartsTooltip/ChartsTooltipContainer.js +11 -5
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  16. package/ChartsTooltip/ChartsTooltipTable.js +1 -0
  17. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  18. package/ChartsXAxis/ChartsGroupedXAxis.d.ts +7 -0
  19. package/ChartsXAxis/ChartsGroupedXAxis.js +143 -0
  20. package/ChartsXAxis/ChartsSingleXAxis.d.ts +7 -0
  21. package/ChartsXAxis/ChartsSingleXAxis.js +144 -0
  22. package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  23. package/ChartsXAxis/ChartsXAxis.js +8 -210
  24. package/ChartsXAxis/getVisibleLabels.d.ts +2 -2
  25. package/ChartsXAxis/useAxisProps.d.ts +4526 -0
  26. package/ChartsXAxis/useAxisProps.js +105 -0
  27. package/ChartsXAxis/utilities.d.ts +11 -0
  28. package/ChartsXAxis/utilities.js +43 -0
  29. package/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  30. package/ChartsYAxis/ChartsGroupedYAxis.js +144 -0
  31. package/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  32. package/ChartsYAxis/ChartsSingleYAxis.js +133 -0
  33. package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  34. package/ChartsYAxis/ChartsYAxis.js +12 -211
  35. package/ChartsYAxis/useAxisProps.d.ts +4452 -0
  36. package/ChartsYAxis/useAxisProps.js +115 -0
  37. package/ChartsYAxis/utilities.d.ts +10 -0
  38. package/ChartsYAxis/utilities.js +42 -0
  39. package/LineChart/LineChart.js +20 -0
  40. package/RadarChart/index.d.ts +9 -2
  41. package/RadarChart/index.js +13 -14
  42. package/ScatterChart/ScatterChart.d.ts +8 -1
  43. package/ScatterChart/ScatterChart.js +20 -0
  44. package/SparkLineChart/SparkLineChart.d.ts +15 -5
  45. package/SparkLineChart/SparkLineChart.js +77 -34
  46. package/esm/BarChart/BarChart.js +20 -0
  47. package/esm/ChartContainer/ChartContainer.js +30 -0
  48. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  49. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -3
  50. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -3
  51. package/esm/ChartsLabel/labelGradientClasses.d.ts +1 -1
  52. package/esm/ChartsLabel/labelMarkClasses.d.ts +1 -1
  53. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  54. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  55. package/esm/ChartsTooltip/ChartsTooltip.d.ts +2 -1
  56. package/esm/ChartsTooltip/ChartsTooltip.js +3 -3
  57. package/esm/ChartsTooltip/ChartsTooltipContainer.d.ts +5 -5
  58. package/esm/ChartsTooltip/ChartsTooltipContainer.js +11 -5
  59. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  60. package/esm/ChartsTooltip/ChartsTooltipTable.js +1 -0
  61. package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  62. package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +7 -0
  63. package/esm/ChartsXAxis/ChartsGroupedXAxis.js +137 -0
  64. package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +7 -0
  65. package/esm/ChartsXAxis/ChartsSingleXAxis.js +140 -0
  66. package/esm/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  67. package/esm/ChartsXAxis/ChartsXAxis.js +7 -207
  68. package/esm/ChartsXAxis/getVisibleLabels.d.ts +2 -2
  69. package/esm/ChartsXAxis/useAxisProps.d.ts +4526 -0
  70. package/esm/ChartsXAxis/useAxisProps.js +98 -0
  71. package/esm/ChartsXAxis/utilities.d.ts +11 -0
  72. package/esm/ChartsXAxis/utilities.js +35 -0
  73. package/esm/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  74. package/esm/ChartsYAxis/ChartsGroupedYAxis.js +138 -0
  75. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  76. package/esm/ChartsYAxis/ChartsSingleYAxis.js +129 -0
  77. package/esm/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  78. package/esm/ChartsYAxis/ChartsYAxis.js +10 -207
  79. package/esm/ChartsYAxis/useAxisProps.d.ts +4452 -0
  80. package/esm/ChartsYAxis/useAxisProps.js +108 -0
  81. package/esm/ChartsYAxis/utilities.d.ts +10 -0
  82. package/esm/ChartsYAxis/utilities.js +34 -0
  83. package/esm/LineChart/LineChart.js +20 -0
  84. package/esm/RadarChart/index.d.ts +9 -2
  85. package/esm/RadarChart/index.js +12 -2
  86. package/esm/ScatterChart/ScatterChart.d.ts +8 -1
  87. package/esm/ScatterChart/ScatterChart.js +20 -0
  88. package/esm/SparkLineChart/SparkLineChart.d.ts +15 -5
  89. package/esm/SparkLineChart/SparkLineChart.js +77 -34
  90. package/esm/hooks/useTicksGrouped.d.ts +28 -0
  91. package/esm/hooks/useTicksGrouped.js +98 -0
  92. package/esm/index.js +1 -1
  93. package/esm/internals/animation/Transition.js +2 -5
  94. package/esm/internals/configInit.js +2 -2
  95. package/esm/internals/getScale.d.ts +1 -1
  96. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -1
  97. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +32 -23
  98. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +1 -1
  99. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  100. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  101. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  102. package/esm/internals/plugins/utils/ChartStore.js +16 -18
  103. package/esm/models/axis.d.ts +46 -2
  104. package/esm/tests/web-components.js +2 -4
  105. package/hooks/useTicksGrouped.d.ts +28 -0
  106. package/hooks/useTicksGrouped.js +104 -0
  107. package/index.js +1 -1
  108. package/internals/animation/Transition.js +2 -5
  109. package/internals/configInit.js +2 -2
  110. package/internals/getScale.d.ts +1 -1
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -1
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +34 -23
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +1 -1
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  115. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  117. package/internals/plugins/utils/ChartStore.js +16 -18
  118. package/models/axis.d.ts +46 -2
  119. package/package.json +16 -18
  120. package/tests/web-components.js +2 -4
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useAxisProps = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
12
+ var _styles = require("@mui/material/styles");
13
+ var _RtlProvider = require("@mui/system/RtlProvider");
14
+ var _ChartsText = require("../ChartsText");
15
+ var _useAxis = require("../hooks/useAxis");
16
+ var _defaultTextPlacement = require("../ChartsText/defaultTextPlacement");
17
+ var _invertTextAnchor = require("../internals/invertTextAnchor");
18
+ var _utilities = require("./utilities");
19
+ var _isBandScale = require("../internals/isBandScale");
20
+ var _isInfinity = require("../internals/isInfinity");
21
+ const _excluded = ["scale", "tickNumber", "reverse"];
22
+ const useAxisProps = inProps => {
23
+ const {
24
+ yAxis,
25
+ yAxisIds
26
+ } = (0, _useAxis.useYAxes)();
27
+ const _yAxis = yAxis[inProps.axisId ?? yAxisIds[0]],
28
+ {
29
+ scale: yScale,
30
+ tickNumber,
31
+ reverse
32
+ } = _yAxis,
33
+ settings = (0, _objectWithoutPropertiesLoose2.default)(_yAxis, _excluded);
34
+
35
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
36
+ const themedProps = (0, _styles.useThemeProps)({
37
+ props: (0, _extends2.default)({}, settings, inProps),
38
+ name: 'MuiChartsYAxis'
39
+ });
40
+ const defaultizedProps = (0, _extends2.default)({}, _utilities.defaultProps, themedProps);
41
+ const {
42
+ position,
43
+ tickLabelStyle,
44
+ labelStyle,
45
+ slots,
46
+ slotProps
47
+ } = defaultizedProps;
48
+ const theme = (0, _styles.useTheme)();
49
+ const isRtl = (0, _RtlProvider.useRtl)();
50
+ const classes = (0, _utilities.useUtilityClasses)(defaultizedProps);
51
+ const positionSign = position === 'right' ? 1 : -1;
52
+ const tickFontSize = typeof tickLabelStyle?.fontSize === 'number' ? tickLabelStyle.fontSize : 12;
53
+ const Line = slots?.axisLine ?? 'line';
54
+ const Tick = slots?.axisTick ?? 'line';
55
+ const TickLabel = slots?.axisTickLabel ?? _ChartsText.ChartsText;
56
+ const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
57
+ const defaultTextAnchor = (0, _defaultTextPlacement.getDefaultTextAnchor)((position === 'right' ? -90 : 90) - (tickLabelStyle?.angle ?? 0));
58
+ const defaultDominantBaseline = (0, _defaultTextPlacement.getDefaultBaseline)((position === 'right' ? -90 : 90) - (tickLabelStyle?.angle ?? 0));
59
+ const axisTickLabelProps = (0, _useSlotProps.default)({
60
+ elementType: TickLabel,
61
+ externalSlotProps: slotProps?.axisTickLabel,
62
+ additionalProps: {
63
+ style: (0, _extends2.default)({}, theme.typography.caption, {
64
+ fontSize: tickFontSize,
65
+ textAnchor: isRtl ? (0, _invertTextAnchor.invertTextAnchor)(defaultTextAnchor) : defaultTextAnchor,
66
+ dominantBaseline: defaultDominantBaseline
67
+ }, tickLabelStyle)
68
+ },
69
+ className: classes.tickLabel,
70
+ ownerState: {}
71
+ });
72
+ const axisLabelProps = (0, _useSlotProps.default)({
73
+ elementType: Label,
74
+ externalSlotProps: slotProps?.axisLabel,
75
+ additionalProps: {
76
+ style: (0, _extends2.default)({}, theme.typography.body1, {
77
+ lineHeight: 1,
78
+ fontSize: 14,
79
+ angle: positionSign * 90,
80
+ textAnchor: 'middle',
81
+ dominantBaseline: 'text-before-edge'
82
+ }, labelStyle)
83
+ },
84
+ ownerState: {}
85
+ });
86
+ const lineProps = (0, _useSlotProps.default)({
87
+ elementType: Line,
88
+ externalSlotProps: slotProps?.axisLine,
89
+ additionalProps: {
90
+ strokeLinecap: 'square'
91
+ },
92
+ ownerState: {}
93
+ });
94
+ const domain = yScale.domain();
95
+ const isScaleBand = (0, _isBandScale.isBandScale)(yScale);
96
+ const skipAxisRendering = isScaleBand && domain.length === 0 || !isScaleBand && domain.some(_isInfinity.isInfinity) || position === 'none';
97
+ return {
98
+ yScale,
99
+ defaultizedProps,
100
+ tickNumber,
101
+ positionSign,
102
+ skipAxisRendering,
103
+ classes,
104
+ Line,
105
+ Tick,
106
+ TickLabel,
107
+ Label,
108
+ axisTickLabelProps,
109
+ axisLabelProps,
110
+ lineProps,
111
+ reverse,
112
+ isRtl
113
+ };
114
+ };
115
+ exports.useAxisProps = useAxisProps;
@@ -0,0 +1,10 @@
1
+ import { AxisConfig, ChartsYAxisProps } from "../models/axis.js";
2
+ export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"line" | "root" | "label" | "tickContainer" | "tick" | "tickLabel", string>;
3
+ export declare const TICK_LABEL_GAP = 2;
4
+ export declare const AXIS_LABEL_TICK_LABEL_GAP = 2;
5
+ export declare const YAxisRoot: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, keyof import("react").SVGProps<SVGGElement> | keyof import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
6
+ export declare const defaultProps: {
7
+ disableLine: boolean;
8
+ disableTicks: boolean;
9
+ tickSize: number;
10
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useUtilityClasses = exports.defaultProps = exports.YAxisRoot = exports.TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = void 0;
8
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
9
+ var _styles = require("@mui/material/styles");
10
+ var _axisClasses = require("../ChartsAxis/axisClasses");
11
+ var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
12
+ const useUtilityClasses = ownerState => {
13
+ const {
14
+ classes,
15
+ position,
16
+ id
17
+ } = ownerState;
18
+ const slots = {
19
+ root: ['root', 'directionY', position, `id-${id}`],
20
+ line: ['line'],
21
+ tickContainer: ['tickContainer'],
22
+ tick: ['tick'],
23
+ tickLabel: ['tickLabel'],
24
+ label: ['label']
25
+ };
26
+ return (0, _composeClasses.default)(slots, _axisClasses.getAxisUtilityClass, classes);
27
+ };
28
+
29
+ /* Gap between a tick and its label. */
30
+ exports.useUtilityClasses = useUtilityClasses;
31
+ const TICK_LABEL_GAP = exports.TICK_LABEL_GAP = 2;
32
+ /* Gap between the axis label and tick labels. */
33
+ const AXIS_LABEL_TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = 2;
34
+ const YAxisRoot = exports.YAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
35
+ name: 'MuiChartsYAxis',
36
+ slot: 'Root'
37
+ })({});
38
+ const defaultProps = exports.defaultProps = {
39
+ disableLine: false,
40
+ disableTicks: false,
41
+ tickSize: 6
42
+ };
@@ -277,6 +277,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
277
277
  disableTicks: _propTypes.default.bool,
278
278
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
279
279
  fill: _propTypes.default.string,
280
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
281
+ getValue: _propTypes.default.func.isRequired,
282
+ tickLabelStyle: _propTypes.default.object,
283
+ tickSize: _propTypes.default.number
284
+ })),
280
285
  height: _propTypes.default.number,
281
286
  hideTooltip: _propTypes.default.bool,
282
287
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -328,6 +333,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
328
333
  disableTicks: _propTypes.default.bool,
329
334
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
330
335
  fill: _propTypes.default.string,
336
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
337
+ getValue: _propTypes.default.func.isRequired,
338
+ tickLabelStyle: _propTypes.default.object,
339
+ tickSize: _propTypes.default.number
340
+ })),
331
341
  height: _propTypes.default.number,
332
342
  hideTooltip: _propTypes.default.bool,
333
343
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -710,6 +720,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
710
720
  disableTicks: _propTypes.default.bool,
711
721
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
712
722
  fill: _propTypes.default.string,
723
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
724
+ getValue: _propTypes.default.func.isRequired,
725
+ tickLabelStyle: _propTypes.default.object,
726
+ tickSize: _propTypes.default.number
727
+ })),
713
728
  hideTooltip: _propTypes.default.bool,
714
729
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
715
730
  ignoreTooltip: _propTypes.default.bool,
@@ -760,6 +775,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
760
775
  disableTicks: _propTypes.default.bool,
761
776
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
762
777
  fill: _propTypes.default.string,
778
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
779
+ getValue: _propTypes.default.func.isRequired,
780
+ tickLabelStyle: _propTypes.default.object,
781
+ tickSize: _propTypes.default.number
782
+ })),
763
783
  hideTooltip: _propTypes.default.bool,
764
784
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
765
785
  ignoreTooltip: _propTypes.default.bool,
@@ -1,7 +1,14 @@
1
- export { RadarChart as Unstable_RadarChart } from "./RadarChart.js";
1
+ import { RadarDataProvider } from "./RadarDataProvider/index.js";
2
2
  export { RadarChart } from "./RadarChart.js";
3
- export { RadarDataProvider as Unstable_RadarDataProvider } from "./RadarDataProvider/index.js";
3
+ /**
4
+ * @deprecated radar chart is now stable, import `RadarChart` instead
5
+ */
6
+ export declare const Unstable_RadarChart: import("react").ForwardRefExoticComponent<import("./RadarChart.js").RadarChartProps & import("react").RefAttributes<SVGSVGElement>>;
4
7
  export { RadarDataProvider } from "./RadarDataProvider/index.js";
8
+ /**
9
+ * @deprecated radar data provider is now stable, import `RadarDataProvider` instead
10
+ */
11
+ export declare const Unstable_RadarDataProvider: typeof RadarDataProvider;
5
12
  export type { RadarChartProps, RadarChartSlots, RadarChartSlotProps } from "./RadarChart.js";
6
13
  export type { RadarDataProviderProps, RadarSeries } from "./RadarDataProvider/index.js";
7
14
  export * from "./RadarGrid/index.js";
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  Unstable_RadarChart: true,
8
- RadarChart: true,
9
8
  Unstable_RadarDataProvider: true,
9
+ RadarChart: true,
10
10
  RadarDataProvider: true
11
11
  };
12
12
  Object.defineProperty(exports, "RadarChart", {
@@ -21,18 +21,7 @@ Object.defineProperty(exports, "RadarDataProvider", {
21
21
  return _RadarDataProvider.RadarDataProvider;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "Unstable_RadarChart", {
25
- enumerable: true,
26
- get: function () {
27
- return _RadarChart.RadarChart;
28
- }
29
- });
30
- Object.defineProperty(exports, "Unstable_RadarDataProvider", {
31
- enumerable: true,
32
- get: function () {
33
- return _RadarDataProvider.RadarDataProvider;
34
- }
35
- });
24
+ exports.Unstable_RadarDataProvider = exports.Unstable_RadarChart = void 0;
36
25
  var _RadarChart = require("./RadarChart");
37
26
  var _RadarDataProvider = require("./RadarDataProvider");
38
27
  var _RadarGrid = require("./RadarGrid");
@@ -82,4 +71,14 @@ Object.keys(_RadarSeriesPlot).forEach(function (key) {
82
71
  return _RadarSeriesPlot[key];
83
72
  }
84
73
  });
85
- });
74
+ });
75
+ /**
76
+ * @deprecated radar chart is now stable, import `RadarChart` instead
77
+ */
78
+ // eslint-disable-next-line @typescript-eslint/naming-convention
79
+ const Unstable_RadarChart = exports.Unstable_RadarChart = _RadarChart.RadarChart;
80
+ /**
81
+ * @deprecated radar data provider is now stable, import `RadarDataProvider` instead
82
+ */
83
+ // eslint-disable-next-line @typescript-eslint/naming-convention
84
+ const Unstable_RadarDataProvider = exports.Unstable_RadarDataProvider = _RadarDataProvider.RadarDataProvider;
@@ -6,6 +6,7 @@ import { ScatterPlotProps, ScatterPlotSlotProps, ScatterPlotSlots } from "./Scat
6
6
  import { ChartContainerProps } from "../ChartContainer/index.js";
7
7
  import { ChartsAxisProps } from "../ChartsAxis/index.js";
8
8
  import { ScatterSeriesType } from "../models/seriesType/scatter.js";
9
+ import { ChartsTooltipProps } from "../ChartsTooltip/index.js";
9
10
  import { ChartsTooltipSlots, ChartsTooltipSlotProps } from "../ChartsTooltip/ChartTooltip.types.js";
10
11
  import { ChartsLegendSlotProps, ChartsLegendSlots } from "../ChartsLegend/index.js";
11
12
  import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "../ChartsOverlay/index.js";
@@ -15,7 +16,13 @@ import { ChartsGridProps } from "../ChartsGrid/index.js";
15
16
  import { UseChartVoronoiSignature } from "../internals/plugins/featurePlugins/useChartVoronoi/index.js";
16
17
  import { ScatterChartPluginsSignatures } from "./ScatterChart.plugins.js";
17
18
  export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
18
- export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
19
+ export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, Omit<ChartsTooltipSlotProps, 'tooltip'>, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {
20
+ /**
21
+ * Slot props for the tooltip component.
22
+ * @default {}
23
+ */
24
+ tooltip?: Partial<ChartsTooltipProps<'item' | 'none'>>;
25
+ }
19
26
  export type ScatterSeries = MakeOptional<ScatterSeriesType, 'type'>;
20
27
  export interface ScatterChartProps extends Omit<ChartContainerProps<'scatter', ScatterChartPluginsSignatures>, 'series' | 'plugins' | 'onItemClick' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
21
28
  /**
@@ -246,6 +246,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
246
246
  disableTicks: _propTypes.default.bool,
247
247
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
248
248
  fill: _propTypes.default.string,
249
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
250
+ getValue: _propTypes.default.func.isRequired,
251
+ tickLabelStyle: _propTypes.default.object,
252
+ tickSize: _propTypes.default.number
253
+ })),
249
254
  height: _propTypes.default.number,
250
255
  hideTooltip: _propTypes.default.bool,
251
256
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -297,6 +302,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
297
302
  disableTicks: _propTypes.default.bool,
298
303
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
299
304
  fill: _propTypes.default.string,
305
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
306
+ getValue: _propTypes.default.func.isRequired,
307
+ tickLabelStyle: _propTypes.default.object,
308
+ tickSize: _propTypes.default.number
309
+ })),
300
310
  height: _propTypes.default.number,
301
311
  hideTooltip: _propTypes.default.bool,
302
312
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -679,6 +689,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
679
689
  disableTicks: _propTypes.default.bool,
680
690
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
681
691
  fill: _propTypes.default.string,
692
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
693
+ getValue: _propTypes.default.func.isRequired,
694
+ tickLabelStyle: _propTypes.default.object,
695
+ tickSize: _propTypes.default.number
696
+ })),
682
697
  hideTooltip: _propTypes.default.bool,
683
698
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
684
699
  ignoreTooltip: _propTypes.default.bool,
@@ -729,6 +744,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
729
744
  disableTicks: _propTypes.default.bool,
730
745
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
731
746
  fill: _propTypes.default.string,
747
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
748
+ getValue: _propTypes.default.func.isRequired,
749
+ tickLabelStyle: _propTypes.default.object,
750
+ tickSize: _propTypes.default.number
751
+ })),
732
752
  hideTooltip: _propTypes.default.bool,
733
753
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
734
754
  ignoreTooltip: _propTypes.default.bool,
@@ -13,7 +13,7 @@ import { BarPlotSlots, BarPlotSlotProps } from "../BarChart/BarPlot.js";
13
13
  import { ChartMargin } from "../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.js";
14
14
  export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, Omit<BarPlotSlots, 'barLabel'>, ChartsTooltipSlots {}
15
15
  export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps {}
16
- export interface SparkLineChartProps extends Omit<ChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'radiusAxis' | 'rotationAxis' | 'margin' | 'plugins' | 'colors' | 'slots' | 'slotProps' | 'experimentalFeatures'> {
16
+ export interface SparkLineChartProps<PlotType extends 'line' | 'bar' = 'line' | 'bar'> extends Omit<ChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'radiusAxis' | 'rotationAxis' | 'margin' | 'plugins' | 'colors' | 'slots' | 'slotProps' | 'experimentalFeatures'> {
17
17
  /**
18
18
  * The xAxis configuration.
19
19
  * Notice it is a single [[AxisConfig]] object, not an array of configuration.
@@ -29,7 +29,7 @@ export interface SparkLineChartProps extends Omit<ChartContainerProps, 'series'
29
29
  * Type of plot used.
30
30
  * @default 'line'
31
31
  */
32
- plotType?: 'line' | 'bar';
32
+ plotType?: PlotType;
33
33
  /**
34
34
  * Data to plot.
35
35
  */
@@ -58,11 +58,21 @@ export interface SparkLineChartProps extends Omit<ChartContainerProps, 'series'
58
58
  * Has no effect if plotType='bar'.
59
59
  * @default false
60
60
  */
61
- area?: LineSeriesType['area'];
61
+ area?: PlotType extends 'line' ? LineSeriesType['area'] : never;
62
62
  /**
63
63
  * @default 'linear'
64
64
  */
65
- curve?: LineSeriesType['curve'];
65
+ curve?: PlotType extends 'line' ? LineSeriesType['curve'] : never;
66
+ /**
67
+ * The value of the line at the base of the series area.
68
+ *
69
+ * - `'min'` the area will fill the space **under** the line.
70
+ * - `'max'` the area will fill the space **above** the line.
71
+ * - `number` the area will fill the space between this value and the line
72
+ *
73
+ * @default 0
74
+ */
75
+ baseline?: PlotType extends 'line' ? LineSeriesType['baseline'] : never;
66
76
  /**
67
77
  * The margin between the SVG and the drawing area.
68
78
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -115,5 +125,5 @@ export interface SparkLineChartProps extends Omit<ChartContainerProps, 'series'
115
125
  *
116
126
  * - [SparkLineChart API](https://mui.com/x/api/charts/spark-line-chart/)
117
127
  */
118
- declare const SparkLineChart: React.ForwardRefExoticComponent<SparkLineChartProps & React.RefAttributes<SVGSVGElement>>;
128
+ declare const SparkLineChart: React.ForwardRefExoticComponent<SparkLineChartProps<"line" | "bar"> & React.RefAttributes<SVGSVGElement>>;
119
129
  export { SparkLineChart };
@@ -21,7 +21,7 @@ var _constants = require("../constants");
21
21
  var _ChartsTooltip = require("../ChartsTooltip");
22
22
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
23
23
  var _jsxRuntime = require("react/jsx-runtime");
24
- const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "color", "sx", "showTooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className", "disableClipping", "clipAreaOffset"];
24
+ const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "color", "baseline", "sx", "showTooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className", "disableClipping", "clipAreaOffset", "onHighlightChange", "onHighlightedAxisChange", "highlightedAxis", "highlightedItem"];
25
25
  const SPARK_LINE_DEFAULT_MARGIN = 5;
26
26
 
27
27
  /**
@@ -35,12 +35,13 @@ const SPARK_LINE_DEFAULT_MARGIN = 5;
35
35
  */
36
36
  const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
37
37
  const {
38
- xAxis,
39
- yAxis,
38
+ xAxis: xAxisProps,
39
+ yAxis: yAxisProps,
40
40
  width,
41
41
  height,
42
42
  margin = SPARK_LINE_DEFAULT_MARGIN,
43
43
  color,
44
+ baseline,
44
45
  sx,
45
46
  showTooltip,
46
47
  showHighlight,
@@ -55,23 +56,27 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
55
56
  curve = 'linear',
56
57
  className,
57
58
  disableClipping,
58
- clipAreaOffset
59
+ clipAreaOffset,
60
+ onHighlightChange,
61
+ onHighlightedAxisChange,
62
+ highlightedAxis,
63
+ highlightedItem
59
64
  } = props,
60
65
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
61
66
  const id = (0, _useId.default)();
62
67
  const clipPathId = `${id}-clip-path`;
63
- const clipPathOffset = {
68
+ const clipPathOffset = React.useMemo(() => ({
64
69
  top: clipAreaOffset?.top ?? 1,
65
70
  right: clipAreaOffset?.right ?? 1,
66
71
  bottom: clipAreaOffset?.bottom ?? 1,
67
72
  left: clipAreaOffset?.left ?? 1
68
- };
69
- const defaultXHighlight = showHighlight && plotType === 'bar' ? {
73
+ }), [clipAreaOffset?.bottom, clipAreaOffset?.left, clipAreaOffset?.right, clipAreaOffset?.top]);
74
+ const defaultXHighlight = React.useMemo(() => showHighlight && plotType === 'bar' ? {
70
75
  x: 'band'
71
76
  } : {
72
77
  x: 'none'
73
- };
74
- const axisHighlight = (0, _extends2.default)({}, defaultXHighlight, inAxisHighlight);
78
+ }, [plotType, showHighlight]);
79
+ const axisHighlight = React.useMemo(() => (0, _extends2.default)({}, defaultXHighlight, inAxisHighlight), [defaultXHighlight, inAxisHighlight]);
75
80
  const Tooltip = props.slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
76
81
  const colors = React.useMemo(() => {
77
82
  if (color == null) {
@@ -79,36 +84,44 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
79
84
  }
80
85
  return typeof color === 'function' ? mode => [color(mode)] : [color];
81
86
  }, [color]);
87
+ const series = React.useMemo(() => [(0, _extends2.default)({
88
+ type: plotType,
89
+ data,
90
+ valueFormatter
91
+ }, plotType === 'bar' ? {} : {
92
+ area,
93
+ curve,
94
+ baseline,
95
+ disableHighlight: !showHighlight
96
+ })], [area, baseline, curve, data, plotType, showHighlight, valueFormatter]);
97
+ const xAxis = React.useMemo(() => [(0, _extends2.default)({
98
+ id: _constants.DEFAULT_X_AXIS_KEY,
99
+ scaleType: plotType === 'bar' ? 'band' : 'point',
100
+ hideTooltip: xAxisProps === undefined
101
+ }, xAxisProps, {
102
+ data: xAxisProps?.data ?? Array.from({
103
+ length: data.length
104
+ }, (_, index) => index),
105
+ position: 'none'
106
+ })], [data.length, plotType, xAxisProps]);
107
+ const yAxis = React.useMemo(() => [(0, _extends2.default)({
108
+ id: _constants.DEFAULT_Y_AXIS_KEY
109
+ }, yAxisProps, {
110
+ position: 'none'
111
+ })], [yAxisProps]);
82
112
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartDataProvider.ChartDataProvider, {
83
- series: [(0, _extends2.default)({
84
- type: plotType,
85
- data,
86
- valueFormatter
87
- }, plotType === 'bar' ? {} : {
88
- area,
89
- curve,
90
- disableHighlight: !showHighlight
91
- })],
113
+ series: series,
92
114
  width: width,
93
115
  height: height,
94
116
  margin: margin,
95
- xAxis: [(0, _extends2.default)({
96
- id: _constants.DEFAULT_X_AXIS_KEY,
97
- scaleType: plotType === 'bar' ? 'band' : 'point',
98
- data: Array.from({
99
- length: data.length
100
- }, (_, index) => index),
101
- hideTooltip: xAxis === undefined
102
- }, xAxis, {
103
- position: 'none'
104
- })],
105
- yAxis: [(0, _extends2.default)({
106
- id: _constants.DEFAULT_Y_AXIS_KEY
107
- }, yAxis, {
108
- position: 'none'
109
- })],
117
+ xAxis: xAxis,
118
+ yAxis: yAxis,
110
119
  colors: colors,
111
- disableAxisListener: (!showTooltip || slotProps?.tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
120
+ disableAxisListener: onHighlightedAxisChange === undefined && (!showTooltip || slotProps?.tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
121
+ onHighlightChange: onHighlightChange,
122
+ onHighlightedAxisChange: onHighlightedAxisChange,
123
+ highlightedAxis: highlightedAxis,
124
+ highlightedItem: highlightedItem,
112
125
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({
113
126
  className: className,
114
127
  ref: ref,
@@ -160,6 +173,16 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
160
173
  x: _propTypes.default.oneOf(['band', 'line', 'none']),
161
174
  y: _propTypes.default.oneOf(['band', 'line', 'none'])
162
175
  }),
176
+ /**
177
+ * The value of the line at the base of the series area.
178
+ *
179
+ * - `'min'` the area will fill the space **under** the line.
180
+ * - `'max'` the area will fill the space **above** the line.
181
+ * - `number` the area will fill the space between this value and the line
182
+ *
183
+ * @default 0
184
+ */
185
+ baseline: _propTypes.default.oneOfType([_propTypes.default.oneOf(['max', 'min']), _propTypes.default.number]),
163
186
  children: _propTypes.default.node,
164
187
  className: _propTypes.default.string,
165
188
  /**
@@ -360,6 +383,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
360
383
  disableTicks: _propTypes.default.bool,
361
384
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
362
385
  fill: _propTypes.default.string,
386
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
387
+ getValue: _propTypes.default.func.isRequired,
388
+ tickLabelStyle: _propTypes.default.object,
389
+ tickSize: _propTypes.default.number
390
+ })),
363
391
  height: _propTypes.default.number,
364
392
  hideTooltip: _propTypes.default.bool,
365
393
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -411,6 +439,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
411
439
  disableTicks: _propTypes.default.bool,
412
440
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
413
441
  fill: _propTypes.default.string,
442
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
443
+ getValue: _propTypes.default.func.isRequired,
444
+ tickLabelStyle: _propTypes.default.object,
445
+ tickSize: _propTypes.default.number
446
+ })),
414
447
  height: _propTypes.default.number,
415
448
  hideTooltip: _propTypes.default.bool,
416
449
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -792,6 +825,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
792
825
  disableTicks: _propTypes.default.bool,
793
826
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
794
827
  fill: _propTypes.default.string,
828
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
829
+ getValue: _propTypes.default.func.isRequired,
830
+ tickLabelStyle: _propTypes.default.object,
831
+ tickSize: _propTypes.default.number
832
+ })),
795
833
  hideTooltip: _propTypes.default.bool,
796
834
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
797
835
  ignoreTooltip: _propTypes.default.bool,
@@ -842,6 +880,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
842
880
  disableTicks: _propTypes.default.bool,
843
881
  domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
844
882
  fill: _propTypes.default.string,
883
+ groups: _propTypes.default.arrayOf(_propTypes.default.shape({
884
+ getValue: _propTypes.default.func.isRequired,
885
+ tickLabelStyle: _propTypes.default.object,
886
+ tickSize: _propTypes.default.number
887
+ })),
845
888
  hideTooltip: _propTypes.default.bool,
846
889
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
847
890
  ignoreTooltip: _propTypes.default.bool,
@@ -264,6 +264,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
264
264
  disableTicks: PropTypes.bool,
265
265
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
266
266
  fill: PropTypes.string,
267
+ groups: PropTypes.arrayOf(PropTypes.shape({
268
+ getValue: PropTypes.func.isRequired,
269
+ tickLabelStyle: PropTypes.object,
270
+ tickSize: PropTypes.number
271
+ })),
267
272
  height: PropTypes.number,
268
273
  hideTooltip: PropTypes.bool,
269
274
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -315,6 +320,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
315
320
  disableTicks: PropTypes.bool,
316
321
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
317
322
  fill: PropTypes.string,
323
+ groups: PropTypes.arrayOf(PropTypes.shape({
324
+ getValue: PropTypes.func.isRequired,
325
+ tickLabelStyle: PropTypes.object,
326
+ tickSize: PropTypes.number
327
+ })),
318
328
  height: PropTypes.number,
319
329
  hideTooltip: PropTypes.bool,
320
330
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -697,6 +707,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
697
707
  disableTicks: PropTypes.bool,
698
708
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
699
709
  fill: PropTypes.string,
710
+ groups: PropTypes.arrayOf(PropTypes.shape({
711
+ getValue: PropTypes.func.isRequired,
712
+ tickLabelStyle: PropTypes.object,
713
+ tickSize: PropTypes.number
714
+ })),
700
715
  hideTooltip: PropTypes.bool,
701
716
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
702
717
  ignoreTooltip: PropTypes.bool,
@@ -747,6 +762,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
747
762
  disableTicks: PropTypes.bool,
748
763
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
749
764
  fill: PropTypes.string,
765
+ groups: PropTypes.arrayOf(PropTypes.shape({
766
+ getValue: PropTypes.func.isRequired,
767
+ tickLabelStyle: PropTypes.object,
768
+ tickSize: PropTypes.number
769
+ })),
750
770
  hideTooltip: PropTypes.bool,
751
771
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
752
772
  ignoreTooltip: PropTypes.bool,