@mui/x-charts-pro 8.0.0-alpha.0 → 8.0.0-alpha.2

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 (53) hide show
  1. package/BarChartPro/BarChartPro.js +3 -35
  2. package/CHANGELOG.md +651 -6
  3. package/ChartContainerPro/ChartContainerPro.js +7 -25
  4. package/ChartContainerPro/useChartContainerProProps.d.ts +2 -39
  5. package/ChartContainerPro/useChartContainerProProps.js +4 -4
  6. package/Heatmap/Heatmap.d.ts +11 -4
  7. package/Heatmap/Heatmap.js +4 -39
  8. package/Heatmap/HeatmapTooltip.d.ts +9 -0
  9. package/Heatmap/HeatmapTooltip.js +272 -0
  10. package/Heatmap/heatmapClasses.js +2 -1
  11. package/Heatmap/index.d.ts +1 -1
  12. package/Heatmap/index.js +1 -1
  13. package/LineChartPro/LineChartPro.js +3 -36
  14. package/README.md +2 -2
  15. package/ScatterChartPro/ScatterChartPro.js +3 -36
  16. package/context/CartesianProviderPro/createAxisFilterMapper.d.ts +2 -1
  17. package/context/ChartDataProviderPro/ChartDataProviderPro.d.ts +1 -1
  18. package/context/ChartDataProviderPro/ChartDataProviderPro.js +20 -268
  19. package/context/ChartDataProviderPro/useChartDataProviderProProps.d.ts +3 -5
  20. package/context/ChartDataProviderPro/useChartDataProviderProProps.js +6 -6
  21. package/index.js +1 -1
  22. package/internals/utils/releaseInfo.js +2 -2
  23. package/modern/BarChartPro/BarChartPro.js +3 -35
  24. package/modern/ChartContainerPro/ChartContainerPro.js +7 -25
  25. package/modern/ChartContainerPro/useChartContainerProProps.js +4 -4
  26. package/modern/Heatmap/Heatmap.js +4 -39
  27. package/modern/Heatmap/HeatmapTooltip.js +272 -0
  28. package/modern/Heatmap/heatmapClasses.js +2 -1
  29. package/modern/Heatmap/index.js +1 -1
  30. package/modern/LineChartPro/LineChartPro.js +3 -36
  31. package/modern/ScatterChartPro/ScatterChartPro.js +3 -36
  32. package/modern/context/ChartDataProviderPro/ChartDataProviderPro.js +20 -268
  33. package/modern/context/ChartDataProviderPro/useChartDataProviderProProps.js +6 -6
  34. package/modern/index.js +1 -1
  35. package/modern/internals/utils/releaseInfo.js +2 -2
  36. package/node/BarChartPro/BarChartPro.js +3 -35
  37. package/node/ChartContainerPro/ChartContainerPro.js +7 -25
  38. package/node/ChartContainerPro/useChartContainerProProps.js +4 -4
  39. package/node/Heatmap/Heatmap.js +4 -39
  40. package/node/Heatmap/HeatmapTooltip.js +278 -0
  41. package/node/Heatmap/heatmapClasses.js +5 -4
  42. package/node/Heatmap/index.js +4 -4
  43. package/node/LineChartPro/LineChartPro.js +3 -36
  44. package/node/ScatterChartPro/ScatterChartPro.js +3 -36
  45. package/node/context/ChartDataProviderPro/ChartDataProviderPro.js +19 -267
  46. package/node/context/ChartDataProviderPro/useChartDataProviderProProps.js +6 -6
  47. package/node/index.js +1 -1
  48. package/node/internals/utils/releaseInfo.js +4 -3
  49. package/package.json +7 -7
  50. package/Heatmap/DefaultHeatmapTooltip.d.ts +0 -7
  51. package/Heatmap/DefaultHeatmapTooltip.js +0 -99
  52. package/modern/Heatmap/DefaultHeatmapTooltip.js +0 -99
  53. package/node/Heatmap/DefaultHeatmapTooltip.js +0 -105
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { Watermark } from '@mui/x-license/Watermark';
7
- import { ResizableContainer } from '@mui/x-charts/internals';
7
+ import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
8
8
  import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
9
9
  import { ChartDataProviderPro } from "../context/ChartDataProviderPro/index.js";
10
10
  import { useChartContainerProProps } from "./useChartContainerProProps.js";
