@mui/x-charts-pro 7.22.3 → 8.0.0-alpha.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 (73) hide show
  1. package/BarChartPro/BarChartPro.d.ts +1 -1
  2. package/BarChartPro/BarChartPro.js +9 -59
  3. package/CHANGELOG.md +348 -12
  4. package/ChartContainerPro/ChartContainerPro.d.ts +1 -1
  5. package/ChartContainerPro/ChartContainerPro.js +21 -47
  6. package/ChartContainerPro/useChartContainerProProps.d.ts +6 -14
  7. package/ChartContainerPro/useChartContainerProProps.js +11 -25
  8. package/Heatmap/Heatmap.d.ts +16 -8
  9. package/Heatmap/Heatmap.js +6 -37
  10. package/Heatmap/HeatmapTooltip.d.ts +9 -0
  11. package/Heatmap/HeatmapTooltip.js +294 -0
  12. package/Heatmap/index.d.ts +1 -1
  13. package/Heatmap/index.js +1 -1
  14. package/LineChartPro/LineChartPro.d.ts +1 -1
  15. package/LineChartPro/LineChartPro.js +9 -60
  16. package/README.md +4 -4
  17. package/ScatterChartPro/ScatterChartPro.d.ts +1 -1
  18. package/ScatterChartPro/ScatterChartPro.js +9 -60
  19. package/context/ChartDataProviderPro/ChartDataProviderPro.d.ts +10 -0
  20. package/{modern/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js → context/ChartDataProviderPro/ChartDataProviderPro.js} +50 -33
  21. package/context/ChartDataProviderPro/index.d.ts +1 -0
  22. package/context/ChartDataProviderPro/index.js +1 -0
  23. package/context/ChartDataProviderPro/useChartDataProviderProProps.d.ts +14 -0
  24. package/context/ChartDataProviderPro/useChartDataProviderProProps.js +43 -0
  25. package/context/ZoomProvider/ZoomProvider.js +1 -0
  26. package/index.d.ts +0 -1
  27. package/index.js +1 -2
  28. package/internals/utils/releaseInfo.js +1 -1
  29. package/models/seriesType/heatmap.d.ts +2 -1
  30. package/modern/BarChartPro/BarChartPro.js +9 -59
  31. package/modern/ChartContainerPro/ChartContainerPro.js +21 -47
  32. package/modern/ChartContainerPro/useChartContainerProProps.js +11 -25
  33. package/modern/Heatmap/Heatmap.js +6 -37
  34. package/modern/Heatmap/HeatmapTooltip.js +294 -0
  35. package/modern/Heatmap/index.js +1 -1
  36. package/modern/LineChartPro/LineChartPro.js +9 -60
  37. package/modern/ScatterChartPro/ScatterChartPro.js +9 -60
  38. package/{ResponsiveChartContainerPro/ResponsiveChartContainerPro.js → modern/context/ChartDataProviderPro/ChartDataProviderPro.js} +50 -33
  39. package/modern/context/ChartDataProviderPro/index.js +1 -0
  40. package/modern/context/ChartDataProviderPro/useChartDataProviderProProps.js +43 -0
  41. package/modern/context/ZoomProvider/ZoomProvider.js +1 -0
  42. package/modern/index.js +1 -2
  43. package/modern/internals/utils/releaseInfo.js +1 -1
  44. package/node/BarChartPro/BarChartPro.js +9 -59
  45. package/node/ChartContainerPro/ChartContainerPro.js +20 -46
  46. package/node/ChartContainerPro/useChartContainerProProps.js +11 -25
  47. package/node/Heatmap/Heatmap.js +6 -37
  48. package/node/Heatmap/HeatmapTooltip.js +300 -0
  49. package/node/Heatmap/index.js +4 -4
  50. package/node/LineChartPro/LineChartPro.js +9 -60
  51. package/node/ScatterChartPro/ScatterChartPro.js +9 -60
  52. package/node/{ResponsiveChartContainerPro/ResponsiveChartContainerPro.js → context/ChartDataProviderPro/ChartDataProviderPro.js} +48 -31
  53. package/node/context/ChartDataProviderPro/index.js +16 -0
  54. package/node/context/ChartDataProviderPro/useChartDataProviderProProps.js +50 -0
  55. package/node/context/ZoomProvider/ZoomProvider.js +1 -0
  56. package/node/index.js +1 -12
  57. package/node/internals/utils/releaseInfo.js +1 -1
  58. package/package.json +8 -8
  59. package/typeOverloads/modules.d.ts +1 -1
  60. package/Heatmap/DefaultHeatmapTooltip.d.ts +0 -7
  61. package/Heatmap/DefaultHeatmapTooltip.js +0 -99
  62. package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.d.ts +0 -7
  63. package/ResponsiveChartContainerPro/index.d.ts +0 -1
  64. package/ResponsiveChartContainerPro/index.js +0 -1
  65. package/ResponsiveChartContainerPro/package.json +0 -6
  66. package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.d.ts +0 -42
  67. package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +0 -27
  68. package/modern/Heatmap/DefaultHeatmapTooltip.js +0 -99
  69. package/modern/ResponsiveChartContainerPro/index.js +0 -1
  70. package/modern/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +0 -27
  71. package/node/Heatmap/DefaultHeatmapTooltip.js +0 -105
  72. package/node/ResponsiveChartContainerPro/index.js +0 -16
  73. package/node/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +0 -34
