Usage
MatrixChart is a heatmap with categorical axes, each cell is colored based on its value:
Data format
Data is an array of MatrixChartCell objects:
x– column identifiery– row identifiervalue– numeric value that defines the cell color,nullfor empty cells
Labels
Set withXLabels and withYLabels to display axis labels. Use xLabels and yLabels props to override labels taken from the data.
Increase yLabelsWidth and xLabelsHeight if your labels are longer than the reserved space:
Set xLabelsPosition="top" to display x-axis labels above the chart:
X-axis labels rotation
Use xLabelsRotation prop to change the angle of x-axis labels, for example, 0 for horizontal labels.
Horizontal labels overlap when they are wider than a cell, rotate long labels instead:
Tooltip
Set withTooltip prop and provide getTooltipLabel function to display a tooltip on cell hover:
Colors
Use colors prop to change the palette. Each cell is painted with the palette color nearest to its value:
Values domain
By default, the palette spans from the lowest to the highest displayed value.
Use domain prop to set a custom [min, max] range. A reversed domain ([max, min]) inverts the colors:
Cell size and gap
Use cellSize, gap and cellRadius props to change cell size, spacing and border radius:
Pass props to cells
Use getCellProps to add props to individual cells based on their data:
Legend
Set withLegend prop to display a color legend below the chart. Use legendLabels prop to change its labels:
Accessibility
Use valueFormatter to include units in the chart summary read by screen readers:
Set aria-label or aria-labelledby to replace the summary with your own description: