@mui/x-charts 8.3.1 → 8.5.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 (204) hide show
  1. package/BarChart/BarChart.d.ts +9 -2
  2. package/BarChart/BarChart.js +11 -3
  3. package/BarChart/useBarChartProps.js +1 -1
  4. package/CHANGELOG.md +213 -0
  5. package/ChartContainer/ChartContainer.d.ts +21 -2
  6. package/ChartContainer/ChartContainer.js +17 -1
  7. package/ChartContainer/useChartContainerProps.js +7 -3
  8. package/ChartDataProvider/ChartDataProvider.d.ts +11 -1
  9. package/ChartDataProvider/ChartDataProvider.js +19 -2
  10. package/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
  11. package/ChartDataProvider/useChartDataProviderProps.js +7 -3
  12. package/ChartsAxis/axisClasses.d.ts +5 -0
  13. package/ChartsAxis/axisClasses.js +1 -1
  14. package/ChartsLegend/ChartsLegend.js +1 -0
  15. package/ChartsLocalizationProvider/ChartsLocalizationProvider.js +1 -3
  16. package/ChartsSurface/ChartsSurface.js +1 -0
  17. package/ChartsXAxis/ChartsXAxis.js +7 -16
  18. package/ChartsYAxis/ChartsYAxis.js +4 -8
  19. package/Gauge/Gauge.js +1 -0
  20. package/Gauge/GaugeContainer.js +1 -0
  21. package/Gauge/GaugeProvider.js +1 -3
  22. package/LineChart/AnimatedLine.js +1 -0
  23. package/LineChart/LineChart.d.ts +9 -2
  24. package/LineChart/LineChart.js +11 -3
  25. package/LineChart/LineHighlightPlot.js +1 -4
  26. package/LineChart/MarkPlot.js +1 -4
  27. package/LineChart/useLineChartProps.js +1 -1
  28. package/PieChart/PieArc.js +1 -0
  29. package/PieChart/PieArcLabel.js +1 -0
  30. package/PieChart/PieChart.d.ts +10 -3
  31. package/PieChart/PieChart.js +18 -9
  32. package/RadarChart/RadarChart.d.ts +21 -3
  33. package/RadarChart/RadarChart.js +20 -4
  34. package/RadarChart/RadarChart.plugins.d.ts +5 -0
  35. package/RadarChart/RadarChart.plugins.js +10 -0
  36. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
  37. package/RadarChart/RadarDataProvider/RadarDataProvider.js +6 -116
  38. package/RadarChart/index.d.ts +2 -0
  39. package/RadarChart/index.js +15 -1
  40. package/RadarChart/useRadarChartProps.d.ts +2 -1
  41. package/RadarChart/useRadarChartProps.js +3 -1
  42. package/ScatterChart/Scatter.js +3 -11
  43. package/ScatterChart/ScatterChart.d.ts +9 -2
  44. package/ScatterChart/ScatterChart.js +13 -5
  45. package/ScatterChart/useScatterChartProps.js +4 -2
  46. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  47. package/SparkLineChart/SparkLineChart.js +31 -26
  48. package/Toolbar/Toolbar.d.ts +9 -3
  49. package/Toolbar/Toolbar.js +23 -7
  50. package/Toolbar/Toolbar.types.d.ts +15 -0
  51. package/Toolbar/Toolbar.types.js +5 -0
  52. package/Toolbar/ToolbarButton.d.ts +8 -2
  53. package/Toolbar/ToolbarButton.js +25 -6
  54. package/Toolbar/chartToolbarClasses.d.ts +6 -0
  55. package/Toolbar/chartToolbarClasses.js +9 -0
  56. package/Toolbar/index.d.ts +3 -1
  57. package/Toolbar/index.js +22 -0
  58. package/Toolbar/internals/ChartsToolbar.d.ts +6 -0
  59. package/Toolbar/internals/ChartsToolbar.js +14 -0
  60. package/context/ChartProvider/ChartContext.js +1 -3
  61. package/context/ChartsSlotsContext.d.ts +20 -0
  62. package/context/ChartsSlotsContext.js +44 -0
  63. package/context/index.d.ts +2 -1
  64. package/context/index.js +11 -0
  65. package/context/useChartApiContext.d.ts +10 -0
  66. package/context/useChartApiContext.js +27 -0
  67. package/esm/BarChart/BarChart.d.ts +9 -2
  68. package/esm/BarChart/BarChart.js +11 -3
  69. package/esm/BarChart/useBarChartProps.js +1 -1
  70. package/esm/ChartContainer/ChartContainer.d.ts +21 -2
  71. package/esm/ChartContainer/ChartContainer.js +17 -1
  72. package/esm/ChartContainer/useChartContainerProps.js +7 -3
  73. package/esm/ChartDataProvider/ChartDataProvider.d.ts +11 -1
  74. package/esm/ChartDataProvider/ChartDataProvider.js +19 -2
  75. package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
  76. package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -3
  77. package/esm/ChartsAxis/axisClasses.d.ts +5 -0
  78. package/esm/ChartsAxis/axisClasses.js +1 -1
  79. package/esm/ChartsLegend/ChartsLegend.js +1 -0
  80. package/esm/ChartsLocalizationProvider/ChartsLocalizationProvider.js +1 -3
  81. package/esm/ChartsSurface/ChartsSurface.js +1 -0
  82. package/esm/ChartsXAxis/ChartsXAxis.js +7 -16
  83. package/esm/ChartsYAxis/ChartsYAxis.js +4 -8
  84. package/esm/Gauge/Gauge.js +1 -0
  85. package/esm/Gauge/GaugeContainer.js +1 -0
  86. package/esm/Gauge/GaugeProvider.js +1 -3
  87. package/esm/LineChart/AnimatedLine.js +1 -0
  88. package/esm/LineChart/LineChart.d.ts +9 -2
  89. package/esm/LineChart/LineChart.js +11 -3
  90. package/esm/LineChart/LineHighlightPlot.js +1 -4
  91. package/esm/LineChart/MarkPlot.js +1 -4
  92. package/esm/LineChart/useLineChartProps.js +1 -1
  93. package/esm/PieChart/PieArc.js +1 -0
  94. package/esm/PieChart/PieArcLabel.js +1 -0
  95. package/esm/PieChart/PieChart.d.ts +10 -3
  96. package/esm/PieChart/PieChart.js +16 -7
  97. package/esm/RadarChart/RadarChart.d.ts +21 -3
  98. package/esm/RadarChart/RadarChart.js +20 -4
  99. package/esm/RadarChart/RadarChart.plugins.d.ts +5 -0
  100. package/esm/RadarChart/RadarChart.plugins.js +4 -0
  101. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
  102. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.js +5 -115
  103. package/esm/RadarChart/index.d.ts +2 -0
  104. package/esm/RadarChart/index.js +2 -0
  105. package/esm/RadarChart/useRadarChartProps.d.ts +2 -1
  106. package/esm/RadarChart/useRadarChartProps.js +3 -1
  107. package/esm/ScatterChart/Scatter.js +3 -11
  108. package/esm/ScatterChart/ScatterChart.d.ts +9 -2
  109. package/esm/ScatterChart/ScatterChart.js +13 -5
  110. package/esm/ScatterChart/useScatterChartProps.js +4 -2
  111. package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
  112. package/esm/SparkLineChart/SparkLineChart.js +31 -26
  113. package/esm/Toolbar/Toolbar.d.ts +9 -3
  114. package/esm/Toolbar/Toolbar.js +22 -7
  115. package/esm/Toolbar/Toolbar.types.d.ts +15 -0
  116. package/esm/Toolbar/Toolbar.types.js +1 -0
  117. package/esm/Toolbar/ToolbarButton.d.ts +8 -2
  118. package/esm/Toolbar/ToolbarButton.js +24 -5
  119. package/esm/Toolbar/chartToolbarClasses.d.ts +6 -0
  120. package/esm/Toolbar/chartToolbarClasses.js +2 -0
  121. package/esm/Toolbar/index.d.ts +3 -1
  122. package/esm/Toolbar/index.js +3 -1
  123. package/esm/Toolbar/internals/ChartsToolbar.d.ts +6 -0
  124. package/esm/Toolbar/internals/ChartsToolbar.js +8 -0
  125. package/esm/context/ChartProvider/ChartContext.js +1 -3
  126. package/esm/context/ChartsSlotsContext.d.ts +20 -0
  127. package/esm/context/ChartsSlotsContext.js +35 -0
  128. package/esm/context/index.d.ts +2 -1
  129. package/esm/context/index.js +1 -0
  130. package/esm/context/useChartApiContext.d.ts +10 -0
  131. package/esm/context/useChartApiContext.js +21 -0
  132. package/esm/hooks/index.d.ts +1 -0
  133. package/esm/hooks/index.js +1 -0
  134. package/esm/hooks/useTicks.js +2 -6
  135. package/esm/index.js +1 -1
  136. package/esm/internals/constants.d.ts +3 -1
  137. package/esm/internals/constants.js +2 -1
  138. package/esm/internals/consumeSlots.js +2 -1
  139. package/esm/internals/consumeThemeProps.js +3 -1
  140. package/esm/internals/dateHelpers.d.ts +15 -0
  141. package/esm/internals/dateHelpers.js +20 -0
  142. package/esm/internals/domUtils.d.ts +1 -2
  143. package/esm/internals/domUtils.js +8 -19
  144. package/esm/internals/index.d.ts +4 -1
  145. package/esm/internals/index.js +4 -1
  146. package/esm/internals/material/index.d.ts +2 -0
  147. package/esm/internals/plugins/allPlugins.d.ts +1 -0
  148. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +11 -17
  149. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +16 -13
  150. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +2 -8
  151. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -3
  152. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
  153. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
  154. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +4 -5
  155. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +1 -3
  156. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
  157. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +83 -0
  158. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -1
  159. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +17 -0
  160. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
  161. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
  162. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -8
  163. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -3
  164. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +2 -5
  165. package/esm/models/index.d.ts +2 -2
  166. package/esm/models/index.js +1 -0
  167. package/esm/models/slots/chartsBaseSlotProps.d.ts +1 -0
  168. package/hooks/index.d.ts +1 -0
  169. package/hooks/index.js +12 -0
  170. package/hooks/useTicks.js +2 -6
  171. package/index.js +1 -1
  172. package/internals/constants.d.ts +3 -1
  173. package/internals/constants.js +3 -2
  174. package/internals/consumeSlots.js +2 -1
  175. package/internals/consumeThemeProps.js +3 -1
  176. package/internals/dateHelpers.d.ts +15 -0
  177. package/internals/dateHelpers.js +28 -0
  178. package/internals/domUtils.d.ts +1 -2
  179. package/internals/domUtils.js +8 -20
  180. package/internals/index.d.ts +4 -1
  181. package/internals/index.js +44 -8
  182. package/internals/material/index.d.ts +2 -0
  183. package/internals/plugins/allPlugins.d.ts +1 -0
  184. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +11 -17
  185. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +16 -13
  186. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -11
  187. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +7 -8
  188. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
  189. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +6 -3
  190. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +4 -5
  191. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +1 -3
  192. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
  193. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +83 -0
  194. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -2
  195. package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +17 -0
  196. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
  197. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
  198. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +5 -11
  199. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -3
  200. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +2 -5
  201. package/models/index.d.ts +2 -2
  202. package/models/index.js +11 -0
  203. package/models/slots/chartsBaseSlotProps.d.ts +1 -0
  204. package/package.json +3 -3
