@mui/x-charts 8.10.0 → 8.10.2

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 (76) hide show
  1. package/BarChart/BarChart.js +4 -0
  2. package/CHANGELOG.md +182 -0
  3. package/ChartContainer/ChartContainer.js +6 -0
  4. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  5. package/ChartsLabel/labelGradientClasses.d.ts +1 -1
  6. package/ChartsLabel/labelMarkClasses.d.ts +1 -1
  7. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  8. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  9. package/ChartsTooltip/ChartsTooltipContainer.js +8 -2
  10. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  11. package/ChartsTooltip/ChartsTooltipTable.js +1 -0
  12. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  13. package/ChartsXAxis/ChartsGroupedXAxis.js +1 -0
  14. package/ChartsXAxis/useAxisProps.d.ts +9 -9
  15. package/ChartsXAxis/utilities.d.ts +1 -1
  16. package/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  17. package/ChartsYAxis/ChartsGroupedYAxis.js +144 -0
  18. package/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  19. package/ChartsYAxis/ChartsSingleYAxis.js +133 -0
  20. package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  21. package/ChartsYAxis/ChartsYAxis.js +12 -211
  22. package/ChartsYAxis/useAxisProps.d.ts +4452 -0
  23. package/ChartsYAxis/useAxisProps.js +115 -0
  24. package/ChartsYAxis/utilities.d.ts +10 -0
  25. package/ChartsYAxis/utilities.js +42 -0
  26. package/LineChart/LineChart.js +4 -0
  27. package/ScatterChart/ScatterChart.js +4 -0
  28. package/SparkLineChart/SparkLineChart.d.ts +15 -5
  29. package/SparkLineChart/SparkLineChart.js +61 -34
  30. package/esm/BarChart/BarChart.js +4 -0
  31. package/esm/ChartContainer/ChartContainer.js +6 -0
  32. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  33. package/esm/ChartsLabel/labelGradientClasses.d.ts +1 -1
  34. package/esm/ChartsLabel/labelMarkClasses.d.ts +1 -1
  35. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  36. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  37. package/esm/ChartsTooltip/ChartsTooltipContainer.js +8 -2
  38. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  39. package/esm/ChartsTooltip/ChartsTooltipTable.js +1 -0
  40. package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  41. package/esm/ChartsXAxis/ChartsGroupedXAxis.js +1 -0
  42. package/esm/ChartsXAxis/useAxisProps.d.ts +9 -9
  43. package/esm/ChartsXAxis/utilities.d.ts +1 -1
  44. package/esm/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  45. package/esm/ChartsYAxis/ChartsGroupedYAxis.js +138 -0
  46. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  47. package/esm/ChartsYAxis/ChartsSingleYAxis.js +129 -0
  48. package/esm/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  49. package/esm/ChartsYAxis/ChartsYAxis.js +10 -207
  50. package/esm/ChartsYAxis/useAxisProps.d.ts +4452 -0
  51. package/esm/ChartsYAxis/useAxisProps.js +108 -0
  52. package/esm/ChartsYAxis/utilities.d.ts +10 -0
  53. package/esm/ChartsYAxis/utilities.js +34 -0
  54. package/esm/LineChart/LineChart.js +4 -0
  55. package/esm/ScatterChart/ScatterChart.js +4 -0
  56. package/esm/SparkLineChart/SparkLineChart.d.ts +15 -5
  57. package/esm/SparkLineChart/SparkLineChart.js +61 -34
  58. package/esm/index.js +1 -1
  59. package/esm/internals/animation/Transition.js +2 -5
  60. package/esm/internals/configInit.js +2 -2
  61. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  62. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  63. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  64. package/esm/internals/plugins/utils/ChartStore.js +16 -18
  65. package/esm/models/axis.d.ts +31 -48
  66. package/esm/tests/web-components.js +2 -4
  67. package/index.js +1 -1
  68. package/internals/animation/Transition.js +2 -5
  69. package/internals/configInit.js +2 -2
  70. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  71. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  72. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  73. package/internals/plugins/utils/ChartStore.js +16 -18
  74. package/models/axis.d.ts +31 -48
  75. package/package.json +16 -17
  76. 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