@@ -3,49 +3,29 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
7
- import { HighlightedProvider, ZAxisContextProvider } from '@mui/x-charts/context';
8
- import { ChartsAxesGradients, DrawingProvider, InteractionProvider, PluginProvider, SeriesProvider, AnimationProvider } from '@mui/x-charts/internals';
9
- import { useLicenseVerifier } from '@mui/x-license/useLicenseVerifier';
6
+ import { Watermark } from '@mui/x-license/Watermark';
7
+ import { ResizableContainer } from '@mui/x-charts/internals';
8
+ import { ChartsSurface } from '@mui/x-charts';
10
9
  import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
11
- import { CartesianProviderPro } from "../context/CartesianProviderPro/index.js";
12
- import { ZoomProvider } from "../context/ZoomProvider/index.js";
10
+ import { ChartDataProviderPro } from "../context/ChartDataProviderPro/index.js";
13
11
  import { useChartContainerProProps } from "./useChartContainerProProps.js";
14
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
13
  const releaseInfo = getReleaseInfo();
16
- const ChartContainerPro = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
14
+ const ChartContainerPro = /*#__PURE__*/React.forwardRef(function ChartContainerPro(props, ref) {
17
15
  const {
18
- zoomProviderProps,
19
- drawingProviderProps,
20
- seriesProviderProps,
21
- zAxisContextProps,
22
- highlightedProviderProps,
23
- cartesianProviderProps,
24
- chartsSurfaceProps,
25
- pluginProviderProps,
26
- animationProviderProps,
27
- children
16
+ chartDataProviderProProps,
17
+ children,
18
+ resizableContainerProps,
19
+ chartsSurfaceProps
28
20
  } = useChartContainerProProps(props, ref);
29
- useLicenseVerifier('x-charts-pro', releaseInfo);
30
- return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
31
- children: /*#__PURE__*/_jsx(AnimationProvider, _extends({}, animationProviderProps, {
32
- children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
33
- children: /*#__PURE__*/_jsx(ZoomProvider, _extends({}, zoomProviderProps, {
34
- children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
35
- children: /*#__PURE__*/_jsx(CartesianProviderPro, _extends({}, cartesianProviderProps, {
36
- children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
37
- children: /*#__PURE__*/_jsx(InteractionProvider, {
38
- children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
39
- children: /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
40
- children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
41
- }))
42
- }))
43
- })
44
- }))
45
- }))
46
- }))
47
- }))
48
- }))
21
+ return /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
22
+ children: /*#__PURE__*/_jsxs(ResizableContainer, _extends({}, resizableContainerProps, {
23
+ children: [/*#__PURE__*/_jsx(ChartsSurface, _extends({}, chartsSurfaceProps, {
24
+ children: children
25
+ })), /*#__PURE__*/_jsx(Watermark, {
26
+ packageName: "x-charts-pro",
27
+ releaseInfo: releaseInfo
28
+ })]
49
29
  }))
