@mui/x-charts 8.14.1 → 8.15.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 (125) hide show
  1. package/BarChart/BarChart.js +8 -0
  2. package/BarChart/BarChart.plugins.d.ts +2 -1
  3. package/BarChart/BarChart.plugins.js +2 -1
  4. package/BarChart/useBarChartProps.js +4 -2
  5. package/CHANGELOG.md +107 -0
  6. package/ChartContainer/ChartContainer.js +8 -0
  7. package/ChartContainer/useChartContainerProps.js +4 -2
  8. package/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
  9. package/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +9 -0
  10. package/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
  11. package/ChartsBrushOverlay/ChartsBrushOverlay.js +102 -0
  12. package/ChartsBrushOverlay/index.d.ts +4 -0
  13. package/ChartsBrushOverlay/index.js +19 -0
  14. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  15. package/ChartsReferenceLine/ChartsXReferenceLine.js +13 -8
  16. package/ChartsReferenceLine/ChartsYReferenceLine.js +13 -8
  17. package/ChartsReferenceLine/common.d.ts +3 -1
  18. package/ChartsReferenceLine/common.js +3 -1
  19. package/ChartsTooltip/ChartsTooltipContainer.js +20 -2
  20. package/ChartsXAxis/getVisibleLabels.js +45 -25
  21. package/LineChart/LineChart.js +8 -0
  22. package/LineChart/LineChart.plugins.d.ts +2 -1
  23. package/LineChart/LineChart.plugins.js +2 -1
  24. package/LineChart/useLineChartProps.js +4 -2
  25. package/ScatterChart/ScatterChart.js +8 -0
  26. package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  27. package/ScatterChart/ScatterChart.plugins.js +2 -1
  28. package/ScatterChart/useScatterChartProps.js +5 -3
  29. package/SparkLineChart/SparkLineChart.js +8 -0
  30. package/esm/BarChart/BarChart.js +8 -0
  31. package/esm/BarChart/BarChart.plugins.d.ts +2 -1
  32. package/esm/BarChart/BarChart.plugins.js +2 -1
  33. package/esm/BarChart/useBarChartProps.js +4 -2
  34. package/esm/ChartContainer/ChartContainer.js +8 -0
  35. package/esm/ChartContainer/useChartContainerProps.js +4 -2
  36. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
  37. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +2 -0
  38. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
  39. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +95 -0
  40. package/esm/ChartsBrushOverlay/index.d.ts +4 -0
  41. package/esm/ChartsBrushOverlay/index.js +2 -0
  42. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  43. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +14 -9
  44. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +14 -9
  45. package/esm/ChartsReferenceLine/common.d.ts +3 -1
  46. package/esm/ChartsReferenceLine/common.js +2 -0
  47. package/esm/ChartsTooltip/ChartsTooltipContainer.js +20 -2
  48. package/esm/ChartsXAxis/getVisibleLabels.js +45 -25
  49. package/esm/LineChart/LineChart.js +8 -0
  50. package/esm/LineChart/LineChart.plugins.d.ts +2 -1
  51. package/esm/LineChart/LineChart.plugins.js +2 -1
  52. package/esm/LineChart/useLineChartProps.js +4 -2
  53. package/esm/ScatterChart/ScatterChart.js +8 -0
  54. package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  55. package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
  56. package/esm/ScatterChart/useScatterChartProps.js +5 -3
  57. package/esm/SparkLineChart/SparkLineChart.js +8 -0
  58. package/esm/hooks/index.d.ts +2 -1
  59. package/esm/hooks/index.js +2 -1
  60. package/esm/hooks/useBrush.d.ts +18 -0
  61. package/esm/hooks/useBrush.js +16 -0
  62. package/esm/index.d.ts +2 -1
  63. package/esm/index.js +2 -1
  64. package/esm/internals/domUtils.d.ts +9 -4
  65. package/esm/internals/domUtils.js +115 -52
  66. package/esm/internals/index.d.ts +1 -0
  67. package/esm/internals/index.js +1 -0
  68. package/esm/internals/plugins/allPlugins.d.ts +4 -3
  69. package/esm/internals/plugins/allPlugins.js +2 -1
  70. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
  71. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
  72. package/esm/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
  73. package/esm/internals/plugins/featurePlugins/useChartBrush/index.js +3 -0
  74. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
  75. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +109 -0
  76. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
  77. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +75 -0
  78. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
  79. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  80. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  81. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
  82. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
  83. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
  84. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  85. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
  86. package/esm/internals/plugins/utils/selectors.d.ts +1 -1
  87. package/esm/locales/elGR.js +97 -99
  88. package/esm/tests/constants.js +1 -0
  89. package/hooks/index.d.ts +2 -1
  90. package/hooks/index.js +12 -0
  91. package/hooks/useBrush.d.ts +18 -0
  92. package/hooks/useBrush.js +21 -0
  93. package/index.d.ts +2 -1
  94. package/index.js +13 -1
  95. package/internals/domUtils.d.ts +9 -4
  96. package/internals/domUtils.js +119 -54
  97. package/internals/index.d.ts +1 -0
  98. package/internals/index.js +12 -0
  99. package/internals/plugins/allPlugins.d.ts +4 -3
  100. package/internals/plugins/allPlugins.js +2 -1
  101. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
  102. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
  103. package/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
  104. package/internals/plugins/featurePlugins/useChartBrush/index.js +38 -0
  105. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
  106. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +117 -0
  107. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
  108. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +82 -0
  109. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
  110. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +5 -0
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
  115. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  117. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
  118. package/internals/plugins/utils/selectors.d.ts +1 -1
  119. package/locales/elGR.js +97 -99
  120. package/package.json +3 -3
  121. package/tests/constants.js +7 -0
  122. package/esm/internals/Flatbush.bench.js +0 -42
  123. package/internals/Flatbush.bench.d.ts +0 -1
  124. package/internals/Flatbush.bench.js +0 -44
  125. /package/esm/internals/{Flatbush.bench.d.ts → plugins/featurePlugins/useChartBrush/useChartBrush.types.js} +0 -0