+ };
@@ -279,6 +279,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
279
279
  fill: _propTypes.default.string,
280
280
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
281
281
  getValue: _propTypes.default.func.isRequired,
282
+ tickLabelStyle: _propTypes.default.object,
282
283
  tickSize: _propTypes.default.number
283
284
  })),
284
285
  height: _propTypes.default.number,
@@ -334,6 +335,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
334
335
  fill: _propTypes.default.string,
335
336
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
336
337
  getValue: _propTypes.default.func.isRequired,
338
+ tickLabelStyle: _propTypes.default.object,
337
339
  tickSize: _propTypes.default.number
338
340
  })),
339
341
  height: _propTypes.default.number,
@@ -720,6 +722,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
720
722
  fill: _propTypes.default.string,
721
723
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
722
724
  getValue: _propTypes.default.func.isRequired,
725
+ tickLabelStyle: _propTypes.default.object,
723
726
  tickSize: _propTypes.default.number
724
727
  })),
725
728
  hideTooltip: _propTypes.default.bool,
@@ -774,6 +777,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
774
777
  fill: _propTypes.default.string,
775
778
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
776
779
  getValue: _propTypes.default.func.isRequired,
780
+ tickLabelStyle: _propTypes.default.object,
777
781
  tickSize: _propTypes.default.number
778
782
  })),
779
783
  hideTooltip: _propTypes.default.bool,
@@ -248,6 +248,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
248
248
  fill: _propTypes.default.string,
249
249
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
250
250
  getValue: _propTypes.default.func.isRequired,
251
+ tickLabelStyle: _propTypes.default.object,
251
252
  tickSize: _propTypes.default.number
252
253
  })),
253
254
  height: _propTypes.default.number,
@@ -303,6 +304,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
303
304
  fill: _propTypes.default.string,
304
305
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
305
306
  getValue: _propTypes.default.func.isRequired,
307
+ tickLabelStyle: _propTypes.default.object,
306
308
  tickSize: _propTypes.default.number
307
309
  })),
308
310
  height: _propTypes.default.number,
@@ -689,6 +691,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
689
691
  fill: _propTypes.default.string,
690
692
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
691
693
  getValue: _propTypes.default.func.isRequired,
694
+ tickLabelStyle: _propTypes.default.object,
692
695
  tickSize: _propTypes.default.number
693
696
  })),
694
697
  hideTooltip: _propTypes.default.bool,
@@ -743,6 +746,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
743
746
  fill: _propTypes.default.string,
744
747
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
745
748
  getValue: _propTypes.default.func.isRequired,
749
+ tickLabelStyle: _propTypes.default.object,
746
750
  tickSize: _propTypes.default.number
747
751
  })),
