MatrixChart

A grid of two categories, where the color of each cell follows a value. Use it to cross two lists, such as services by weekday.

It is plain svg, so it does not need any extra package. For days on a calendar, use Heatmap.

General

Each item has the column in x, the row in y and a value. A cell with null or 0 stays empty.

Colors and labels

Set type or colors for the scale, xLabelsRotation for long names and valueLabel for the hover title.

APIs

MatrixChart.Props

AttributeDescriptionTypeAccepted valuesDefault
dataone item per cellMatrixCell[]MatrixCell-
typetheme color of the scaleNormalTypes'default', 'primary', 'secondary', 'success', 'warning', 'error', 'info'primary
colorscolors of the levels, from the lowest to the higheststring[]-4 shades of type
domainvalues that get the lowest and the highest color[number, number]-from the data
cellSizeside of a cell, in pixelsnumber-28
gapspace between cells, in pixelsnumber-2
cellRadiuscorner radius of a cell, in pixelsnumber-3
withXLabelsname the columnsboolean-true
withYLabelsname the rowsboolean-true
xLabelsRotationangle of the column names, in degreesnumber-0
withLegendshow the scale belowboolean-false
legendLabelstexts at the two ends of the legend[string, string]-Less, More
valueLabeltext of the hover title of a cell(cell: MatrixCell) => string-row, column: value
...native props, passed to the svgSVGAttributes'aria-label', 'className', ...-

MatrixCell

type MatrixCell = {
  x: string // the column
  y: string // the row
  value: number | null // `null` leaves the cell empty
}

Ref

The ref points at the svg.

Accessibility

Value is shown by color only, and each cell has a hover title with its row, column and value. Describe the chart with aria-label or aria-labelledby. With a name it is an image, without one it is hidden from assistive technology.

For the exact numbers, offer the same data in a Table next to it.

Edit this page on GitHub