@mui/x-charts 7.7.1 → 7.9.0

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 (136) hide show
  1. package/BarChart/BarChart.d.ts +3 -3
  2. package/BarChart/BarElement.d.ts +225 -228
  3. package/BarChart/BarLabel/BarLabel.d.ts +225 -228
  4. package/BarChart/BarLabel/getBarLabel.d.ts +1 -1
  5. package/BarChart/useBarChartProps.d.ts +20 -88
  6. package/CHANGELOG.md +166 -1
  7. package/ChartContainer/ChartContainer.d.ts +1 -1
  8. package/ChartContainer/ChartContainer.js +3 -1
  9. package/ChartContainer/useChartContainerHooks.d.ts +1 -1
  10. package/ChartsAxisHighlight/ChartsAxisHighlight.js +19 -4
  11. package/ChartsReferenceLine/common.d.ts +0 -1
  12. package/ChartsSurface.js +5 -1
  13. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +3 -3
  14. package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -39
  15. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +7 -6
  16. package/ChartsTooltip/ChartsItemTooltipContent.js +4 -27
  17. package/ChartsTooltip/ChartsTooltip.d.ts +10 -9
  18. package/ChartsTooltip/ChartsTooltip.js +8 -2
  19. package/ChartsTooltip/ChartsTooltipTable.d.ts +15 -1
  20. package/ChartsTooltip/ChartsTooltipTable.js +19 -0
  21. package/ChartsTooltip/index.d.ts +1 -0
  22. package/ChartsTooltip/index.js +11 -0
  23. package/ChartsTooltip/utils.d.ts +7 -6
  24. package/ChartsTooltip/utils.js +24 -30
  25. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
  26. package/ChartsXAxis/ChartsXAxis.js +7 -5
  27. package/ChartsYAxis/ChartsYAxis.js +3 -1
  28. package/Gauge/GaugeProvider.d.ts +1 -1
  29. package/LineChart/AnimatedArea.d.ts +225 -228
  30. package/LineChart/AnimatedLine.d.ts +225 -228
  31. package/LineChart/LineChart.d.ts +3 -3
  32. package/LineChart/MarkPlot.js +6 -2
  33. package/LineChart/useLineChartProps.d.ts +26 -103
  34. package/LineChart/useLineChartProps.js +3 -3
  35. package/PieChart/PieArc.d.ts +0 -1
  36. package/PieChart/PieArcLabel.d.ts +0 -1
  37. package/PieChart/PieChart.d.ts +3 -3
  38. package/PieChart/dataTransform/transition.d.ts +0 -1
  39. package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -2
  40. package/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
  41. package/ScatterChart/Scatter.js +7 -5
  42. package/ScatterChart/ScatterChart.d.ts +3 -3
  43. package/ScatterChart/ScatterChart.js +3 -1
  44. package/ScatterChart/useScatterChartProps.d.ts +20 -75
  45. package/SparkLineChart/SparkLineChart.d.ts +3 -3
  46. package/context/CartesianProvider/computeValue.d.ts +2 -2
  47. package/context/CartesianProvider/computeValue.js +36 -5
  48. package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
  49. package/context/ZAxisContextProvider.js +7 -2
  50. package/esm/BarChart/useBarChartProps.js +0 -1
  51. package/esm/ChartContainer/ChartContainer.js +3 -1
  52. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +19 -4
  53. package/esm/ChartsSurface.js +5 -1
  54. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +3 -38
  55. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +3 -26
  56. package/esm/ChartsTooltip/ChartsTooltip.js +8 -2
  57. package/esm/ChartsTooltip/ChartsTooltipTable.js +20 -0
  58. package/esm/ChartsTooltip/index.js +2 -1
  59. package/esm/ChartsTooltip/utils.js +23 -30
  60. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
  61. package/esm/ChartsXAxis/ChartsXAxis.js +7 -5
  62. package/esm/ChartsYAxis/ChartsYAxis.js +3 -1
  63. package/esm/LineChart/MarkPlot.js +6 -2
  64. package/esm/LineChart/useLineChartProps.js +3 -3
  65. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
  66. package/esm/ScatterChart/Scatter.js +7 -5
  67. package/esm/ScatterChart/ScatterChart.js +3 -1
  68. package/esm/context/CartesianProvider/computeValue.js +37 -6
  69. package/esm/context/ZAxisContextProvider.js +7 -2
  70. package/esm/hooks/index.js +1 -0
  71. package/esm/hooks/useAxis.js +17 -0
  72. package/esm/hooks/useAxisEvents.js +25 -17
  73. package/esm/hooks/useInteractionItemProps.js +11 -4
  74. package/esm/hooks/useScale.js +7 -14
  75. package/esm/hooks/useTicks.js +2 -1
  76. package/esm/internals/getSVGPoint.js +11 -0
  77. package/esm/internals/index.js +4 -0
  78. package/esm/internals/utils.js +0 -12
  79. package/hooks/index.d.ts +1 -0
  80. package/hooks/index.js +12 -0
  81. package/hooks/useAxis.d.ts +2 -0
  82. package/hooks/useAxis.js +24 -0
  83. package/hooks/useAxisEvents.js +25 -17
  84. package/hooks/useChartDimensions.d.ts +1 -1
  85. package/hooks/useColor.d.ts +1 -1
  86. package/hooks/useInteractionItemProps.d.ts +4 -2
  87. package/hooks/useInteractionItemProps.js +11 -4
  88. package/hooks/useScale.js +6 -14
  89. package/hooks/useTicks.js +2 -1
  90. package/index.js +1 -1
  91. package/internals/components/AxisSharedComponents.d.ts +0 -1
  92. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
  93. package/internals/defaultizeColor.d.ts +68 -68
  94. package/internals/getSVGPoint.d.ts +6 -0
  95. package/internals/getSVGPoint.js +17 -0
  96. package/internals/getWordsByLines.d.ts +0 -1
  97. package/internals/index.d.ts +4 -0
  98. package/internals/index.js +40 -0
  99. package/internals/useAnimatedPath.d.ts +0 -1
  100. package/internals/utils.d.ts +0 -6
  101. package/internals/utils.js +0 -13
  102. package/models/axis.d.ts +1 -2
  103. package/models/colorMapping.d.ts +1 -1
  104. package/models/z-axis.d.ts +8 -0
  105. package/modern/BarChart/useBarChartProps.js +0 -1
  106. package/modern/ChartContainer/ChartContainer.js +3 -1
  107. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +19 -4
  108. package/modern/ChartsSurface.js +5 -1
  109. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -38
  110. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +3 -26
  111. package/modern/ChartsTooltip/ChartsTooltip.js +8 -2
  112. package/modern/ChartsTooltip/ChartsTooltipTable.js +20 -0
  113. package/modern/ChartsTooltip/index.js +2 -1
  114. package/modern/ChartsTooltip/utils.js +23 -30
  115. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
  116. package/modern/ChartsXAxis/ChartsXAxis.js +7 -5
  117. package/modern/ChartsYAxis/ChartsYAxis.js +3 -1
  118. package/modern/LineChart/MarkPlot.js +6 -2
  119. package/modern/LineChart/useLineChartProps.js +3 -3
  120. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
  121. package/modern/ScatterChart/Scatter.js +7 -5
  122. package/modern/ScatterChart/ScatterChart.js +3 -1
  123. package/modern/context/CartesianProvider/computeValue.js +37 -6
  124. package/modern/context/ZAxisContextProvider.js +7 -2
  125. package/modern/hooks/index.js +1 -0
  126. package/modern/hooks/useAxis.js +17 -0
  127. package/modern/hooks/useAxisEvents.js +25 -17
  128. package/modern/hooks/useInteractionItemProps.js +11 -4
  129. package/modern/hooks/useScale.js +7 -14
  130. package/modern/hooks/useTicks.js +2 -1
  131. package/modern/index.js +1 -1
  132. package/modern/internals/getSVGPoint.js +11 -0
  133. package/modern/internals/index.js +4 -0
  134. package/modern/internals/utils.js +0 -12
  135. package/package.json +3 -3
  136. package/themeAugmentation/props.d.ts +2 -1
