@mui/x-charts-pro 8.26.0 → 9.0.0-alpha.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.
- package/BarChartPro/BarChartPro.d.ts +1 -1
- package/BarChartPro/BarChartPro.js +9 -4
- package/CHANGELOG.md +355 -3
- package/ChartContainerPro/ChartContainerPro.d.ts +17 -31
- package/ChartContainerPro/ChartContainerPro.js +14 -287
- package/ChartContainerPro/useChartContainerProProps.d.ts +9 -5
- package/ChartContainerPro/useChartContainerProProps.js +9 -34
- package/ChartDataProviderPro/ChartDataProviderPro.d.ts +5 -3
- package/ChartDataProviderPro/ChartDataProviderPro.js +2 -2
- package/ChartDataProviderPro/index.d.ts +1 -1
- package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +3 -3
- package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +8 -6
- package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +6 -4
- package/ChartZoomSlider/internals/previews/AreaPreviewPlot.d.ts +1 -1
- package/ChartZoomSlider/internals/previews/AreaPreviewPlot.js +4 -4
- package/ChartZoomSlider/internals/previews/BarPreviewPlot.js +1 -1
- package/ChartZoomSlider/internals/previews/LinePreviewPlot.d.ts +1 -1
- package/ChartZoomSlider/internals/previews/LinePreviewPlot.js +4 -4
- package/ChartsContainer/index.d.ts +1 -0
- package/ChartsContainer/index.js +16 -0
- package/ChartsContainerPro/ChartsContainerPro.d.ts +37 -0
- package/ChartsContainerPro/ChartsContainerPro.js +187 -0
- package/ChartsContainerPro/index.d.ts +9 -0
- package/ChartsContainerPro/index.js +17 -0
- package/ChartsContainerPro/useChartsContainerProProps.d.ts +9 -0
- package/ChartsContainerPro/useChartsContainerProProps.js +44 -0
- package/FunnelChart/FunnelChart.js +4 -4
- package/FunnelChart/FunnelSection.d.ts +1 -1
- package/FunnelChart/funnel.types.d.ts +1 -1
- package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +12 -9
- package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +3 -2
- package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
- package/FunnelChart/index.d.ts +1 -0
- package/FunnelChart/index.js +12 -0
- package/FunnelChart/seriesConfig/index.js +2 -1
- package/FunnelChart/seriesConfig/legend.js +0 -1
- package/Heatmap/Heatmap.d.ts +14 -2
- package/Heatmap/Heatmap.js +36 -130
- package/Heatmap/Heatmap.plugins.d.ts +2 -2
- package/Heatmap/Heatmap.plugins.js +1 -1
- package/Heatmap/Heatmap.types.d.ts +19 -0
- package/Heatmap/Heatmap.types.js +5 -0
- package/Heatmap/HeatmapItem.d.ts +6 -0
- package/Heatmap/HeatmapItem.js +11 -3
- package/Heatmap/HeatmapPlot.d.ts +7 -3
- package/Heatmap/HeatmapPlot.js +16 -54
- package/Heatmap/HeatmapSVGPlot.d.ts +2 -0
- package/Heatmap/HeatmapSVGPlot.js +70 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +5 -1
- package/Heatmap/HeatmapTooltip/index.d.ts +1 -1
- package/Heatmap/index.d.ts +3 -2
- package/Heatmap/seriesConfig/getItemAtPosition.d.ts +6 -0
- package/Heatmap/seriesConfig/getItemAtPosition.js +45 -0
- package/Heatmap/seriesConfig/index.js +3 -0
- package/Heatmap/useHeatmapProps.d.ts +24 -0
- package/Heatmap/useHeatmapProps.js +159 -0
- package/LineChartPro/LineChartPro.d.ts +1 -1
- package/LineChartPro/LineChartPro.js +9 -4
- package/PieChartPro/PieChartPro.d.ts +1 -1
- package/PieChartPro/PieChartPro.js +4 -4
- package/RadarChartPro/RadarChartPro.d.ts +1 -1
- package/RadarChartPro/RadarChartPro.js +4 -4
- package/RadarChartPro/RadarChartPro.plugins.d.ts +2 -2
- package/RadarChartPro/RadarChartPro.plugins.js +1 -1
- package/SankeyChart/SankeyChart.js +4 -4
- package/SankeyChart/SankeyTooltip/SankeyTooltip.types.d.ts +5 -1
- package/SankeyChart/SankeyTooltip/index.d.ts +1 -1
- package/SankeyChart/index.d.ts +1 -1
- package/SankeyChart/plugins/useSankeyHighlight.selectors.d.ts +7 -7
- package/SankeyChart/sankey.highlight.types.d.ts +4 -0
- package/SankeyChart/sankey.types.d.ts +6 -3
- package/SankeyChart/seriesConfig/getSeriesWithDefaultValues.js +13 -1
- package/SankeyChart/seriesConfig/identifierCleaner.d.ts +3 -0
- package/SankeyChart/seriesConfig/identifierCleaner.js +24 -0
- package/SankeyChart/seriesConfig/index.js +3 -1
- package/ScatterChartPro/ScatterChartPro.d.ts +1 -1
- package/ScatterChartPro/ScatterChartPro.js +9 -4
- package/esm/BarChartPro/BarChartPro.d.ts +1 -1
- package/esm/BarChartPro/BarChartPro.js +9 -4
- package/esm/ChartContainerPro/ChartContainerPro.d.ts +17 -31
- package/esm/ChartContainerPro/ChartContainerPro.js +15 -286
- package/esm/ChartContainerPro/useChartContainerProProps.d.ts +9 -5
- package/esm/ChartContainerPro/useChartContainerProProps.js +10 -33
- package/esm/ChartDataProviderPro/ChartDataProviderPro.d.ts +5 -3
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +2 -2
- package/esm/ChartDataProviderPro/index.d.ts +1 -1
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +3 -3
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +9 -7
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +7 -5
- package/esm/ChartZoomSlider/internals/previews/AreaPreviewPlot.d.ts +1 -1
- package/esm/ChartZoomSlider/internals/previews/AreaPreviewPlot.js +4 -4
- package/esm/ChartZoomSlider/internals/previews/BarPreviewPlot.js +1 -1
- package/esm/ChartZoomSlider/internals/previews/LinePreviewPlot.d.ts +1 -1
- package/esm/ChartZoomSlider/internals/previews/LinePreviewPlot.js +4 -4
- package/esm/ChartsContainer/index.d.ts +1 -0
- package/esm/ChartsContainer/index.js +2 -0
- package/esm/ChartsContainerPro/ChartsContainerPro.d.ts +37 -0
- package/esm/ChartsContainerPro/ChartsContainerPro.js +181 -0
- package/esm/ChartsContainerPro/index.d.ts +9 -0
- package/esm/ChartsContainerPro/index.js +6 -0
- package/esm/ChartsContainerPro/useChartsContainerProProps.d.ts +9 -0
- package/esm/ChartsContainerPro/useChartsContainerProProps.js +37 -0
- package/esm/FunnelChart/FunnelChart.js +4 -4
- package/esm/FunnelChart/FunnelSection.d.ts +1 -1
- package/esm/FunnelChart/funnel.types.d.ts +1 -1
- package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +13 -10
- package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +3 -2
- package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
- package/esm/FunnelChart/index.d.ts +1 -0
- package/esm/FunnelChart/index.js +1 -0
- package/esm/FunnelChart/seriesConfig/index.js +3 -2
- package/esm/FunnelChart/seriesConfig/legend.js +0 -1
- package/esm/Heatmap/Heatmap.d.ts +14 -2
- package/esm/Heatmap/Heatmap.js +37 -131
- package/esm/Heatmap/Heatmap.plugins.d.ts +2 -2
- package/esm/Heatmap/Heatmap.plugins.js +2 -2
- package/esm/Heatmap/Heatmap.types.d.ts +19 -0
- package/esm/Heatmap/Heatmap.types.js +1 -0
- package/esm/Heatmap/HeatmapItem.d.ts +6 -0
- package/esm/Heatmap/HeatmapItem.js +11 -3
- package/esm/Heatmap/HeatmapPlot.d.ts +7 -3
- package/esm/Heatmap/HeatmapPlot.js +17 -56
- package/esm/Heatmap/HeatmapSVGPlot.d.ts +2 -0
- package/esm/Heatmap/HeatmapSVGPlot.js +64 -0
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +5 -1
- package/esm/Heatmap/HeatmapTooltip/index.d.ts +1 -1
- package/esm/Heatmap/index.d.ts +3 -2
- package/esm/Heatmap/seriesConfig/getItemAtPosition.d.ts +6 -0
- package/esm/Heatmap/seriesConfig/getItemAtPosition.js +39 -0
- package/esm/Heatmap/seriesConfig/index.js +4 -1
- package/esm/Heatmap/useHeatmapProps.d.ts +24 -0
- package/esm/Heatmap/useHeatmapProps.js +151 -0
- package/esm/LineChartPro/LineChartPro.d.ts +1 -1
- package/esm/LineChartPro/LineChartPro.js +9 -4
- package/esm/PieChartPro/PieChartPro.d.ts +1 -1
- package/esm/PieChartPro/PieChartPro.js +4 -4
- package/esm/RadarChartPro/RadarChartPro.d.ts +1 -1
- package/esm/RadarChartPro/RadarChartPro.js +4 -4
- package/esm/RadarChartPro/RadarChartPro.plugins.d.ts +2 -2
- package/esm/RadarChartPro/RadarChartPro.plugins.js +2 -2
- package/esm/SankeyChart/SankeyChart.js +4 -4
- package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.types.d.ts +5 -1
- package/esm/SankeyChart/SankeyTooltip/index.d.ts +1 -1
- package/esm/SankeyChart/index.d.ts +1 -1
- package/esm/SankeyChart/plugins/useSankeyHighlight.selectors.d.ts +7 -7
- package/esm/SankeyChart/sankey.highlight.types.d.ts +4 -0
- package/esm/SankeyChart/sankey.types.d.ts +6 -3
- package/esm/SankeyChart/seriesConfig/getSeriesWithDefaultValues.js +13 -1
- package/esm/SankeyChart/seriesConfig/identifierCleaner.d.ts +3 -0
- package/esm/SankeyChart/seriesConfig/identifierCleaner.js +18 -0
- package/esm/SankeyChart/seriesConfig/index.js +3 -1
- package/esm/ScatterChartPro/ScatterChartPro.d.ts +1 -1
- package/esm/ScatterChartPro/ScatterChartPro.js +9 -4
- package/esm/index.d.ts +3 -1
- package/esm/index.js +2 -1
- package/esm/internals/index.d.ts +8 -1
- package/esm/internals/index.js +6 -1
- package/esm/internals/plugins/useChartProExport/common.d.ts +5 -1
- package/esm/internals/plugins/useChartProExport/common.js +36 -0
- package/esm/internals/plugins/useChartProExport/exportImage.d.ts +1 -1
- package/esm/internals/plugins/useChartProExport/exportImage.js +10 -1
- package/esm/internals/plugins/useChartProExport/print.d.ts +1 -1
- package/esm/internals/plugins/useChartProExport/print.js +2 -1
- package/esm/internals/plugins/useChartProExport/useChartProExport.js +4 -2
- package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +2 -2
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +4 -2
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +4 -2
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.js +6 -4
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnBrush.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnBrush.js +7 -5
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnDoubleTapReset.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnDoubleTapReset.js +4 -2
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +6 -4
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +6 -4
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +2 -3
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +6 -4
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +5 -5
- package/esm/models/seriesType/heatmap.d.ts +3 -3
- package/esm/plugins/selectors/useChartHeatmapPosition.selectors.d.ts +1 -1
- package/esm/plugins/selectors/useChartHeatmapPosition.selectors.js +3 -1
- package/esm/typeOverloads/modules.d.ts +9 -5
- package/index.d.ts +3 -1
- package/index.js +9 -1
- package/internals/index.d.ts +8 -1
- package/internals/index.js +50 -1
- package/internals/plugins/useChartProExport/common.d.ts +5 -1
- package/internals/plugins/useChartProExport/common.js +37 -0
- package/internals/plugins/useChartProExport/exportImage.d.ts +1 -1
- package/internals/plugins/useChartProExport/exportImage.js +9 -0
- package/internals/plugins/useChartProExport/print.d.ts +1 -1
- package/internals/plugins/useChartProExport/print.js +1 -0
- package/internals/plugins/useChartProExport/useChartProExport.js +4 -2
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +2 -2
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +4 -2
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +4 -2
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.js +5 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnBrush.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnBrush.js +6 -4
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnDoubleTapReset.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnDoubleTapReset.js +4 -2
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +5 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +5 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +2 -3
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +5 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +5 -5
- package/models/seriesType/heatmap.d.ts +3 -3
- package/package.json +8 -8
- package/plugins/selectors/useChartHeatmapPosition.selectors.d.ts +1 -1
- package/plugins/selectors/useChartHeatmapPosition.selectors.js +3 -1
- package/typeOverloads/modules.d.ts +9 -5
package/esm/Heatmap/Heatmap.d.ts
CHANGED
|
@@ -28,7 +28,16 @@ export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlot
|
|
|
28
28
|
tooltip?: Partial<HeatmapTooltipProps>;
|
|
29
29
|
}
|
|
30
30
|
export type HeatmapSeries = MakeOptional<HeatmapSeriesType, 'type'>;
|
|
31
|
-
export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation' | 'slots' | 'slotProps' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
|
|
31
|
+
export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'axesGap' | 'skipAnimation' | 'slots' | 'slotProps' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange' | 'seriesConfig' | 'onAxisClick'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
|
|
32
|
+
/**
|
|
33
|
+
* The function called for onClick events.
|
|
34
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
35
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
36
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Use `onItemClick` instead to get access to both x- and y-axis values.
|
|
39
|
+
*/
|
|
40
|
+
onAxisClick?: ChartContainerProProps<'heatmap', HeatmapPluginSignatures>['onAxisClick'];
|
|
32
41
|
/**
|
|
33
42
|
* The configuration of the x-axes.
|
|
34
43
|
* If not provided, a default axis config is used.
|
|
@@ -53,7 +62,6 @@ export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', Hea
|
|
|
53
62
|
tooltip?: ChartsTooltipProps;
|
|
54
63
|
/**
|
|
55
64
|
* If `true`, the legend is not rendered.
|
|
56
|
-
* @default true
|
|
57
65
|
*/
|
|
58
66
|
hideLegend?: boolean;
|
|
59
67
|
/**
|
|
@@ -61,6 +69,10 @@ export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', Hea
|
|
|
61
69
|
* @default false
|
|
62
70
|
*/
|
|
63
71
|
showToolbar?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The border radius of the heatmap cells in pixels.
|
|
74
|
+
*/
|
|
75
|
+
borderRadius?: number;
|
|
64
76
|
/**
|
|
65
77
|
* Overridable component slots.
|
|
66
78
|
* @default {}
|
package/esm/Heatmap/Heatmap.js
CHANGED
|
@@ -4,158 +4,57 @@ 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 { useThemeProps } from '@mui/material/styles';
|
|
7
|
-
import useId from '@mui/utils/useId';
|
|
8
|
-
import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
|
|
9
7
|
import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
|
|
10
8
|
import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
|
|
11
9
|
import { ChartsWrapper } from '@mui/x-charts/ChartsWrapper';
|
|
12
10
|
import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
|
|
13
11
|
import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
|
|
14
|
-
import {
|
|
15
|
-
import { ChartsLegend, ContinuousColorLegend } from '@mui/x-charts/ChartsLegend';
|
|
12
|
+
import { ChartsLegend } from '@mui/x-charts/ChartsLegend';
|
|
16
13
|
import { ChartsBrushOverlay } from '@mui/x-charts/ChartsBrushOverlay';
|
|
17
14
|
import { HeatmapPlot } from "./HeatmapPlot.js";
|
|
18
|
-
import { heatmapSeriesConfig } from "./seriesConfig/index.js";
|
|
19
15
|
import { HeatmapTooltip } from "./HeatmapTooltip/index.js";
|
|
20
|
-
import { HEATMAP_PLUGINS } from "./Heatmap.plugins.js";
|
|
21
16
|
import { ChartDataProviderPro } from "../ChartDataProviderPro/index.js";
|
|
22
17
|
import { ChartsToolbarPro } from "../ChartsToolbarPro/index.js";
|
|
23
18
|
import { FocusedHeatmapCell } from "./FocusedHeatmapCell.js";
|
|
19
|
+
import { useHeatmapProps } from "./useHeatmapProps.js";
|
|
24
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
// The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
|
|
26
|
-
const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
|
|
27
|
-
const seriesConfig = {
|
|
28
|
-
heatmap: heatmapSeriesConfig
|
|
29
|
-
};
|
|
30
|
-
function getDefaultDataForAxis(series, dimension) {
|
|
31
|
-
if (series?.[0]?.data === undefined || series[0].data.length === 0) {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
return Array.from({
|
|
35
|
-
length: Math.max(...series[0].data.map(dataPoint => dataPoint[dimension])) + 1
|
|
36
|
-
}, (_, index) => index);
|
|
37
|
-
}
|
|
38
|
-
const getDefaultDataForXAxis = series => getDefaultDataForAxis(series, 0);
|
|
39
|
-
const getDefaultDataForYAxis = series => getDefaultDataForAxis(series, 1);
|
|
40
21
|
const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
|
|
41
22
|
const props = useThemeProps({
|
|
42
23
|
props: inProps,
|
|
43
24
|
name: 'MuiHeatmap'
|
|
44
25
|
});
|
|
45
26
|
const {
|
|
46
|
-
apiRef,
|
|
47
|
-
xAxis,
|
|
48
|
-
yAxis,
|
|
49
|
-
zAxis,
|
|
50
|
-
series,
|
|
51
|
-
width,
|
|
52
|
-
height,
|
|
53
|
-
margin,
|
|
54
|
-
colors,
|
|
55
|
-
dataset,
|
|
56
27
|
sx,
|
|
57
|
-
onAxisClick,
|
|
58
|
-
children,
|
|
59
28
|
slots,
|
|
60
29
|
slotProps,
|
|
61
30
|
loading,
|
|
62
|
-
|
|
63
|
-
onHighlightChange,
|
|
64
|
-
enableKeyboardNavigation,
|
|
65
|
-
hideLegend = true,
|
|
31
|
+
hideLegend,
|
|
66
32
|
showToolbar = false
|
|
67
33
|
} = props;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
id: DEFAULT_Y_AXIS_KEY
|
|
80
|
-
}]).map(axis => _extends({
|
|
81
|
-
scaleType: 'band',
|
|
82
|
-
categoryGapRatio: 0
|
|
83
|
-
}, axis, {
|
|
84
|
-
data: axis.data ?? getDefaultDataForYAxis(series)
|
|
85
|
-
})), [series, yAxis]);
|
|
86
|
-
const zAxisWithDefault = React.useMemo(() => zAxis ?? [{
|
|
87
|
-
colorMap: {
|
|
88
|
-
type: 'continuous',
|
|
89
|
-
min: 0,
|
|
90
|
-
max: 100,
|
|
91
|
-
color: defaultColorMap
|
|
92
|
-
}
|
|
93
|
-
}], [zAxis]);
|
|
94
|
-
const chartsWrapperProps = {
|
|
95
|
-
sx,
|
|
96
|
-
legendPosition: props.slotProps?.legend?.position,
|
|
97
|
-
legendDirection: props.slotProps?.legend?.direction,
|
|
98
|
-
hideLegend
|
|
99
|
-
};
|
|
34
|
+
const {
|
|
35
|
+
chartDataProviderProProps,
|
|
36
|
+
chartsWrapperProps,
|
|
37
|
+
chartsAxisProps,
|
|
38
|
+
clipPathProps,
|
|
39
|
+
clipPathGroupProps,
|
|
40
|
+
legendProps,
|
|
41
|
+
heatmapPlotProps,
|
|
42
|
+
overlayProps,
|
|
43
|
+
children
|
|
44
|
+
} = useHeatmapProps(props);
|
|
100
45
|
const Tooltip = slots?.tooltip ?? HeatmapTooltip;
|
|
101
46
|
const Toolbar = slots?.toolbar ?? ChartsToolbarPro;
|
|
102
|
-
return /*#__PURE__*/_jsx(ChartDataProviderPro, {
|
|
103
|
-
apiRef: apiRef,
|
|
104
|
-
seriesConfig: seriesConfig,
|
|
105
|
-
series: series.map(s => _extends({
|
|
106
|
-
type: 'heatmap'
|
|
107
|
-
}, s)),
|
|
108
|
-
width: width,
|
|
109
|
-
height: height,
|
|
110
|
-
margin: margin,
|
|
111
|
-
xAxis: xAxisWithDefault,
|
|
112
|
-
yAxis: yAxisWithDefault,
|
|
113
|
-
zAxis: zAxisWithDefault,
|
|
114
|
-
colors: colors,
|
|
115
|
-
dataset: dataset,
|
|
116
|
-
disableAxisListener: true,
|
|
117
|
-
highlightedItem: highlightedItem,
|
|
118
|
-
onHighlightChange: onHighlightChange,
|
|
119
|
-
enableKeyboardNavigation: enableKeyboardNavigation,
|
|
120
|
-
onAxisClick: onAxisClick,
|
|
121
|
-
plugins: HEATMAP_PLUGINS,
|
|
47
|
+
return /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
|
|
122
48
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
123
|
-
children: [showToolbar ? /*#__PURE__*/_jsx(Toolbar, _extends({}, props.slotProps?.toolbar)) : null, !hideLegend && /*#__PURE__*/_jsx(ChartsLegend, {
|
|
124
|
-
slots: _extends({}, slots, {
|
|
125
|
-
legend: slots?.legend ?? ContinuousColorLegend
|
|
126
|
-
}),
|
|
127
|
-
slotProps: {
|
|
128
|
-
legend: _extends({
|
|
129
|
-
labelPosition: 'extremes'
|
|
130
|
-
}, slotProps?.legend)
|
|
131
|
-
},
|
|
132
|
-
sx: slotProps?.legend?.direction === 'vertical' ? {
|
|
133
|
-
height: 150
|
|
134
|
-
} : {
|
|
135
|
-
width: '50%'
|
|
136
|
-
}
|
|
137
|
-
}), /*#__PURE__*/_jsxs(ChartsSurface, {
|
|
49
|
+
children: [showToolbar ? /*#__PURE__*/_jsx(Toolbar, _extends({}, props.slotProps?.toolbar)) : null, !hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, {
|
|
138
50
|
ref: ref,
|
|
139
51
|
sx: sx,
|
|
140
|
-
children: [/*#__PURE__*/_jsxs("g", {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
slots: slots,
|
|
144
|
-
slotProps: slotProps
|
|
145
|
-
}), /*#__PURE__*/_jsx(FocusedHeatmapCell, {}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
146
|
-
loading: loading,
|
|
147
|
-
slots: slots,
|
|
148
|
-
slotProps: slotProps
|
|
149
|
-
})]
|
|
150
|
-
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
151
|
-
slots: slots,
|
|
152
|
-
slotProps: slotProps
|
|
153
|
-
}), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
154
|
-
id: clipPathId
|
|
155
|
-
}), /*#__PURE__*/_jsx(ChartsBrushOverlay, {}), children]
|
|
52
|
+
children: [/*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
53
|
+
children: [/*#__PURE__*/_jsx(HeatmapPlot, _extends({}, heatmapPlotProps)), /*#__PURE__*/_jsx(FocusedHeatmapCell, {}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps))]
|
|
54
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), /*#__PURE__*/_jsx(ChartsBrushOverlay, {}), children]
|
|
156
55
|
}), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip))]
|
|
157
56
|
}))
|
|
158
|
-
});
|
|
57
|
+
}));
|
|
159
58
|
});
|
|
160
59
|
if (process.env.NODE_ENV !== "production") Heatmap.displayName = "Heatmap";
|
|
161
60
|
process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
@@ -171,6 +70,10 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
171
70
|
setZoomData: PropTypes.func.isRequired
|
|
172
71
|
})
|
|
173
72
|
}),
|
|
73
|
+
/**
|
|
74
|
+
* The border radius of the heatmap cells in pixels.
|
|
75
|
+
*/
|
|
76
|
+
borderRadius: PropTypes.number,
|
|
174
77
|
/**
|
|
175
78
|
* Configuration for the brush interaction.
|
|
176
79
|
*/
|
|
@@ -203,7 +106,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
203
106
|
height: PropTypes.number,
|
|
204
107
|
/**
|
|
205
108
|
* If `true`, the legend is not rendered.
|
|
206
|
-
* @default true
|
|
207
109
|
*/
|
|
208
110
|
hideLegend: PropTypes.bool,
|
|
209
111
|
/**
|
|
@@ -212,7 +114,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
212
114
|
*/
|
|
213
115
|
highlightedItem: PropTypes.shape({
|
|
214
116
|
dataIndex: PropTypes.number,
|
|
215
|
-
seriesId: PropTypes.
|
|
117
|
+
seriesId: PropTypes.string.isRequired
|
|
216
118
|
}),
|
|
217
119
|
/**
|
|
218
120
|
* This prop is used to help implement the accessibility logic.
|
|
@@ -254,6 +156,8 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
254
156
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
255
157
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
256
158
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
159
|
+
*
|
|
160
|
+
* @deprecated Use `onItemClick` instead to get access to both x- and y-axis values.
|
|
257
161
|
*/
|
|
258
162
|
onAxisClick: PropTypes.func,
|
|
259
163
|
/**
|
|
@@ -262,6 +166,13 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
262
166
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
263
167
|
*/
|
|
264
168
|
onHighlightChange: PropTypes.func,
|
|
169
|
+
/**
|
|
170
|
+
* The callback fired when an item is clicked.
|
|
171
|
+
*
|
|
172
|
+
* @param {React.MouseEvent<SVGSVGElement, MouseEvent>} event The click event.
|
|
173
|
+
* @param {SeriesItemIdentifier<SeriesType>} item The clicked item.
|
|
174
|
+
*/
|
|
175
|
+
onItemClick: PropTypes.func,
|
|
265
176
|
/**
|
|
266
177
|
* The callback fired when the tooltip item changes.
|
|
267
178
|
*
|
|
@@ -279,11 +190,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
279
190
|
* An array of [[HeatmapSeries]] objects.
|
|
280
191
|
*/
|
|
281
192
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
282
|
-
/**
|
|
283
|
-
* The configuration helpers used to compute attributes according to the series type.
|
|
284
|
-
* @ignore Unstable props for internal usage.
|
|
285
|
-
*/
|
|
286
|
-
seriesConfig: PropTypes.object,
|
|
287
193
|
/**
|
|
288
194
|
* If true, shows the default chart toolbar.
|
|
289
195
|
* @default false
|
|
@@ -313,10 +219,10 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
313
219
|
*/
|
|
314
220
|
tooltipItem: PropTypes.shape({
|
|
315
221
|
dataIndex: PropTypes.number,
|
|
316
|
-
seriesId: PropTypes.
|
|
222
|
+
seriesId: PropTypes.string.isRequired,
|
|
317
223
|
type: PropTypes.oneOf(['heatmap']).isRequired,
|
|
318
|
-
xIndex: PropTypes.number,
|
|
319
|
-
yIndex: PropTypes.number
|
|
224
|
+
xIndex: PropTypes.number.isRequired,
|
|
225
|
+
yIndex: PropTypes.number.isRequired
|
|
320
226
|
}),
|
|
321
227
|
/**
|
|
322
228
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type UseChartZAxisSignature, type UseChartCartesianAxisSignature, type UseChartTooltipSignature, type UseChartInteractionSignature, type UseChartHighlightSignature, type
|
|
1
|
+
import { type UseChartZAxisSignature, type UseChartCartesianAxisSignature, type UseChartTooltipSignature, type UseChartInteractionSignature, type UseChartHighlightSignature, type UseChartBrushSignature, type UseChartItemClickSignature, type UseChartKeyboardNavigationSignature, type ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
|
|
2
2
|
import { type UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
|
|
3
3
|
import { type UseChartProZoomSignature } from "../internals/plugins/useChartProZoom/index.js";
|
|
4
|
-
export type HeatmapPluginSignatures = [UseChartZAxisSignature, UseChartTooltipSignature<'heatmap'>, UseChartInteractionSignature, UseChartCartesianAxisSignature<'heatmap'>, UseChartHighlightSignature, UseChartProExportSignature, UseChartBrushSignature, UseChartProZoomSignature, UseChartKeyboardNavigationSignature];
|
|
4
|
+
export type HeatmapPluginSignatures = [UseChartZAxisSignature, UseChartTooltipSignature<'heatmap'>, UseChartInteractionSignature, UseChartCartesianAxisSignature<'heatmap'>, UseChartHighlightSignature, UseChartProExportSignature, UseChartBrushSignature, UseChartProZoomSignature, UseChartItemClickSignature<'heatmap'>, UseChartKeyboardNavigationSignature];
|
|
5
5
|
export declare const HEATMAP_PLUGINS: ConvertSignaturesIntoPlugins<HeatmapPluginSignatures>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useChartZAxis, useChartCartesianAxis, useChartTooltip, useChartInteraction, useChartHighlight, useChartBrush, useChartKeyboardNavigation } from '@mui/x-charts/internals';
|
|
1
|
+
import { useChartZAxis, useChartCartesianAxis, useChartTooltip, useChartInteraction, useChartHighlight, useChartBrush, useChartItemClick, useChartKeyboardNavigation } from '@mui/x-charts/internals';
|
|
2
2
|
import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
|
|
3
3
|
import { useChartProZoom } from "../internals/plugins/useChartProZoom/index.js";
|
|
4
|
-
export const HEATMAP_PLUGINS = [useChartZAxis, useChartTooltip, useChartInteraction, useChartCartesianAxis, useChartHighlight, useChartProExport, useChartBrush, useChartProZoom, useChartKeyboardNavigation];
|
|
4
|
+
export const HEATMAP_PLUGINS = [useChartZAxis, useChartTooltip, useChartInteraction, useChartCartesianAxis, useChartHighlight, useChartProExport, useChartBrush, useChartProZoom, useChartItemClick, useChartKeyboardNavigation];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type HeatmapItemProps, type HeatmapItemSlotProps, type HeatmapItemSlots } from "./HeatmapItem.js";
|
|
2
|
+
export interface HeatmapPlotSlots extends HeatmapItemSlots {}
|
|
3
|
+
export interface HeatmapPlotSlotProps extends HeatmapItemSlotProps {}
|
|
4
|
+
export interface HeatmapRendererPlotProps extends Pick<HeatmapItemProps, 'slots' | 'slotProps'> {
|
|
5
|
+
/**
|
|
6
|
+
* The border radius of the heatmap cells in pixels.
|
|
7
|
+
*/
|
|
8
|
+
borderRadius?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Overridable component slots.
|
|
11
|
+
* @default {}
|
|
12
|
+
*/
|
|
13
|
+
slots?: HeatmapPlotSlots;
|
|
14
|
+
/**
|
|
15
|
+
* The props used for each component slot.
|
|
16
|
+
* @default {}
|
|
17
|
+
*/
|
|
18
|
+
slotProps?: HeatmapPlotSlotProps;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -19,9 +19,15 @@ export interface HeatmapItemProps {
|
|
|
19
19
|
height: number;
|
|
20
20
|
x: number;
|
|
21
21
|
y: number;
|
|
22
|
+
xIndex: number;
|
|
23
|
+
yIndex: number;
|
|
22
24
|
color: string;
|
|
23
25
|
isHighlighted?: boolean;
|
|
24
26
|
isFaded?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The border radius of the heatmap cell in pixels.
|
|
29
|
+
*/
|
|
30
|
+
borderRadius?: number;
|
|
25
31
|
/**
|
|
26
32
|
* The props used for each component slot.
|
|
27
33
|
* @default {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["seriesId", "dataIndex", "color", "value", "isHighlighted", "isFaded", "slotProps", "slots"];
|
|
3
|
+
const _excluded = ["seriesId", "dataIndex", "color", "value", "isHighlighted", "isFaded", "borderRadius", "xIndex", "yIndex", "slotProps", "slots"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
@@ -34,6 +34,9 @@ function HeatmapItem(props) {
|
|
|
34
34
|
value,
|
|
35
35
|
isHighlighted = false,
|
|
36
36
|
isFaded = false,
|
|
37
|
+
borderRadius,
|
|
38
|
+
xIndex,
|
|
39
|
+
yIndex,
|
|
37
40
|
slotProps = {},
|
|
38
41
|
slots = {}
|
|
39
42
|
} = props,
|
|
@@ -45,7 +48,9 @@ function HeatmapItem(props) {
|
|
|
45
48
|
const interactionProps = useInteractionItemProps({
|
|
46
49
|
type: 'heatmap',
|
|
47
50
|
seriesId,
|
|
48
|
-
dataIndex
|
|
51
|
+
dataIndex,
|
|
52
|
+
xIndex,
|
|
53
|
+
yIndex
|
|
49
54
|
}, skipInteractionItemProps);
|
|
50
55
|
const ownerState = {
|
|
51
56
|
seriesId,
|
|
@@ -59,7 +64,10 @@ function HeatmapItem(props) {
|
|
|
59
64
|
const Cell = slots?.cell ?? HeatmapCell;
|
|
60
65
|
const cellProps = useSlotProps({
|
|
61
66
|
elementType: Cell,
|
|
62
|
-
additionalProps: interactionProps,
|
|
67
|
+
additionalProps: _extends({}, interactionProps, {
|
|
68
|
+
rx: borderRadius,
|
|
69
|
+
ry: borderRadius
|
|
70
|
+
}),
|
|
63
71
|
externalForwardedProps: _extends({}, other),
|
|
64
72
|
externalSlotProps: slotProps.cell,
|
|
65
73
|
ownerState,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type HeatmapRendererPlotProps } from "./Heatmap.types.js";
|
|
3
|
+
export interface HeatmapPlotProps extends HeatmapRendererPlotProps {}
|
|
4
|
+
declare function HeatmapPlot({
|
|
5
|
+
borderRadius,
|
|
6
|
+
...props
|
|
7
|
+
}: HeatmapPlotProps): React.ReactNode;
|
|
4
8
|
declare namespace HeatmapPlot {
|
|
5
9
|
var propTypes: any;
|
|
6
10
|
}
|
|
@@ -1,69 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["borderRadius"];
|
|
3
6
|
import * as React from 'react';
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const xScale = useXScale();
|
|
16
|
-
const yScale = useYScale();
|
|
17
|
-
const colorScale = useZColorScale();
|
|
18
|
-
const series = useHeatmapSeriesContext();
|
|
19
|
-
const isHighlighted = store.use(selectorChartsIsHighlightedCallback);
|
|
20
|
-
const isFaded = store.use(selectorChartsIsFadedCallback);
|
|
21
|
-
const xDomain = xScale.domain();
|
|
22
|
-
const yDomain = yScale.domain();
|
|
23
|
-
if (!series || series.seriesOrder.length === 0) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const seriesToDisplay = series.series[series.seriesOrder[0]];
|
|
27
|
-
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
28
|
-
children: [shouldRegisterPointerInteractionsGlobally(props.slots, props.slotProps) ? /*#__PURE__*/_jsx(RegisterHeatmapPointerInteractions, {}) : null, /*#__PURE__*/_jsx("g", {
|
|
29
|
-
children: seriesToDisplay.data.map(([xIndex, yIndex, value], dataIndex) => {
|
|
30
|
-
const x = xScale(xDomain[xIndex]);
|
|
31
|
-
const y = yScale(yDomain[yIndex]);
|
|
32
|
-
const color = colorScale?.(value);
|
|
33
|
-
if (x === undefined || y === undefined || !color) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const item = {
|
|
37
|
-
seriesId: seriesToDisplay.id,
|
|
38
|
-
dataIndex
|
|
39
|
-
};
|
|
40
|
-
return /*#__PURE__*/_jsx(HeatmapItem, {
|
|
41
|
-
width: xScale.bandwidth(),
|
|
42
|
-
height: yScale.bandwidth(),
|
|
43
|
-
x: x,
|
|
44
|
-
y: y,
|
|
45
|
-
color: color,
|
|
46
|
-
dataIndex: dataIndex,
|
|
47
|
-
seriesId: series.seriesOrder[0],
|
|
48
|
-
value: value,
|
|
49
|
-
slots: props.slots,
|
|
50
|
-
slotProps: props.slotProps,
|
|
51
|
-
isHighlighted: isHighlighted(item),
|
|
52
|
-
isFaded: isFaded(item)
|
|
53
|
-
}, `${xIndex}_${yIndex}`);
|
|
54
|
-
})
|
|
55
|
-
})]
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function RegisterHeatmapPointerInteractions() {
|
|
59
|
-
useRegisterPointerInteractions(selectorHeatmapItemAtPosition);
|
|
60
|
-
return null;
|
|
8
|
+
import { HeatmapSVGPlot } from "./HeatmapSVGPlot.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
function HeatmapPlot(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
borderRadius
|
|
13
|
+
} = _ref,
|
|
14
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
|
+
return /*#__PURE__*/_jsx(HeatmapSVGPlot, _extends({
|
|
16
|
+
borderRadius: borderRadius
|
|
17
|
+
}, props));
|
|
61
18
|
}
|
|
62
19
|
process.env.NODE_ENV !== "production" ? HeatmapPlot.propTypes = {
|
|
63
20
|
// ----------------------------- Warning --------------------------------
|
|
64
21
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
22
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
66
23
|
// ----------------------------------------------------------------------
|
|
24
|
+
/**
|
|
25
|
+
* The border radius of the heatmap cells in pixels.
|
|
26
|
+
*/
|
|
27
|
+
borderRadius: PropTypes.number,
|
|
67
28
|
/**
|
|
68
29
|
* The props used for each component slot.
|
|
69
30
|
* @default {}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useXScale, useYScale, useZColorScale } from '@mui/x-charts/hooks';
|
|
5
|
+
import { selectorChartsIsFadedCallback, selectorChartsIsHighlightedCallback, useStore, useRegisterPointerInteractions } from '@mui/x-charts/internals';
|
|
6
|
+
import { useHeatmapSeriesContext } from "../hooks/index.js";
|
|
7
|
+
import { HeatmapItem } from "./HeatmapItem.js";
|
|
8
|
+
import { selectorHeatmapItemAtPosition } from "../plugins/selectors/useChartHeatmapPosition.selectors.js";
|
|
9
|
+
import { shouldRegisterPointerInteractionsGlobally } from "./shouldRegisterPointerInteractionsGlobally.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const MemoHeatmapItem = /*#__PURE__*/React.memo(HeatmapItem);
|
|
12
|
+
if (process.env.NODE_ENV !== "production") MemoHeatmapItem.displayName = "MemoHeatmapItem";
|
|
13
|
+
export function HeatmapSVGPlot(props) {
|
|
14
|
+
const store = useStore();
|
|
15
|
+
const xScale = useXScale();
|
|
16
|
+
const yScale = useYScale();
|
|
17
|
+
const colorScale = useZColorScale();
|
|
18
|
+
const series = useHeatmapSeriesContext();
|
|
19
|
+
const isHighlighted = store.use(selectorChartsIsHighlightedCallback);
|
|
20
|
+
const isFaded = store.use(selectorChartsIsFadedCallback);
|
|
21
|
+
const xDomain = xScale.domain();
|
|
22
|
+
const yDomain = yScale.domain();
|
|
23
|
+
if (!series || series.seriesOrder.length === 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const seriesToDisplay = series.series[series.seriesOrder[0]];
|
|
27
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
28
|
+
children: [shouldRegisterPointerInteractionsGlobally(props.slots, props.slotProps) ? /*#__PURE__*/_jsx(RegisterHeatmapPointerInteractions, {}) : null, /*#__PURE__*/_jsx("g", {
|
|
29
|
+
children: seriesToDisplay.data.map(([xIndex, yIndex, value], dataIndex) => {
|
|
30
|
+
const x = xScale(xDomain[xIndex]);
|
|
31
|
+
const y = yScale(yDomain[yIndex]);
|
|
32
|
+
const color = colorScale?.(value);
|
|
33
|
+
if (x === undefined || y === undefined || !color) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const item = {
|
|
37
|
+
seriesId: seriesToDisplay.id,
|
|
38
|
+
dataIndex
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/_jsx(MemoHeatmapItem, {
|
|
41
|
+
width: xScale.bandwidth(),
|
|
42
|
+
height: yScale.bandwidth(),
|
|
43
|
+
x: x,
|
|
44
|
+
y: y,
|
|
45
|
+
xIndex: xIndex,
|
|
46
|
+
yIndex: yIndex,
|
|
47
|
+
color: color,
|
|
48
|
+
dataIndex: dataIndex,
|
|
49
|
+
seriesId: series.seriesOrder[0],
|
|
50
|
+
value: value,
|
|
51
|
+
slots: props.slots,
|
|
52
|
+
slotProps: props.slotProps,
|
|
53
|
+
isHighlighted: isHighlighted(item),
|
|
54
|
+
isFaded: isFaded(item),
|
|
55
|
+
borderRadius: props.borderRadius
|
|
56
|
+
}, `${xIndex}_${yIndex}`);
|
|
57
|
+
})
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function RegisterHeatmapPointerInteractions() {
|
|
62
|
+
useRegisterPointerInteractions(selectorHeatmapItemAtPosition);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { type ChartsTooltipContainerProps } from '@mui/x-charts/ChartsTooltip';
|
|
1
|
+
import { type ChartsTooltipContainerProps, type ChartsTooltipClasses, type ChartsTooltipSlots, type ChartsTooltipSlotProps } from '@mui/x-charts/ChartsTooltip';
|
|
2
|
+
export interface HeatmapTooltipSlots extends ChartsTooltipSlots {}
|
|
3
|
+
export interface HeatmapTooltipSlotProps extends ChartsTooltipSlotProps {}
|
|
4
|
+
export interface HeatmapTooltipClasses extends ChartsTooltipClasses {}
|
|
5
|
+
export interface HeatmapTooltipContentClasses extends ChartsTooltipClasses {}
|
|
2
6
|
export interface HeatmapTooltipProps extends Omit<ChartsTooltipContainerProps, 'trigger' | 'children'> {
|
|
3
7
|
/**
|
|
4
8
|
* Select the kind of tooltip to display
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from "./HeatmapTooltip.js";
|
|
2
2
|
export * from "./HeatmapTooltipContent.js";
|
|
3
|
-
export type { HeatmapTooltipProps } from "./HeatmapTooltip.types.js";
|
|
3
|
+
export type { HeatmapTooltipProps, HeatmapTooltipClasses, HeatmapTooltipContentClasses, HeatmapTooltipSlots, HeatmapTooltipSlotProps } from "./HeatmapTooltip.types.js";
|
package/esm/Heatmap/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Heatmap } from "./Heatmap.js";
|
|
2
|
-
export type { HeatmapSeries, HeatmapProps } from "./Heatmap.js";
|
|
3
|
-
export { HeatmapPlot } from "./HeatmapPlot.js";
|
|
2
|
+
export type { HeatmapSeries, HeatmapProps, HeatmapSlots, HeatmapSlotProps } from "./Heatmap.js";
|
|
3
|
+
export { HeatmapPlot, type HeatmapPlotProps } from "./HeatmapPlot.js";
|
|
4
|
+
export type { HeatmapPlotSlots, HeatmapPlotSlotProps } from "./Heatmap.types.js";
|
|
4
5
|
export * from "./FocusedHeatmapCell.js";
|
|
5
6
|
export type { HeatmapCellProps } from "./internals/HeatmapCell.js";
|
|
6
7
|
export * from "./HeatmapTooltip/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ChartState, UseChartCartesianAxisSignature } from '@mui/x-charts/internals';
|
|
2
|
+
import type { SeriesItemIdentifier } from '@mui/x-charts/models';
|
|
3
|
+
export default function getItemAtPosition(state: ChartState<[UseChartCartesianAxisSignature]>, point: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}): SeriesItemIdentifier<'heatmap'> | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { selectorAllSeriesOfType, selectorChartXAxis, selectorChartYAxis, getCartesianAxisIndex } from '@mui/x-charts/internals';
|
|
2
|
+
export default function getItemAtPosition(state, point) {
|
|
3
|
+
const {
|
|
4
|
+
axis: xAxis,
|
|
5
|
+
axisIds: xAxisIds
|
|
6
|
+
} = selectorChartXAxis(state);
|
|
7
|
+
const {
|
|
8
|
+
axis: yAxis,
|
|
9
|
+
axisIds: yAxisIds
|
|
10
|
+
} = selectorChartYAxis(state);
|
|
11
|
+
const series = selectorAllSeriesOfType(state, 'heatmap');
|
|
12
|
+
const xAxisWithScale = xAxis[xAxisIds[0]];
|
|
13
|
+
const yAxisWithScale = yAxis[yAxisIds[0]];
|
|
14
|
+
const seriesId = series?.seriesOrder[0];
|
|
15
|
+
if (seriesId === undefined) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const xIndex = getCartesianAxisIndex(xAxisWithScale, point.x);
|
|
19
|
+
const yIndex = getCartesianAxisIndex(yAxisWithScale, point.y);
|
|
20
|
+
if (xIndex === -1 || yIndex === -1) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const dataIndex = series ? series.series[series.seriesOrder[0]].data.findIndex(d => d[0] === xIndex && d[1] === yIndex) : -1;
|
|
24
|
+
if (dataIndex === -1) {
|
|
25
|
+
return {
|
|
26
|
+
type: 'heatmap',
|
|
27
|
+
seriesId,
|
|
28
|
+
xIndex,
|
|
29
|
+
yIndex
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
type: 'heatmap',
|
|
34
|
+
seriesId,
|
|
35
|
+
dataIndex,
|
|
36
|
+
xIndex,
|
|
37
|
+
yIndex
|
|
38
|
+
};
|
|
39
|
+
}
|