react-heatmap-grid
A React component for heatmap in grid layout using div.
Installation
yarn add react-heatmap-grid
or
npm install react-heatmap-grid --save
Usage
Mandatory fields
Name | Type | Sample |
---|---|---|
xLabels |
Array of string | ['1am', '2am', '3am'] |
yLabels |
Array of string | ['Sun', 'Mon'] |
data |
2D Array of numbers having yLabels.length rows and xLabels.length rows |
[[2,3,5][5,6,9]] |
Configuration
Name | Type | Description | Default Value |
---|---|---|---|
background | string | The base color for the heatmap | "#329fff" |
height | number | Height of each cell of the heatmap in px | 30 |
onClick | function | Adds an handler to cell click | undefined |
squares | boolean | If set to true will render cells as square |
false |
xLabelWidth | number | Width of the x label area in pixel | 60 |
yLabelTextAlign | string | Text alignment of the yLabels | "right" |
xLabelsLocation | string | Location of y labels. It can be top or bottom | "top" |
xLabelsVisibility | [boolean] |
Array of bool conveying which x labels to display. For ex: [true, false, true, false] means the 1st and the 3rd labels will be displayed and the 2nd and 4th will be hidden |
|
unit | string | Unit to display next to the value on hover | |
cellRender | function | Render custom content in cell | () => null |
cellStyle | function | To set custom cell style. It is useful for using own colour scheme |
Example
For developers
New build
npm run build
Run dev server
npm run dev
Run test
npm run test