@@ -2,92 +2,92 @@ import { AllSeriesType } from '../models/seriesType';
2
2
  export declare function defaultizeColor(series: AllSeriesType, seriesIndex: number, colors?: string[]): {
3
3
  data: {
4
4
  color: string;
5
- label?: string | ((location: "tooltip" | "legend" | "arc") => string) | undefined;
5
+ label?: string | ((location: "tooltip" | "legend" | "arc") => string);
6
6
  value: number;
7
7
  id?: import("../models/seriesType").PieItemId | undefined;
8
8
  }[];
9
9
  type: "pie";
10
- innerRadius?: string | number | undefined;
11
- outerRadius?: string | number | undefined;
12
- arcLabelRadius?: string | number | undefined;
13
- cornerRadius?: number | undefined;
14
- startAngle?: number | undefined;
15
- endAngle?: number | undefined;
16
- paddingAngle?: number | undefined;
17
- sortingValues?: import("../models/seriesType").ChartsPieSorting | undefined;
18
- arcLabel?: "label" | "value" | "formattedValue" | ((item: Omit<import("../models/seriesType").DefaultizedPieValueType, "label"> & {
19
- label?: string | undefined;
20
- }) => string) | undefined;
21
- arcLabelMinAngle?: number | undefined;
22
- cx?: string | number | undefined;
23
- cy?: string | number | undefined;
10
+ innerRadius?: number | string;
11
+ outerRadius?: number | string;
12
+ arcLabelRadius?: number | string;
13
+ cornerRadius?: number;
14
+ startAngle?: number;
15
+ endAngle?: number;
16
+ paddingAngle?: number;
17
+ sortingValues?: import("../models/seriesType").ChartsPieSorting;
18
+ arcLabel?: "formattedValue" | "label" | "value" | ((item: Omit<import("../models/seriesType").DefaultizedPieValueType, "label"> & {
19
+ label?: string;
20
+ }) => string);
21
+ arcLabelMinAngle?: number;
22
+ cx?: number | string;
23
+ cy?: number | string;
24
24
  highlighted?: {
25
- additionalRadius?: number | undefined;
26
- innerRadius?: number | undefined;
27
- outerRadius?: number | undefined;
28
- cornerRadius?: number | undefined;
29
- paddingAngle?: number | undefined;
30
- arcLabelRadius?: number | undefined;
31
- color?: string | undefined;
32
- } | undefined;
25
+ additionalRadius?: number;
26
+ innerRadius?: number;
27
+ outerRadius?: number;
28
+ cornerRadius?: number;
29
+ paddingAngle?: number;
30
+ arcLabelRadius?: number;
31
+ color?: string;
32
+ };
33
33
  faded?: {
34
- additionalRadius?: number | undefined;
35
- innerRadius?: number | undefined;
36
- outerRadius?: number | undefined;
37
- cornerRadius?: number | undefined;
38
- paddingAngle?: number | undefined;
39
- arcLabelRadius?: number | undefined;
40
- color?: string | undefined;
41
- } | undefined;
42
- id?: import(".").SeriesId | undefined;
43
- color?: string | undefined;
34
+ additionalRadius?: number;
35
+ innerRadius?: number;
36
+ outerRadius?: number;
37
+ cornerRadius?: number;
38
+ paddingAngle?: number;
39
+ arcLabelRadius?: number;
40
+ color?: string;
41
+ };
42
+ id?: import(".").SeriesId;
43
+ color?: string;
44
44
  valueFormatter?: import(".").SeriesValueFormatter<import(".").MakeOptional<import("../models/seriesType").PieValueType, "id">> | undefined;
