@mui/x-charts-pro 8.3.1 → 8.4.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 (90) hide show
  1. package/BarChartPro/BarChartPro.js +37 -20
  2. package/CHANGELOG.md +110 -0
  3. package/ChartContainerPro/ChartContainerPro.js +1 -0
  4. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  5. package/ChartZoomSlider/index.d.ts +1 -1
  6. package/ChartZoomSlider/index.js +4 -4
  7. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +94 -60
  8. package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.d.ts +12 -0
  9. package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +92 -0
  10. package/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.d.ts +11 -0
  11. package/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.js +58 -0
  12. package/ChartZoomSlider/internals/chartAxisZoomSliderThumbClasses.d.ts +17 -0
  13. package/ChartZoomSlider/internals/{chartAxisZoomSliderHandleClasses.js → chartAxisZoomSliderThumbClasses.js} +6 -6
  14. package/FunnelChart/FunnelChart.js +4 -3
  15. package/FunnelChart/FunnelPlot.js +2 -0
  16. package/FunnelChart/FunnelSection.js +2 -1
  17. package/FunnelChart/curves/curve.types.d.ts +4 -0
  18. package/FunnelChart/curves/pyramid.d.ts +3 -1
  19. package/FunnelChart/curves/pyramid.js +37 -10
  20. package/FunnelChart/curves/step-pyramid.d.ts +10 -2
  21. package/FunnelChart/curves/step-pyramid.js +96 -20
  22. package/FunnelChart/curves/step.d.ts +5 -1
  23. package/FunnelChart/curves/step.js +20 -2
  24. package/FunnelChart/funnel.types.d.ts +7 -0
  25. package/FunnelChart/seriesConfig/seriesProcessor.js +47 -1
  26. package/Heatmap/Heatmap.d.ts +1 -1
  27. package/Heatmap/Heatmap.js +25 -21
  28. package/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.d.ts +2 -0
  29. package/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.js +27 -0
  30. package/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +1 -10
  31. package/Heatmap/HeatmapTooltip/HeatmapTooltip.js +4 -102
  32. package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +10 -0
  33. package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.js +5 -0
  34. package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.d.ts +7 -0
  35. package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +96 -0
  36. package/Heatmap/HeatmapTooltip/index.d.ts +3 -1
  37. package/Heatmap/HeatmapTooltip/index.js +11 -0
  38. package/LineChartPro/LineChartPro.js +37 -20
  39. package/ScatterChartPro/ScatterChartPro.js +38 -21
  40. package/esm/BarChartPro/BarChartPro.js +35 -18
  41. package/esm/ChartContainerPro/ChartContainerPro.js +1 -0
  42. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  43. package/esm/ChartZoomSlider/index.d.ts +1 -1
  44. package/esm/ChartZoomSlider/index.js +1 -1
  45. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +94 -60
  46. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.d.ts +12 -0
  47. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +85 -0
  48. package/esm/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.d.ts +11 -0
  49. package/esm/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.js +52 -0
  50. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderThumbClasses.d.ts +17 -0
  51. package/esm/ChartZoomSlider/internals/{chartAxisZoomSliderHandleClasses.js → chartAxisZoomSliderThumbClasses.js} +4 -4
  52. package/esm/FunnelChart/FunnelChart.js +4 -3
  53. package/esm/FunnelChart/FunnelPlot.js +2 -0
  54. package/esm/FunnelChart/FunnelSection.js +1 -0
  55. package/esm/FunnelChart/curves/curve.types.d.ts +4 -0
  56. package/esm/FunnelChart/curves/pyramid.d.ts +3 -1
  57. package/esm/FunnelChart/curves/pyramid.js +37 -10
  58. package/esm/FunnelChart/curves/step-pyramid.d.ts +10 -2
  59. package/esm/FunnelChart/curves/step-pyramid.js +96 -20
  60. package/esm/FunnelChart/curves/step.d.ts +5 -1
  61. package/esm/FunnelChart/curves/step.js +20 -2
  62. package/esm/FunnelChart/funnel.types.d.ts +7 -0
  63. package/esm/FunnelChart/seriesConfig/seriesProcessor.js +47 -1
  64. package/esm/Heatmap/Heatmap.d.ts +1 -1
  65. package/esm/Heatmap/Heatmap.js +23 -19
  66. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.d.ts +2 -0
  67. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.js +19 -0
  68. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +1 -10
  69. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.js +5 -103
  70. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +10 -0
  71. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.js +1 -0
  72. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipContent.d.ts +7 -0
  73. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +89 -0
  74. package/esm/Heatmap/HeatmapTooltip/index.d.ts +3 -1
  75. package/esm/Heatmap/HeatmapTooltip/index.js +3 -1
  76. package/esm/LineChartPro/LineChartPro.js +35 -18
  77. package/esm/ScatterChartPro/ScatterChartPro.js +36 -19
  78. package/esm/index.js +1 -1
  79. package/esm/internals/plugins/useChartProExport/exportImage.js +1 -1
  80. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +2 -2
  81. package/index.js +1 -1
  82. package/internals/plugins/useChartProExport/exportImage.js +1 -1
  83. package/internals/plugins/useChartProZoom/useChartProZoom.js +2 -2
  84. package/package.json +5 -5
  85. package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +0 -12
  86. package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +0 -92
  87. package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +0 -17
  88. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +0 -12
  89. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +0 -85
  90. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +0 -17
