@mui/x-charts 8.5.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 (90) hide show
  1. package/BarChart/BarChart.js +2 -3
  2. package/BarChart/BarLabel/BarLabel.d.ts +1 -1
  3. package/BarChart/seriesConfig/seriesProcessor.js +1 -1
  4. package/CHANGELOG.md +112 -0
  5. package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
  6. package/ChartsGrid/styledComponents.d.ts +2 -2
  7. package/ChartsReferenceLine/common.d.ts +1 -1
  8. package/ChartsTooltip/ChartsTooltip.js +1 -1
  9. package/ChartsTooltip/ChartsTooltipContainer.js +21 -16
  10. package/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
  11. package/ChartsTooltip/utils.d.ts +6 -0
  12. package/ChartsTooltip/utils.js +19 -1
  13. package/LineChart/LineChart.js +2 -3
  14. package/PieChart/PieChart.js +4 -11
  15. package/RadarChart/RadarChart.js +2 -3
  16. package/ScatterChart/ScatterChart.js +2 -3
  17. package/Toolbar/Toolbar.d.ts +9 -8
  18. package/Toolbar/Toolbar.js +23 -8
  19. package/Toolbar/Toolbar.types.d.ts +1 -1
  20. package/Toolbar/ToolbarButton.js +18 -4
  21. package/esm/BarChart/BarChart.js +2 -3
  22. package/esm/BarChart/BarLabel/BarLabel.d.ts +1 -1
  23. package/esm/BarChart/seriesConfig/seriesProcessor.js +1 -1
  24. package/esm/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
  25. package/esm/ChartsGrid/styledComponents.d.ts +2 -2
  26. package/esm/ChartsReferenceLine/common.d.ts +1 -1
  27. package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
  28. package/esm/ChartsTooltip/ChartsTooltipContainer.js +22 -17
  29. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
  30. package/esm/ChartsTooltip/utils.d.ts +6 -0
  31. package/esm/ChartsTooltip/utils.js +16 -1
  32. package/esm/LineChart/LineChart.js +2 -3
  33. package/esm/PieChart/PieChart.js +4 -11
  34. package/esm/RadarChart/RadarChart.js +2 -3
  35. package/esm/ScatterChart/ScatterChart.js +2 -3
  36. package/esm/Toolbar/Toolbar.d.ts +9 -8
  37. package/esm/Toolbar/Toolbar.js +22 -7
  38. package/esm/Toolbar/Toolbar.types.d.ts +1 -1
  39. package/esm/Toolbar/ToolbarButton.js +19 -4
  40. package/esm/index.js +1 -1
  41. package/esm/internals/components/AxisSharedComponents.d.ts +1 -1
  42. package/esm/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  43. package/esm/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
  44. package/esm/internals/constants.d.ts +8 -1
  45. package/esm/internals/constants.js +9 -1
  46. package/esm/internals/index.d.ts +2 -0
  47. package/esm/internals/index.js +2 -0
  48. package/esm/internals/invertScale.d.ts +2 -0
  49. package/esm/internals/invertScale.js +8 -0
  50. package/esm/internals/material/index.js +2 -0
  51. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +2917 -0
  52. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +1 -0
  53. package/esm/locales/index.d.ts +3 -1
  54. package/esm/locales/index.js +2 -0
  55. package/esm/locales/ptBR.d.ts +16 -0
  56. package/esm/locales/ptBR.js +9 -0
  57. package/esm/locales/ptPT.d.ts +16 -0
  58. package/esm/locales/ptPT.js +9 -0
  59. package/esm/models/axis.d.ts +2 -1
  60. package/esm/models/seriesType/bar.d.ts +2 -2
  61. package/esm/models/slots/chartsBaseSlotProps.d.ts +6 -0
  62. package/esm/models/slots/chartsBaseSlots.d.ts +2 -1
  63. package/index.js +1 -1
  64. package/internals/components/AxisSharedComponents.d.ts +1 -1
  65. package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  66. package/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
  67. package/internals/constants.d.ts +8 -1
  68. package/internals/constants.js +10 -2
  69. package/internals/index.d.ts +2 -0
  70. package/internals/index.js +24 -0
  71. package/internals/invertScale.d.ts +2 -0
  72. package/internals/invertScale.js +14 -0
  73. package/internals/material/index.js +2 -0
  74. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +2917 -0
  75. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +2 -1
  76. package/locales/index.d.ts +3 -1
  77. package/locales/index.js +22 -0
  78. package/locales/ptBR.d.ts +16 -0
  79. package/locales/ptBR.js +15 -0
  80. package/locales/ptPT.d.ts +16 -0
  81. package/locales/ptPT.js +15 -0
  82. package/models/axis.d.ts +2 -1
  83. package/models/seriesType/bar.d.ts +2 -2
  84. package/models/slots/chartsBaseSlotProps.d.ts +6 -0
  85. package/models/slots/chartsBaseSlots.d.ts +2 -1
  86. package/package.json +5 -5
  87. package/Toolbar/internals/ChartsToolbar.d.ts +0 -6
  88. package/Toolbar/internals/ChartsToolbar.js +0 -14
  89. package/esm/Toolbar/internals/ChartsToolbar.d.ts +0 -6
  90. package/esm/Toolbar/internals/ChartsToolbar.js +0 -8