45
- highlightScope?: Partial<import("..").HighlightScope> | undefined;
45
+ highlightScope?: Partial<import("..").HighlightScope>;
46
46
  } | {
47
47
  type: "bar";
48
- data?: (number | null)[] | undefined;
49
- dataKey?: string | undefined;
50
- label?: string | ((location: "tooltip" | "legend") => string) | undefined;
51
- layout?: "horizontal" | "vertical" | undefined;
52
- stackOffset?: import("..").StackOffsetType | undefined;
53
- id?: import(".").SeriesId | undefined;
48
+ data?: (number | null)[];
49
+ dataKey?: string;
50
+ label?: string | ((location: "tooltip" | "legend") => string);
51
+ layout?: "horizontal" | "vertical";
52
+ stackOffset?: import("..").StackOffsetType;
53
+ id?: import(".").SeriesId;
54
54
  color: string;
55
55
  valueFormatter?: import(".").SeriesValueFormatter<number | null> | undefined;
56
- highlightScope?: Partial<import("..").HighlightScope> | undefined;
57
- xAxisKey?: string | undefined;
58
- yAxisKey?: string | undefined;
59
- stack?: string | undefined;
60
- stackOrder?: import("..").StackOrderType | undefined;
56
+ highlightScope?: Partial<import("..").HighlightScope>;
57
+ xAxisKey?: string;
58
+ yAxisKey?: string;
59
+ stack?: string;
60
+ stackOrder?: import("..").StackOrderType;
61
61
  } | {
62
62
  type: "line";
63
- data?: (number | null)[] | undefined;
64
- dataKey?: string | undefined;
65
- stack?: string | undefined;
66
- area?: boolean | undefined;
67
- label?: string | ((location: "tooltip" | "legend") => string) | undefined;
68
- curve?: import("../models/seriesType").CurveType | undefined;
69
- showMark?: boolean | ((params: import("../models/seriesType").ShowMarkParams<number | Date>) => boolean) | undefined;
70
- disableHighlight?: boolean | undefined;
71
- connectNulls?: boolean | undefined;
72
- stackOffset?: import("..").StackOffsetType | undefined;
73
- id?: import(".").SeriesId | undefined;
63
+ data?: (number | null)[];
64
+ dataKey?: string;
65
+ stack?: string;
66
+ area?: boolean;
67
+ label?: string | ((location: "tooltip" | "legend") => string);
68
+ curve?: import("../models/seriesType").CurveType;
69
+ showMark?: boolean | ((params: import("../models/seriesType").ShowMarkParams) => boolean);
70
+ disableHighlight?: boolean;
71
+ connectNulls?: boolean;
72
+ stackOffset?: import("..").StackOffsetType;
73
+ id?: import(".").SeriesId;
74
74
  color: string;
75
75
  valueFormatter?: import(".").SeriesValueFormatter<number | null> | undefined;
76
- highlightScope?: Partial<import("..").HighlightScope> | undefined;
77
- xAxisKey?: string | undefined;
78
- yAxisKey?: string | undefined;
79
- stackOrder?: import("..").StackOrderType | undefined;
76
+ highlightScope?: Partial<import("..").HighlightScope>;
77
+ xAxisKey?: string;
78
+ yAxisKey?: string;
79
+ stackOrder?: import("..").StackOrderType;
80
80
  } | {
81
81
  type: "scatter";
82
82
  data: import("../models/seriesType").ScatterValueType[];
83
- markerSize?: number | undefined;
84
- label?: string | ((location: "tooltip" | "legend") => string) | undefined;
85
- disableHover?: boolean | undefined;
86
- zAxisKey?: string | undefined;
87
- id?: import(".").SeriesId | undefined;
83
+ markerSize?: number;
84
+ label?: string | ((location: "tooltip" | "legend") => string);
85
+ disableHover?: boolean;
86
+ zAxisKey?: string;
87
+ id?: import(".").SeriesId;
88
88
  color: string;
89
89
  valueFormatter?: import(".").SeriesValueFormatter<import("../models/seriesType").ScatterValueType> | undefined;
90
- highlightScope?: Partial<import("..").HighlightScope> | undefined;
91
- xAxisKey?: string | undefined;
92
- yAxisKey?: string | undefined;
90
+ highlightScope?: Partial<import("..").HighlightScope>;
91
+ xAxisKey?: string;
92
+ yAxisKey?: string;
93
93
  };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Transform mouse event position to coordinates inside the SVG.