@@ -9,7 +9,8 @@ import useId from '@mui/utils/useId';
9
9
  import { ChartsClipPath } from "../ChartsClipPath/index.js";
10
10
  import { BarPlot } from "../BarChart/index.js";
11
11
  import { LinePlot, AreaPlot, LineHighlightPlot } from "../LineChart/index.js";
12
- import { ChartContainer } from "../ChartContainer/index.js";
12
+ import { ChartDataProvider } from "../ChartDataProvider/index.js";
13
+ import { ChartsSurface } from "../ChartsSurface/index.js";
13
14
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../constants/index.js";
14
15
  import { ChartsTooltip } from "../ChartsTooltip/index.js";
15
16
  import { ChartsAxisHighlight } from "../ChartsAxisHighlight/index.js";
@@ -71,8 +72,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
71
72
  }
72
73
  return typeof color === 'function' ? mode => [color(mode)] : [color];
73
74
  }, [color]);
74
- return /*#__PURE__*/_jsxs(ChartContainer, _extends({}, other, {
75
- ref: ref,
75
+ return /*#__PURE__*/_jsxs(ChartDataProvider, {
76
76
  series: [_extends({
77
77
  type: plotType,
78
78
  data,
@@ -85,7 +85,6 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
85
85
  width: width,
86
86
  height: height,
87
87
  margin: margin,
88
- className: className,
89
88
  xAxis: [_extends({
90
89
  id: DEFAULT_X_AXIS_KEY,
91
90
  scaleType: plotType === 'bar' ? 'band' : 'point',
@@ -102,34 +101,40 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
102
101
  position: 'none'
103
102
  })],
104
103
  colors: colors,
105
- sx: sx,
106
104
  disableAxisListener: (!showTooltip || slotProps?.tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
107
- children: [/*#__PURE__*/_jsxs("g", {
108
- clipPath: `url(#${clipPathId})`,
109
- children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
110
- skipAnimation: true,
111
- slots: slots,
112
- slotProps: slotProps
113
- }), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
114
- children: [/*#__PURE__*/_jsx(AreaPlot, {
115
- skipAnimation: true,
116
- slots: slots,
117
- slotProps: slotProps
118
- }), /*#__PURE__*/_jsx(LinePlot, {
105
+ children: [/*#__PURE__*/_jsxs(ChartsSurface, _extends({
106
+ className: className,
107
+ ref: ref,
108
+ sx: sx
109
+ }, other, {
110
+ children: [/*#__PURE__*/_jsxs("g", {
111
+ clipPath: `url(#${clipPathId})`,
112
+ children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
119
113
  skipAnimation: true,
120
114
  slots: slots,
121
115
  slotProps: slotProps
116
+ }), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
117
+ children: [/*#__PURE__*/_jsx(AreaPlot, {
118
+ skipAnimation: true,
119
+ slots: slots,
120
+ slotProps: slotProps
121
+ }), /*#__PURE__*/_jsx(LinePlot, {
122
+ skipAnimation: true,
123
+ slots: slots,
124
+ slotProps: slotProps
125
+ })]
122
126
  })]
123
- })]
124
- }), plotType === 'line' && /*#__PURE__*/_jsx(LineHighlightPlot, {
125
- slots: slots,
126
- slotProps: slotProps
127
- }), disableClipping ? null : /*#__PURE__*/_jsx(ChartsClipPath, {
128
- id: clipPathId,
129
- offset: clipPathOffset
130
- }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), children]
131
- }));
127
+ }), plotType === 'line' && /*#__PURE__*/_jsx(LineHighlightPlot, {
128
+ slots: slots,
129
+ slotProps: slotProps
130
+ }), disableClipping ? null : /*#__PURE__*/_jsx(ChartsClipPath, {
131
+ id: clipPathId,
132
+ offset: clipPathOffset
133
+ }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), children]
134
+ })), showTooltip && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
135
+ });
132
136
  });