@@ -13,11 +13,13 @@ const releaseInfo = getReleaseInfo();
13
13
  const ChartContainerPro = /*#__PURE__*/React.forwardRef(function ChartContainerPro(props, ref) {
14
14
  const {
15
15
  chartDataProviderProProps,
16
- resizableChartContainerProps,
17
- hasIntrinsicSize
16
+ children,
17
+ chartsSurfaceProps
18
18
  } = useChartContainerProProps(props, ref);
19
- return /*#__PURE__*/_jsxs(ResizableContainer, _extends({}, resizableChartContainerProps, {
20
- children: [hasIntrinsicSize ? /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps)) : null, /*#__PURE__*/_jsx(Watermark, {
19
+ return /*#__PURE__*/_jsxs(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
20
+ children: [/*#__PURE__*/_jsx(ChartsSurface, _extends({}, chartsSurfaceProps, {
21
+ children: children
22
+ })), /*#__PURE__*/_jsx(Watermark, {
21
23
  packageName: "x-charts-pro",
22
24
  releaseInfo: releaseInfo
23
25
  })]
@@ -86,16 +88,6 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
86
88
  * If not provided, the container supports line, bar, scatter and pie charts.
87
89
  */
88
90
  plugins: PropTypes.arrayOf(PropTypes.object),
89
- /**
90
- * The chart will try to wait for the parent container to resolve its size
91
- * before it renders for the first time.
92
- *
93
- * This can be useful in some scenarios where the chart appear to grow after
94
- * the first render, like when used inside a grid.
95
- *
96
- * @default false
97
- */
98
- resolveSizeBeforeRender: PropTypes.bool,
99
91
  /**
100
92
  * The array of series to display.
101
93
  * Each type of series has its own specificity.
@@ -109,12 +101,6 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
109
101
  skipAnimation: PropTypes.bool,
110
102
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
111
103
  title: PropTypes.string,
112
- viewBox: PropTypes.shape({
113
- height: PropTypes.number,
114
- width: PropTypes.number,
115
- x: PropTypes.number,
116
- y: PropTypes.number
117
- }),
118
104
  /**
119
105
  * The width of the chart in px. If not defined, it takes the width of the parent element.
120
106
  */
@@ -150,7 +136,6 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
150
136
  hideTooltip: PropTypes.bool,
151
137
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
152
138
  label: PropTypes.string,
153
- labelFontSize: PropTypes.number,
154
139
  labelStyle: PropTypes.object,
155
140
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
156
141
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
@@ -161,7 +146,6 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
161
146
  slots: PropTypes.object,
162
147
  stroke: PropTypes.string,
163
148
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
164
- tickFontSize: PropTypes.number,
165
149
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
166
150
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
167
151
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
@@ -213,7 +197,6 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
213
197
  hideTooltip: PropTypes.bool,
214
198
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
215
199
  label: PropTypes.string,
216
- labelFontSize: PropTypes.number,
217
200
  labelStyle: PropTypes.object,
218
201
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
219
202
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
@@ -224,7 +207,6 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
224
207
  slots: PropTypes.object,
225
208
  stroke: PropTypes.string,
226
209
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
227
- tickFontSize: PropTypes.number,
228
210
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
229
211
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
230
212
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
@@ -1,45 +1,8 @@
1
1
  import { UseChartContainerPropsReturnValue } from '@mui/x-charts/internals';
2
+ import * as React from 'react';
2
3
  import type { ChartDataProviderProProps } from '../context/ChartDataProviderPro';
3
4
  import type { ChartContainerProProps } from './ChartContainerPro';
4
5
  export type UseChartContainerProPropsReturnValue = Omit<UseChartContainerPropsReturnValue, 'chartDataProviderProps'> & {
5
6
  chartDataProviderProProps: ChartDataProviderProProps;
6
7
  };
7
- export declare const useChartContainerProProps: (props: ChartContainerProProps, ref: React.Ref<SVGSVGElement>) => {
8
- chartDataProviderProProps: {
9
- zoom?: import("..").ZoomData[] | undefined;
10
- onZoomChange?: ((zoomData: import("..").ZoomData[] | ((zoomData: import("..").ZoomData[]) => import("..").ZoomData[])) => void) | undefined;
11
- height: number;
12
- width: number;
13
- margin?: Partial<import("@mui/x-charts").CardinalDirections<number>> | undefined;
14
- title?: string | undefined;
15
- desc?: string | undefined;
16
- className?: string | undefined;
17
- viewBox?: {
18
- x?: number;
19
- y?: number;
20
- width?: number;
21
- height?: number;
22
- } | undefined;
23
- plugins?: import("@mui/x-charts/internals").ChartsPlugin<import("@mui/x-charts/internals").ChartSeriesType>[] | undefined;
24
- sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
25
- series: (import("@mui/x-charts").ScatterSeriesType | import("@mui/x-charts").LineSeriesType | import("@mui/x-charts").BarSeriesType | import("@mui/x-charts").PieSeriesType<import("@mui/x-internals/types").MakeOptional<import("@mui/x-charts").PieValueType, "id">> | import("../models").HeatmapSeriesType)[];
26
- onHighlightChange?: ((highlightedItem: import("@mui/x-charts").HighlightItemData | null) => void) | undefined;
27
- skipAnimation?: boolean | undefined;
28
- zAxis?: import("@mui/x-internals/types").MakeOptional<import("@mui/x-charts/internals").ZAxisConfig, "id">[] | undefined;
29
- dataset?: import("@mui/x-charts/internals").DatasetType | undefined;
30
- colors?: import("@mui/x-charts").ChartsColorPalette | undefined;
31
- disableAxisListener?: boolean | undefined;
32
- highlightedItem?: (import("@mui/x-charts").HighlightItemData | null) | undefined;
33
- xAxis?: import("@mui/x-internals/types").MakeOptional<import("@mui/x-charts").AxisConfig<import("@mui/x-charts").ScaleName, any, import("@mui/x-charts").ChartsXAxisProps>, "id">[];
34
- yAxis?: import("@mui/x-internals/types").MakeOptional<import("@mui/x-charts").AxisConfig<import("@mui/x-charts").ScaleName, any, import("@mui/x-charts").ChartsYAxisProps>, "id">[];
35
- children?: React.ReactNode;
36
- };
37
- resizableChartContainerProps: {
38
- ownerState: {
39
- width: import("@mui/x-charts").ChartContainerProps["width"];
40
- height: import("@mui/x-charts").ChartContainerProps["height"];
41
- };
42
- ref: React.Ref<HTMLDivElement>;
43
- };
44
- hasIntrinsicSize: boolean;
45
- };
8
+ export declare const useChartContainerProProps: (props: ChartContainerProProps, ref: React.Ref<SVGSVGElement>) => UseChartContainerProPropsReturnValue;
@@ -16,12 +16,12 @@ export const useChartContainerProProps = (props, ref) => {
16
16
  };
17
17
  const {
18
18
  chartDataProviderProps,
19
- resizableChartContainerProps,
20
- hasIntrinsicSize
19
+ chartsSurfaceProps,
20
+ children
21
21
  } = useChartContainerProps(baseProps, ref);
22
22
  return {
23
23
  chartDataProviderProProps: _extends({}, chartDataProviderProps, chartDataProviderProProps),
24
- resizableChartContainerProps,
25
- hasIntrinsicSize
24
+ chartsSurfaceProps,
25
+ children
26
26
  };
27
27
  };
@@ -1,16 +1,23 @@
1
1
  import * as React from 'react';
2
2
  import { MakeOptional } from '@mui/x-internals/types';
3
3
  import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
4
- import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '@mui/x-charts/ChartsTooltip';
4
+ import { ChartsTooltipProps } from '@mui/x-charts/ChartsTooltip';
5
5
  import { ChartsAxisSlots, ChartsAxisSlotProps, ChartsXAxisProps, ChartsYAxisProps, AxisConfig } from '@mui/x-charts/internals';
6
6
  import { ChartsOnAxisClickHandlerProps } from '@mui/x-charts/ChartsOnAxisClickHandler';
7
7
  import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
8
8
  import { ChartContainerProProps } from '../ChartContainerPro';
9
9
  import { HeatmapSeriesType } from '../models/seriesType/heatmap';
10
+ import { HeatmapTooltipProps } from './HeatmapTooltip';
10
11
  import { HeatmapItemSlotProps, HeatmapItemSlots } from './HeatmapItem';
11
- 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>;
12
18
  }
13
- export interface HeatmapSlotProps extends ChartsAxisSlotProps, Omit<ChartsTooltipSlotProps<'heatmap'>, 'axisContent'>, ChartsOverlaySlotProps, HeatmapItemSlotProps {
19
+ export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps {
20
+ tooltip?: Partial<HeatmapTooltipProps>;
14
21
  }
15
22
  export interface HeatmapProps extends Omit<ChartContainerProProps, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'zoom' | 'onZoomChange' | 'skipAnimation'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, ChartsOnAxisClickHandlerProps {
16
23
  /**
@@ -34,7 +41,7 @@ export interface HeatmapProps extends Omit<ChartContainerProProps, 'series' | 'p
34
41
  * The configuration of the tooltip.
35
42
  * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
36
43
  */
37
- tooltip?: ChartsTooltipProps<'heatmap'>;
44
+ tooltip?: ChartsTooltipProps;
38
45
  /**
39
46
  * Overridable component slots.
40
47
  * @default {}
@@ -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
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,6 +63,7 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
65
63
  color: defaultColorMap
66
64
  }
67
65
  }], [zAxis]);
66
+ const Tooltip = props.slots?.tooltip ?? HeatmapTooltip;
68
67
  return /*#__PURE__*/_jsxs(ChartContainerPro, {
69
68
  ref: ref,
70
69
  plugins: [heatmapPlugin],
@@ -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
  */
@@ -284,7 +253,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
284
253
  hideTooltip: PropTypes.bool,
285
254
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
286
255
  label: PropTypes.string,
287
- labelFontSize: PropTypes.number,
288
256
  labelStyle: PropTypes.object,
289
257
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
290
258
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
@@ -295,7 +263,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
295
263
  slots: PropTypes.object,
296
264
  stroke: PropTypes.string,
297
265
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
298
- tickFontSize: PropTypes.number,
299
266
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
300
267
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
301
268
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
@@ -349,7 +316,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
349
316
  hideTooltip: PropTypes.bool,
350
317
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
351
318
  label: PropTypes.string,
352
- labelFontSize: PropTypes.number,
353
319
  labelStyle: PropTypes.object,
354
320
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
355
321
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
@@ -360,7 +326,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
360
326
  slots: PropTypes.object,
361
327
  stroke: PropTypes.string,
362
328
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
363
- tickFontSize: PropTypes.number,
364
329
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
365
330
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
366
331
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
@@ -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,272 @@
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 HTMLElementType from '@mui/utils/HTMLElementType';
8
+ import composeClasses from '@mui/utils/composeClasses';
9
+ import { ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipRow, ChartsTooltipCell, ChartsTooltipMark, useItemTooltip, getChartsTooltipUtilityClass, ChartsTooltipContainer } from '@mui/x-charts/ChartsTooltip';
10
+ import { useXAxis, useYAxis } from '@mui/x-charts/hooks';
11
+ import { getLabel } from '@mui/x-charts/internals';
12
+ import { useHeatmapSeries } from "../hooks/useSeries.js";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const useUtilityClasses = ownerState => {
15
+ const {
16
+ classes
17
+ } = ownerState;
18
+ const slots = {
19
+ root: ['root'],
20
+ paper: ['paper'],
21
+ table: ['table'],
22
+ row: ['row'],
23
+ cell: ['cell'],
24
+ mark: ['mark'],
25
+ markCell: ['markCell'],
26
+ labelCell: ['labelCell'],
27
+ valueCell: ['valueCell']
28
+ };
29
+ return composeClasses(slots, getChartsTooltipUtilityClass, classes);
30
+ };
31
+ function DefaultHeatmapTooltipContent(props) {
32
+ const {
33
+ classes
34
+ } = props;
35
+ const xAxis = useXAxis();
36
+ const yAxis = useYAxis();
37
+ const heatmapSeries = useHeatmapSeries();
38
+ const tooltipData = useItemTooltip();
39
+ if (!tooltipData || !heatmapSeries || heatmapSeries.seriesOrder.length === 0) {
40
+ return null;
41
+ }
42
+ const {
43
+ series,
44
+ seriesOrder
45
+ } = heatmapSeries;
46
+ const seriesId = seriesOrder[0];
47
+ const {
48
+ color,
49
+ value,
50
+ identifier
51
+ } = tooltipData;
52
+ const [xIndex, yIndex] = value;
53
+ const formattedX = xAxis.valueFormatter?.(xAxis.data[xIndex], {
54
+ location: 'tooltip'
55
+ }) ?? xAxis.data[xIndex].toLocaleString();
56
+ const formattedY = yAxis.valueFormatter?.(yAxis.data[yIndex], {
57
+ location: 'tooltip'
58
+ }) ?? yAxis.data[yIndex].toLocaleString();
59
+ const formattedValue = series[seriesId].valueFormatter(value, {
60
+ dataIndex: identifier.dataIndex
61
+ });
62
+ const seriesLabel = getLabel(series[seriesId].label, 'tooltip');
63
+ return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
64
+ className: classes?.paper,
65
+ children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
66
+ className: classes?.table,
67
+ children: [/*#__PURE__*/_jsx("thead", {
68
+ children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
69
+ className: classes?.row,
70
+ children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
71
+ className: classes?.cell,
72
+ children: formattedX
73
+ }), formattedX && formattedY && /*#__PURE__*/_jsx(ChartsTooltipCell, {}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
74
+ className: classes?.cell,
75
+ children: formattedY
76
+ })]
77
+ })
78
+ }), /*#__PURE__*/_jsx("tbody", {
79
+ children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
80
+ className: classes?.row,
81
+ children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
82
+ className: clsx(classes?.markCell, classes?.cell),
83
+ children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
84
+ color: color,
85
+ className: classes?.mark
86
+ })
87
+ }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
88
+ className: clsx(classes?.labelCell, classes?.cell),
89
+ children: seriesLabel
90
+ }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
91
+ className: clsx(classes?.valueCell, classes?.cell),
92
+ children: formattedValue
93
+ })]
94
+ })
95
+ })]
96
+ })
97
+ });
98
+ }
99
+ process.env.NODE_ENV !== "production" ? DefaultHeatmapTooltipContent.propTypes = {
100
+ // ----------------------------- Warning --------------------------------
101
+ // | These PropTypes are generated from the TypeScript type definitions |
102
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
103
+ // ----------------------------------------------------------------------
104
+ /**
105
+ * Override or extend the styles applied to the component.
106
+ */
107
+ classes: PropTypes.object
108
+ } : void 0;
109
+ function HeatmapTooltip(props) {
110
+ const classes = useUtilityClasses({
111
+ classes: props.classes
112
+ });
113
+ return /*#__PURE__*/_jsx(ChartsTooltipContainer, _extends({}, props, {
114
+ classes: classes,
115
+ trigger: "item",
116
+ children: /*#__PURE__*/_jsx(DefaultHeatmapTooltipContent, {
117
+ classes: classes
118
+ })
119
+ }));
120
+ }
121
+ process.env.NODE_ENV !== "production" ? HeatmapTooltip.propTypes = {
122
+ // ----------------------------- Warning --------------------------------
123
+ // | These PropTypes are generated from the TypeScript type definitions |
124
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
125
+ // ----------------------------------------------------------------------
126
+ /**
127
+ * An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
128
+ * or a function that returns either.
129
+ * It's used to set the position of the popper.
130
+ * The return value will passed as the reference object of the Popper instance.
131
+ */
132
+ anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]),
133
+ /**
134
+ * Override or extend the styles applied to the component.
135
+ */
136
+ classes: PropTypes.object,
137
+ /**
138
+ * The component used for the root node.
139
+ * Either a string to use a HTML element or a component.
140
+ */
141
+ component: PropTypes.elementType,
142
+ /**
143
+ * The components used for each slot inside the Popper.
144
+ * Either a string to use a HTML element or a component.
145
+ * @default {}
146
+ */
147
+ components: PropTypes.shape({
148
+ Root: PropTypes.elementType
149
+ }),
150
+ /**
151
+ * The props used for each slot inside the Popper.
152
+ * @default {}
153
+ */
154
+ componentsProps: PropTypes.shape({
155
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
156
+ }),
157
+ /**
158
+ * An HTML element or function that returns one.
159
+ * The `container` will have the portal children appended to it.
160
+ *
161
+ * You can also provide a callback, which is called in a React layout effect.
162
+ * This lets you set the container from a ref, and also makes server-side rendering possible.
163
+ *
164
+ * By default, it uses the body of the top-level document object,
165
+ * so it's simply `document.body` most of the time.
166
+ */
167
+ container: PropTypes.oneOfType([(props, propName) => {
168
+ if (props[propName] == null) {
169
+ return new Error(`Prop '${propName}' is required but wasn't specified`);
170
+ }
171
+ if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
172
+ return new Error(`Expected prop '${propName}' to be of type Element`);
173
+ }
174
+ return null;
175
+ }, PropTypes.func]),
176
+ /**
177
+ * The `children` will be under the DOM hierarchy of the parent component.
178
+ * @default false
179
+ */
180
+ disablePortal: PropTypes.bool,
181
+ /**
182
+ * Always keep the children in the DOM.
183
+ * This prop can be useful in SEO situation or
184
+ * when you want to maximize the responsiveness of the Popper.
185
+ * @default false
186
+ */
187
+ keepMounted: PropTypes.bool,
188
+ /**
189
+ * Popper.js is based on a "plugin-like" architecture,
190
+ * most of its features are fully encapsulated "modifiers".
191
+ *
192
+ * A modifier is a function that is called each time Popper.js needs to
193
+ * compute the position of the popper.
194
+ * For this reason, modifiers should be very performant to avoid bottlenecks.
195
+ * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
196
+ */
197
+ modifiers: PropTypes.arrayOf(PropTypes.shape({
198
+ data: PropTypes.object,
199
+ effect: PropTypes.func,
200
+ enabled: PropTypes.bool,
201
+ fn: PropTypes.func,
202
+ name: PropTypes.any,
203
+ options: PropTypes.object,
204
+ phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
205
+ requires: PropTypes.arrayOf(PropTypes.string),
206
+ requiresIfExists: PropTypes.arrayOf(PropTypes.string)
207
+ })),
208
+ /**
209
+ * If `true`, the component is shown.
210
+ */
211
+ open: PropTypes.bool,
212
+ /**
213
+ * Popper placement.
214
+ * @default 'bottom'
215
+ */
216
+ 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']),
217
+ /**
218
+ * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
219
+ * @default {}
220
+ */
221
+ popperOptions: PropTypes.shape({
222
+ modifiers: PropTypes.array,
223
+ onFirstUpdate: PropTypes.func,
224
+ 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']),
225
+ strategy: PropTypes.oneOf(['absolute', 'fixed'])
226
+ }),
227
+ /**
228
+ * A ref that points to the used popper instance.
229
+ */
230
+ popperRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
231
+ current: PropTypes.shape({
232
+ destroy: PropTypes.func.isRequired,
233
+ forceUpdate: PropTypes.func.isRequired,
234
+ setOptions: PropTypes.func.isRequired,
235
+ state: PropTypes.shape({
236
+ attributes: PropTypes.object.isRequired,
237
+ elements: PropTypes.object.isRequired,
238
+ modifiersData: PropTypes.object.isRequired,
239
+ options: PropTypes.object.isRequired,
240
+ orderedModifiers: PropTypes.arrayOf(PropTypes.object).isRequired,
241
+ 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,
242
+ rects: PropTypes.object.isRequired,
243
+ reset: PropTypes.bool.isRequired,
244
+ scrollParents: PropTypes.object.isRequired,
245
+ strategy: PropTypes.oneOf(['absolute', 'fixed']).isRequired,
246
+ styles: PropTypes.object.isRequired
247
+ }).isRequired,
248
+ update: PropTypes.func.isRequired
249
+ })
250
+ })]),
251
+ /**
252
+ * The props used for each slot inside the Popper.
253
+ * @default {}
254
+ */
255
+ slotProps: PropTypes.object,
256
+ /**
257
+ * The components used for each slot inside the Popper.
258
+ * Either a string to use a HTML element or a component.
259
+ * @default {}
260
+ */
261
+ slots: PropTypes.object,
262
+ /**
263
+ * The system prop that allows defining system overrides as well as additional CSS styles.
264
+ */
265
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
266
+ /**
267
+ * Help supporting a react-transition-group/Transition component.
268
+ * @default false
269
+ */
270
+ transition: PropTypes.bool
271
+ } : void 0;
272
+ export { HeatmapTooltip };
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
3
4
  export function getHeatmapUtilityClass(slot) {
4
5
  // Those should be common to all charts
5
6
  if (['highlighted', 'faded'].includes(slot)) {
@@ -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";