@@ -32,6 +32,9 @@ const seriesProcessor = params => {
32
32
  const isHorizontal = seriesOrder.some(seriesId => series[seriesId].layout === 'horizontal');
33
33
  seriesOrder.forEach(seriesId => {
34
34
  const currentSeries = series[seriesId];
35
+ const firstDataPoint = currentSeries.data.at(0);
36
+ const lastDataPoint = currentSeries.data.at(-1);
37
+ const dataDirection = firstDataPoint !== undefined && lastDataPoint !== undefined && firstDataPoint.value < lastDataPoint.value ? 'increasing' : 'decreasing';
35
38
  completedSeries[seriesId] = (0, _extends2.default)({
36
39
  labelMarkType: 'square',
37
40
  layout: isHorizontal ? 'horizontal' : 'vertical',
@@ -40,6 +43,7 @@ const seriesProcessor = params => {
40
43
  data: currentSeries.data.map((v, i) => (0, _extends2.default)({
41
44
  id: `${seriesId}-funnel-item-${v.id ?? i}`
42
45
  }, v)),
46
+ dataDirection,
43
47
  dataPoints: []
44
48
  });
45
49
  const stackOffsets = completedSeries[seriesId].data.toReversed().map((_, i, array) => array.slice(0, i).reduce((acc, item) => acc + item.value, 0)).toReversed();
@@ -47,12 +51,54 @@ const seriesProcessor = params => {
47
51
  // Main = main axis, Other = other axis
48
52
  // For horizontal layout, main is y, other is x
49
53
  // For vertical layout, main is x, other is y
54
+ const isIncreasing = completedSeries[seriesId].dataDirection === 'increasing';
50
55
  const currentMaxMain = item.value;
51
- const nextDataIndex = dataIndex === array.length - 1 ? dataIndex : dataIndex + 1;
56
+ const getNextDataIndex = () => {
57
+ if (isIncreasing) {
58
+ return dataIndex === 0 ? dataIndex : dataIndex - 1;
59
+ }
60
+ return dataIndex === array.length - 1 ? dataIndex : dataIndex + 1;
61
+ };
62
+ const nextDataIndex = getNextDataIndex();
52
63
  const nextMaxMain = array[nextDataIndex].value ?? 0;
53
64
  const nextMaxOther = 0;
54
65
  const currentMaxOther = completedSeries[seriesId].data[dataIndex].value;
55
66
  const stackOffset = stackOffsets[dataIndex];
67
+ if (isIncreasing) {
68
+ return [
69
+ // Top right (vertical) or Top left (horizontal)
70
+ createPoint({
71
+ main: nextMaxMain,
72
+ other: nextMaxOther,
73
+ inverse: isHorizontal,
74
+ useBandWidth: false,
75
+ stackOffset
76
+ }),
77
+ // Bottom right (vertical) or Top right (horizontal)
78
+ createPoint({
79
+ main: currentMaxMain,
80
+ other: currentMaxOther,
81
+ inverse: isHorizontal,
82
+ useBandWidth: true,
83
+ stackOffset
84
+ }),
85
+ // Bottom left (vertical) or Bottom right (horizontal)
86
+ createPoint({
87
+ main: -currentMaxMain,
88
+ other: currentMaxOther,
89
+ inverse: isHorizontal,
90
+ useBandWidth: true,
91
+ stackOffset
92
+ }),
93
+ // Top left (vertical) or Bottom left (horizontal)
94
+ createPoint({
95
+ main: -nextMaxMain,
96
+ other: nextMaxOther,
97
+ inverse: isHorizontal,
98
+ useBandWidth: false,
99
+ stackOffset
100
+ })];
101
+ }
56
102
  return [
57
103
  // Top right (vertical) or Top left (horizontal)
58
104
  createPoint({
@@ -6,7 +6,7 @@ import { ChartsAxisSlots, ChartsAxisSlotProps, XAxis, YAxis } from '@mui/x-chart
6
6
  import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
7
7
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
8
8
  import { HeatmapSeriesType } from "../models/seriesType/heatmap.js";
9
- import { HeatmapTooltipProps } from "./HeatmapTooltip/HeatmapTooltip.js";
9
+ import { HeatmapTooltipProps } from "./HeatmapTooltip/index.js";
10
10
  import { HeatmapItemSlotProps, HeatmapItemSlots } from "./HeatmapItem.js";
11
11
  import { HeatmapPluginsSignatures } from "./Heatmap.plugins.js";
12
12
  export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots {
@@ -14,14 +14,15 @@ var _styles = require("@mui/material/styles");
14
14
  var _useId = _interopRequireDefault(require("@mui/utils/useId"));
15
15
  var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
16
16
  var _ChartsAxis = require("@mui/x-charts/ChartsAxis");
17
+ var _ChartsSurface = require("@mui/x-charts/ChartsSurface");
17
18
  var _ChartsClipPath = require("@mui/x-charts/ChartsClipPath");
18
19
  var _ChartsOverlay = require("@mui/x-charts/ChartsOverlay");
19
20
  var _constants = require("@mui/x-charts/constants");
20
- var _ChartContainerPro = require("../ChartContainerPro");
21
21
  var _HeatmapPlot = require("./HeatmapPlot");
22
22
  var _seriesConfig = require("./seriesConfig");
23
- var _HeatmapTooltip = require("./HeatmapTooltip/HeatmapTooltip");
24
- var _Heatmap = require("./Heatmap.plugins");
23
+ var _HeatmapTooltip = require("./HeatmapTooltip");
24
+ var _Heatmap2 = require("./Heatmap.plugins");
25
+ var _ChartDataProviderPro = require("../ChartDataProviderPro");
25
26
  var _jsxRuntime = require("react/jsx-runtime");
26
27
  // The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
27
28
  const defaultColorMap = (0, _d3Interpolate.interpolateRgbBasis)(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
@@ -89,8 +90,7 @@ const Heatmap = exports.Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap
89
90
  }
90
91
  }], [zAxis]);
91
92
  const Tooltip = props.slots?.tooltip ?? _HeatmapTooltip.HeatmapTooltip;
92
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartContainerPro.ChartContainerPro, {
93
- ref: ref,
93
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartDataProviderPro.ChartDataProviderPro, {
94
94
  seriesConfig: seriesConfig,
95
95
  series: series.map(s => (0, _extends2.default)({
96
96
  type: 'heatmap'
@@ -103,30 +103,34 @@ const Heatmap = exports.Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap
103
103
  zAxis: zAxisWithDefault,
104
104
  colors: colors,
105
105
  dataset: dataset,
106
- sx: sx,
107
106
  disableAxisListener: true,
108
107
  highlightedItem: highlightedItem,
109
108
  onHighlightChange: onHighlightChange,
110
109
  onAxisClick: onAxisClick,
111
- plugins: _Heatmap.HEATMAP_PLUGINS,
112
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
113
- clipPath: `url(#${clipPathId})`,
114
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HeatmapPlot.HeatmapPlot, {
110
+ plugins: _Heatmap2.HEATMAP_PLUGINS,
111
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, {
112
+ ref: ref,
113
+ sx: sx,
114
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
115
+ clipPath: `url(#${clipPathId})`,
116
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HeatmapPlot.HeatmapPlot, {
117
+ slots: slots,
118
+ slotProps: slotProps
119
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
120
+ loading: loading,
121
+ slots: slots,
122
+ slotProps: slotProps
123
+ })]
124
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
115
125
  slots: slots,
116
126
  slotProps: slotProps
117
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
118
- loading: loading,
119
- slots: slots,
120
- slotProps: slotProps
121
- })]
122
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
123
- slots: slots,
124
- slotProps: slotProps
125
- }), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, slotProps?.tooltip)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, {
126
- id: clipPathId
127
- }), children]
127
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, {
128
+ id: clipPathId
129
+ }), children]
130
+ }), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, slotProps?.tooltip))]
128
131
  });