137
+ if (process.env.NODE_ENV !== "production") SparkLineChart.displayName = "SparkLineChart";
133
138
  process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
134
139
  // ----------------------------- Warning --------------------------------
135
140
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -1,5 +1,11 @@
1
1
  import * as React from 'react';
2
- export interface ToolbarProps extends React.PropsWithChildren {}
2
+ export interface ChartsToolbarProps extends React.ComponentProps<'div'> {
3
+ className?: string;
4
+ }
3
5
  export declare function Toolbar({
4
- children
5
- }: ToolbarProps): React.JSX.Element;
6
+ className,
7
+ ...other
8
+ }: ChartsToolbarProps): React.JSX.Element;
9
+ export declare namespace Toolbar {
10
+ var propTypes: any;
11
+ }
@@ -1,5 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["className"];
1
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
2
6
  import { styled } from '@mui/material/styles';
7
+ import clsx from 'clsx';
8
+ import { chartsToolbarClasses } from "./chartToolbarClasses.js";
3
9
  import { jsx as _jsx } from "react/jsx-runtime";
4
10
  const ToolbarRoot = styled('div', {
5
11
  name: 'MuiChartsToolbar',
@@ -18,10 +24,19 @@ const ToolbarRoot = styled('div', {
18
24
  border: `1px solid ${(theme.vars || theme).palette.divider}`,
19
25
  borderRadius: 4
20
26
  }));
21
- export function Toolbar({
22
- children
23
- }) {
24
- return /*#__PURE__*/_jsx(ToolbarRoot, {
25
- children: children
26
- });
27
- }
27
+ export function Toolbar(_ref) {
28
+ let {
29
+ className
30
+ } = _ref,
31
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
32
+ return /*#__PURE__*/_jsx(ToolbarRoot, _extends({
33
+ className: clsx(chartsToolbarClasses.root, className)
34
+ }, other));
35
+ }
36
+ process.env.NODE_ENV !== "production" ? Toolbar.propTypes = {
37
+ // ----------------------------- Warning --------------------------------
38
+ // | These PropTypes are generated from the TypeScript type definitions |
39
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
40
+ // ----------------------------------------------------------------------
41
+ className: PropTypes.string
42
+ } : void 0;
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { ChartsToolbarProps } from "./Toolbar.js";
3
+ export interface ChartsToolbarSlots {
4
+ /**
5
+ * Custom component for the toolbar.
6
+ * @default ChartsToolbar
7
+ */
8
+ toolbar?: React.ElementType<ChartsToolbarProps>;
9
+ }
10
+ export interface ChartsToolbarSlotProps {
11
+ /**
12
+ * Props for the toolbar component.
13
+ */
14
+ toolbar?: Partial<ChartsToolbarProps>;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,11 @@
1
1
  import * as React from 'react';
2
- import { ChartBaseIconButtonProps } from "../models/slots/chartsBaseSlotProps.js";
3
- export interface ToolbarButtonProps extends ChartBaseIconButtonProps {}
2
+ import { RenderProp } from '@mui/x-internals/useComponentRenderer';
3
+ import { ChartsSlotProps } from "../internals/material/index.js";
4
+ export type ToolbarButtonProps = ChartsSlotProps['baseIconButton'] & {
5
+ /**
6
+ * A function to customize the rendering of the component.
7
+ */
8
+ render?: RenderProp<ChartsSlotProps['baseIconButton']>;
9
+ };
4
10
  declare const ToolbarButton: React.ForwardRefExoticComponent<Omit<ToolbarButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
5
11
  export { ToolbarButton };
@@ -1,20 +1,39 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["render"];
2
4
  import PropTypes from 'prop-types';
3
5
  import * as React from 'react';
4
- import { defaultSlotsMaterial } from "../internals/material/index.js";
6
+ import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
7
+ import { useChartsSlots } from "../context/ChartsSlotsContext.js";
5
8
  import { jsx as _jsx } from "react/jsx-runtime";
6
9
  const ToolbarButton = /*#__PURE__*/React.forwardRef(function ToolbarButton(props, ref) {
7
- const IconButton = defaultSlotsMaterial.baseIconButton;
8
- return /*#__PURE__*/_jsx(IconButton, _extends({
9
- ref: ref
10
- }, props));
10
+ const {
11
+ render
12
+ } = props,
13
+ other = _objectWithoutPropertiesLoose(props, _excluded);
14
+ const {
15
+ slots,
16
+ slotProps
17
+ } = useChartsSlots();
18
+ const element = useComponentRenderer(slots.baseIconButton, render, _extends({}, slotProps?.baseIconButton, other, {
19
+ ref
20
+ }));
21
+ return /*#__PURE__*/_jsx(React.Fragment, {
22
+ children: element
23
+ });
11
24
  });
25
+ if (process.env.NODE_ENV !== "production") ToolbarButton.displayName = "ToolbarButton";
12
26
  process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
13
27
  // ----------------------------- Warning --------------------------------
14
28
  // | These PropTypes are generated from the TypeScript type definitions |
15
29
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
16
30
  // ----------------------------------------------------------------------
17
31
  className: PropTypes.string,
32
+ disabled: PropTypes.bool,
33
+ /**
34
+ * A function to customize the rendering of the component.
35
+ */
36
+ render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
18
37
  style: PropTypes.object
19
38
  } : void 0;
20
39
  export { ToolbarButton };
@@ -0,0 +1,6 @@
1
+ export interface ChartsToolbarClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ }
5
+ export type ChartsToolbarClassKey = keyof ChartsToolbarClasses;
6
+ export declare const chartsToolbarClasses: ChartsToolbarClasses;
@@ -0,0 +1,2 @@
1
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
2
+ export const chartsToolbarClasses = generateUtilityClasses('MuiChartsToolbar', ['root']);
@@ -1,2 +1,4 @@
1
1
  export * from "./Toolbar.js";