50
30
  }));
51
31
  });
@@ -73,9 +53,9 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
73
53
  */
74
54
  disableAxisListener: PropTypes.bool,
75
55
  /**
76
- * The height of the chart in px.
56
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
77
57
  */
78
- height: PropTypes.number.isRequired,
58
+ height: PropTypes.number,
79
59
  /**
80
60
  * The item currently highlighted. Turns highlighting into a controlled prop.
81
61
  */
@@ -125,16 +105,10 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
125
105
  skipAnimation: PropTypes.bool,
126
106
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
127
107
  title: PropTypes.string,
128
- viewBox: PropTypes.shape({
129
- height: PropTypes.number,
130
- width: PropTypes.number,
131
- x: PropTypes.number,
132
- y: PropTypes.number
133
- }),
134
108
  /**
135
- * The width of the chart in px.
109
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
136
110
  */
137
- width: PropTypes.number.isRequired,
111
+ width: PropTypes.number,
138
112
  /**
139
113
  * The configuration of the x-axes.
140
114
  * If not provided, a default axis config is used.
@@ -1,16 +1,8 @@
1
- import { ZoomProviderProps } from '../context/ZoomProvider';
1
+ import { UseChartContainerPropsReturnValue } from '@mui/x-charts/internals';
2
+ import * as React from 'react';
3
+ import type { ChartDataProviderProProps } from '../context/ChartDataProviderPro';
2
4
  import type { ChartContainerProProps } from './ChartContainerPro';
3
- export declare const useChartContainerProProps: (props: ChartContainerProProps, ref: React.ForwardedRef<unknown>) => {
4
- zoomProviderProps: Omit<ZoomProviderProps, "children">;
5
- children: import("react").ReactNode;
6
- drawingProviderProps: Omit<import("@mui/x-charts/internals").DrawingProviderProps, "children">;
7
- pluginProviderProps: Omit<import("@mui/x-charts/internals").PluginProviderProps, "children">;
8
- seriesProviderProps: Omit<import("@mui/x-charts/internals").SeriesProviderProps, "children">;
9
- cartesianProviderProps: Omit<import("@mui/x-charts/internals").CartesianProviderProps, "children">;
10
- zAxisContextProps: Omit<import("@mui/x-charts").ZAxisContextProviderProps, "children">;
11
- highlightedProviderProps: Omit<import("@mui/x-charts").HighlightedProviderProps, "children">;
12
- chartsSurfaceProps: import("@mui/x-charts").ChartsSurfaceProps & {
13
- ref: any;
14
- };
15
- animationProviderProps: Omit<import("@mui/x-charts/internals").AnimationProviderProps, "children">;
5
+ export type UseChartContainerProPropsReturnValue = Omit<UseChartContainerPropsReturnValue, 'chartDataProviderProps'> & {
6
+ chartDataProviderProProps: ChartDataProviderProProps;
16
7
  };
8
+ export declare const useChartContainerProProps: (props: ChartContainerProProps, ref: React.Ref<SVGSVGElement>) => UseChartContainerProPropsReturnValue;
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
5
  const _excluded = ["zoom", "onZoomChange"];
5
6
  import { useChartContainerProps } from '@mui/x-charts/internals';
@@ -9,35 +10,20 @@ export const useChartContainerProProps = (props, ref) => {
9
10
  onZoomChange
10
11
  } = props,
11
12
  baseProps = _objectWithoutPropertiesLoose(props, _excluded);
13
+ const chartDataProviderProProps = {
14
+ zoom,
15
+ onZoomChange
16
+ };
12
17
  const {
13
- children,
14
- drawingProviderProps,
15
- seriesProviderProps,
16
- cartesianProviderProps,
17
- zAxisContextProps,
18
- highlightedProviderProps,
18
+ chartDataProviderProps,
19
19
  chartsSurfaceProps,
20
- pluginProviderProps,
21
- animationProviderProps,
22
- xAxis,
23
- yAxis
20
+ resizableContainerProps,
21
+ children
24
22
  } = useChartContainerProps(baseProps, ref);
25
- const zoomProviderProps = {
26
- zoom,
27
- onZoomChange,
28
- xAxis,
29
- yAxis
30
- };
31
23
  return {
32
- zoomProviderProps,
33
- children,
34
- drawingProviderProps,
35
- pluginProviderProps,
36
- seriesProviderProps,
37
- cartesianProviderProps,
38
- zAxisContextProps,
39
- highlightedProviderProps,
24
+ chartDataProviderProProps: _extends({}, chartDataProviderProps, chartDataProviderProProps),
25
+ resizableContainerProps,
40
26
  chartsSurfaceProps,
41
- animationProviderProps
27
+ children
42
28
  };
43
29
  };
@@ -1,17 +1,25 @@
1
1
  import * as React from 'react';
2
+ import { MakeOptional } from '@mui/x-internals/types';
2
3
  import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
3
- import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '@mui/x-charts/ChartsTooltip';
4
- import { MakeOptional, ChartsAxisSlots, ChartsAxisSlotProps, ChartsXAxisProps, ChartsYAxisProps, AxisConfig } from '@mui/x-charts/internals';
4
+ import { ChartsTooltipProps } from '@mui/x-charts/ChartsTooltip';
5
+ import { ChartsAxisSlots, ChartsAxisSlotProps, ChartsXAxisProps, ChartsYAxisProps, AxisConfig } from '@mui/x-charts/internals';
5
6
  import { ChartsOnAxisClickHandlerProps } from '@mui/x-charts/ChartsOnAxisClickHandler';
6
7
  import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
7
- import { ResponsiveChartContainerProProps } from '../ResponsiveChartContainerPro';
8
+ import { ChartContainerProProps } from '../ChartContainerPro';
8
9
  import { HeatmapSeriesType } from '../models/seriesType/heatmap';
10
+ import { HeatmapTooltipProps } from './HeatmapTooltip';
9
11
  import { HeatmapItemSlotProps, HeatmapItemSlots } from './HeatmapItem';
10
- export interface HeatmapSlots extends ChartsAxisSlots, Omit<ChartsTooltipSlots<'heatmap'>, 'axisContent'>, ChartsOverlaySlots, HeatmapItemSlots {
12
+ export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots {
13
+ /**
14
+ * Custom component for the tooltip popper.
15
+ * @default ChartsTooltipRoot
16
+ */
17
+ tooltip?: React.ElementType<HeatmapTooltipProps>;
11
18
  }
