@mui/x-charts 8.4.0 → 8.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/BarChart/BarChart.d.ts +9 -2
  2. package/BarChart/BarChart.js +7 -1
  3. package/BarChart/BarLabel/BarLabel.d.ts +1 -1
  4. package/BarChart/seriesConfig/seriesProcessor.js +1 -1
  5. package/BarChart/useBarChartProps.js +1 -1
  6. package/CHANGELOG.md +215 -0
  7. package/ChartContainer/ChartContainer.d.ts +21 -2
  8. package/ChartContainer/ChartContainer.js +16 -0
  9. package/ChartContainer/useChartContainerProps.js +7 -3
  10. package/ChartDataProvider/ChartDataProvider.d.ts +11 -1
  11. package/ChartDataProvider/ChartDataProvider.js +19 -2
  12. package/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
  13. package/ChartDataProvider/useChartDataProviderProps.js +7 -3
  14. package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
  15. package/ChartsGrid/styledComponents.d.ts +2 -2
  16. package/ChartsReferenceLine/common.d.ts +1 -1
  17. package/ChartsTooltip/ChartsTooltip.js +1 -1
  18. package/ChartsTooltip/ChartsTooltipContainer.js +21 -16
  19. package/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
  20. package/ChartsTooltip/utils.d.ts +6 -0
  21. package/ChartsTooltip/utils.js +19 -1
  22. package/LineChart/LineChart.d.ts +9 -2
  23. package/LineChart/LineChart.js +7 -1
  24. package/LineChart/useLineChartProps.js +1 -1
  25. package/PieChart/PieChart.d.ts +10 -3
  26. package/PieChart/PieChart.js +12 -11
  27. package/RadarChart/RadarChart.d.ts +21 -3
  28. package/RadarChart/RadarChart.js +16 -2
  29. package/RadarChart/RadarChart.plugins.d.ts +5 -0
  30. package/RadarChart/RadarChart.plugins.js +10 -0
  31. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
  32. package/RadarChart/RadarDataProvider/RadarDataProvider.js +6 -116
  33. package/RadarChart/index.d.ts +2 -0
  34. package/RadarChart/index.js +15 -1
  35. package/RadarChart/useRadarChartProps.d.ts +2 -1
  36. package/RadarChart/useRadarChartProps.js +3 -1
  37. package/ScatterChart/ScatterChart.d.ts +9 -2
  38. package/ScatterChart/ScatterChart.js +7 -1
  39. package/ScatterChart/useScatterChartProps.js +4 -2
  40. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  41. package/Toolbar/Toolbar.d.ts +11 -4
  42. package/Toolbar/Toolbar.js +38 -7
  43. package/Toolbar/Toolbar.types.d.ts +15 -0
  44. package/Toolbar/Toolbar.types.js +5 -0
  45. package/Toolbar/ToolbarButton.d.ts +8 -2
  46. package/Toolbar/ToolbarButton.js +39 -7
  47. package/Toolbar/chartToolbarClasses.d.ts +6 -0
  48. package/Toolbar/chartToolbarClasses.js +9 -0
  49. package/Toolbar/index.d.ts +3 -1
  50. package/Toolbar/index.js +22 -0
  51. package/context/ChartsSlotsContext.d.ts +20 -0
  52. package/context/ChartsSlotsContext.js +44 -0
  53. package/context/index.d.ts +2 -1
  54. package/context/index.js +11 -0
  55. package/context/useChartApiContext.d.ts +10 -0
  56. package/context/useChartApiContext.js +27 -0
  57. package/esm/BarChart/BarChart.d.ts +9 -2
  58. package/esm/BarChart/BarChart.js +7 -1
  59. package/esm/BarChart/BarLabel/BarLabel.d.ts +1 -1
  60. package/esm/BarChart/seriesConfig/seriesProcessor.js +1 -1
  61. package/esm/BarChart/useBarChartProps.js +1 -1
  62. package/esm/ChartContainer/ChartContainer.d.ts +21 -2
  63. package/esm/ChartContainer/ChartContainer.js +16 -0
  64. package/esm/ChartContainer/useChartContainerProps.js +7 -3
  65. package/esm/ChartDataProvider/ChartDataProvider.d.ts +11 -1
  66. package/esm/ChartDataProvider/ChartDataProvider.js +19 -2
  67. package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
  68. package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -3
  69. package/esm/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
  70. package/esm/ChartsGrid/styledComponents.d.ts +2 -2
  71. package/esm/ChartsReferenceLine/common.d.ts +1 -1
  72. package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
  73. package/esm/ChartsTooltip/ChartsTooltipContainer.js +22 -17
  74. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
  75. package/esm/ChartsTooltip/utils.d.ts +6 -0
  76. package/esm/ChartsTooltip/utils.js +16 -1
  77. package/esm/LineChart/LineChart.d.ts +9 -2
  78. package/esm/LineChart/LineChart.js +7 -1
  79. package/esm/LineChart/useLineChartProps.js +1 -1
  80. package/esm/PieChart/PieChart.d.ts +10 -3
  81. package/esm/PieChart/PieChart.js +12 -11
  82. package/esm/RadarChart/RadarChart.d.ts +21 -3
  83. package/esm/RadarChart/RadarChart.js +16 -2
  84. package/esm/RadarChart/RadarChart.plugins.d.ts +5 -0
  85. package/esm/RadarChart/RadarChart.plugins.js +4 -0
  86. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
  87. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.js +5 -115
  88. package/esm/RadarChart/index.d.ts +2 -0
  89. package/esm/RadarChart/index.js +2 -0
  90. package/esm/RadarChart/useRadarChartProps.d.ts +2 -1
  91. package/esm/RadarChart/useRadarChartProps.js +3 -1
  92. package/esm/ScatterChart/ScatterChart.d.ts +9 -2
  93. package/esm/ScatterChart/ScatterChart.js +7 -1
  94. package/esm/ScatterChart/useScatterChartProps.js +4 -2
  95. package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
  96. package/esm/Toolbar/Toolbar.d.ts +11 -4
  97. package/esm/Toolbar/Toolbar.js +36 -6
  98. package/esm/Toolbar/Toolbar.types.d.ts +15 -0
  99. package/esm/Toolbar/Toolbar.types.js +1 -0
  100. package/esm/Toolbar/ToolbarButton.d.ts +8 -2
  101. package/esm/Toolbar/ToolbarButton.js +39 -6
  102. package/esm/Toolbar/chartToolbarClasses.d.ts +6 -0
  103. package/esm/Toolbar/chartToolbarClasses.js +2 -0
  104. package/esm/Toolbar/index.d.ts +3 -1
  105. package/esm/Toolbar/index.js +3 -1
  106. package/esm/context/ChartsSlotsContext.d.ts +20 -0
  107. package/esm/context/ChartsSlotsContext.js +35 -0
  108. package/esm/context/index.d.ts +2 -1
  109. package/esm/context/index.js +1 -0
  110. package/esm/context/useChartApiContext.d.ts +10 -0
  111. package/esm/context/useChartApiContext.js +21 -0
  112. package/esm/hooks/index.d.ts +1 -0
  113. package/esm/hooks/index.js +1 -0
  114. package/esm/index.js +1 -1
  115. package/esm/internals/components/AxisSharedComponents.d.ts +1 -1
  116. package/esm/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  117. package/esm/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
  118. package/esm/internals/constants.d.ts +10 -1
  119. package/esm/internals/constants.js +10 -1
  120. package/esm/internals/dateHelpers.d.ts +15 -0
  121. package/esm/internals/dateHelpers.js +20 -0
  122. package/esm/internals/domUtils.d.ts +1 -2
  123. package/esm/internals/domUtils.js +8 -19
  124. package/esm/internals/index.d.ts +6 -1
  125. package/esm/internals/index.js +6 -1
  126. package/esm/internals/invertScale.d.ts +2 -0
  127. package/esm/internals/invertScale.js +8 -0
  128. package/esm/internals/material/index.d.ts +2 -0
  129. package/esm/internals/material/index.js +2 -0
  130. package/esm/internals/plugins/allPlugins.d.ts +1 -0
  131. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +2 -8
  132. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
  133. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -3
  134. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
  135. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3000 -0
  136. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -1
  137. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +9 -0
  138. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
  139. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
  140. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -8
  141. package/esm/locales/index.d.ts +3 -1
  142. package/esm/locales/index.js +2 -0
  143. package/esm/locales/ptBR.d.ts +16 -0
  144. package/esm/locales/ptBR.js +9 -0
  145. package/esm/locales/ptPT.d.ts +16 -0
  146. package/esm/locales/ptPT.js +9 -0
  147. package/esm/models/axis.d.ts +2 -1
  148. package/esm/models/index.d.ts +2 -2
  149. package/esm/models/index.js +1 -0
  150. package/esm/models/seriesType/bar.d.ts +2 -2
  151. package/esm/models/slots/chartsBaseSlotProps.d.ts +7 -0
  152. package/esm/models/slots/chartsBaseSlots.d.ts +2 -1
  153. package/hooks/index.d.ts +1 -0
  154. package/hooks/index.js +12 -0
  155. package/index.js +1 -1
  156. package/internals/components/AxisSharedComponents.d.ts +1 -1
  157. package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  158. package/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
  159. package/internals/constants.d.ts +10 -1
  160. package/internals/constants.js +11 -2
  161. package/internals/dateHelpers.d.ts +15 -0
  162. package/internals/dateHelpers.js +28 -0
  163. package/internals/domUtils.d.ts +1 -2
  164. package/internals/domUtils.js +8 -20
  165. package/internals/index.d.ts +6 -1
  166. package/internals/index.js +68 -8
  167. package/internals/invertScale.d.ts +2 -0
  168. package/internals/invertScale.js +14 -0
  169. package/internals/material/index.d.ts +2 -0
  170. package/internals/material/index.js +2 -0
  171. package/internals/plugins/allPlugins.d.ts +1 -0
  172. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -11
  173. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
  174. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -3
  175. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
  176. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3000 -0
  177. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +10 -2
  178. package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +9 -0
  179. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
  180. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
  181. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +5 -11
  182. package/locales/index.d.ts +3 -1
  183. package/locales/index.js +22 -0
  184. package/locales/ptBR.d.ts +16 -0
  185. package/locales/ptBR.js +15 -0
  186. package/locales/ptPT.d.ts +16 -0
  187. package/locales/ptPT.js +15 -0
  188. package/models/axis.d.ts +2 -1
  189. package/models/index.d.ts +2 -2
  190. package/models/index.js +11 -0
  191. package/models/seriesType/bar.d.ts +2 -2
  192. package/models/slots/chartsBaseSlotProps.d.ts +7 -0
  193. package/models/slots/chartsBaseSlots.d.ts +2 -1
  194. package/package.json +5 -5