2
- export * from "./ToolbarButton.js";
2
+ export * from "./ToolbarButton.js";
3
+ export * from "./Toolbar.types.js";
4
+ export * from "./chartToolbarClasses.js";
@@ -1,2 +1,4 @@
1
1
  export * from "./Toolbar.js";
2
- export * from "./ToolbarButton.js";
2
+ export * from "./ToolbarButton.js";
3
+ export * from "./Toolbar.types.js";
4
+ export * from "./chartToolbarClasses.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The chart toolbar component.
3
+ *
4
+ * In the community package, this component is empty and does not render anything.
5
+ */
6
+ export declare function ChartsToolbar(): null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The chart toolbar component.
3
+ *
4
+ * In the community package, this component is empty and does not render anything.
5
+ */
6
+ export function ChartsToolbar() {
7
+ return null;
8
+ }
@@ -3,6 +3,4 @@ import * as React from 'react';
3
3
  * @ignore - internal component.
4
4
  */
5
5
  export const ChartContext = /*#__PURE__*/React.createContext(null);
6
- if (process.env.NODE_ENV !== 'production') {
7
- ChartContext.displayName = 'ChartContext';
8
- }
6
+ if (process.env.NODE_ENV !== "production") ChartContext.displayName = "ChartContext";
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
3
+ type SlotProps<T extends Record<keyof T, React.ComponentType<any>>> = { [key in keyof T]: React.ComponentProps<T[key]> };
4
+ export interface ChartsSlotsContextValue<T extends ChartsSlots & Record<keyof T, React.ComponentType<any>> = ChartsSlots> {
5
+ slots: T;
6
+ slotProps: Partial<SlotProps<T>>;
7
+ }
8
+ export declare const ChartsSlotsContext: React.Context<ChartsSlotsContextValue<ChartsSlots> | null>;
9
+ /**
10
+ * Get the slots and slotProps from the nearest `ChartDataProvider` or `ChartDataProviderPro`.
11
+ * @returns {ChartsSlotsContextValue} The slots and slotProps from the context.
12
+ */
13
+ export declare function useChartsSlots<T extends ChartsSlots & Record<keyof T, React.ComponentType<any>> = ChartsSlots>(): ChartsSlotsContextValue<T>;
14
+ interface ChartsSlotsProviderProps {
15
+ slots?: Partial<ChartsSlots>;
16
+ slotProps?: Partial<ChartsSlotProps>;
17
+ defaultSlots: ChartsSlots;
18
+ }
19
+ export declare function ChartsSlotsProvider(props: React.PropsWithChildren<ChartsSlotsProviderProps>): React.JSX.Element;
20
+ export {};
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export const ChartsSlotsContext = /*#__PURE__*/React.createContext(null);
7
+
8
+ /**
9
+ * Get the slots and slotProps from the nearest `ChartDataProvider` or `ChartDataProviderPro`.
10
+ * @returns {ChartsSlotsContextValue} The slots and slotProps from the context.
11
+ */
12
+ if (process.env.NODE_ENV !== "production") ChartsSlotsContext.displayName = "ChartsSlotsContext";
13
+ export function useChartsSlots() {
14
+ const context = React.useContext(ChartsSlotsContext);
15
+ if (context == null) {
16
+ throw new Error(['MUI X Charts: Could not find the Charts Slots context.', 'It looks like you rendered your component outside of a ChartDataProvider.', 'This can also happen if you are bundling multiple versions of the library.'].join('\n'));
17
+ }
18
+ return context;
19
+ }
20
+ export function ChartsSlotsProvider(props) {
21
+ const {
22
+ slots,
23
+ slotProps = {},
24
+ defaultSlots,
25
+ children
26
+ } = props;
27
+ const value = React.useMemo(() => ({
28
+ slots: _extends({}, defaultSlots, slots),
29
+ slotProps
30
+ }), [defaultSlots, slots, slotProps]);
31
+ return /*#__PURE__*/_jsx(ChartsSlotsContext.Provider, {
32
+ value: value,
33
+ children: children
34
+ });
35
+ }
@@ -1 +1,2 @@
1
- export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
1
+ export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
2
+ export * from "./useChartApiContext.js";
@@ -1 +1,2 @@
1
+ export * from "./useChartApiContext.js";
1
2
  export {};
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ChartApi } from "../ChartContainer/index.js";
3
+ /**
4
+ * The `useChartApiContext` hook provides access to the chart API.
5
+ * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
6
+ * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
7
+ * @example
8
+ * const apiRef = useChartApiContext<ChartApi<'bar'>>();
9
+ */
10
+ export declare function useChartApiContext<Api extends ChartApi>(): React.RefObject<Api>;
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { useChartContext } from "./ChartProvider/index.js";
5
+ /**
6
+ * The `useChartApiContext` hook provides access to the chart API.
7
+ * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
8
+ * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
9
+ * @example
10
+ * const apiRef = useChartApiContext<ChartApi<'bar'>>();
11
+ */
12
+ export function useChartApiContext() {
13
+ const {
14
+ publicAPI
15
+ } = useChartContext();
16
+ const apiRef = React.useRef(publicAPI);
17
+ React.useEffect(() => {
18
+ apiRef.current = publicAPI;
19
+ }, [publicAPI]);
20
+ return apiRef;
21
+ }
@@ -10,6 +10,7 @@ export * from "./useScatterSeries.js";
10
10
  export * from "./usePieSeries.js";
