Skip to content

Commit a248ff5

Browse files
[charts][docs] Revise the Heatmap doc (#21676)
1 parent 478f00c commit a248ff5

File tree

1 file changed

+50
-42
lines changed

1 file changed

+50
-42
lines changed

docs/data/charts/heatmap/heatmap.md

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ components: Heatmap, HeatmapPlot, HeatmapTooltip, HeatmapTooltipContent, Heatmap
66

77
# Charts - Heatmap [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')
88

9-
<p class="description">Heatmap charts visually represents data with color variations to highlight patterns and trends across two dimensions.</p>
9+
<p class="description">Use heatmap charts to show intensity as a grid of colored cells across two dimensions.</p>
1010

1111
## Overview
1212

13-
Heatmaps are ideal for visualizing intensity variations across two categorical or continuous dimensions. They highlight areas of high and low concentration in a dataset, making it easy to detect trends, clusters, or anomalies at a glance. Each cell in a heatmap represents the intersection of two variables, with color encoding used to convey the magnitude of a numerical value.
13+
A heatmap shows how a numeric value varies across two dimensions as a grid of colored cells.
14+
Each cell is the intersection of an x and y category or tick, and color encodes the value.
15+
16+
Use heatmaps to spot areas of higher or lower intensity, clusters, or anomalies.
17+
18+
The demo below shows bicycle counts in Paris by day and hour.
19+
1420
{{"demo": "HeatmapDemo.js", "disableAd": true, "defaultCodeOpen": false}}
1521

1622
## Basics
1723

18-
Heatmap charts series must contain a `data` property containing an array of 3-tuples.
19-
The first two numbers in each tuple correspond to the x and y indexes of the cell, respectively.
20-
The third number is the value for the given cell.
24+
A heatmap series must include a `data` property with an array of 3-tuples.
25+
Each tuple is `[xIndex, yIndex, value]`.
26+
The first two numbers are the cell's x and y indices, and the third is the cell value.
2127

2228
```jsx
2329
<Heatmap
@@ -32,92 +38,94 @@ The third number is the value for the given cell.
3238
/>
3339
```
3440

35-
You can specify x and y ticks with the `xAxis` and `yAxis` props.
41+
Use the `xAxis` and `yAxis` props to set x and y ticks.
3642

3743
{{"demo": "BasicHeatmap.js"}}
3844

3945
## Color mapping
4046

41-
To customize the color mapping, use the `zAxis` configuration.
42-
You can either use the piecewise or continuous [color mapping](https://mui.com/x/react-charts/styling/#value-based-colors).
47+
Use the `zAxis` configuration to customize how values map to color.
48+
You can use piecewise or continuous scales.
49+
See [Styling—Value-based colors](/x/react-charts/styling/#value-based-colors) for details.
4350

4451
{{"demo": "ColorConfig.js"}}
4552

4653
## Highlight
4754

48-
You can choose to highlight the hovered element by setting `highlightScope.highlight` to `'item'`.
49-
To fade the other item, set `highlightScope.fade` to `'global'`.
55+
Set `highlightScope.highlight` to `'item'` to highlight the hovered cell.
56+
Set `highlightScope.fade` to `'global'` to fade the other cells.
5057

5158
{{"demo": "HighlightHeatmap.js"}}
5259

53-
By default highlighted/faded effect is obtained by applying the CSS property `filter: saturate(...)` to cells.
54-
To modify this styling, use the `heatmapClasses.highlighted` and `heatmapClasses.faded` CSS classes to override the applied style.
60+
By default, the highlight and fade use the CSS `filter: saturate(...)` property.
61+
You can override the effect with the `heatmapClasses.highlighted` and `heatmapClasses.faded` classes.
5562

56-
In the following demo, we replace the highlight saturation by a border radius and reduce the saturation of the faded cells.
63+
The demo below uses border radius on the highlighted cell and reduced saturation for faded cells.
5764

5865
{{"demo": "HighlightClasses.js"}}
5966

60-
## Click event
67+
## Click events
6168

62-
Use `onItemClick` to know which cell is clicked by user.
69+
Use `onItemClick` to handle cell clicks.
6370

64-
The first argument is the click event.
65-
The second one is the item identifier.
66-
It contains the properties `xIndex` and `yIndex` that are the indexes of the clicked cell along the x- and y-axes respectively.
67-
68-
If this cell has associated data, the `dataIndex` property indicates the position of the cell's data within the series' `data` array.
71+
The handler receives the click event as the first argument and an item object as the second.
72+
The item includes `xIndex` and `yIndex` (cell position on the x- and y-axes) and, when the cell has data, `dataIndex` (index in the series `data` array).
6973

7074
{{"demo": "HeatmapCellClick.js"}}
7175

72-
## Common features
76+
## Shared features
7377

74-
The heatmap shares several features with other charts.
75-
This section only explains the details that are specific to the heatmap.
76-
If you'd like to learn more about the shared features, you can visit their dedicated pages.
78+
Heatmap charts use the same axis, tooltip, and legend patterns as other charts.
79+
This section notes heatmap-specific details.
80+
See the linked pages for full options.
7781

7882
### Axes
7983

80-
The Heatmap axes can be customized like any other chart axis.
81-
The available options are available in the [axis customization page](/x/react-charts/axis/#axis-customization).
84+
You can configure heatmap axes like other chart axes.
85+
See [Axis—Customization](/x/react-charts/axis/#axis-customization) for details.
8286

8387
### Tooltip
8488

85-
The Heatmap has an item tooltip that can be customized as described in the [Tooltip documentation page](/x/react-charts/tooltip/).
89+
The default heatmap tooltip is item-based.
90+
You can customize it with slots.
91+
See [Tooltip](/x/react-charts/tooltip/) for details.
8692

87-
The only difference of the Heatmap Tooltip is its default content.
88-
You can import the default tooltip, or only its content as follows:
93+
The heatmap package exports the default tooltip and its content if you want to reuse or extend them:
8994

9095
```js
91-
import { HeatmapTooltip, HeatmapTooltipContent } from '@mui/x-charts/Heatmap',
96+
import { HeatmapTooltip, HeatmapTooltipContent } from '@mui/x-charts/Heatmap';
9297
```
9398

9499
### Legend
95100

96-
The Heatmap comes with a legend which is by default the [ContinuousColorLegend](/x/react-charts/legend/#color-legend).
101+
The heatmap includes a [`ContinuousColorLegend`](/x/react-charts/legend/#color-legend) by default.
97102

98-
To display it set `hideLegend` to `false`.
99-
You can modify it with `slots.legend` and `slotProps.legend`.
103+
Set `hideLegend` to `true` to hide the legend.
104+
Customize it with `slots.legend` and `slotProps.legend`.
100105

101106
{{"demo": "HeatmapLegend.js"}}
102107

103-
## Custom item
108+
## Custom cells
109+
110+
Use the `cell` slot to replace the default cell shape or add labels.
104111

105112
{{"demo": "CustomItem.js"}}
106113

107-
## WebGL Renderer [<span class="plan-premium"></span>](/x/introduction/licensing/#premium-plan 'Premium plan')🧪
114+
## WebGL renderer [<span class="plan-premium"></span>](/x/introduction/licensing/#premium-plan 'Premium plan')🧪
108115

109116
:::info
110-
This feature is in preview. It is ready for production use, but its API, visuals and behavior may change in future minor or patch releases.
117+
This feature is in preview.
118+
It is ready for production use, but its API, visuals and behavior may change in future minor or patch releases.
111119
:::
112120

113-
Heatmaps can contain a large number of cells.
114-
To improve performance when rendering many cells, you can use the WebGL renderer by setting the `renderer` prop to `'webgl'`.
121+
Heatmaps can have many cells, which can slow down rendering.
122+
Set the `renderer` prop to `'webgl'` for better performance with large datasets.
115123

116-
The WebGL renderer has some limitations compared to the SVG renderer:
124+
The WebGL renderer has some limitations:
117125

118-
- The `cell` slot is not supported;
119-
- The heatmap cell cannot be customized using CSS;
126+
- The `cell` slot is not supported
127+
- You cannot style cells with CSS
120128

121-
The following example showcases a heatmap with approximately 8800 cells rendered using WebGL.
129+
The demo below shows roughly 8,800 cells rendered with WebGL.
122130

123131
{{"demo": "WebGLHeatmap.js"}}

0 commit comments

Comments
 (0)