@@ -88,6 +88,7 @@ export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selecto
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]);
91
92
  export const selectorChartRawAxis = createSelector([selectorChartRawXAxis, selectorChartRawYAxis, (state, axisId) => axisId], (xAxes, yAxes, axisId) => {
92
93
  const axis = xAxes?.find(a => a.id === axisId) ?? yAxes?.find(a => a.id === axisId) ?? null;
93
94
  if (!axis) {
@@ -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,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,7 +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>;
13
18
  disabled?: boolean;
19
+ tabIndex?: number;
14
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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.5.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
  }
@@ -3,4 +3,11 @@ import type { ZoomSliderShowTooltip } from "./plugins/featurePlugins/useChartCar
3
3
  export declare const ZOOM_SLIDER_MARGIN = 4;
4
4
  /** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
5
5
  export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
6
- export declare const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP: ZoomSliderShowTooltip;
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,10 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ZOOM_SLIDER_MARGIN = exports.DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = 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
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';
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
+ };
@@ -28,6 +28,7 @@ export * from "../BarChart/BarChart.plugins.js";
28
28
  export * from "../LineChart/LineChart.plugins.js";
29
29
  export * from "../ScatterChart/ScatterChart.plugins.js";
30
30
  export * from "../RadarChart/RadarChart.plugins.js";
31
+ export * from "../PieChart/PieChart.plugins.js";
31
32
  export * from "./defaultizeValueFormatter.js";
32
33
  export * from "./configInit.js";
33
34
  export * from "./getLabel.js";
@@ -40,6 +41,7 @@ export * from "./consumeSlots.js";
40
41
  export * from "./consumeThemeProps.js";
41
42
  export * from "./defaultizeMargin.js";
42
43
  export * from "./dateHelpers.js";
44
+ export * from "./invertScale.js";
43
45
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
44
46
  export * from "../context/ChartProvider/index.js";
45
47
  export * from "../context/ChartsSlotsContext.js";
@@ -344,6 +344,18 @@ Object.keys(_RadarChart).forEach(function (key) {
344
344
  }
345
345
  });
346
346
  });
347
+ var _PieChart = require("../PieChart/PieChart.plugins");
348
+ Object.keys(_PieChart).forEach(function (key) {
349
+ if (key === "default" || key === "__esModule") return;
350
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
351
+ if (key in exports && exports[key] === _PieChart[key]) return;
352
+ Object.defineProperty(exports, key, {
353
+ enumerable: true,
354
+ get: function () {
355
+ return _PieChart[key];
356
+ }
357
+ });
358
+ });
347
359
  var _defaultizeValueFormatter = require("./defaultizeValueFormatter");
348
360
  Object.keys(_defaultizeValueFormatter).forEach(function (key) {
349
361
  if (key === "default" || key === "__esModule") return;
@@ -488,6 +500,18 @@ Object.keys(_dateHelpers).forEach(function (key) {
488
500
  }
489
501
  });
490
502
  });
503
+ var _invertScale = require("./invertScale");
504
+ Object.keys(_invertScale).forEach(function (key) {
505
+ if (key === "default" || key === "__esModule") return;
506
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
507
+ if (key in exports && exports[key] === _invertScale[key]) return;
508
+ Object.defineProperty(exports, key, {
509
+ enumerable: true,
510
+ get: function () {
511
+ return _invertScale[key];
512
+ }
513
+ });
514
+ });
491
515
  var _getAxisExtremum = require("./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum");
492
516
  var _ChartProvider = require("../context/ChartProvider");
493
517
  Object.keys(_ChartProvider).forEach(function (key) {
@@ -0,0 +1,2 @@
1
+ import { D3Scale } from "../models/axis.js";
2
+ export declare function invertScale<T>(scale: D3Scale, data: readonly T[], value: number): number | Date | T;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.invertScale = invertScale;
7
+ var _isBandScale = require("./isBandScale");
8
+ function invertScale(scale, data, value) {
9
+ if ((0, _isBandScale.isBandScale)(scale)) {
10
+ const dataIndex = scale.bandwidth() === 0 ? Math.floor((value - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((value - Math.min(...scale.range())) / scale.step());
11
+ return data[dataIndex];
12
+ }
13
+ return scale.invert(value);
14
+ }
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.defaultSlotsMaterial = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
10
+ var _Button = _interopRequireDefault(require("@mui/material/Button"));
10
11
  const baseSlots = {
12
+ baseButton: _Button.default,
11
13
  baseIconButton: _IconButton.default
12
14
  };
13
15
  const iconSlots = {};