12
- export interface HeatmapSlotProps extends ChartsAxisSlotProps, Omit<ChartsTooltipSlotProps<'heatmap'>, 'axisContent'>, ChartsOverlaySlotProps, HeatmapItemSlotProps {
19
+ export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps {
20
+ tooltip?: Partial<HeatmapTooltipProps>;
13
21
  }
14
- export interface HeatmapProps extends Omit<ResponsiveChartContainerProProps, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'zoom' | 'onZoomChange' | 'skipAnimation'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, ChartsOnAxisClickHandlerProps {
22
+ export interface HeatmapProps extends Omit<ChartContainerProProps, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'zoom' | 'onZoomChange' | 'skipAnimation'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, ChartsOnAxisClickHandlerProps {
15
23
  /**
16
24
  * The configuration of the x-axes.
17
25
  * If not provided, a default axis config is used.
@@ -33,7 +41,7 @@ export interface HeatmapProps extends Omit<ResponsiveChartContainerProProps, 'se
33
41
  * The configuration of the tooltip.
34
42
  * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
35
43
  */
36
- tooltip?: ChartsTooltipProps<'heatmap'>;
44
+ tooltip?: ChartsTooltipProps;
37
45
  /**
38
46
  * Overridable component slots.
39
47
  * @default {}
@@ -45,5 +53,5 @@ export interface HeatmapProps extends Omit<ResponsiveChartContainerProProps, 'se
45
53
  */
46
54
  slotProps?: HeatmapSlotProps;
47
55
  }
48
- declare const Heatmap: React.ForwardRefExoticComponent<HeatmapProps & React.RefAttributes<unknown>>;
56
+ declare const Heatmap: React.ForwardRefExoticComponent<HeatmapProps & React.RefAttributes<SVGSVGElement>>;
49
57
  export { Heatmap };
@@ -7,14 +7,13 @@ import { useThemeProps } from '@mui/material/styles';
7
7
  import useId from '@mui/utils/useId';
8
8
  import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
9
9
  import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
10
- import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
11
10
  import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
12
11
  import { ChartsOnAxisClickHandler } from '@mui/x-charts/ChartsOnAxisClickHandler';
13
12
  import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
14
- import { ResponsiveChartContainerPro } from "../ResponsiveChartContainerPro/index.js";
13
+ import { ChartContainerPro } from "../ChartContainerPro/index.js";
15
14
  import { HeatmapPlot } from "./HeatmapPlot.js";
16
15
  import { plugin as heatmapPlugin } from "./plugin.js";
17
- import { DefaultHeatmapTooltip } from "./DefaultHeatmapTooltip.js";
16
+ import { HeatmapTooltip } from "./HeatmapTooltip.js";
18
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
18
  // The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
20
19
  const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
@@ -34,7 +33,6 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
34
33
  colors,
35
34
  dataset,
36
35
  sx,
37
- tooltip,
38
36
  topAxis,
39
37
  leftAxis,
40
38
  rightAxis,
@@ -65,7 +63,8 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
65
63
  color: defaultColorMap
66
64
  }
67
65
  }], [zAxis]);
