Heatmap
A colour for each row and column. Good for days and hours, products and regions.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'heatmap',
rows: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
columns: ['8 h', '10 h', '12 h', '14 h', '16 h', '18 h'],
labels: true,
color: '#2a9d8f',
values: [
[16, 12, 6, 15, 4, 4],
[19, 16, 7, 8, 7, 7],
[29, 2, 19, 1, 13, 8],
[8, 22, 1, 13, 18, 14],
[25, 6, 12, 16, 26, 7],
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type heatmap takes:
interface HeatmapSpec extends Base {
type: 'heatmap';
columns: string[];
rows: string[];
values: (number | null)[][];
color?: string;
/** Values written in the cells. */ labels?: boolean;
labelWidth?: number;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More