@mui/x-charts 7.7.0 → 7.8.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 (167) hide show
  1. package/BarChart/BarChart.js +21 -104
  2. package/BarChart/BarElement.d.ts +225 -228
  3. package/BarChart/BarLabel/BarLabel.d.ts +225 -228
  4. package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
  5. package/BarChart/BarLabel/BarLabelPlot.js +1 -24
  6. package/BarChart/BarLabel/getBarLabel.d.ts +1 -1
  7. package/BarChart/BarPlot.js +2 -2
  8. package/BarChart/checkScaleErrors.d.ts +5 -9
  9. package/BarChart/types.d.ts +2 -2
  10. package/BarChart/useBarChartProps.d.ts +34 -0
  11. package/BarChart/useBarChartProps.js +143 -0
  12. package/CHANGELOG.md +181 -0
  13. package/ChartContainer/ChartContainer.d.ts +2 -2
  14. package/ChartContainer/ChartContainer.js +6 -10
  15. package/ChartContainer/useChartContainerHooks.d.ts +11 -0
  16. package/ChartContainer/useChartContainerHooks.js +34 -0
  17. package/ChartContainer/usePluginsMerge.d.ts +1 -2
  18. package/ChartsAxis/ChartsAxis.js +2 -2
  19. package/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  20. package/ChartsGrid/ChartsGrid.js +2 -2
  21. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  22. package/ChartsReferenceLine/common.d.ts +0 -1
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  24. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  25. package/ChartsTooltip/ChartsTooltipTable.d.ts +0 -1
  26. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -4
  27. package/ChartsXAxis/ChartsXAxis.js +2 -2
  28. package/ChartsYAxis/ChartsYAxis.js +5 -3
  29. package/Gauge/GaugeProvider.d.ts +1 -1
  30. package/LineChart/AnimatedArea.d.ts +225 -228
  31. package/LineChart/AnimatedLine.d.ts +225 -228
  32. package/LineChart/AreaPlot.js +2 -2
  33. package/LineChart/LineChart.js +24 -106
  34. package/LineChart/LineHighlightPlot.js +2 -2
  35. package/LineChart/LinePlot.js +2 -2
  36. package/LineChart/MarkPlot.js +2 -2
  37. package/LineChart/useLineChartProps.d.ts +40 -0
  38. package/LineChart/useLineChartProps.js +152 -0
  39. package/PieChart/PieArc.d.ts +0 -1
  40. package/PieChart/PieArcLabel.d.ts +0 -1
  41. package/PieChart/dataTransform/transition.d.ts +0 -1
  42. package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -2
  43. package/ScatterChart/ScatterChart.js +20 -75
  44. package/ScatterChart/ScatterPlot.js +2 -2
  45. package/ScatterChart/useScatterChartProps.d.ts +31 -0
  46. package/ScatterChart/useScatterChartProps.js +116 -0
  47. package/context/CartesianProvider/CartesianContext.d.ts +25 -0
  48. package/context/CartesianProvider/CartesianContext.js +21 -0
  49. package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
  50. package/context/CartesianProvider/CartesianProvider.js +44 -0
  51. package/context/CartesianProvider/computeValue.d.ts +19 -0
  52. package/context/CartesianProvider/computeValue.js +104 -0
  53. package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
  54. package/context/CartesianProvider/getAxisExtremum.js +28 -0
  55. package/context/CartesianProvider/index.d.ts +9 -0
  56. package/context/CartesianProvider/index.js +51 -0
  57. package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
  58. package/context/CartesianProvider/normalizeAxis.js +23 -0
  59. package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
  60. package/context/CartesianProvider/useCartesianContext.js +17 -0
  61. package/context/ColorProvider.d.ts +2 -2
  62. package/esm/BarChart/BarChart.js +21 -104
  63. package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
  64. package/esm/BarChart/BarPlot.js +2 -2
  65. package/esm/BarChart/useBarChartProps.js +135 -0
  66. package/esm/ChartContainer/ChartContainer.js +5 -9
  67. package/esm/ChartContainer/useChartContainerHooks.js +24 -0
  68. package/esm/ChartsAxis/ChartsAxis.js +2 -2
  69. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  70. package/esm/ChartsGrid/ChartsGrid.js +2 -2
  71. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  72. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  73. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  74. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  75. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  76. package/esm/ChartsYAxis/ChartsYAxis.js +5 -3
  77. package/esm/LineChart/AreaPlot.js +2 -2
  78. package/esm/LineChart/LineChart.js +24 -106
  79. package/esm/LineChart/LineHighlightPlot.js +2 -2
  80. package/esm/LineChart/LinePlot.js +2 -2
  81. package/esm/LineChart/MarkPlot.js +2 -2
  82. package/esm/LineChart/useLineChartProps.js +144 -0
  83. package/esm/ScatterChart/ScatterChart.js +20 -75
  84. package/esm/ScatterChart/ScatterPlot.js +2 -2
  85. package/esm/ScatterChart/useScatterChartProps.js +108 -0
  86. package/esm/context/CartesianProvider/CartesianContext.js +13 -0
  87. package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
  88. package/esm/context/CartesianProvider/computeValue.js +97 -0
  89. package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
  90. package/esm/context/CartesianProvider/index.js +10 -0
  91. package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
  92. package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
  93. package/esm/hooks/useAxisEvents.js +7 -10
  94. package/esm/hooks/useColorScale.js +3 -3
  95. package/esm/hooks/useScale.js +4 -5
  96. package/esm/hooks/useTicks.js +2 -1
  97. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  98. package/esm/internals/getSVGPoint.js +11 -0
  99. package/esm/internals/index.js +8 -2
  100. package/esm/internals/utils.js +0 -12
  101. package/hooks/useAxisEvents.js +8 -11
  102. package/hooks/useChartDimensions.d.ts +1 -1
  103. package/hooks/useColor.d.ts +1 -1
  104. package/hooks/useColorScale.js +3 -3
  105. package/hooks/useDrawingArea.d.ts +2 -8
  106. package/hooks/useScale.js +4 -7
  107. package/hooks/useTicks.js +2 -1
  108. package/index.js +1 -1
  109. package/internals/components/AxisSharedComponents.d.ts +0 -1
  110. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
  111. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  112. package/internals/defaultizeColor.d.ts +68 -68
  113. package/internals/getSVGPoint.d.ts +6 -0
  114. package/internals/getSVGPoint.js +17 -0
  115. package/internals/getWordsByLines.d.ts +0 -1
  116. package/internals/index.d.ts +9 -1
  117. package/internals/index.js +69 -5
  118. package/internals/useAnimatedPath.d.ts +0 -1
  119. package/internals/utils.d.ts +0 -6
  120. package/internals/utils.js +0 -13
  121. package/models/axis.d.ts +1 -2
  122. package/models/plugin.d.ts +4 -1
  123. package/modern/BarChart/BarChart.js +21 -104
  124. package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
  125. package/modern/BarChart/BarPlot.js +2 -2
  126. package/modern/BarChart/useBarChartProps.js +135 -0
  127. package/modern/ChartContainer/ChartContainer.js +5 -9
  128. package/modern/ChartContainer/useChartContainerHooks.js +24 -0
  129. package/modern/ChartsAxis/ChartsAxis.js +2 -2
  130. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  131. package/modern/ChartsGrid/ChartsGrid.js +2 -2
  132. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  133. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  134. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  135. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  136. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  137. package/modern/ChartsYAxis/ChartsYAxis.js +5 -3
  138. package/modern/LineChart/AreaPlot.js +2 -2
  139. package/modern/LineChart/LineChart.js +24 -106
  140. package/modern/LineChart/LineHighlightPlot.js +2 -2
  141. package/modern/LineChart/LinePlot.js +2 -2
  142. package/modern/LineChart/MarkPlot.js +2 -2
  143. package/modern/LineChart/useLineChartProps.js +144 -0
  144. package/modern/ScatterChart/ScatterChart.js +20 -75
  145. package/modern/ScatterChart/ScatterPlot.js +2 -2
  146. package/modern/ScatterChart/useScatterChartProps.js +108 -0
  147. package/modern/context/CartesianProvider/CartesianContext.js +13 -0
  148. package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
  149. package/modern/context/CartesianProvider/computeValue.js +97 -0
  150. package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
  151. package/modern/context/CartesianProvider/index.js +10 -0
  152. package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
  153. package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
  154. package/modern/hooks/useAxisEvents.js +7 -10
  155. package/modern/hooks/useColorScale.js +3 -3
  156. package/modern/hooks/useScale.js +4 -5
  157. package/modern/hooks/useTicks.js +2 -1
  158. package/modern/index.js +1 -1
  159. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  160. package/modern/internals/getSVGPoint.js +11 -0
  161. package/modern/internals/index.js +8 -2
  162. package/modern/internals/utils.js +0 -12
  163. package/package.json +3 -3
  164. package/context/CartesianContextProvider.d.ts +0 -61
  165. package/context/CartesianContextProvider.js +0 -220
  166. package/esm/context/CartesianContextProvider.js +0 -211
  167. package/modern/context/CartesianContextProvider.js +0 -211