3
+ * @param svg The SVG element
4
+ * @param event The mouseEvent to transform
5
+ */
6
+ export declare function getSVGPoint(svg: SVGSVGElement, event: Pick<MouseEvent, 'clientX' | 'clientY'>): DOMPoint;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSVGPoint = getSVGPoint;
7
+ /**
8
+ * Transform mouse event position to coordinates inside the SVG.
9
+ * @param svg The SVG element
10
+ * @param event The mouseEvent to transform
11
+ */
12
+ function getSVGPoint(svg, event) {
13
+ const pt = svg.createSVGPoint();
14
+ pt.x = event.clientX;
15
+ pt.y = event.clientY;
16
+ return pt.matrixTransform(svg.getScreenCTM().inverse());
17
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type ChartsTextBaseline = 'hanging' | 'central' | 'auto';
3
2
  export interface ChartsTextStyle extends React.CSSProperties {
4
3
  angle?: number;
@@ -3,12 +3,16 @@ export * from '../ResponsiveChartContainer/useChartContainerDimensions';
3
3
  export * from '../ResponsiveChartContainer/ResizableContainer';
4
4
  export { useReducedMotion } from '../hooks/useReducedMotion';
5
5
  export { useSeries } from '../hooks/useSeries';
6
+ export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
7
+ export { useDrawingArea } from '../hooks/useDrawingArea';
6
8
  export { useChartContainerHooks } from '../ChartContainer/useChartContainerHooks';
7
9
  export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
8
10
  export { useLineChartProps } from '../LineChart/useLineChartProps';
9
11
  export { useBarChartProps } from '../BarChart/useBarChartProps';
10
12
  export * from './defaultizeValueFormatter';
11
13
  export * from './configInit';
14
+ export * from './getLabel';
15
+ export * from './getSVGPoint';
12
16
  export * from '../context/CartesianProvider';
13
17
  export * from '../context/DrawingProvider';
14
18
  export * from '../context/ColorProvider';
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  useReducedMotion: true,
8
8
  useSeries: true,
9
+ useInteractionItemProps: true,
10
+ useDrawingArea: true,
9
11
  useChartContainerHooks: true,
10
12
  useScatterChartProps: true,
11
13
  useLineChartProps: true,
@@ -23,6 +25,18 @@ Object.defineProperty(exports, "useChartContainerHooks", {
23
25
  return _useChartContainerHooks.useChartContainerHooks;
24
26
  }
25
27
  });
28
+ Object.defineProperty(exports, "useDrawingArea", {
29
+ enumerable: true,
30
+ get: function () {
31
+ return _useDrawingArea.useDrawingArea;
32
+ }
33
+ });
34
+ Object.defineProperty(exports, "useInteractionItemProps", {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _useInteractionItemProps.useInteractionItemProps;
38
+ }
39
+ });
26
40
  Object.defineProperty(exports, "useLineChartProps", {
27
41
  enumerable: true,
28
42
  get: function () {
@@ -85,6 +99,8 @@ Object.keys(_ResizableContainer).forEach(function (key) {
85
99
  });
86
100
  var _useReducedMotion = require("../hooks/useReducedMotion");
87
101
  var _useSeries = require("../hooks/useSeries");
102
+ var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
103
+ var _useDrawingArea = require("../hooks/useDrawingArea");
88
104
  var _useChartContainerHooks = require("../ChartContainer/useChartContainerHooks");
89
105
  var _useScatterChartProps = require("../ScatterChart/useScatterChartProps");
90
106
  var _useLineChartProps = require("../LineChart/useLineChartProps");
@@ -113,6 +129,30 @@ Object.keys(_configInit).forEach(function (key) {
113
129
  }
114
130
  });
115
131
  });