@@ -87,4 +87,12 @@ export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selecto
87
87
  zoomMap,
88
88
  zoomOptions,
89
89
  getFilters
90
- }));
90
+ }));
91
+ export const selectorChartAxis = createSelector([selectorChartXAxis, selectorChartYAxis, (_, axisId) => axisId], (xAxes, yAxes, axisId) => xAxes?.axis[axisId] ?? yAxes?.axis[axisId]);
92
+ export const selectorChartRawAxis = createSelector([selectorChartRawXAxis, selectorChartRawYAxis, (state, axisId) => axisId], (xAxes, yAxes, axisId) => {
93
+ const axis = xAxes?.find(a => a.id === axisId) ?? yAxes?.find(a => a.id === axisId) ?? null;
94
+ if (!axis) {
95
+ return undefined;
96
+ }
97
+ return axis;
98
+ });
@@ -15,6 +15,7 @@ export type ZoomData = {
15
15
  end: number;
16
16
  };
17
17
  export type ZoomFilterMode = 'keep' | 'discard';
18
+ export type ZoomSliderShowTooltip = 'always' | 'hover' | 'never';
18
19
  export interface ZoomOptions {
19
20
  /**
20
21
  * The starting percentage of the zoom range. In the range of 0 to 100.
@@ -85,6 +86,14 @@ export interface ZoomSliderOptions {
85
86
  * @default 28
86
87
  */
87
88
  size?: number;
89
+ /**
90
+ * Defines when the tooltip with the zoom values should be shown.
91
+ * - 'always': The tooltip is always shown.
92
+ * - 'hover': The tooltip is shown when hovering over the track or thumb.
93
+ * - 'never': The tooltip is never shown.
94
+ * @default 'hover'
95
+ */
96
+ showTooltip?: ZoomSliderShowTooltip;
88
97
  }
