Skip to content

Commit a8acf78

Browse files
[charts-pro] Render the toolbar in the heatmap chart (#18247)
1 parent a9bb071 commit a8acf78

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

docs/pages/x/api/charts/heatmap.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"describedArgs": ["highlightedItem"]
5656
}
5757
},
58+
"showToolbar": { "type": { "name": "bool" }, "default": "false" },
5859
"slotProps": { "type": { "name": "object" }, "default": "{}" },
5960
"slots": {
6061
"type": { "name": "object" },

docs/translations/api-docs/charts/heatmap/heatmap.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"series": {
3838
"description": "The series to display in the bar chart. An array of HeatmapSeriesType objects."
3939
},
40+
"showToolbar": { "description": "If true, shows the default chart toolbar." },
4041
"slotProps": { "description": "The props used for each component slot." },
4142
"slots": { "description": "Overridable component slots." },
4243
"tooltip": {

packages/x-charts-pro/src/Heatmap/Heatmap.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { HeatmapTooltip, HeatmapTooltipProps } from './HeatmapTooltip';
4141
import { HeatmapItemSlotProps, HeatmapItemSlots } from './HeatmapItem';
4242
import { HEATMAP_PLUGINS, HeatmapPluginsSignatures } from './Heatmap.plugins';
4343
import { ChartDataProviderPro } from '../ChartDataProviderPro';
44+
import { ChartsToolbarPro } from '../ChartsToolbarPro';
4445

4546
export interface HeatmapSlots
4647
extends ChartsAxisSlots,
@@ -103,6 +104,11 @@ export interface HeatmapProps
103104
* @default true
104105
*/
105106
hideLegend?: boolean;
107+
/**
108+
* If true, shows the default chart toolbar.
109+
* @default false
110+
*/
111+
showToolbar?: boolean;
106112
/**
107113
* Overridable component slots.
108114
* @default {}
@@ -168,6 +174,7 @@ const Heatmap = React.forwardRef(function Heatmap(
168174
highlightedItem,
169175
onHighlightChange,
170176
hideLegend = true,
177+
showToolbar = false,
171178
} = props;
172179

173180
const id = useId();
@@ -216,6 +223,7 @@ const Heatmap = React.forwardRef(function Heatmap(
216223
legendDirection: props.slotProps?.legend?.direction,
217224
};
218225
const Tooltip = slots?.tooltip ?? HeatmapTooltip;
226+
const Toolbar = slots?.toolbar ?? ChartsToolbarPro;
219227

220228
return (
221229
<ChartDataProviderPro<'heatmap', HeatmapPluginsSignatures>
@@ -240,6 +248,7 @@ const Heatmap = React.forwardRef(function Heatmap(
240248
plugins={HEATMAP_PLUGINS}
241249
>
242250
<ChartsWrapper {...chartsWrapperProps}>
251+
{showToolbar ? <Toolbar {...props.slotProps?.toolbar} /> : null}
243252
{!hideLegend && (
244253
<ChartsLegend
245254
slots={{ ...slots, legend: slots?.legend ?? ContinuousColorLegend }}
@@ -359,6 +368,11 @@ Heatmap.propTypes = {
359368
* @ignore Unstable props for internal usage.
360369
*/
361370
seriesConfig: PropTypes.object,
371+
/**
372+
* If true, shows the default chart toolbar.
373+
* @default false
374+
*/
375+
showToolbar: PropTypes.bool,
362376
/**
363377
* The props used for each component slot.
364378
* @default {}

0 commit comments

Comments
 (0)