132
+ var _getLabel = require("./getLabel");
133
+ Object.keys(_getLabel).forEach(function (key) {
134
+ if (key === "default" || key === "__esModule") return;
135
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
136
+ if (key in exports && exports[key] === _getLabel[key]) return;
137
+ Object.defineProperty(exports, key, {
138
+ enumerable: true,
139
+ get: function () {
140
+ return _getLabel[key];
141
+ }
142
+ });
143
+ });
144
+ var _getSVGPoint = require("./getSVGPoint");
145
+ Object.keys(_getSVGPoint).forEach(function (key) {
146
+ if (key === "default" || key === "__esModule") return;
147
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
148
+ if (key in exports && exports[key] === _getSVGPoint[key]) return;
149
+ Object.defineProperty(exports, key, {
150
+ enumerable: true,
151
+ get: function () {
152
+ return _getSVGPoint[key];
153
+ }
154
+ });
155
+ });
116
156
  var _CartesianProvider = require("../context/CartesianProvider");
117
157
  Object.keys(_CartesianProvider).forEach(function (key) {
118
158
  if (key === "default" || key === "__esModule") return;
@@ -1,2 +1 @@
1
- /// <reference types="@react-spring/core" />
2
1
  export declare const useAnimatedPath: (path: string, skipAnimation?: boolean) => import("@react-spring/core").Interpolation<string, any>;
@@ -4,12 +4,6 @@ type Without<T, U> = {
4
4
  [P in Exclude<keyof T, keyof U>]?: never;
5
5
  };
6
6
  export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
7
- /**
8
- * Transform mouse event position to coordinates inside the SVG.
9
- * @param svg The SVG element
10
- * @param event The mouseEvent to transform
11
- */
12
- export declare function getSVGPoint(svg: SVGSVGElement, event: Pick<MouseEvent, 'clientX' | 'clientY'>): DOMPoint;
13
7
  /**
14
8
  * Helper that converts values and percentages into values.
15
9
  * @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
@@ -5,25 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.cleanId = cleanId;
7
7
  exports.getPercentageValue = getPercentageValue;
8
- exports.getSVGPoint = getSVGPoint;
9
8
  exports.getSymbol = getSymbol;
10
9
  // Returns the index of a defined shape
11
10
  function getSymbol(shape) {
12
11
  const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
13
12
  return symbolNames.indexOf(shape) || 0;
14
13
  }
15
- /**
16
- * Transform mouse event position to coordinates inside the SVG.
17
- * @param svg The SVG element
18
- * @param event The mouseEvent to transform
19
- */
20
- function getSVGPoint(svg, event) {
21
- const pt = svg.createSVGPoint();
22
- pt.x = event.clientX;
23
- pt.y = event.clientY;
24
- return pt.matrixTransform(svg.getScreenCTM().inverse());
25
- }
26
-
27
14
  /**
28
15
  * Helper that converts values and percentages into values.
29
16
  * @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
package/models/axis.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, ScalePoint, ScaleOrdinal, ScaleSequential, ScaleThreshold } from 'd3-scale';
3
2
  import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
4
3
  import type { TickParams } from '../hooks/useTicks';
@@ -126,7 +125,7 @@ export interface ChartsXAxisProps extends ChartsAxisProps {
126
125
  */
127
126
  position?: 'top' | 'bottom';
128
127
  }
129
- export type ScaleName = 'linear' | 'band' | 'point' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
128
+ export type ScaleName = keyof AxisScaleConfig;
130
129
  export type ContinuousScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
131
130
  export interface AxisScaleConfig {
132
131
  band: {
@@ -13,7 +13,7 @@ export interface ContinuousColorConfig<Value = number | Date> {
13
13
  /**
14
14
  * The colors to render. It can be an array with the extremum colors, or an interpolation function.
15
15
  */
16
- color: [string, string] | ((t: number) => string);
16
+ color: readonly [string, string] | ((t: number) => string);
17
17
  }
18
18
  export interface PiecewiseColorConfig<Value = number | Date> {
19
19
  type: 'piecewise';
@@ -7,6 +7,14 @@ export interface ZAxisConfig<V = any> {
7
7
  * The key used to retrieve `data` from the `dataset` prop.
8
8
  */
9
9
  dataKey?: string;
10
+ /**
11
+ * The minimal value of the scale.
12
+ */
13
+ min?: number;
14
+ /**
15
+ * The maximal value of the scale.
16
+ */
17
+ max?: number;
10
18
  colorMap?: OrdinalColorConfig | ContinuousColorConfig | PiecewiseColorConfig;
11
19
  }
12
20
  export interface ZAxisDefaultized extends ZAxisConfig {
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import useId from '@mui/utils/useId';
3
3
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
4
-
5
4
  /**
6
5
  * A helper function that extracts BarChartProps from the input props
7
6
  * and returns an object with props for the children components of BarChart.
@@ -283,7 +283,9 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
283
283
  })]),
284
284
  data: PropTypes.array,
285
285
  dataKey: PropTypes.string,
286
- id: PropTypes.string
286
+ id: PropTypes.string,
287
+ max: PropTypes.number,
288
+ min: PropTypes.number
287
289
  }))
288
290
  } : void 0;
289
291
  export { ChartContainer };
@@ -66,15 +66,30 @@ function ChartsAxisHighlight(props) {
66
66
  } = React.useContext(InteractionContext);
67
67
  const getXPosition = getValueToPositionMapper(xScale);
68
68
  const getYPosition = getValueToPositionMapper(yScale);
69
+ const axisX = axis.x;
70
+ const axisY = axis.y;
71
+ const isBandScaleX = xAxisHighlight === 'band' && axisX !== null && isBandScale(xScale);
72
+ const isBandScaleY = yAxisHighlight === 'band' && axisY !== null && isBandScale(yScale);
73
+ if (process.env.NODE_ENV !== 'production') {
74
+ const isXError = isBandScaleX && xScale(axisX.value) === undefined;
75
+ const isYError = isBandScaleY && yScale(axisY.value) === undefined;
76
+ if (isXError || isYError) {
77
+ console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
78
+ }
79
+ }
69
80
  return /*#__PURE__*/_jsxs(React.Fragment, {
70
- children: [xAxisHighlight === 'band' && axis.x !== null && isBandScale(xScale) && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
71
- d: `M ${xScale(axis.x.value) - (xScale.step() - xScale.bandwidth()) / 2} ${yScale.range()[0]} l ${xScale.step()} 0 l 0 ${yScale.range()[1] - yScale.range()[0]} l ${-xScale.step()} 0 Z`,
81
+ children: [isBandScaleX && xScale(axisX.value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath
82
+ // @ts-expect-error, xScale value is checked in the statement above
83
+ , {
84
+ d: `M ${xScale(axisX.value) - (xScale.step() - xScale.bandwidth()) / 2} ${yScale.range()[0]} l ${xScale.step()} 0 l 0 ${yScale.range()[1] - yScale.range()[0]} l ${-xScale.step()} 0 Z`,
72
85
  className: classes.root,
73
86
  ownerState: {
74
87
  axisHighlight: 'band'
75
88
  }
76
- }), yAxisHighlight === 'band' && axis.y !== null && isBandScale(yScale) && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
77
- d: `M ${xScale.range()[0]} ${yScale(axis.y.value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${xScale.range()[1] - xScale.range()[0]} 0 l 0 ${-yScale.step()} Z`,
89
+ }), isBandScaleY && yScale(axisY.value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
90
+ d: `M ${xScale.range()[0]} ${
91
+ // @ts-expect-error, yScale value is checked in the statement above
92
+ yScale(axisY.value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${xScale.range()[1] - xScale.range()[0]} 0 l 0 ${-yScale.step()} Z`,
78
93
  className: classes.root,
79
94
  ownerState: {
80
95
  axisHighlight: 'band'
@@ -9,7 +9,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  const ChartChartsSurfaceStyles = styled('svg', {
10
10
  name: 'MuiChartsSurface',
11
11
  slot: 'Root'
12
- })(() => ({}));
12
+ })(() => ({
13
+ // This prevents default touch actions when using the svg on mobile devices.
14
+ // For example, prevent page scroll & zoom.
15
+ touchAction: 'none'
16
+ }));
13
17
  const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
14
18
  const {
15
19
  children,
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import PropTypes from 'prop-types';
4
3
  import { useSlotProps } from '@mui/base/utils';
5
4
  import { useCartesianContext } from '../context/CartesianProvider';
6
5
  import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
@@ -9,6 +8,9 @@ import { useColorProcessor } from '../hooks/useColor';
9
8
  import { isCartesianSeriesType } from '../internals/isCartesian';
10
9
  import { useSeries } from '../hooks/useSeries';
11
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ /**
12
+ * @ignore - internal component.
13
+ */
12
14
  function ChartsAxisTooltipContent(props) {
13
15
  const {
14
16
  content,
@@ -71,41 +73,4 @@ function ChartsAxisTooltipContent(props) {
71
73
  });
72
74
  return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
73
75
  }
74
- process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
75
- // ----------------------------- Warning --------------------------------
76
- // | These PropTypes are generated from the TypeScript type definitions |
77
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
78
- // ----------------------------------------------------------------------
79
- axisData: PropTypes.shape({
80
- x: PropTypes.shape({
81
- index: PropTypes.number,
82
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
83
- }),
84
- y: PropTypes.shape({
85
- index: PropTypes.number,
86
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
87
- })
88
- }).isRequired,
89
- classes: PropTypes.object.isRequired,
90
- content: PropTypes.elementType,
91
- contentProps: PropTypes.shape({
92
- axis: PropTypes.object,
93
- axisData: PropTypes.shape({
94
- x: PropTypes.shape({
95
- index: PropTypes.number,
96
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
97
- }),
98
- y: PropTypes.shape({
99
- index: PropTypes.number,
100
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
101
- })
102
- }),
103
- axisValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]),
104
- classes: PropTypes.object,
105
- dataIndex: PropTypes.number,
106
- series: PropTypes.arrayOf(PropTypes.object),
107
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
108
- }),
109
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
110
- } : void 0;
111
76
  export { ChartsAxisTooltipContent };
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import PropTypes from 'prop-types';
4
3
  import { useSlotProps } from '@mui/base/utils';
5
4
  import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
6
5
  import { useCartesianContext } from '../context/CartesianProvider';
@@ -8,6 +7,9 @@ import { ZAxisContext } from '../context/ZAxisContextProvider';
8
7
  import { useColorProcessor } from '../hooks/useColor';
9
8
  import { useSeries } from '../hooks/useSeries';
10
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
+ /**
11
+ * @ignore - internal component.
12
+ */
11
13
  function ChartsItemTooltipContent(props) {
12
14
  const {
13
15
  content,
@@ -47,29 +49,4 @@ function ChartsItemTooltipContent(props) {
47
49
  });
48
50
  return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
49
51
  }
50
- process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
51
- // ----------------------------- Warning --------------------------------
52
- // | These PropTypes are generated from the TypeScript type definitions |
53
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
54
- // ----------------------------------------------------------------------
55
- classes: PropTypes.object.isRequired,
56
- content: PropTypes.elementType,
57
- contentProps: PropTypes.shape({
58
- classes: PropTypes.object,
59
- getColor: PropTypes.func,
60
- itemData: PropTypes.shape({
61
- dataIndex: PropTypes.number,
62
- seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
63
- type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
64
- }),
65
- series: PropTypes.object,
66
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
67
- }),
68
- itemData: PropTypes.shape({
69
- dataIndex: PropTypes.number,
70
- seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
71
- type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
72
- }).isRequired,
73
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
74
- } : void 0;
75
52
  export { ChartsItemTooltipContent };
@@ -77,8 +77,14 @@ function ChartsTooltip(props) {
77
77
  externalSlotProps: slotProps?.popper,
78
78
  additionalProps: {
79
79
  open: popperOpen,
80
- placement: 'right-start',
81
- anchorEl: generateVirtualElement(mousePosition)
80
+ placement: mousePosition?.pointerType === 'mouse' ? 'right-start' : 'top',
81
+ anchorEl: generateVirtualElement(mousePosition),
82
+ modifiers: [{
83
+ name: 'offset',
84
+ options: {
85
+ offset: [0, mousePosition?.pointerType === 'touch' ? 40 - mousePosition.height : 0]
86
+ }
87
+ }]
82
88
  },
83
89
  ownerState: {}
84
90
  });
@@ -1,6 +1,10 @@
1
1
  import { styled } from '@mui/material/styles';
2
2
  import { shouldForwardProp } from '@mui/system';
3
3
  import { chartsTooltipClasses } from './chartsTooltipClasses';
4
+
5
+ /**
6
+ * @ignore - internal component.
7
+ */
4
8
  export const ChartsTooltipPaper = styled('div', {
5
9
  name: 'MuiChartsTooltip',
6
10
  slot: 'Container'
@@ -13,6 +17,10 @@ export const ChartsTooltipPaper = styled('div', {
13
17
  transition: theme.transitions.create('box-shadow'),
14
18
  borderRadius: theme.shape.borderRadius
15
19
  }));
20
+
21
+ /**
22
+ * @ignore - internal component.
23
+ */
16
24
  export const ChartsTooltipTable = styled('table', {
17
25
  name: 'MuiChartsTooltip',
18
26
  slot: 'Table'
@@ -24,6 +32,10 @@ export const ChartsTooltipTable = styled('table', {
24
32
  borderBottom: `solid ${(theme.vars || theme).palette.divider} 1px`
25
33
  }
26
34
  }));
35
+
36
+ /**
37
+ * @ignore - internal component.
38
+ */
27
39
  export const ChartsTooltipRow = styled('tr', {
28
40
  name: 'MuiChartsTooltip',
29
41
  slot: 'Row'
@@ -37,6 +49,10 @@ export const ChartsTooltipRow = styled('tr', {
37
49
  paddingBottom: theme.spacing(1)
38
50
  }
39
51
  }));
52
+
53
+ /**
54
+ * @ignore - internal component.
55
+ */
40
56
  export const ChartsTooltipCell = styled('td', {
41
57
  name: 'MuiChartsTooltip',
42
58
  slot: 'Cell'
@@ -59,6 +75,10 @@ export const ChartsTooltipCell = styled('td', {
59
75
  paddingRight: theme.spacing(2)
60
76
  }
61
77
  }));
78
+
79
+ /**
80
+ * @ignore - internal component.
81
+ */
62
82
  export const ChartsTooltipMark = styled('div', {
63
83
  name: 'MuiChartsTooltip',
64
84
  slot: 'Mark',
@@ -3,4 +3,5 @@ export * from './chartsTooltipClasses';
3
3
  export * from './ChartsAxisTooltipContent';
4
4
  export * from './ChartsItemTooltipContent';
5
5
  export * from './DefaultChartsAxisTooltipContent';
6
- export * from './DefaultChartsItemTooltipContent';
6
+ export * from './DefaultChartsItemTooltipContent';
7
+ export * from './ChartsTooltipTable';