@@ -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,13 +3,21 @@ 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 { useDrawingArea } from '../hooks/useDrawingArea';
7
+ export { useChartContainerHooks } from '../ChartContainer/useChartContainerHooks';
8
+ export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
9
+ export { useLineChartProps } from '../LineChart/useLineChartProps';
10
+ export { useBarChartProps } from '../BarChart/useBarChartProps';
6
11
  export * from './defaultizeValueFormatter';
7
12
  export * from './configInit';
8
- export * from '../context/CartesianContextProvider';
13
+ export * from './getSVGPoint';
14
+ export * from '../context/CartesianProvider';
9
15
  export * from '../context/DrawingProvider';
16
+ export * from '../context/ColorProvider';
10
17
  export * from '../context/InteractionProvider';
11
18
  export * from '../context/SeriesContextProvider';
12
19
  export * from '../context/ZAxisContextProvider';
20
+ export type * from '../context/context.types';
13
21
  export * from '../models/seriesType/config';
14
22
  export * from '../models/seriesType/common';
15
23
  export * from '../models/helpers';
@@ -5,14 +5,49 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  useReducedMotion: true,
8
- useSeries: true
8
+ useSeries: true,
9
+ useDrawingArea: true,
10
+ useChartContainerHooks: true,
11
+ useScatterChartProps: true,
12
+ useLineChartProps: true,
13
+ useBarChartProps: true
9
14
  };