11
11
  export * from "./useBarSeries.js";
12
12
  export * from "./useLineSeries.js";
13
+ export * from "./useRadarSeries.js";
13
14
  export * from "./useItemHighlighted.js";
14
15
  export * from "./useItemHighlightedGetter.js";
15
16
  export * from "./useLegend.js";
@@ -10,6 +10,7 @@ export * from "./useScatterSeries.js";
10
10
  export * from "./usePieSeries.js";
11
11
  export * from "./useBarSeries.js";
12
12
  export * from "./useLineSeries.js";
13
+ export * from "./useRadarSeries.js";
13
14
  export * from "./useItemHighlighted.js";
14
15
  export * from "./useItemHighlightedGetter.js";
15
16
  export * from "./useLegend.js";
@@ -72,12 +72,8 @@ export function useTicks(options) {
72
72
  for (let i = 0; i < ticks.length; i += 1) {
73
73
  const value = ticks[i];
74
74
  const offset = scale(value);
75
- if (instance.isPointInside({
76
- x: offset,
77
- y: offset
78
- }, {
79
- direction
80
- })) {
75
+ const isInside = direction === 'x' ? instance.isXInside(offset) : instance.isYInside(offset);
76
+ if (isInside) {
81
77
  visibleTicks.push({
82
78
  value,
83
79
  formattedValue: valueFormatter?.(value, {
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.3.1
2
+ * @mui/x-charts v8.5.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,4 +1,6 @@
1
+ import type { ZoomSliderShowTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/zoom.types.js";
1
2
  /** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
2
3
  export declare const ZOOM_SLIDER_MARGIN = 4;
3
4
  /** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
4
- export declare const ZOOM_SLIDER_SIZE: number;
5
+ export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
6
+ export declare const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP: ZoomSliderShowTooltip;
@@ -2,4 +2,5 @@
2
2
  export const ZOOM_SLIDER_MARGIN = 4;
3
3
 
4
4
  /** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
5
- export const ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
5
+ export const DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
6
+ export const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = 'hover';
@@ -94,4 +94,5 @@ export const consumeSlots = (name, slotPropName, options, InComponent) => {
94
94
  }));
95
95
  }
96
96
  return /*#__PURE__*/React.forwardRef(ConsumeSlotsInternal);
97
- };
97
+ };
98
+ if (process.env.NODE_ENV !== "production") consumeSlots.displayName = "consumeSlots";
@@ -60,6 +60,7 @@ export const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/Re
60
60
  const theme = useTheme();
61
61
  const classes = options.classesResolver?.(outProps, theme);
62
62
  const OutComponent = /*#__PURE__*/React.forwardRef(InComponent);
63
+ if (process.env.NODE_ENV !== "production") OutComponent.displayName = "OutComponent";
63
64
  if (process.env.NODE_ENV !== 'production') {
64
65
  OutComponent.displayName = `consumeThemeProps(${name})`;
65
66
  }
@@ -67,4 +68,5 @@ export const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/Re
67
68
  classes: classes,
68
69
  ref: ref
69
70
  }));
70
- });
71
+ });
72
+ if (process.env.NODE_ENV !== "production") consumeThemeProps.displayName = "consumeThemeProps";
@@ -0,0 +1,15 @@
1
+ import { AxisConfig } from "../models/index.js";
2
+ import { ChartsAxisProps } from "../models/axis.js";
3
+ /**
4
+ * Checks if the provided data array contains Date objects.
5
+ * @param data The data array to check.
6
+ * @returns A type predicate indicating if the data is an array of Date objects.
7
+ */
8
+ export declare const isDateData: (data?: readonly any[]) => data is Date[];
9
+ /**
10
+ * Creates a formatter function for date values.
11
+ * @param axis The axis configuration.
12
+ * @param range The range for the time scale.
13
+ * @returns A formatter function for date values.
14
+ */
15
+ export declare function createDateFormatter(axis: AxisConfig<'band' | 'point', any, ChartsAxisProps>, range: number[]): AxisConfig<'band' | 'point', any, ChartsAxisProps>['valueFormatter'];
@@ -0,0 +1,20 @@
1
+ import { scaleTime } from '@mui/x-charts-vendor/d3-scale';
2
+ /**
3
+ * Checks if the provided data array contains Date objects.
4
+ * @param data The data array to check.
5
+ * @returns A type predicate indicating if the data is an array of Date objects.
6
+ */
7
+ export const isDateData = data => data?.[0] instanceof Date;
8
+
9
+ /**
10
+ * Creates a formatter function for date values.
11
+ * @param axis The axis configuration.
12
+ * @param range The range for the time scale.
13
+ * @returns A formatter function for date values.
14
+ */
15
+ export function createDateFormatter(axis, range) {
16
+ const timeScale = scaleTime(axis.data, range);
17
+ return (v, {
18
+ location
19
+ }) => location === 'tick' ? timeScale.tickFormat(axis.tickNumber)(v) : `${v.toLocaleString()}`;
20
+ }
@@ -14,5 +14,4 @@ export declare const getStyleString: (style: React.CSSProperties) => string;
14
14
  export declare const getStringSize: (text: string | number, style?: React.CSSProperties) => {
15
15
  width: number;
16
16
  height: number;
17
- };
18
- export declare function unstable_cleanupDOM(): void;
17
+ };
@@ -5,10 +5,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  function isSsr() {
6
6
  return typeof window === 'undefined';
7
7
  }