89
98
  export type ZoomAxisFilters = Record<AxisId, ExtremumFilter>;
90
99
  export type GetZoomAxisFilters = (params: {
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { useAssertModelConsistency } from '@mui/x-internals/useAssertModelConsistency';
3
3
  import useEventCallback from '@mui/utils/useEventCallback';
4
4
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
+ import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
5
6
  export const useChartHighlight = ({
6
7
  store,
7
8
  params
@@ -29,6 +30,10 @@ export const useChartHighlight = ({
29
30
  }));
30
31
  });
31
32
  const setHighlight = useEventCallback(newItem => {
33
+ const prevItem = store.getSnapshot().highlight.item;
34
+ if (fastObjectShallowCompare(prevItem, newItem)) {
35
+ return;
36
+ }
32
37
  params.onHighlightChange?.(newItem);
33
38
  store.update(prev => _extends({}, prev, {
34
39
  highlight: {
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import useEventCallback from '@mui/utils/useEventCallback';
3
+ import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
3
4
  export const useChartInteraction = ({
4
5
  store
5
6
  }) => {
@@ -36,11 +37,16 @@ export const useChartInteraction = ({
36
37
  });
37
38
  });
38
39
  const setItemInteraction = useEventCallback(newItem => {
39
- store.update(prev => _extends({}, prev, {
40
- interaction: _extends({}, prev.interaction, {
41
- item: newItem
42
- })
43
- }));
40
+ store.update(prev => {
41
+ if (fastObjectShallowCompare(prev.interaction.item, newItem)) {
42
+ return prev;
43
+ }
44
+ return _extends({}, prev, {
45
+ interaction: _extends({}, prev.interaction, {
46
+ item: newItem
47
+ })
48
+ });
49
+ });
44
50
  });
45
51
  const setPointerCoordinate = useEventCallback(coordinate => {
46
52
  store.update(prev => _extends({}, prev, {
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { scaleBand, scalePoint, scaleTime } from '@mui/x-charts-vendor/d3-scale';
2
+ import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
3
3
  import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
4
4
  import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
5
5
  import { getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
6
6
  import { getScale } from "../../../getScale.js";
7
+ import { isDateData, createDateFormatter } from "../../../dateHelpers.js";
7
8
  import { getAxisExtremum } from "./getAxisExtremum.js";
8
9
  import { deg2rad } from "../../../angleConversion.js";
9
10
  import { getAxisTriggerTooltip } from "./getAxisTriggerTooltip.js";
@@ -22,13 +23,6 @@ function getRange(drawingArea, axisDirection, axis) {
22
23
  }
23
24
  return [0, Math.min(drawingArea.height, drawingArea.width) / 2];
24
25
  }
25
- const isDateData = data => data?.[0] instanceof Date;
26
- function createDateFormatter(axis, range) {
27
- const timeScale = scaleTime(axis.data, range);
28
- return (v, {
29
- location
30
- }) => location === 'tick' ? timeScale.tickFormat(axis.tickNumber)(v) : `${v.toLocaleString()}`;
31
- }
32
26
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
33
27
  const DEFAULT_BAR_GAP_RATIO = 0.1;
34
28
  export function computeAxisValue({
@@ -1,3 +1,5 @@
1
1
  export type { ChartsLocaleText } from "./utils/chartsLocaleTextApi.js";
2
2
  export * from "./enUS.js";
3
- export * from "./frFR.js";
3
+ export * from "./frFR.js";
4
+ export * from "./ptBR.js";
5
+ export * from "./ptPT.js";
@@ -1,3 +1,5 @@
1
1
  export * from "./enUS.js";
2
2
  export * from "./frFR.js";
3
+ export * from "./ptBR.js";
4
+ export * from "./ptPT.js";
3
5
  export {};
@@ -0,0 +1,16 @@
1
+ import { ChartsLocaleText } from "./utils/chartsLocaleTextApi.js";
2
+ export declare const ptBRLocaleText: Partial<ChartsLocaleText>;
3
+ export declare const ptBR: {
4
+ components: {
5
+ MuiChartsLocalizationProvider: {
6
+ defaultProps: {
7
+ localeText: {
8
+ loading?: string | undefined;
9
+ noData?: string | undefined;
10
+ zoomIn?: string | undefined;
11
+ zoomOut?: string | undefined;
12
+ };
13
+ };
14
+ };
15
+ };
16
+ };
@@ -0,0 +1,9 @@
1
+ import { getChartsLocalization } from "./utils/getChartsLocalization.js";
2
+ export const ptBRLocaleText = {
3
+ // Overlay
4
+ loading: 'Carregando dados…',
5
+ noData: 'Sem dados para exibir',
6
+ zoomIn: 'Aumentar zoom',
7
+ zoomOut: 'Diminuir zoom'
8
+ };
9
+ export const ptBR = getChartsLocalization(ptBRLocaleText);
@@ -0,0 +1,16 @@
1
+ import { ChartsLocaleText } from "./utils/chartsLocaleTextApi.js";
2
+ export declare const ptPTLocaleText: Partial<ChartsLocaleText>;
3
+ export declare const ptPT: {
4
+ components: {
5
+ MuiChartsLocalizationProvider: {
6
+ defaultProps: {
7
+ localeText: {
8
+ loading?: string | undefined;
9
+ noData?: string | undefined;
10
+ zoomIn?: string | undefined;
11
+ zoomOut?: string | undefined;
12
+ };
13
+ };
14
+ };
15
+ };
16
+ };
@@ -0,0 +1,9 @@
1
+ import { getChartsLocalization } from "./utils/getChartsLocalization.js";
2
+ export const ptPTLocaleText = {
3
+ // Overlay
4
+ loading: 'Carregando dados…',
5
+ noData: 'Sem dados para mostrar',
6
+ zoomIn: 'Aumentar zoom',
7
+ zoomOut: 'Diminuir zoom'
8
+ };
9
+ export const ptPT = getChartsLocalization(ptPTLocaleText);
@@ -270,8 +270,9 @@ export type AxisValueFormatterContext<S extends ScaleName = ScaleName> = {
270
270
  * - `'tick'` The value is displayed on the axis ticks.
271
271
  * - `'tooltip'` The value is displayed in the tooltip when hovering the chart.
272
272
  * - `'legend'` The value is displayed in the legend when using color legend.
273
+ * - `'zoom-slider-tooltip'` The value is displayed in the zoom slider tooltip.
273
274
  */
274
- location: 'legend';
275
+ location: 'legend' | 'zoom-slider-tooltip';
275
276
  } | {
276
277
  /**
277
278
  * Location indicates where the value will be displayed.
@@ -1,7 +1,7 @@
1
1
  export * from "./seriesType/index.js";
2
2
  export * from "./stacking.js";
3
+ export * from "./slots/index.js";
3
4
  export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, ChartsAxisData, XAxis, YAxis, RadiusAxis, RotationAxis } from "./axis.js";
4
5
  export type { PropsFromSlot } from '@mui/x-internals/slots';
5
6
  export type { Position } from "./position.js";
6
- export type { CurveType } from "./curve.js";
7
- export type { ChartBaseCommonProps, ChartBaseIconProps, ChartsIconSlots, ChartsBaseSlots } from "./slots/index.js";
7
+ export type { CurveType } from "./curve.js";
@@ -1,5 +1,6 @@
1
1
  export * from "./seriesType/index.js";
2
2
  export * from "./stacking.js";
3
+ export * from "./slots/index.js";
3
4
 
4
5
  // Utils shared across the X packages
5
6
  export {};
@@ -1,6 +1,6 @@
1
1
  import { DefaultizedProps } from '@mui/x-internals/types';
2
2
  import type { StackOffsetType } from "../stacking.js";
3
- import { CartesianSeriesType, CommonSeriesType, CommonDefaultizedProps, StackableSeriesType } from "./common.js";
3
+ import { CartesianSeriesType, CommonSeriesType, CommonDefaultizedProps, StackableSeriesType, SeriesId } from "./common.js";
4
4
  export interface BarSeriesType extends CommonSeriesType<number | null>, CartesianSeriesType, StackableSeriesType {
5
5
  type: 'bar';
6
6
  /**
@@ -32,7 +32,7 @@ export interface BarSeriesType extends CommonSeriesType<number | null>, Cartesia
32
32
  */
33
33
  export type BarItemIdentifier = {
34
34
  type: 'bar';
35
- seriesId: DefaultizedBarSeriesType['id'];
35
+ seriesId: SeriesId;
36
36
  dataIndex: number;
37
37
  };
38
38
  export interface DefaultizedBarSeriesType extends DefaultizedProps<BarSeriesType, CommonDefaultizedProps | 'color' | 'layout'> {}
@@ -8,6 +8,13 @@ export type ChartBaseCommonProps<T = HTMLElement> = React.DOMAttributes<T> & {
8
8
  export type ChartBaseIconProps = ChartBaseCommonProps<SVGSVGElement> & {
9
9
  titleAccess?: string;
10
10
  };
11
+ export type ChartBaseButtonProps = ChartBaseCommonProps & {
12
+ ref?: React.Ref<HTMLButtonElement>;
13
+ disabled?: boolean;
14
+ tabIndex?: number;
15
+ };
11
16
  export type ChartBaseIconButtonProps = ChartBaseCommonProps & {
12
17
  ref?: React.Ref<HTMLButtonElement>;
18
+ disabled?: boolean;
19
+ tabIndex?: number;
13
20
  };
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- import { ChartBaseIconButtonProps } from "./chartsBaseSlotProps.js";
2
+ import { ChartBaseButtonProps, ChartBaseIconButtonProps } from "./chartsBaseSlotProps.js";
3
3
  export interface ChartsBaseSlots {
4
+ baseButton: React.ComponentType<ChartBaseButtonProps>;
4
5
  baseIconButton: React.ComponentType<ChartBaseIconButtonProps>;
5
6
  }
package/hooks/index.d.ts CHANGED
@@ -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";
package/hooks/index.js CHANGED
@@ -163,6 +163,18 @@ Object.keys(_useLineSeries).forEach(function (key) {
163
163
  }
164
164
  });
165
165
  });
166
+ var _useRadarSeries = require("./useRadarSeries");
167
+ Object.keys(_useRadarSeries).forEach(function (key) {
168
+ if (key === "default" || key === "__esModule") return;
169
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
170
+ if (key in exports && exports[key] === _useRadarSeries[key]) return;
171
+ Object.defineProperty(exports, key, {
172
+ enumerable: true,
173
+ get: function () {
174
+ return _useRadarSeries[key];
175
+ }
176
+ });
177
+ });
166
178
  var _useItemHighlighted = require("./useItemHighlighted");
167
179
  Object.keys(_useItemHighlighted).forEach(function (key) {
168
180
  if (key === "default" || key === "__esModule") return;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.4.0
2
+ * @mui/x-charts v8.5.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1 +1 @@
1
- export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
1
+ export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
@@ -5,6 +5,11 @@ import { Position } from "../../../models/index.js";
5
5
  export interface ChartsWrapperProps {
6
6
  legendPosition?: Position;
7
7
  legendDirection?: Direction;
8
+ /**
9
+ * If `true`, the chart wrapper set `height: 100%`.
10
+ * @default `false` if the `height` prop is set. And `true` otherwise.
11
+ */
12
+ extendVertically?: boolean;
8
13
  children: React.ReactNode;
9
14
  sx?: SxProps<Theme>;
10
15
  }
@@ -7,7 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ChartsWrapper = ChartsWrapper;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _styles = require("@mui/material/styles");
10
+ var _createStyled = require("@mui/system/createStyled");
10
11
  var _useChartRootRef = require("../../../hooks/useChartRootRef");
12
+ var _useStore = require("../../store/useStore");
13
+ var _useSelector = require("../../store/useSelector");
14
+ var _useChartDimensions = require("../../plugins/corePlugins/useChartDimensions");
11
15
  var _jsxRuntime = require("react/jsx-runtime");
12
16
  const getDirection = (direction, position) => {
13
17
  if (direction === 'vertical') {
@@ -42,7 +46,8 @@ const getAlign = (direction, position) => {
42
46
  };
43
47
  const Root = (0, _styles.styled)('div', {
44
48
  name: 'MuiChartsWrapper',
45
- slot: 'Root'
49
+ slot: 'Root',
50
+ shouldForwardProp: prop => (0, _createStyled.shouldForwardProp)(prop) && prop !== 'extendVertically'
46
51
  })(({
47
52
  ownerState
48
53
  }) => ({
@@ -50,7 +55,15 @@ const Root = (0, _styles.styled)('div', {
50
55
  flexDirection: getDirection(ownerState.legendDirection, ownerState.legendPosition),
51
56
  flex: 1,
52
57
  justifyContent: 'center',
53
- alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition)
58
+ alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition),
59
+ variants: [{
60
+ props: {
61
+ extendVertically: true
62
+ },
63
+ style: {
64
+ height: '100%'
65
+ }
66
+ }]
54
67
  }));
55
68
 
56
69
  /**
@@ -62,13 +75,19 @@ const Root = (0, _styles.styled)('div', {
62
75
  function ChartsWrapper(props) {
63
76
  const {
64
77
  children,
65
- sx
78
+ sx,
79
+ extendVertically
66
80
  } = props;
67
81
  const chartRootRef = (0, _useChartRootRef.useChartRootRef)();
82
+ const store = (0, _useStore.useStore)();
83
+ const {
84
+ height: propsHeight
85
+ } = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartPropsSize);
68
86
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
69
87
  ref: chartRootRef,
70
88
  ownerState: props,
71
89
  sx: sx,
90
+ extendVertically: extendVertically ?? propsHeight === undefined,
72
91
  children: children
73
92
  });
74
93
  }
@@ -1,4 +1,13 @@
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 DEFAULT_ZOOM_SLIDER_SIZE: number;
5
+ export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
6
+ export declare const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP: ZoomSliderShowTooltip;
7
+ /** Default margin for pie charts. */
8
+ export declare const DEFAULT_PIE_CHART_MARGIN: {
9
+ top: number;
10
+ bottom: number;
11
+ left: number;
12
+ right: number;
13
+ };
@@ -3,9 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ZOOM_SLIDER_MARGIN = exports.DEFAULT_ZOOM_SLIDER_SIZE = void 0;
6
+ exports.ZOOM_SLIDER_MARGIN = exports.DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = exports.DEFAULT_PIE_CHART_MARGIN = void 0;
7
7
  /** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
8
8
  const ZOOM_SLIDER_MARGIN = exports.ZOOM_SLIDER_MARGIN = 4;
9
9
 
10
10
  /** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
11
- const DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
11
+ const DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
12
+ const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = exports.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = 'hover';
13
+
14
+ /** Default margin for pie charts. */
15
+ const DEFAULT_PIE_CHART_MARGIN = exports.DEFAULT_PIE_CHART_MARGIN = {
16
+ top: 5,
17
+ bottom: 5,
18
+ left: 5,
19
+ right: 5
20
+ };
@@ -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,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createDateFormatter = createDateFormatter;
7
+ exports.isDateData = void 0;
8
+ var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
9
+ /**
10
+ * Checks if the provided data array contains Date objects.
11
+ * @param data The data array to check.
12
+ * @returns A type predicate indicating if the data is an array of Date objects.
13
+ */
14
+ const isDateData = data => data?.[0] instanceof Date;
15
+
16
+ /**
17
+ * Creates a formatter function for date values.
18
+ * @param axis The axis configuration.
19
+ * @param range The range for the time scale.
20
+ * @returns A formatter function for date values.
21
+ */
22
+ exports.isDateData = isDateData;
23
+ function createDateFormatter(axis, range) {
24
+ const timeScale = (0, _d3Scale.scaleTime)(axis.data, range);
25
+ return (v, {
26
+ location
27
+ }) => location === 'tick' ? timeScale.tickFormat(axis.tickNumber)(v) : `${v.toLocaleString()}`;
28
+ }
@@ -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,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.getStyleString = exports.getStringSize = exports.MEASUREMENT_SPAN_ID = void 0;
8
- exports.unstable_cleanupDOM = unstable_cleanupDOM;
9
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
9
  // DOM utils taken from
11
10
  // https://github.com/recharts/recharts/blob/master/src/util/DOMUtils.ts
@@ -13,10 +12,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
12
  function isSsr() {
14
13
  return typeof window === 'undefined';
15
14
  }
16
- const stringCache = {
17
- widthCache: {},
18
- cacheCount: 0
19
- };
15
+ const stringCache = new Map();
20
16
  const MAX_CACHE_NUM = 2000;
21
17
  const SPAN_STYLE = {
22
18
  position: 'absolute',
@@ -84,8 +80,9 @@ const getStringSize = (text, style = {}) => {
84
80
  const str = `${text}`;
85
81
  const styleString = getStyleString(style);
86
82
  const cacheKey = `${str}-${styleString}`;
87
- if (stringCache.widthCache[cacheKey]) {
88
- return stringCache.widthCache[cacheKey];
83
+ const size = stringCache.get(cacheKey);
84
+ if (size) {
85
+ return size;
89
86
  }
90
87
  try {
91
88
  let measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
@@ -108,12 +105,9 @@ const getStringSize = (text, style = {}) => {
108
105
  width: rect.width,
109
106
  height: rect.height
110
107
  };
111
- stringCache.widthCache[cacheKey] = result;
112
- if (stringCache.cacheCount + 1 > MAX_CACHE_NUM) {
113
- stringCache.cacheCount = 0;
114
- stringCache.widthCache = {};
115
- } else {
116
- stringCache.cacheCount += 1;
108
+ stringCache.set(cacheKey, result);
109
+ if (stringCache.size + 1 > MAX_CACHE_NUM) {
110
+ stringCache.clear();
117
111
  }
118
112
  if (process.env.NODE_ENV === 'test') {
119
113
  // In test environment, we clean the measurement span immediately
@@ -135,10 +129,4 @@ const getStringSize = (text, style = {}) => {
135
129
  };
136
130
  }
137
131
  };
138
-
139
- // eslint-disable-next-line @typescript-eslint/naming-convention
140
- exports.getStringSize = getStringSize;
141
- function unstable_cleanupDOM() {
142
- // const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
143
- // measurementSpan?.remove();
144
- }
132
+ exports.getStringSize = getStringSize;
@@ -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,24 @@ 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";
31
+ export * from "../PieChart/PieChart.plugins.js";
29
32
  export * from "./defaultizeValueFormatter.js";
30
33
  export * from "./configInit.js";
31
34
  export * from "./getLabel.js";
32
35
  export * from "./getSVGPoint.js";
33
36
  export * from "./isDefined.js";
34
- export { unstable_cleanupDOM } from "./domUtils.js";
35
37
  export * from "./getScale.js";
36
38
  export * from "./stackSeries.js";
37
39
  export * from "./getCurve.js";
38
40
  export * from "./consumeSlots.js";
39
41
  export * from "./consumeThemeProps.js";
40
42
  export * from "./defaultizeMargin.js";
43
+ export * from "./dateHelpers.js";
44
+ export * from "./invertScale.js";
41
45
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
42
46
  export * from "../context/ChartProvider/index.js";
47
+ export * from "../context/ChartsSlotsContext.js";
43
48
  export * from "../models/seriesType/config.js";
44
49
  export * from "../models/seriesType/common.js";
45
50
  export * from "../models/z-axis.js";