@@ -101,6 +101,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
101
101
  * Defines the border radius of the bar element.
102
102
  */
103
103
  borderRadius: _propTypes.default.number,
104
+ /**
105
+ * Configuration for the brush interaction.
106
+ */
107
+ brushConfig: _propTypes.default.shape({
108
+ enabled: _propTypes.default.bool,
109
+ preventHighlight: _propTypes.default.bool,
110
+ preventTooltip: _propTypes.default.bool
111
+ }),
104
112
  children: _propTypes.default.node,
105
113
  className: _propTypes.default.string,
106
114
  /**
@@ -4,5 +4,6 @@ import { UseChartInteractionSignature } from "../internals/plugins/featurePlugin
4
4
  import { UseChartHighlightSignature } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
5
5
  import { UseChartKeyboardNavigationSignature } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
6
6
  import { ConvertSignaturesIntoPlugins } from "../internals/plugins/models/helpers.js";
7
- export type BarChartPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'bar'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature];
7
+ import { UseChartBrushSignature } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
8
+ export type BarChartPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<'bar'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature];
8
9
  export declare const BAR_CHART_PLUGINS: ConvertSignaturesIntoPlugins<BarChartPluginSignatures>;
@@ -9,4 +9,5 @@ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useCha
9
9
  var _useChartInteraction = require("../internals/plugins/featurePlugins/useChartInteraction");
10
10
  var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
11
11
  var _useChartKeyboardNavigation = require("../internals/plugins/featurePlugins/useChartKeyboardNavigation");
12
- const BAR_CHART_PLUGINS = exports.BAR_CHART_PLUGINS = [_useChartZAxis.useChartZAxis, _useChartCartesianAxis.useChartCartesianAxis, _useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight, _useChartKeyboardNavigation.useChartKeyboardNavigation];
12
+ var _useChartBrush = require("../internals/plugins/featurePlugins/useChartBrush");
13
+ const BAR_CHART_PLUGINS = exports.BAR_CHART_PLUGINS = [_useChartZAxis.useChartZAxis, _useChartBrush.useChartBrush, _useChartCartesianAxis.useChartCartesianAxis, _useChartInteraction.useChartInteraction, _useChartHighlight.useChartHighlight, _useChartKeyboardNavigation.useChartKeyboardNavigation];
@@ -13,7 +13,7 @@ var React = _interopRequireWildcard(require("react"));
13
13
  var _useId = _interopRequireDefault(require("@mui/utils/useId"));
14
14
  var _constants = require("../constants");
15
15
  var _BarChart = require("./BarChart.plugins");
16
- const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar"];
16
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar", "brushConfig"];
17
17
  /**
18
18
  * A helper function that extracts BarChartProps from the input props
19
19
  * and returns an object with props for the children components of BarChart.
@@ -45,7 +45,8 @@ const useBarChartProps = props => {
45
45
  onHighlightChange,
46
46
  borderRadius,
47
47
  barLabel,
48
- className
48
+ className,
49
+ brushConfig
49
50
  } = props,
50
51
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
51
52
  const id = (0, _useId.default)();
@@ -102,6 +103,7 @@ const useBarChartProps = props => {
102
103
  disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
103
104
  className,
104
105
  skipAnimation,
106
+ brushConfig,
105
107
  plugins: _BarChart.BAR_CHART_PLUGINS
106
108
  });
107
109
  const barPlotProps = {
package/CHANGELOG.md CHANGED
@@ -5,6 +5,113 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.15.0
9
+
10
+ _Oct 23, 2025_
11
+
12
+ We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 🖌️ Add new [`brush` charts interaction](https://mui.com/x/react-charts/brush/) for building custom behavior.
15
+ ![brush visualization example](https://github.com/user-attachments/assets/60c382a1-e418-4736-8dcb-1567c4e361e3)
16
+ - ⚡️ Performance improvements for large bar charts
17
+ - 🤖 Data Grid AI assistant can now [visualize the query results](https://mui.com/x/react-data-grid/ai-assistant/#data-visualization) by controlling the chart integration settings
18
+ - 📦 DataGrid uses an internal MUI fork of ExcelJS that does not depend on vulnerable versions of NPM packages
19
+ - 🐞 Bugfixes
20
+ - 📚 Documentation improvements
21
+
22
+ Special thanks go out to the community members for their valuable contributions:
23
+ @ZagrebaAlex
24
+
25
+ The following are all team members who have contributed to this release:
26
+ @alexfauquette, @bernardobelchior, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @KenanYusuf, @prakhargupta1, @rita-codes, @siriwatknp, @arminmeh, @brijeshb42, @noraleonte
27
+
28
+ ### Data Grid
29
+
30
+ #### `@mui/x-data-grid@8.15.0`
31
+
32
+ - [DataGrid] Fix `dataSource.fetchRows` API's return type (#20068) @arminmeh
33
+
34
+ #### `@mui/x-data-grid-pro@8.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
35
+
36
+ Same changes as in `@mui/x-data-grid@8.15.0`, plus:
37
+
38
+ - [DataGridPro] Keep children in the tree after parent row is re-fetched with the data source (#19934) @arminmeh
39
+ - [DataGridPro] Support scroll shadows customization (#19982) @KenanYusuf
40
+
41
+ #### `@mui/x-data-grid-premium@8.15.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
42
+
43
+ Same changes as in `@mui/x-data-grid-pro@8.15.0`, plus:
44
+
45
+ - [DataGridPremium] Use ExcelJS fork (#19796) @cherniavskii
46
+ - [DataGridPremium] Support data visualization in AI Assistant (#19831) @arminmeh
47
+
48
+ ### Date and Time Pickers
49
+
50
+ #### `@mui/x-date-pickers@8.15.0`
51
+
52
+ Internal changes.
53
+
54
+ #### `@mui/x-date-pickers-pro@8.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
55
+
56
+ Same changes as in `@mui/x-date-pickers@8.15.0`.
57
+
58
+ ### Charts
59
+
60
+ #### `@mui/x-charts@8.15.0`
61
+
62
+ - [charts] Add `ChartsBrushOverlay` and allow brush configuration (#19956) @JCQuintas
63
+ - [charts] Add `getStringSize` benchmark. Remove benchmarks from built package. (#19995) @bernardobelchior
64
+ - [charts] Batch string size measurement (#19994) @bernardobelchior
65
+ - [charts] Fix console issue (#20025) @JCQuintas
66
+ - [charts] Fix is[ZoomFeature]Enabled type (#20058) @alexfauquette
67
+ - [charts] Fix reference line middle spacing (#20004) @JCQuintas
68
+ - [charts] Improve `getStringSize` and `batchMeasureStrings` performance (#19996) @bernardobelchior
69
+ - [charts] Improve deep export script (#20007) @JCQuintas
70
+ - [charts] Improve string measurement benchmarks (#19999) @bernardobelchior
71
+ - [charts] Measure string sizes using SVG elements (#19981) @bernardobelchior
72
+ - [l10n] Improve Greek (gr-GR) locale (#20060) @ZagrebaAlex
73
+
74
+ #### `@mui/x-charts-pro@8.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
75
+
76
+ Same changes as in `@mui/x-charts@8.15.0`, plus:
77
+
78
+ - [charts-pro] Fix pan with `axis.reverse` (#20031) @JCQuintas
79
+
80
+ #### `@mui/x-charts-premium@8.15.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
81
+
82
+ Same changes as in `@mui/x-charts-pro@8.15.0`.
83
+
84
+ ### Tree View
85
+
86
+ #### `@mui/x-tree-view@8.15.0`
87
+
88
+ - [tree view] Multi character type-ahead (#19942) @noraleonte
89
+
90
+ #### `@mui/x-tree-view-pro@8.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
91
+
92
+ Same changes as in `@mui/x-tree-view@8.15.0`.
93
+
94
+ ### Codemod
95
+
96
+ #### `@mui/x-codemod@8.14.0`
97
+
98
+ Internal changes.
99
+
100
+ ### Docs
101
+
102
+ - [docs] Add overview section for scatter chart and heatmap (#19888) @prakhargupta1
103
+ - [docs] Add charts bell curve example (#20003) @JCQuintas
104
+ - [docs] Add grouped multiple fields for Data Grid row grouping recipe (#19964) @siriwatknp
105
+ - [docs] Add Data Grid loading state recipe (#19958) @siriwatknp
106
+
107
+ ### Core
108
+
109
+ - [code-infra] Remove @mui/monorepo usage for react versioning (#19894) @Janpot
110
+ - [code-infra] Remove invalid `environment: 'browser'` from vitest browser config (#19993) @bernardobelchior
111
+ - [code-infra] Remove unused babel aliases (#19987) @Janpot
112
+ - [code-infra] Turn on all testing-library eslint rules (#19946) @brijeshb42
113
+ - [docs-infra] Fix broken hash link (#20062) @Janpot
114
+
8
115
  ## 8.14.1
9
116
 
10
117
  _Oct 16, 2025_
@@ -61,6 +61,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
61
61
  apiRef: _propTypes.default.shape({
62
62
  current: _propTypes.default.object
63
63
  }),
64
+ /**
65
+ * Configuration for the brush interaction.
66
+ */
67
+ brushConfig: _propTypes.default.shape({
68
+ enabled: _propTypes.default.bool,
69
+ preventHighlight: _propTypes.default.bool,
70
+ preventTooltip: _propTypes.default.bool
71
+ }),
64
72
  children: _propTypes.default.node,