15
+ Object.defineProperty(exports, "useBarChartProps", {
16
+ enumerable: true,
17
+ get: function () {
18
+ return _useBarChartProps.useBarChartProps;
19
+ }
20
+ });
21
+ Object.defineProperty(exports, "useChartContainerHooks", {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useChartContainerHooks.useChartContainerHooks;
25
+ }
26
+ });
27
+ Object.defineProperty(exports, "useDrawingArea", {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _useDrawingArea.useDrawingArea;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "useLineChartProps", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _useLineChartProps.useLineChartProps;
37
+ }
38
+ });
10
39
  Object.defineProperty(exports, "useReducedMotion", {
11
40
  enumerable: true,
12
41
  get: function () {
13
42
  return _useReducedMotion.useReducedMotion;
14
43
  }
15
44
  });
45
+ Object.defineProperty(exports, "useScatterChartProps", {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _useScatterChartProps.useScatterChartProps;
49
+ }
50
+ });
16
51
  Object.defineProperty(exports, "useSeries", {
17
52
  enumerable: true,
18
53
  get: function () {
@@ -57,6 +92,11 @@ Object.keys(_ResizableContainer).forEach(function (key) {
57
92
  });
58
93
  var _useReducedMotion = require("../hooks/useReducedMotion");
59
94
  var _useSeries = require("../hooks/useSeries");
95
+ var _useDrawingArea = require("../hooks/useDrawingArea");
96
+ var _useChartContainerHooks = require("../ChartContainer/useChartContainerHooks");
97
+ var _useScatterChartProps = require("../ScatterChart/useScatterChartProps");
98
+ var _useLineChartProps = require("../LineChart/useLineChartProps");
99
+ var _useBarChartProps = require("../BarChart/useBarChartProps");
60
100
  var _defaultizeValueFormatter = require("./defaultizeValueFormatter");
61
101
  Object.keys(_defaultizeValueFormatter).forEach(function (key) {
62
102
  if (key === "default" || key === "__esModule") return;
@@ -81,15 +121,27 @@ Object.keys(_configInit).forEach(function (key) {
81
121
  }
82
122
  });
83
123
  });
84
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
85
- Object.keys(_CartesianContextProvider).forEach(function (key) {
124
+ var _getSVGPoint = require("./getSVGPoint");
125
+ Object.keys(_getSVGPoint).forEach(function (key) {
126
+ if (key === "default" || key === "__esModule") return;
127
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
128
+ if (key in exports && exports[key] === _getSVGPoint[key]) return;
129
+ Object.defineProperty(exports, key, {
130
+ enumerable: true,
131
+ get: function () {
132
+ return _getSVGPoint[key];
133
+ }
134
+ });
135
+ });
136
+ var _CartesianProvider = require("../context/CartesianProvider");
137
+ Object.keys(_CartesianProvider).forEach(function (key) {
86
138
  if (key === "default" || key === "__esModule") return;
87
139
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
88
- if (key in exports && exports[key] === _CartesianContextProvider[key]) return;
140
+ if (key in exports && exports[key] === _CartesianProvider[key]) return;
89
141
  Object.defineProperty(exports, key, {
90
142
  enumerable: true,
91
143
  get: function () {
92
- return _CartesianContextProvider[key];
144
+ return _CartesianProvider[key];
93
145
  }
94
146
  });
95
147
  });
@@ -105,6 +157,18 @@ Object.keys(_DrawingProvider).forEach(function (key) {
105
157
  }
106
158
  });
107
159
  });
160
+ var _ColorProvider = require("../context/ColorProvider");
161
+ Object.keys(_ColorProvider).forEach(function (key) {
162
+ if (key === "default" || key === "__esModule") return;
163
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
164
+ if (key in exports && exports[key] === _ColorProvider[key]) return;
165
+ Object.defineProperty(exports, key, {
166
+ enumerable: true,
167
+ get: function () {
168
+ return _ColorProvider[key];
169
+ }
170
+ });
171
+ });
108
172
  var _InteractionProvider = require("../context/InteractionProvider");
109
173
  Object.keys(_InteractionProvider).forEach(function (key) {
110
174
  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: {
@@ -1,4 +1,4 @@
1
- import { ChartSeriesType, ExtremumGetter, Formatter } from './seriesType/config';
1
+ import { CartesianChartSeriesType, ChartSeriesType, ExtremumGetter, Formatter } from './seriesType/config';
2
2
  import { AxisDefaultized } from './axis';
3
3
  import { DefaultizedSeriesType } from './seriesType';
4
4
  import { ZAxisDefaultized } from './z-axis';
@@ -13,4 +13,7 @@ export type ChartsPluginType<T> = T extends ChartSeriesType ? {
13
13
  xExtremumGetter?: ExtremumGetter<T>;
14
14
  yExtremumGetter?: ExtremumGetter<T>;
15
15
  } : never;
16
+ export type ExtremumGettersConfig<T extends ChartSeriesType = CartesianChartSeriesType> = {
17
+ [K in T]?: ExtremumGetter<K>;
18
+ };
16
19
  export {};
@@ -1,11 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import useId from '@mui/utils/useId';
4
3
  import PropTypes from 'prop-types';
5
4
  import { BarPlot } from './BarPlot';
6
5
  import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
7
6
  import { ChartsAxis } from '../ChartsAxis';
8
- import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
9
7
  import { ChartsTooltip } from '../ChartsTooltip';
10
8
  import { ChartsLegend } from '../ChartsLegend';
11
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
@@ -13,6 +11,7 @@ import { ChartsClipPath } from '../ChartsClipPath';
13
11
  import { ChartsGrid } from '../ChartsGrid';
14
12
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
15
13
  import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
14
+ import { useBarChartProps } from './useBarChartProps';
16
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
16
  /**
18
17
  * Demos:
@@ -27,108 +26,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
26
  */
28
27
  const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
29
28
  const {
30
- xAxis,
31
- yAxis,
32
- series,
33
- width,
34
- height,
35
- margin,
36
- colors,
37
- dataset,
38
- sx,
39
- layout,
40
- tooltip,
41
- axisHighlight,
42
- legend,
43
- grid,
44
- topAxis,
45
- leftAxis,
46
- rightAxis,
47
- bottomAxis,
48
- skipAnimation,
49
- borderRadius,
50
- onItemClick,
51
- onAxisClick,
52
- children,
53
- slots,
54
- slotProps,
55
- loading,
56
- barLabel,
57
- highlightedItem,
58
- onHighlightChange
59
- } = props;
60
- const id = useId();
61
- const clipPathId = `${id}-clip-path`;
62
- const hasHorizontalSeries = layout === 'horizontal' || layout === undefined && series.some(item => item.layout === 'horizontal');
63
- const defaultAxisConfig = {
64
- scaleType: 'band',
65
- data: Array.from({
66
- length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
67
- }, (_, index) => index)
68
- };
69
- const defaultizedAxisHighlight = _extends({}, hasHorizontalSeries ? {
70
- y: 'band'
71
- } : {
72
- x: 'band'
73
- }, axisHighlight);
74
- return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
75
- ref: ref,
76
- series: series.map(s => _extends({
77
- type: 'bar'
78
- }, s, {
79
- layout: hasHorizontalSeries ? 'horizontal' : 'vertical'
80
- })),
81
- width: width,
82
- height: height,
83
- margin: margin,
84
- xAxis: xAxis ?? (hasHorizontalSeries ? undefined : [_extends({
85
- id: DEFAULT_X_AXIS_KEY
86
- }, defaultAxisConfig)]),
87
- yAxis: yAxis ?? (hasHorizontalSeries ? [_extends({
88
- id: DEFAULT_Y_AXIS_KEY
89
- }, defaultAxisConfig)] : undefined),
90
- colors: colors,
91
- dataset: dataset,
92
- sx: sx,
93
- disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
94
- highlightedItem: highlightedItem,
95
- onHighlightChange: onHighlightChange,
96
- children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
97
- onAxisClick: onAxisClick
98
- }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
99
- vertical: grid.vertical,
100
- horizontal: grid.horizontal
101
- }), /*#__PURE__*/_jsxs("g", {
102
- clipPath: `url(#${clipPathId})`,
103
- children: [/*#__PURE__*/_jsx(BarPlot, {
104
- slots: slots,
105
- slotProps: slotProps,
106
- skipAnimation: skipAnimation,
107
- onItemClick: onItemClick,
108
- borderRadius: borderRadius,
109
- barLabel: barLabel
110
- }), /*#__PURE__*/_jsx(ChartsOverlay, {
111
- loading: loading,
112
- slots: slots,
113
- slotProps: slotProps
114
- })]
115
- }), /*#__PURE__*/_jsx(ChartsAxis, {
116
- topAxis: topAxis,
117
- leftAxis: leftAxis,
118
- rightAxis: rightAxis,
119
- bottomAxis: bottomAxis,
120
- slots: slots,
121
- slotProps: slotProps
122
- }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
123
- slots: slots,
124
- slotProps: slotProps
125
- })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, defaultizedAxisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
126
- slots: slots,
127
- slotProps: slotProps
128
- })), /*#__PURE__*/_jsx(ChartsClipPath, {
129
- id: clipPathId
130
- }), children]
131
- });
29
+ chartContainerProps,
30
+ barPlotProps,
31
+ axisClickHandlerProps,
32
+ gridProps,
33
+ clipPathProps,
34
+ clipPathGroupProps,
35
+ overlayProps,
36
+ chartsAxisProps,
37
+ axisHighlightProps,
38
+ legendProps,
39
+ tooltipProps,
40
+ children
41
+ } = useBarChartProps(props);
42
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, _extends({
43
+ ref: ref
44
+ }, chartContainerProps, {
45
+ children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
46
+ children: [/*#__PURE__*/_jsx(BarPlot, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps))]
47
+ })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
48
+ }));
132
49
  });
