Heatmap
A grid of colored cells shows a value across two categories at once: traffic per weekday and hour, conversion per channel and day, orders per week and weekday. Darker means more.
Traffic by weekday and hour
Each HeatmapSeries is a row, named by Name; its x values are the columns and its y values the colors.
All rows share one scale: the lowest value is pale, the highest has the full color, and the legend shows the range. Hover a
cell to see its value; with the chart focused, the arrow keys move between cells and rows.
Code
<RioChart TItem="HourCount" Title="Sessions per hour, last month" XAxis="@(new AxisOptions { Title = "Hour" })">
@foreach (var (day, hours) in weekTraffic)
{
<HeatmapSeries Items="hours" Name="@day" XValue="h => h.Hour" YValue="h => h.Sessions" Format="#,0" />
}
</RioChart>Values in the cells
DataLabels writes each value in its cell when it fits, in light text on dark cells. Max sets the value
that gets the full color; here the app's weekend rate stands out against the others.
Code
<RioChart TItem="Share" Title="Conversion rate per channel">
@foreach (var (channel, days) in channelConversion)
{
<HeatmapSeries Items="days" Name="@channel" XValue="d => d.Name" YValue="d => d.Value"
Format="0.0'%'" DataLabels="true" Max="5" />
}
</RioChart>Above and below a midpoint
For changes, or values around a normal level, set Midpoint: values above it take the series color and values below
it BelowColor (default --rio-negative), each side faint near the midpoint and full at its furthest
value. The legend shows both sides. Here, sessions against the same hour last week: fewer in the mornings, more in the evenings.
Code
<RioChart TItem="HourCount" Title="Sessions against last week">
@foreach (var (day, hours) in weekChange)
{
<HeatmapSeries Items="hours" Name="@day" XValue="h => h.Hour" YValue="h => h.Sessions"
Format="+0'%';-0'%';0'%'" Midpoint="0" />
}
</RioChart>Stepped colors
For fixed ranges, such as green, yellow and red levels, set ColorBands on the first row: each cell takes the solid
color of the band its value is in, and the legend lists the bands. Later bands win where they overlap, so a first band without
bounds and then Above limits leave no gaps (a value of exactly 50 is still green); values outside every band take
the series color.
ColorValue gives single cells a color of their own, which wins over the bands.
Code
<RioChart TItem="Share" Title="Server load per hour">
@foreach (var (server, hours) in serverLoad)
{
<HeatmapSeries Items="hours" Name="@server" XValue="h => h.Name" YValue="h => h.Value"
Format="0'%'" DataLabels="true" ColorBands="levels" />
}
</RioChart>
@code {
ColorBand[] levels =
[
new() { Color = "--rio-series-5" }, // green: every value...
new() { Above = 50, Color = "--rio-series-2" }, // ...yellow above 50...
new() { Above = 80, Color = "--rio-negative" }, // ...red above 80 (later bands win)
];
}Options
| Option | Default | Meaning |
|---|---|---|
Name | The row's label. Rows are drawn top to bottom in the order of the series. | |
XValue | The column: categories, numbers or times (cells as wide as the spacing of the data). | |
YValue | The value that sets the cell's color. Missing values leave the cell empty. | |
Color, Format, Max | first row's | The hue, value format and full-color value, shared by all rows. |
Midpoint, BelowColor | first row's | Colors diverge from the midpoint: above it the series color, below it BelowColor (default --rio-negative). JSON: "midpoint", "belowColor". |
ColorBands | first row's | Stepped colors: each cell takes the solid color of its value's band, and the legend lists the bands, by their Label (e.g. "High") or else their range. JSON: "colorBands". |
ColorValue | A cell's own solid color (a CSS color or theme token); wins over the scale and the bands. JSON: "colorField". | |
Legend (on the chart) | top | The color scale sits above the rows, or below them with Position = LegendPosition.Bottom; Mode = LegendMode.Hide hides it. |
DataLabels | false | Write the values in the cells (when they fit). |
| JSON | "type": "heatmap" with "groupBy" on the row field makes one row per value, e.g. "x": "hour", "y": "sessions", "groupBy": "weekday". |