129
132
  });
133
+ if (process.env.NODE_ENV !== "production") Heatmap.displayName = "Heatmap";
130
134
  process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
131
135
  // ----------------------------- Warning --------------------------------
132
136
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -0,0 +1,2 @@
1
+ import { HeatmapTooltipProps } from "./HeatmapTooltip.types.js";
2
+ export declare const useUtilityClasses: (props: Pick<HeatmapTooltipProps, "classes">) => Record<"mark" | "table" | "cell" | "row" | "root" | "paper" | "markContainer" | "labelCell" | "valueCell", string>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useUtilityClasses = void 0;
8
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
9
+ var _ChartsTooltip = require("@mui/x-charts/ChartsTooltip");
10
+ const useUtilityClasses = props => {
11
+ const {
12
+ classes
13
+ } = props;
14
+ const slots = {
15
+ root: ['root'],
16
+ paper: ['paper'],
17
+ table: ['table'],
18
+ row: ['row'],
19
+ cell: ['cell'],
20
+ mark: ['mark'],
21
+ markContainer: ['markContainer'],
22
+ labelCell: ['labelCell'],
23
+ valueCell: ['valueCell']
24
+ };
25
+ return (0, _composeClasses.default)(slots, _ChartsTooltip.getChartsTooltipUtilityClass, classes);
26
+ };
27
+ exports.useUtilityClasses = useUtilityClasses;
@@ -1,14 +1,5 @@
1
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
- * Select the kind of tooltip to display
6
- * - 'item': Shows data about the item below the mouse.
7
- * - 'none': Does not display tooltip
8
- * @default 'item'
9
- */
10
- trigger?: 'item' | 'none';
11
- }
2
+ import { HeatmapTooltipProps } from "./HeatmapTooltip.types.js";
12
3
  declare function HeatmapTooltip(props: HeatmapTooltipProps): React.JSX.Element;