133
50
  process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
134
51
  // ----------------------------- Warning --------------------------------
@@ -2,7 +2,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["bars", "skipAnimation"];
4
4
  import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
5
  import { useTransition } from '@react-spring/web';
7
6
  import { BarLabelItem } from './BarLabelItem';
8
7
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -73,26 +72,4 @@ function BarLabelPlot(props) {
73
72
  })))
74
73
  });
75
74
  }
76
- process.env.NODE_ENV !== "production" ? BarLabelPlot.propTypes = {
77
- // ----------------------------- Warning --------------------------------
78
- // | These PropTypes are generated from the TypeScript type definitions |
79
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
80
- // ----------------------------------------------------------------------
81
- barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
82
- bars: PropTypes.arrayOf(PropTypes.shape({
83
- color: PropTypes.string.isRequired,
84
- dataIndex: PropTypes.number.isRequired,
85
- height: PropTypes.number.isRequired,
86
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
87
- maskId: PropTypes.string.isRequired,
88
- seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
89
- value: PropTypes.number,
90
- width: PropTypes.number.isRequired,
91
- x: PropTypes.number.isRequired,
92
- xOrigin: PropTypes.number.isRequired,
93
- y: PropTypes.number.isRequired,
94
- yOrigin: PropTypes.number.isRequired
95
- })).isRequired,
96
- skipAnimation: PropTypes.bool
97
- } : void 0;
98
75
  export { BarLabelPlot };
@@ -4,7 +4,7 @@ const _excluded = ["skipAnimation", "onItemClick", "borderRadius", "barLabel"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useTransition } from '@react-spring/web';
7
- import { CartesianContext } from '../context/CartesianContextProvider';
7
+ import { useCartesianContext } from '../context/CartesianProvider';
8
8
  import { BarElement } from './BarElement';
9
9
  import getColor from './getColor';
10
10
  import { useChartId } from '../hooks';
@@ -47,7 +47,7 @@ const useAggregatedData = () => {
47
47
  stackingGroups: [],
48
48
  seriesOrder: []
49
49
  };
50
- const axisData = React.useContext(CartesianContext);
50
+ const axisData = useCartesianContext();
51
51
  const chartId = useChartId();
52
52
  const {
53
53
  series,