68
- return /*#__PURE__*/_jsxs(ResponsiveChartContainerPro, {
66
+ const Tooltip = props.slots?.tooltip ?? HeatmapTooltip;
67
+ return /*#__PURE__*/_jsxs(ChartContainerPro, {
69
68
  ref: ref,
70
69
  plugins: [heatmapPlugin],
71
70
  series: series.map(s => _extends({
@@ -102,14 +101,7 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
102
101
  bottomAxis: bottomAxis,
103
102
  slots: slots,
104
103
  slotProps: slotProps
105
- }), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({
106
- trigger: "item"
107
- }, tooltip, {
108
- slots: _extends({
109
- itemContent: DefaultHeatmapTooltip
110
- }, slots),
111
- slotProps: slotProps
112
- })), /*#__PURE__*/_jsx(ChartsClipPath, {
104
+ }), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
113
105
  id: clipPathId
114
106
  }), children]
115
107
  });
@@ -190,16 +182,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
190
182
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
191
183
  */
192
184
  onHighlightChange: PropTypes.func,
193
- /**
194
- * The chart will try to wait for the parent container to resolve its size
195
- * before it renders for the first time.
196
- *
197
- * This can be useful in some scenarios where the chart appear to grow after
198
- * the first render, like when used inside a grid.
199
- *
200
- * @default false
201
- */
202
- resolveSizeBeforeRender: PropTypes.bool,
203
185
  /**
204
186
  * Indicate which axis to display the right of the charts.
205
187
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -227,26 +209,13 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
227
209
  * The configuration of the tooltip.
228
210
  * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
229
211
  */
230
- tooltip: PropTypes.shape({
231
- axisContent: PropTypes.elementType,
232
- classes: PropTypes.object,
233
- itemContent: PropTypes.elementType,
234
- slotProps: PropTypes.object,
235
- slots: PropTypes.object,
236
- trigger: PropTypes.oneOf(['axis', 'item', 'none'])
237
- }),
212
+ tooltip: PropTypes.object,
238
213
  /**
239
214
  * Indicate which axis to display the top of the charts.
240
215
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
241
216
  * @default null
242
217
  */
243
218
  topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