13
4
  declare namespace HeatmapTooltip {
14
5
  var propTypes: any;
@@ -10,118 +10,20 @@ exports.HeatmapTooltip = HeatmapTooltip;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
- var _clsx = _interopRequireDefault(require("clsx"));
14
13
  var _HTMLElementType = _interopRequireDefault(require("@mui/utils/HTMLElementType"));
15
- var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
16
14
  var _ChartsTooltip = require("@mui/x-charts/ChartsTooltip");
17
- var _hooks = require("@mui/x-charts/hooks");
18
- var _internals = require("@mui/x-charts/internals");
19
- var _useHeatmapSeries = require("../../hooks/useHeatmapSeries");
20
- var _HeatmapTooltipAxesValue = require("./HeatmapTooltipAxesValue");
15
+ var _HeatmapTooltipContent = require("./HeatmapTooltipContent");
16
+ var _HeatmapTooltip = require("./HeatmapTooltip.classes");
21
17
  var _jsxRuntime = require("react/jsx-runtime");
22
- const useUtilityClasses = props => {
23
- const {
24
- classes
25
- } = props;
26
- const slots = {
27
- root: ['root'],
28
- paper: ['paper'],
29
- table: ['table'],
30
- row: ['row'],
31
- cell: ['cell'],
32
- mark: ['mark'],
33
- markContainer: ['markContainer'],
34
- labelCell: ['labelCell'],
35
- valueCell: ['valueCell']
36
- };
37
- return (0, _composeClasses.default)(slots, _ChartsTooltip.getChartsTooltipUtilityClass, classes);
38
- };
39
- function DefaultHeatmapTooltipContent(props) {
40
- const classes = useUtilityClasses(props);
41
- const xAxis = (0, _hooks.useXAxis)();
42
- const yAxis = (0, _hooks.useYAxis)();
43
- const heatmapSeries = (0, _useHeatmapSeries.useHeatmapSeriesContext)();
44
- const tooltipData = (0, _ChartsTooltip.useItemTooltip)();
45
- if (!tooltipData || !heatmapSeries || heatmapSeries.seriesOrder.length === 0) {
46
- return null;
47
- }
48
- const {
49
- series,
50
- seriesOrder
51
- } = heatmapSeries;
52
- const seriesId = seriesOrder[0];
53
- const {
54
- color,
55
- value,
56
- identifier,
57
- markType
58
- } = tooltipData;
59
- const [xIndex, yIndex] = value;
60
- const formattedX = xAxis.valueFormatter?.(xAxis.data[xIndex], {
61
- location: 'tooltip',
62
- scale: xAxis.scale
63
- }) ?? xAxis.data[xIndex].toLocaleString();
64
- const formattedY = yAxis.valueFormatter?.(yAxis.data[yIndex], {
65
- location: 'tooltip',
66
- scale: yAxis.scale
67
- }) ?? yAxis.data[yIndex].toLocaleString();
68
- const formattedValue = series[seriesId].valueFormatter(value, {
69
- dataIndex: identifier.dataIndex
70
- });
71
- const seriesLabel = (0, _internals.getLabel)(series[seriesId].label, 'tooltip');
72
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltipPaper, {
73
- className: classes.paper,
74
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltip.ChartsTooltipTable, {
75
- className: classes.table,
76
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_HeatmapTooltipAxesValue.HeatmapTooltipAxesValue, {
77
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
78
- children: formattedX
79
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
80
- children: formattedY
81
- })]
82
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
83
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltip.ChartsTooltipRow, {
84
- className: classes.row,
85
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltip.ChartsTooltipCell, {
86
- className: (0, _clsx.default)(classes.labelCell, classes.cell),
87
- component: "th",
88
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
89
- className: classes.markContainer,
90
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.ChartsLabelMark, {
91
- type: markType,
92
- color: color,
93
- className: classes.mark
94
- })
95
- }), seriesLabel]
96
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltipCell, {
97
- className: (0, _clsx.default)(classes.valueCell, classes.cell),
98
- component: "td",
99
- children: formattedValue
100
- })]
101
- })
102
- })]
103
- })
104
- });
105
- }
106
- process.env.NODE_ENV !== "production" ? DefaultHeatmapTooltipContent.propTypes = {
107
- // ----------------------------- Warning --------------------------------
108
- // | These PropTypes are generated from the TypeScript type definitions |
109
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
110
- // ----------------------------------------------------------------------
111
- /**
112
- * Override or extend the styles applied to the component.
113
- */
114
- classes: _propTypes.default.object
115
- } : void 0;
116
18
  function HeatmapTooltip(props) {
117
- const classes = useUtilityClasses({
19
+ const classes = (0, _HeatmapTooltip.useUtilityClasses)({
118
20
  classes: props.classes
119
21
  });
120
22
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltipContainer, (0, _extends2.default)({
121
23
  trigger: "item"
122
24
  }, props, {
123
25
  classes: classes,
124
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultHeatmapTooltipContent, {
26
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeatmapTooltipContent.HeatmapTooltipContent, {
125
27
  classes: classes
126
28
  })
127
29
  }));
@@ -0,0 +1,10 @@
1
+ import { ChartsTooltipContainerProps } from '@mui/x-charts/ChartsTooltip';
2
+ export interface HeatmapTooltipProps extends Omit<ChartsTooltipContainerProps, 'trigger' | 'children'> {
3
+ /**
4
+ * Select the kind of tooltip to display
5
+ * - 'item': Shows data about the item below the mouse.
6
+ * - 'none': Does not display tooltip
7
+ * @default 'item'
8
+ */
9
+ trigger?: 'item' | 'none';
10
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { HeatmapTooltipProps } from "./HeatmapTooltip.types.js";
3
+ export interface HeatmapTooltipContentProps extends Pick<HeatmapTooltipProps, 'classes'> {}
4
+ export declare function HeatmapTooltipContent(props: HeatmapTooltipContentProps): React.JSX.Element | null;
5
+ export declare namespace HeatmapTooltipContent {
6
+ var propTypes: any;
7
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.HeatmapTooltipContent = HeatmapTooltipContent;
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _clsx = _interopRequireDefault(require("clsx"));
13
+ var _ChartsTooltip = require("@mui/x-charts/ChartsTooltip");
14
+ var _hooks = require("@mui/x-charts/hooks");
15
+ var _internals = require("@mui/x-charts/internals");
16
+ var _useHeatmapSeries = require("../../hooks/useHeatmapSeries");
17
+ var _HeatmapTooltipAxesValue = require("./HeatmapTooltipAxesValue");
18
+ var _HeatmapTooltip = require("./HeatmapTooltip.classes");
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ function HeatmapTooltipContent(props) {
21
+ const classes = (0, _HeatmapTooltip.useUtilityClasses)(props);
22
+ const xAxis = (0, _hooks.useXAxis)();
23
+ const yAxis = (0, _hooks.useYAxis)();
24
+ const heatmapSeries = (0, _useHeatmapSeries.useHeatmapSeriesContext)();
25
+ const tooltipData = (0, _ChartsTooltip.useItemTooltip)();
26
+ if (!tooltipData || !heatmapSeries || heatmapSeries.seriesOrder.length === 0) {
27
+ return null;
28
+ }
29
+ const {
30
+ series,
31
+ seriesOrder
32
+ } = heatmapSeries;
33
+ const seriesId = seriesOrder[0];
34
+ const {
35
+ color,
36
+ value,
37
+ identifier,
38
+ markType
39
+ } = tooltipData;
40
+ const [xIndex, yIndex] = value;
41
+ const formattedX = xAxis.valueFormatter?.(xAxis.data[xIndex], {
42
+ location: 'tooltip',
43
+ scale: xAxis.scale
44
+ }) ?? xAxis.data[xIndex].toLocaleString();
45
+ const formattedY = yAxis.valueFormatter?.(yAxis.data[yIndex], {
46
+ location: 'tooltip',
47
+ scale: yAxis.scale
48
+ }) ?? yAxis.data[yIndex].toLocaleString();
49
+ const formattedValue = series[seriesId].valueFormatter(value, {
50
+ dataIndex: identifier.dataIndex
51
+ });
52
+ const seriesLabel = (0, _internals.getLabel)(series[seriesId].label, 'tooltip');
53
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltipPaper, {
54
+ className: classes.paper,
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltip.ChartsTooltipTable, {
56
+ className: classes.table,
57
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_HeatmapTooltipAxesValue.HeatmapTooltipAxesValue, {
58
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
59
+ children: formattedX
60
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
61
+ children: formattedY
62
+ })]
63
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
64
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltip.ChartsTooltipRow, {
65
+ className: classes.row,
66
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltip.ChartsTooltipCell, {
67
+ className: (0, _clsx.default)(classes.labelCell, classes.cell),
68
+ component: "th",
69
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
70
+ className: classes.markContainer,
71
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.ChartsLabelMark, {
72
+ type: markType,
73
+ color: color,
74
+ className: classes.mark
75
+ })
76
+ }), seriesLabel]
77
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltipCell, {
78
+ className: (0, _clsx.default)(classes.valueCell, classes.cell),
79
+ component: "td",
80
+ children: formattedValue
81
+ })]
82
+ })
83
+ })]
84
+ })
85
+ });
86
+ }
87
+ process.env.NODE_ENV !== "production" ? HeatmapTooltipContent.propTypes = {
88
+ // ----------------------------- Warning --------------------------------
89
+ // | These PropTypes are generated from the TypeScript type definitions |
90
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
91
+ // ----------------------------------------------------------------------
92
+ /**
93
+ * Override or extend the styles applied to the component.
94
+ */
95
+ classes: _propTypes.default.object
96
+ } : void 0;
@@ -1 +1,3 @@
1
- export * from "./HeatmapTooltip.js";
1
+ export * from "./HeatmapTooltip.js";
2
+ export * from "./HeatmapTooltipContent.js";
3
+ export type { HeatmapTooltipProps } from "./HeatmapTooltip.types.js";
@@ -13,4 +13,15 @@ Object.keys(_HeatmapTooltip).forEach(function (key) {
13
13
  return _HeatmapTooltip[key];
14
14
  }
15
15
  });
16
+ });
17
+ var _HeatmapTooltipContent = require("./HeatmapTooltipContent");
18
+ Object.keys(_HeatmapTooltipContent).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _HeatmapTooltipContent[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _HeatmapTooltipContent[key];
25
+ }
26
+ });
16
27
  });