8
- const stringCache = {
9
- widthCache: {},
10
- cacheCount: 0
11
- };
8
+ const stringCache = new Map();
12
9
  const MAX_CACHE_NUM = 2000;
13
10
  const SPAN_STYLE = {
14
11
  position: 'absolute',
@@ -75,8 +72,9 @@ export const getStringSize = (text, style = {}) => {
75
72
  const str = `${text}`;
76
73
  const styleString = getStyleString(style);
77
74
  const cacheKey = `${str}-${styleString}`;
78
- if (stringCache.widthCache[cacheKey]) {
79
- return stringCache.widthCache[cacheKey];
75
+ const size = stringCache.get(cacheKey);
76
+ if (size) {
77
+ return size;
80
78
  }
81
79
  try {
82
80
  let measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
@@ -99,12 +97,9 @@ export const getStringSize = (text, style = {}) => {
99
97
  width: rect.width,
100
98
  height: rect.height
101
99
  };
102
- stringCache.widthCache[cacheKey] = result;
103
- if (stringCache.cacheCount + 1 > MAX_CACHE_NUM) {
104
- stringCache.cacheCount = 0;
105
- stringCache.widthCache = {};
106
- } else {
107
- stringCache.cacheCount += 1;
100
+ stringCache.set(cacheKey, result);
101
+ if (stringCache.size + 1 > MAX_CACHE_NUM) {
102
+ stringCache.clear();
108
103
  }
109
104
  if (process.env.NODE_ENV === 'test') {
110
105
  // In test environment, we clean the measurement span immediately
@@ -125,10 +120,4 @@ export const getStringSize = (text, style = {}) => {
125
120
  height: 0
126
121
  };
127
122
  }
128
- };
129
-
130
- // eslint-disable-next-line @typescript-eslint/naming-convention
131
- export function unstable_cleanupDOM() {
132
- // const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
133
- // measurementSpan?.remove();
134
- }
123
+ };
@@ -7,6 +7,7 @@ export { useDrawingArea } from "../hooks/useDrawingArea.js";
7
7
  export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
8
8
  export { useLineChartProps } from "../LineChart/useLineChartProps.js";
9
9
  export { useBarChartProps } from "../BarChart/useBarChartProps.js";
10
+ export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
10
11
  export * from "../ChartContainer/useChartContainerProps.js";
11
12
  export * from "../ChartDataProvider/useChartDataProviderProps.js";
12
13
  export * from "./createSeriesSelectorOfType.js";
@@ -26,20 +27,22 @@ export * from "./store/useSelector.js";
26
27
  export * from "../BarChart/BarChart.plugins.js";
27
28
  export * from "../LineChart/LineChart.plugins.js";
28
29
  export * from "../ScatterChart/ScatterChart.plugins.js";
30
+ export * from "../RadarChart/RadarChart.plugins.js";
29
31
  export * from "./defaultizeValueFormatter.js";
30
32
  export * from "./configInit.js";
31
33
  export * from "./getLabel.js";
32
34
  export * from "./getSVGPoint.js";
33
35
  export * from "./isDefined.js";
34
- export { unstable_cleanupDOM } from "./domUtils.js";
35
36
  export * from "./getScale.js";
36
37
  export * from "./stackSeries.js";
37
38
  export * from "./getCurve.js";
38
39
  export * from "./consumeSlots.js";
39
40
  export * from "./consumeThemeProps.js";
40
41
  export * from "./defaultizeMargin.js";
42
+ export * from "./dateHelpers.js";
41
43
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
42
44
  export * from "../context/ChartProvider/index.js";
45
+ export * from "../context/ChartsSlotsContext.js";
43
46
  export * from "../models/seriesType/config.js";
44
47
  export * from "../models/seriesType/common.js";
45
48
  export * from "../models/z-axis.js";
@@ -10,6 +10,7 @@ export { useDrawingArea } from "../hooks/useDrawingArea.js";
10
10
  export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
11
11
  export { useLineChartProps } from "../LineChart/useLineChartProps.js";
12
12
  export { useBarChartProps } from "../BarChart/useBarChartProps.js";
13
+ export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
13
14
  export * from "../ChartContainer/useChartContainerProps.js";
14
15
  export * from "../ChartDataProvider/useChartDataProviderProps.js";
15
16
  export * from "./createSeriesSelectorOfType.js";
@@ -34,6 +35,7 @@ export * from "./store/useSelector.js";
34
35
  export * from "../BarChart/BarChart.plugins.js";
35
36
  export * from "../LineChart/LineChart.plugins.js";
36
37
  export * from "../ScatterChart/ScatterChart.plugins.js";
38
+ export * from "../RadarChart/RadarChart.plugins.js";
37
39
 
38
40
  // utils
39
41
  export * from "./defaultizeValueFormatter.js";
@@ -41,17 +43,18 @@ export * from "./configInit.js";
41
43
  export * from "./getLabel.js";
42
44
  export * from "./getSVGPoint.js";
43
45
  export * from "./isDefined.js";
44
- export { unstable_cleanupDOM } from "./domUtils.js";
45
46
  export * from "./getScale.js";
46
47
  export * from "./stackSeries.js";
47
48
  export * from "./getCurve.js";
48
49
  export * from "./consumeSlots.js";
49
50
  export * from "./consumeThemeProps.js";
50
51
  export * from "./defaultizeMargin.js";
52
+ export * from "./dateHelpers.js";
51
53
 
52
54
  // contexts
53
55
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
54
56
  export * from "../context/ChartProvider/index.js";
57
+ export * from "../context/ChartsSlotsContext.js";
55
58
 
56
59
  // series configuration
57
60
  export * from "../models/seriesType/config.js";
@@ -1,4 +1,6 @@
1
+ import type * as React from 'react';
1
2
  import { ChartsBaseSlots } from "../../models/slots/chartsBaseSlots.js";
2
3
  import { ChartsIconSlots } from "../../models/slots/chartsIconSlots.js";
3
4
  export type ChartsSlots = ChartsBaseSlots & ChartsIconSlots;
5
+ export type ChartsSlotProps = { [key in keyof ChartsSlots]: React.ComponentProps<ChartsSlots[key]> };
4
6
  export declare const defaultSlotsMaterial: ChartsSlots;