65
73
  className: _propTypes.default.string,
66
74
  /**
@@ -9,7 +9,7 @@ exports.useChartContainerProps = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
11
  var _allPlugins = require("../internals/plugins/allPlugins");
12
- const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "highlightedAxis", "onHighlightedAxisChange", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText", "slots", "slotProps", "experimentalFeatures", "enableKeyboardNavigation"];
12
+ const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "highlightedAxis", "onHighlightedAxisChange", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText", "slots", "slotProps", "experimentalFeatures", "enableKeyboardNavigation", "brushConfig"];
13
13
  const useChartContainerProps = (props, ref) => {
14
14
  const _ref = props,
15
15
  {
@@ -44,7 +44,8 @@ const useChartContainerProps = (props, ref) => {
44
44
  slots,
45
45
  slotProps,
46
46
  experimentalFeatures,
47
- enableKeyboardNavigation
47
+ enableKeyboardNavigation,
48
+ brushConfig
48
49
  } = _ref,
49
50
  other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
50
51
  const chartsSurfaceProps = (0, _extends2.default)({
@@ -79,6 +80,7 @@ const useChartContainerProps = (props, ref) => {
79
80
  seriesConfig,
80
81
  experimentalFeatures,
81
82
  enableKeyboardNavigation,
83
+ brushConfig,
82
84
  plugins: plugins ?? _allPlugins.DEFAULT_PLUGINS,
83
85
  slots,
84
86
  slotProps
@@ -0,0 +1,12 @@
1
+ export interface BrushOverlayClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ /** Styles applied to the brush lines. */
5
+ rect: string;
6
+ /** Styles applied when the brush is selecting the x axis. */
7
+ x: string;
8
+ /** Styles applied when the brush is selecting the y axis. */
9
+ y: string;
10
+ }
11
+ export type BrushOverlayClassKey = keyof BrushOverlayClasses;
12
+ export declare const brushOverlayClasses: BrushOverlayClasses;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.brushOverlayClasses = void 0;
8
+ var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
9
+ const brushOverlayClasses = exports.brushOverlayClasses = (0, _generateUtilityClasses.default)('MuiChartsBrushOverlay', ['root', 'rect', 'x', 'y']);
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export interface ChartsBrushOverlayProps {}
3
+ /**
4
+ * Component that renders visual feedback during brush interaction
5
+ */
6
+ export declare function ChartsBrushOverlay(props: ChartsBrushOverlayProps): React.JSX.Element | null;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsBrushOverlay = ChartsBrushOverlay;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _clsx = _interopRequireDefault(require("clsx"));
13
+ var _styles = require("@mui/material/styles");
14
+ var _ChartsBrushOverlay = require("./ChartsBrushOverlay.classes");
15
+ var _useChartDimensions = require("../internals/plugins/corePlugins/useChartDimensions");
16
+ var _useChartBrush = require("../internals/plugins/featurePlugins/useChartBrush");
17
+ var _useSelector = require("../internals/store/useSelector");
18
+ var _useStore = require("../internals/store/useStore");
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ function BrushRect(props) {
21
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({
22
+ className: _ChartsBrushOverlay.brushOverlayClasses.rect,
23
+ strokeWidth: 1,
24
+ fillOpacity: 0.2,
25
+ pointerEvents: 'none'
26
+ }, props));
27
+ }
28
+ /**
29
+ * Component that renders visual feedback during brush interaction
30
+ */
31
+ function ChartsBrushOverlay(props) {
32
+ const store = (0, _useStore.useStore)();
33
+ const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
34
+ const theme = (0, _styles.useTheme)();
35
+ const brushStartX = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushStartX);
36
+ const brushStartY = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushStartY);
37
+ const brushCurrentX = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushCurrentX);
38
+ const brushCurrentY = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushCurrentY);
39
+ const brushConfig = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushConfig);
40
+ if (brushStartX === null || brushStartY === null || brushCurrentX === null || brushCurrentY === null) {
41
+ return null;
42
+ }
43
+ const {
44
+ left,
45
+ top,
46
+ width,
47
+ height
48
+ } = drawingArea;
49
+
50
+ // Clamp coordinates to drawing area
51
+ const clampX = x => Math.max(left, Math.min(left + width, x));
52
+ const clampY = y => Math.max(top, Math.min(top + height, y));
53
+ const startX = clampX(brushStartX);
54
+ const startY = clampY(brushStartY);
55
+ const currentX = clampX(brushCurrentX);
56
+ const currentY = clampY(brushCurrentY);
57
+ const rectColor = theme.palette.mode === 'light' ? theme.palette.common.black : theme.palette.common.white;
58
+
59
+ // For scatter charts, show only the rectangle without guide lines
60
+ if (brushConfig === 'xy') {
61
+ const rectWidth = currentX - startX;
62
+ const rectHeight = currentY - startY;
63
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
64
+ className: (0, _clsx.default)(_ChartsBrushOverlay.brushOverlayClasses.root, _ChartsBrushOverlay.brushOverlayClasses.x, _ChartsBrushOverlay.brushOverlayClasses.y),
65
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrushRect, (0, _extends2.default)({
66
+ fill: rectColor,
67
+ x: rectWidth >= 0 ? startX : currentX,
68
+ y: rectHeight >= 0 ? startY : currentY,
69
+ width: Math.abs(rectWidth),
70
+ height: Math.abs(rectHeight)
71
+ }, props))
72
+ });
73
+ }
74
+ if (brushConfig === 'y') {
75
+ const minY = Math.min(startY, currentY);
76
+ const maxY = Math.max(startY, currentY);
77
+ const rectHeight = maxY - minY;
78
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
79
+ className: (0, _clsx.default)(_ChartsBrushOverlay.brushOverlayClasses.root, _ChartsBrushOverlay.brushOverlayClasses.y),
80
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrushRect, (0, _extends2.default)({
81
+ fill: rectColor,
82
+ x: left,
83
+ y: minY,
84
+ width: width,
85
+ height: rectHeight
86
+ }, props))
87
+ });
88
+ }
89
+ const minX = Math.min(startX, currentX);
90
+ const maxX = Math.max(startX, currentX);
91
+ const rectWidth = maxX - minX;
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
93
+ className: (0, _clsx.default)(_ChartsBrushOverlay.brushOverlayClasses.root, _ChartsBrushOverlay.brushOverlayClasses.x),
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrushRect, (0, _extends2.default)({
95
+ fill: rectColor,
96
+ x: minX,
97
+ y: top,
98
+ width: rectWidth,
99
+ height: height
100
+ }, props))
101
+ });
102
+ }
@@ -0,0 +1,4 @@
1
+ export { ChartsBrushOverlay } from "./ChartsBrushOverlay.js";
2
+ export type { ChartsBrushOverlayProps } from "./ChartsBrushOverlay.js";
3
+ export { brushOverlayClasses } from "./ChartsBrushOverlay.classes.js";
4
+ export type { BrushOverlayClasses, BrushOverlayClassKey } from "./ChartsBrushOverlay.classes.js";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ChartsBrushOverlay", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ChartsBrushOverlay.ChartsBrushOverlay;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "brushOverlayClasses", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _ChartsBrushOverlay2.brushOverlayClasses;
16
+ }
17
+ });
18
+ var _ChartsBrushOverlay = require("./ChartsBrushOverlay");
19
+ var _ChartsBrushOverlay2 = require("./ChartsBrushOverlay.classes");
@@ -63,7 +63,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
63
63
  /**
64
64
  * Additional space around the label in px.
65
65
  * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
66
- * @default 5
66
+ * @default { x: 0, y: 5 } on a horizontal line and { x: 5, y: 0 } on a vertical line.
67
67
  */