244
- viewBox: PropTypes.shape({
245
- height: PropTypes.number,
246
- width: PropTypes.number,
247
- x: PropTypes.number,
248
- y: PropTypes.number
249
- }),
250
219
  /**
251
220
  * The width of the chart in px. If not defined, it takes the width of the parent element.
252
221
  */
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { ChartsTooltipContainerProps } from '@mui/x-charts/ChartsTooltip';
3
+ export interface HeatmapTooltipProps extends Omit<ChartsTooltipContainerProps, 'trigger' | 'children'> {
4
+ }
5
+ declare function HeatmapTooltip(props: HeatmapTooltipProps): React.JSX.Element;
6
+ declare namespace HeatmapTooltip {
7
+ var propTypes: any;
8
+ }
9
+ export { HeatmapTooltip };
@@ -0,0 +1,294 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import clsx from 'clsx';
7
+ import composeClasses from '@mui/utils/composeClasses';
8
+ import { ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipRow, ChartsTooltipCell, ChartsTooltipMark, useItemTooltip, getChartsTooltipUtilityClass, ChartsTooltipContainer } from '@mui/x-charts/ChartsTooltip';
9
+ import { useXAxis, useYAxis } from '@mui/x-charts/hooks';
10
+ import { getLabel } from '@mui/x-charts/internals';
11
+ import { useHeatmapSeries } from "../hooks/useSeries.js";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const useUtilityClasses = ownerState => {
14
+ const {
15
+ classes
16
+ } = ownerState;
17
+ const slots = {
18
+ root: ['root'],
19
+ paper: ['paper'],
20
+ table: ['table'],
21
+ row: ['row'],
22
+ cell: ['cell'],
23
+ mark: ['mark'],
24
+ markCell: ['markCell'],
25
+ labelCell: ['labelCell'],
26
+ valueCell: ['valueCell']
27
+ };
28
+ return composeClasses(slots, getChartsTooltipUtilityClass, classes);
29
+ };
30
+
31
+ /**
32
+ * @ignore - internal component.
33
+ */
34
+ function DefaultHeatmapTooltipContent(props) {
35
+ const {
36
+ classes
37
+ } = props;
38
+ const xAxis = useXAxis();
39
+ const yAxis = useYAxis();
40
+ const heatmapSeries = useHeatmapSeries();
41
+ const tooltipData = useItemTooltip();
42
+ if (!tooltipData || !heatmapSeries || heatmapSeries.seriesOrder.length === 0) {
43
+ return null;
44
+ }
45
+ const {
46
+ series,
47
+ seriesOrder
48
+ } = heatmapSeries;
49
+ const seriesId = seriesOrder[0];
50
+ const {
51
+ color,
52
+ value,
53
+ identifier
54
+ } = tooltipData;
55
+ const [xIndex, yIndex] = value;
56
+ const formattedX = xAxis.valueFormatter?.(xAxis.data[xIndex], {
57
+ location: 'tooltip'
58
+ }) ?? xAxis.data[xIndex].toLocaleString();
59
+ const formattedY = yAxis.valueFormatter?.(yAxis.data[yIndex], {
60
+ location: 'tooltip'
61
+ }) ?? yAxis.data[yIndex].toLocaleString();
62
+ const formattedValue = series[seriesId].valueFormatter(value, {
63
+ dataIndex: identifier.dataIndex
64
+ });
65
+ const seriesLabel = getLabel(series[seriesId].label, 'tooltip');
66
+ return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
67
+ className: classes?.paper,
68
+ children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
69
+ className: classes?.table,
70
+ children: [/*#__PURE__*/_jsx("thead", {
71
+ children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
72
+ className: classes?.row,
73
+ children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
74
+ className: classes?.cell,
75
+ children: formattedX
76
+ }), formattedX && formattedY && /*#__PURE__*/_jsx(ChartsTooltipCell, {}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
77
+ className: classes?.cell,
78
+ children: formattedY
79
+ })]
80
+ })
81
+ }), /*#__PURE__*/_jsx("tbody", {
82
+ children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
83
+ className: classes?.row,
84
+ children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
85
+ className: clsx(classes?.markCell, classes?.cell),
86
+ children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
87
+ color: color,
88
+ className: classes?.mark
89
+ })
90
+ }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
91
+ className: clsx(classes?.labelCell, classes?.cell),
92
+ children: seriesLabel
93
+ }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
94
+ className: clsx(classes?.valueCell, classes?.cell),
95
+ children: formattedValue
96
+ })]
97
+ })
98
+ })]
99
+ })
100
+ });
101
+ }
102
+ process.env.NODE_ENV !== "production" ? DefaultHeatmapTooltipContent.propTypes = {
103
+ // ----------------------------- Warning --------------------------------
104
+ // | These PropTypes are generated from the TypeScript type definitions |
105
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
106
+ // ----------------------------------------------------------------------
107
+ /**
108
+ * Override or extend the styles applied to the component.
109
+ */
110
+ classes: PropTypes.object
111
+ } : void 0;
112
+ function HeatmapTooltip(props) {
113
+ const classes = useUtilityClasses({
114
+ classes: props.classes
115
+ });
116
+ return /*#__PURE__*/_jsx(ChartsTooltipContainer, _extends({}, props, {
117
+ classes: classes,
118
+ trigger: "item",
119
+ children: /*#__PURE__*/_jsx(DefaultHeatmapTooltipContent, {
120
+ classes: classes
121
+ })
122
+ }));
123
+ }
124
+ process.env.NODE_ENV !== "production" ? HeatmapTooltip.propTypes = {
125
+ // ----------------------------- Warning --------------------------------
126
+ // | These PropTypes are generated from the TypeScript type definitions |
127
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
128
+ // ----------------------------------------------------------------------
129
+ /**
130
+ * An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
131
+ * or a function that returns either.
132
+ * It's used to set the position of the popper.
133
+ * The return value will passed as the reference object of the Popper instance.
134
+ */
135
+ anchorEl: PropTypes.oneOfType([(props, propName) => {
136
+ if (props[propName] == null) {
137
+ return new Error(`Prop '${propName}' is required but wasn't specified`);
138
+ }
139
+ if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
140
+ return new Error(`Expected prop '${propName}' to be of type Element`);
141
+ }
142
+ return null;
143
+ }, PropTypes.func, PropTypes.shape({
144
+ contextElement: (props, propName) => {
145
+ if (props[propName] == null) {
146
+ return null;
147
+ }
148
+ if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
149
+ return new Error(`Expected prop '${propName}' to be of type Element`);
150
+ }
151
+ return null;
152
+ },
153
+ getBoundingClientRect: PropTypes.func.isRequired
154
+ })]),
155
+ /**
156
+ * Override or extend the styles applied to the component.
157
+ */
158
+ classes: PropTypes.object,
159
+ /**
160
+ * The component used for the root node.
161
+ * Either a string to use a HTML element or a component.
162
+ */
163
+ component: PropTypes.elementType,
164
+ /**
165
+ * The components used for each slot inside the Popper.
166
+ * Either a string to use a HTML element or a component.
167
+ * @default {}
168
+ */
169
+ components: PropTypes.shape({
170
+ Root: PropTypes.elementType
171
+ }),
172
+ /**
173
+ * The props used for each slot inside the Popper.
174
+ * @default {}
175
+ */
176
+ componentsProps: PropTypes.shape({
177
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
178
+ }),
179
+ /**
180
+ * An HTML element or function that returns one.
181
+ * The `container` will have the portal children appended to it.
182
+ *
183
+ * You can also provide a callback, which is called in a React layout effect.
184
+ * This lets you set the container from a ref, and also makes server-side rendering possible.
185
+ *
186
+ * By default, it uses the body of the top-level document object,
187
+ * so it's simply `document.body` most of the time.
188
+ */
189
+ container: PropTypes.oneOfType([(props, propName) => {
190
+ if (props[propName] == null) {
191
+ return new Error(`Prop '${propName}' is required but wasn't specified`);
192
+ }
193
+ if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
194
+ return new Error(`Expected prop '${propName}' to be of type Element`);
195
+ }
196
+ return null;
197
+ }, PropTypes.func]),
198
+ /**
199
+ * The `children` will be under the DOM hierarchy of the parent component.
200
+ * @default false
201
+ */
202
+ disablePortal: PropTypes.bool,
203
+ /**
204
+ * Always keep the children in the DOM.
205
+ * This prop can be useful in SEO situation or
206
+ * when you want to maximize the responsiveness of the Popper.
207
+ * @default false
208
+ */
209
+ keepMounted: PropTypes.bool,
210
+ /**
211
+ * Popper.js is based on a "plugin-like" architecture,
212
+ * most of its features are fully encapsulated "modifiers".
213
+ *
214
+ * A modifier is a function that is called each time Popper.js needs to
215
+ * compute the position of the popper.
216
+ * For this reason, modifiers should be very performant to avoid bottlenecks.
217
+ * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
218
+ */
219
+ modifiers: PropTypes.arrayOf(PropTypes.shape({
220
+ data: PropTypes.object,
221
+ effect: PropTypes.func,
222
+ enabled: PropTypes.bool,
223
+ fn: PropTypes.func,
224
+ name: PropTypes.any,
225
+ options: PropTypes.object,
226
+ phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
227
+ requires: PropTypes.arrayOf(PropTypes.string),
228
+ requiresIfExists: PropTypes.arrayOf(PropTypes.string)
229
+ })),
230
+ /**
231
+ * If `true`, the component is shown.
232
+ */
233
+ open: PropTypes.bool,
234
+ /**
235
+ * Popper placement.
236
+ * @default 'bottom'
237
+ */
238
+ placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
239
+ /**
240
+ * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
241
+ * @default {}
242
+ */
243
+ popperOptions: PropTypes.shape({
244
+ modifiers: PropTypes.array,
245
+ onFirstUpdate: PropTypes.func,
246
+ placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
247
+ strategy: PropTypes.oneOf(['absolute', 'fixed'])
248
+ }),
249
+ /**
250
+ * A ref that points to the used popper instance.
251
+ */
252
+ popperRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
253
+ current: PropTypes.shape({
254
+ destroy: PropTypes.func.isRequired,
255
+ forceUpdate: PropTypes.func.isRequired,
256
+ setOptions: PropTypes.func.isRequired,
257
+ state: PropTypes.shape({
258
+ attributes: PropTypes.object.isRequired,
259
+ elements: PropTypes.object.isRequired,
260
+ modifiersData: PropTypes.object.isRequired,
261
+ options: PropTypes.object.isRequired,
262
+ orderedModifiers: PropTypes.arrayOf(PropTypes.object).isRequired,
263
+ placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']).isRequired,
264
+ rects: PropTypes.object.isRequired,
265
+ reset: PropTypes.bool.isRequired,
266
+ scrollParents: PropTypes.object.isRequired,
267
+ strategy: PropTypes.oneOf(['absolute', 'fixed']).isRequired,
268
+ styles: PropTypes.object.isRequired
269
+ }).isRequired,
270
+ update: PropTypes.func.isRequired
271
+ })
272
+ })]),
273
+ /**
274
+ * The props used for each slot inside the Popper.
275
+ * @default {}
276
+ */
277
+ slotProps: PropTypes.object,
278
+ /**
279
+ * The components used for each slot inside the Popper.
280
+ * Either a string to use a HTML element or a component.
281
+ * @default {}
282
+ */
283
+ slots: PropTypes.object,
284
+ /**
285
+ * The system prop that allows defining system overrides as well as additional CSS styles.
286
+ */
287
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
288
+ /**
289
+ * Help supporting a react-transition-group/Transition component.
290
+ * @default false
291
+ */
292
+ transition: PropTypes.bool
293
+ } : void 0;
294
+ export { HeatmapTooltip };
@@ -1,4 +1,4 @@
1
1
  export { Heatmap } from './Heatmap';
2
2
  export { HeatmapPlot } from './HeatmapPlot';
3
- export * from './DefaultHeatmapTooltip';
3
+ export * from './HeatmapTooltip';
4
4
  export * from './heatmapClasses';
package/Heatmap/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Heatmap } from "./Heatmap.js";
2
2
  export { HeatmapPlot } from "./HeatmapPlot.js";
3
- export * from "./DefaultHeatmapTooltip.js";
3
+ export * from "./HeatmapTooltip.js";
4
4
  export * from "./heatmapClasses.js";
@@ -13,5 +13,5 @@ export interface LineChartProProps extends LineChartProps, ZoomProps {
13
13
  *
14
14
  * - [LineChart API](https://mui.com/x/api/charts/line-chart/)
15
15
  */
16
- declare const LineChartPro: React.ForwardRefExoticComponent<LineChartProProps & React.RefAttributes<unknown>>;
16
+ declare const LineChartPro: React.ForwardRefExoticComponent<LineChartProProps & React.RefAttributes<SVGSVGElement>>;
17
17
  export { LineChartPro };