748
752
  hideTooltip: _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
  /**
@@ -362,6 +385,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
362
385
  fill: _propTypes.default.string,
363
386
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
364
387
  getValue: _propTypes.default.func.isRequired,
388
+ tickLabelStyle: _propTypes.default.object,
365
389
  tickSize: _propTypes.default.number
366
390
  })),
367
391
  height: _propTypes.default.number,
@@ -417,6 +441,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
417
441
  fill: _propTypes.default.string,
418
442
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
419
443
  getValue: _propTypes.default.func.isRequired,
444
+ tickLabelStyle: _propTypes.default.object,
420
445
  tickSize: _propTypes.default.number
421
446
  })),
422
447
  height: _propTypes.default.number,
@@ -802,6 +827,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
802
827
  fill: _propTypes.default.string,
803
828
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
804
829
  getValue: _propTypes.default.func.isRequired,
830
+ tickLabelStyle: _propTypes.default.object,
805
831
  tickSize: _propTypes.default.number
806
832
  })),
807
833
  hideTooltip: _propTypes.default.bool,
@@ -856,6 +882,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
856
882
  fill: _propTypes.default.string,
857
883
  groups: _propTypes.default.arrayOf(_propTypes.default.shape({
858
884
  getValue: _propTypes.default.func.isRequired,
885
+ tickLabelStyle: _propTypes.default.object,
859
886
  tickSize: _propTypes.default.number
860
887
  })),
861
888
  hideTooltip: _propTypes.default.bool,
@@ -266,6 +266,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
266
266
  fill: PropTypes.string,
267
267
  groups: PropTypes.arrayOf(PropTypes.shape({
268
268
  getValue: PropTypes.func.isRequired,
269
+ tickLabelStyle: PropTypes.object,
269
270
  tickSize: PropTypes.number
270
271
  })),
271
272
  height: PropTypes.number,
@@ -321,6 +322,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
321
322
  fill: PropTypes.string,
322
323
  groups: PropTypes.arrayOf(PropTypes.shape({
323
324
  getValue: PropTypes.func.isRequired,
325
+ tickLabelStyle: PropTypes.object,
324
326
  tickSize: PropTypes.number
325
327
  })),
326
328
  height: PropTypes.number,
@@ -707,6 +709,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
707
709
  fill: PropTypes.string,
708
710
  groups: PropTypes.arrayOf(PropTypes.shape({
709
711
  getValue: PropTypes.func.isRequired,
712
+ tickLabelStyle: PropTypes.object,
710
713
  tickSize: PropTypes.number
711
714
  })),
712
715
  hideTooltip: PropTypes.bool,
@@ -761,6 +764,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
761
764
  fill: PropTypes.string,
762
765
  groups: PropTypes.arrayOf(PropTypes.shape({
763
766
  getValue: PropTypes.func.isRequired,
767
+ tickLabelStyle: PropTypes.object,
764
768
  tickSize: PropTypes.number
765
769
  })),
766
770
  hideTooltip: PropTypes.bool,
@@ -236,6 +236,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
236
236
  fill: PropTypes.string,
237
237
  groups: PropTypes.arrayOf(PropTypes.shape({
238
238
  getValue: PropTypes.func.isRequired,
239
+ tickLabelStyle: PropTypes.object,
239
240
  tickSize: PropTypes.number
240
241
  })),
241
242
  height: PropTypes.number,
@@ -292,6 +293,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
292
293
  fill: PropTypes.string,
293
294
  groups: PropTypes.arrayOf(PropTypes.shape({
294
295
  getValue: PropTypes.func.isRequired,
296
+ tickLabelStyle: PropTypes.object,
295
297
  tickSize: PropTypes.number
296
298
  })),
297
299
  height: PropTypes.number,
@@ -717,6 +719,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
717
719
  fill: PropTypes.string,
718
720
  groups: PropTypes.arrayOf(PropTypes.shape({
719
721
  getValue: PropTypes.func.isRequired,
722
+ tickLabelStyle: PropTypes.object,
720
723
  tickSize: PropTypes.number
721
724
  })),
722
725
  height: PropTypes.number,
@@ -772,6 +775,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
772
775
  fill: PropTypes.string,
773
776
  groups: PropTypes.arrayOf(PropTypes.shape({
774
777
  getValue: PropTypes.func.isRequired,
778
+ tickLabelStyle: PropTypes.object,
775
779
  tickSize: PropTypes.number
776
780
  })),
777
781
  height: PropTypes.number,
@@ -1158,6 +1162,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
1158
1162
  fill: PropTypes.string,
1159
1163
  groups: PropTypes.arrayOf(PropTypes.shape({
1160
1164
  getValue: PropTypes.func.isRequired,
1165
+ tickLabelStyle: PropTypes.object,
1161
1166
  tickSize: PropTypes.number
1162
1167
  })),
1163
1168
  hideTooltip: PropTypes.bool,
@@ -1212,6 +1217,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
1212
1217
  fill: PropTypes.string,
1213
1218
  groups: PropTypes.arrayOf(PropTypes.shape({
1214
1219
  getValue: PropTypes.func.isRequired,
1220
+ tickLabelStyle: PropTypes.object,
1215
1221
  tickSize: PropTypes.number
1216
1222
  })),
1217
1223
  hideTooltip: PropTypes.bool,
@@ -30,10 +30,10 @@ function ChartsAxisHighlight(props) {
30
30
  } = props;
31
31
  const classes = useUtilityClasses();
32
32
  return /*#__PURE__*/_jsxs(React.Fragment, {
33
- children: [xAxisHighlight && /*#__PURE__*/_jsx(ChartsXHighlight, {
33
+ children: [xAxisHighlight && xAxisHighlight !== 'none' && /*#__PURE__*/_jsx(ChartsXHighlight, {
34
34
  type: xAxisHighlight,
35
35
  classes: classes
36
- }), yAxisHighlight && /*#__PURE__*/_jsx(ChartsYHighlight, {
36
+ }), yAxisHighlight && yAxisHighlight !== 'none' && /*#__PURE__*/_jsx(ChartsYHighlight, {
37
37
  type: yAxisHighlight,
38
38
  classes: classes
39
39
  })]
@@ -13,4 +13,4 @@ export interface ChartsLabelGradientClasses {
13
13
  }
14
14
  export declare function getLabelGradientUtilityClass(slot: string): string;
15
15
  export declare const labelGradientClasses: ChartsLabelGradientClasses;
16
- export declare const useUtilityClasses: (props: ChartsLabelGradientProps) => Record<"root" | "mask" | "fill", string>;
16
+ export declare const useUtilityClasses: (props: ChartsLabelGradientProps) => Record<"root" | "fill" | "mask", string>;
@@ -15,4 +15,4 @@ export interface ChartsLabelMarkClasses {
15
15
  }
16
16
  export declare function getLabelMarkUtilityClass(slot: string): string;
17
17
  export declare const labelMarkClasses: ChartsLabelMarkClasses;
18
- export declare const useUtilityClasses: (props: ChartsLabelMarkProps) => Record<"root" | "mask" | "fill", string>;
18
+ export declare const useUtilityClasses: (props: ChartsLabelMarkProps) => Record<"root" | "fill" | "mask", string>;
@@ -8,7 +8,7 @@ export type ChartsXReferenceLineProps<TValue extends string | number | Date = st
8
8
  */
9
9
  x: TValue;
10
10
  };
11
- export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
11
+ export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"line" | "root" | "label", string>;
12
12
  declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
13
13
  declare namespace ChartsXReferenceLine {
14
14
  var propTypes: any;
@@ -8,7 +8,7 @@ export type ChartsYReferenceLineProps<TValue extends string | number | Date = st
8
8
  */
9
9
  y: TValue;
10
10
  };
11
- export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
11
+ export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"line" | "root" | "label", string>;
12
12
  declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
13
13
  declare namespace ChartsYReferenceLine {
14
14
  var propTypes: any;
@@ -117,8 +117,14 @@ function ChartsTooltipContainer(inProps) {
117
117
  options: {
118
118
  fallbackPlacements: ['top-end', 'top-start', 'bottom-end', 'bottom']
119
119
  }
120
- }] : []) // Keep default behavior
121
- ], [isMouse, isTouch]);
120
+ }] : []),
121
+ // Keep default behavior
122
+ {
123
+ name: 'preventOverflow',
124
+ options: {
125
+ altAxis: true
126
+ }
127
+ }], [isMouse, isTouch]);
122
128
  if (trigger === 'none') {
123
129
  return null;
124
130
  }