68
68
  spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
69
69
  x: _propTypes.default.number,
@@ -21,12 +21,17 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
  const getTextParams = ({
22
22
  top,
23
23
  height,
24
- spacingY,
24
+ spacing,
25
+ position,
25
26
  labelAlign = 'middle'
26
27
  }) => {
28
+ const defaultSpacingOtherAxis = labelAlign === 'middle' ? _common.DEFAULT_SPACING_MIDDLE_OTHER_AXIS : _common.DEFAULT_SPACING;
29
+ const spacingX = (typeof spacing === 'object' ? spacing.x : spacing) ?? _common.DEFAULT_SPACING;
30
+ const spacingY = (typeof spacing === 'object' ? spacing.y : defaultSpacingOtherAxis) ?? defaultSpacingOtherAxis;
27
31
  switch (labelAlign) {
28
32
  case 'start':
29
33
  return {
34
+ x: position + spacingX,
30
35
  y: top + spacingY,
31
36
  style: {
32
37
  dominantBaseline: 'hanging',
@@ -35,6 +40,7 @@ const getTextParams = ({
35
40
  };
36
41
  case 'end':
37
42
  return {
43
+ x: position + spacingX,
38
44
  y: top + height - spacingY,
39
45
  style: {
40
46
  dominantBaseline: 'auto',
@@ -43,7 +49,8 @@ const getTextParams = ({
43
49
  };
44
50
  default:
45
51
  return {
46
- y: top + height / 2,
52
+ x: position + spacingX,
53
+ y: top + height / 2 + spacingY,
47
54
  style: {
48
55
  dominantBaseline: 'central',
49
56
  textAnchor: 'start'
@@ -62,9 +69,9 @@ function ChartsXReferenceLine(props) {
62
69
  const {
63
70
  x,
64
71
  label = '',
65
- spacing = 5,
72
+ spacing,
66
73
  classes: inClasses,
67
- labelAlign,
74
+ labelAlign = 'middle',
68
75
  lineStyle,
69
76
  labelStyle,
70
77
  axisId
@@ -83,16 +90,14 @@ function ChartsXReferenceLine(props) {
83
90
  }
84
91
  const d = `M ${xPosition} ${top} l 0 ${height}`;
85
92
  const classes = getXReferenceLineClasses(inClasses);
86
- const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
87
- const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
88
93
  const textParams = (0, _extends2.default)({
89
- x: xPosition + spacingX,
90
94
  text: label,
91
95
  fontSize: 12
92
96
  }, getTextParams({
93
97
  top,
94
98
  height,
95
- spacingY,
99
+ spacing,
100
+ position: xPosition,
96
101
  labelAlign
97
102
  }), {
98
103
  className: classes.label
@@ -21,12 +21,17 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
  const getTextParams = ({
22
22
  left,
23
23
  width,
24
- spacingX,
24
+ spacing,
25
+ position,
25
26
  labelAlign = 'middle'
26
27
  }) => {
28
+ const defaultSpacingOtherAxis = labelAlign === 'middle' ? _common.DEFAULT_SPACING_MIDDLE_OTHER_AXIS : _common.DEFAULT_SPACING;
29
+ const spacingX = (typeof spacing === 'object' ? spacing.x : defaultSpacingOtherAxis) ?? defaultSpacingOtherAxis;
30
+ const spacingY = (typeof spacing === 'object' ? spacing.y : spacing) ?? _common.DEFAULT_SPACING;
27
31
  switch (labelAlign) {
28
32
  case 'start':
29
33
  return {
34
+ y: position - spacingY,
30
35
  x: left + spacingX,
31
36
  style: {
32
37
  dominantBaseline: 'auto',
@@ -35,6 +40,7 @@ const getTextParams = ({
35
40
  };
36
41
  case 'end':
37
42
  return {
43
+ y: position - spacingY,
38
44
  x: left + width - spacingX,
39
45
  style: {
40
46
  dominantBaseline: 'auto',
@@ -43,7 +49,8 @@ const getTextParams = ({
43
49
  };
44
50
  default:
45
51
  return {
46
- x: left + width / 2,
52
+ y: position - spacingY,
53
+ x: left + width / 2 + spacingX,
47
54
  style: {
48
55
  dominantBaseline: 'auto',
49
56
  textAnchor: 'middle'
@@ -62,9 +69,9 @@ function ChartsYReferenceLine(props) {
62
69
  const {
63
70
  y,
64
71
  label = '',
65
- spacing = 5,
72
+ spacing,
66
73
  classes: inClasses,
67
- labelAlign,
74
+ labelAlign = 'middle',
68
75
  lineStyle,
69
76
  labelStyle,
70
77
  axisId
@@ -83,16 +90,14 @@ function ChartsYReferenceLine(props) {
83
90
  }
84
91
  const d = `M ${left} ${yPosition} l ${width} 0`;
85
92
  const classes = getYReferenceLineClasses(inClasses);
86
- const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
87
- const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
88
93
  const textParams = (0, _extends2.default)({
89
- y: yPosition - spacingY,
90
94
  text: label,
91
95
  fontSize: 12
92
96
  }, getTextParams({
93
97
  left,
94
98
  width,
95
- spacingX,
99
+ spacing,
100
+ position: yPosition,
96
101
  labelAlign
97
102
  }), {
98
103
  className: classes.label
@@ -1,6 +1,8 @@
1
1
  import { ChartsReferenceLineClasses } from "./chartsReferenceLineClasses.js";
2
2
  import { ChartsTextStyle } from "../ChartsText/index.js";
3
3
  import { AxisId } from "../models/axis.js";
4
+ export declare const DEFAULT_SPACING = 5;
5
+ export declare const DEFAULT_SPACING_MIDDLE_OTHER_AXIS = 0;
4
6
  export type CommonChartsReferenceLineProps = {
5
7
  /**
6
8
  * The alignment if the label is in the chart drawing area.
@@ -14,7 +16,7 @@ export type CommonChartsReferenceLineProps = {
14
16
  /**
15
17
  * Additional space around the label in px.
16
18
  * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
17
- * @default 5
19
+ * @default { x: 0, y: 5 } on a horizontal line and { x: 5, y: 0 } on a vertical line.
18
20
  */
19
21
  spacing?: number | {
20
22
  x?: number;
@@ -4,10 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ReferenceLineRoot = void 0;
7
+ exports.ReferenceLineRoot = exports.DEFAULT_SPACING_MIDDLE_OTHER_AXIS = exports.DEFAULT_SPACING = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _styles = require("@mui/material/styles");
10
10
  var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
11
+ const DEFAULT_SPACING = exports.DEFAULT_SPACING = 5;
12
+ const DEFAULT_SPACING_MIDDLE_OTHER_AXIS = exports.DEFAULT_SPACING_MIDDLE_OTHER_AXIS = 0;
11
13
  const ReferenceLineRoot = exports.ReferenceLineRoot = (0, _styles.styled)('g')(({
12
14
  theme
13
15
  }) => ({
@@ -26,9 +26,11 @@ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useCha
26
26
  var _useChartPolarInteraction = require("../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors");
27
27
  var _useAxisSystem = require("../hooks/useAxisSystem");
28
28
  var _hooks = require("../hooks");
29
+ var _useChartBrush = require("../internals/plugins/featurePlugins/useChartBrush");
30
+ var _selectors = require("../internals/plugins/utils/selectors");
29
31
  var _jsxRuntime = require("react/jsx-runtime");
30
32
  const _excluded = ["trigger", "classes", "children"];
31
- const noAxis = () => false;
33
+ const selectorReturnFalse = () => false;
32
34
  const ChartsTooltipRoot = (0, _styles.styled)(_Popper.default, {
33
35
  name: 'MuiChartsTooltip',
34
36
  slot: 'Root'
@@ -38,6 +40,21 @@ const ChartsTooltipRoot = (0, _styles.styled)(_Popper.default, {
38
40
  pointerEvents: 'none',
39
41
  zIndex: theme.zIndex.modal
40
42
  }));
43
+ const selectorSelectIsOpenSelector = (0, _selectors.createSelector)([_useChartBrush.selectorBrushShouldPreventTooltip, (_, trigger) => trigger, (_, __, axisSystem) => axisSystem], (shouldPreventBecauseOfBrush, trigger, axisSystem) => {
44
+ if (shouldPreventBecauseOfBrush) {
45
+ return selectorReturnFalse;
46
+ }
47
+ if (trigger === 'item') {
48
+ return _useChartInteraction.selectorChartsInteractionItemIsDefined;
49
+ }
50
+ if (axisSystem === 'polar') {
51
+ return _useChartPolarInteraction.selectorChartsInteractionPolarAxisTooltip;
52
+ }
53
+ if (axisSystem === 'cartesian') {
54
+ return _useChartCartesianAxis.selectorChartsInteractionAxisTooltip;
55
+ }
56
+ return selectorReturnFalse;
57
+ });
41
58
 
42
59
  /**
43
60
  * Demos:
@@ -70,7 +87,8 @@ function ChartsTooltipContainer(inProps) {
70
87
  }));
71
88
  const axisSystem = (0, _useAxisSystem.useAxisSystem)();
72
89
  const store = (0, _useStore.useStore)();
73
- const isOpen = (0, _useSelector.useSelector)(store, trigger === 'axis' ? axisSystem === 'polar' && _useChartPolarInteraction.selectorChartsInteractionPolarAxisTooltip || axisSystem === 'cartesian' && _useChartCartesianAxis.selectorChartsInteractionAxisTooltip || noAxis : _useChartInteraction.selectorChartsInteractionItemIsDefined);
90
+ const isOpenSelector = (0, _useSelector.useSelector)(store, selectorSelectIsOpenSelector, [trigger, axisSystem]);
91
+ const isOpen = (0, _useSelector.useSelector)(store, isOpenSelector);
74
92
  React.useEffect(() => {
75
93
  const element = svgRef.current;
76
94
  if (element === null) {