Radar chart
Since 0.1.0-alpha.22Use a radar to compare one to three items across a handful of measures, such as two phones' review scores. The overall shape is the message. The shape changes with the order of the spokes, so it's hard to rank from. To compare exactly, use bars side by side.
Series on one scale
Give RadarChart the Items, one per spoke, each one's name as Argument, a RadarSeries for each thing compared, and a Title, here two phones' review scores.
Static
Preview
- Phone A
- Phone B
| Quality | Phone A | Phone B |
|---|---|---|
| Camera | 9.2 | 7.6 |
| Display | 8.8 | 8 |
| Speed | 9 | 7.8 |
| Build | 8.7 | 7.5 |
| Value | 6 | 8.9 |
| Battery | 8.5 | 9.1 |
Code
@* Two phones' review scores, out of 10, in six qualities. *@
<RadarChart Items="_scores" Argument="s => s.Quality" Max="10" Title="Review scores, out of 10">
<RadarSeries Value="s => s.PhoneA" Name="Phone A" />
<RadarSeries Value="s => s.PhoneB" Name="Phone B" />
</RadarChart>
{
private record Score(string Quality, double PhoneA, double PhoneB);
private readonly Score[] _scores =
[
new("Camera", 9.2, 7.6),
new("Display", 8.8, 8.0),
new("Speed", 9.0, 7.8),
new("Build", 8.7, 7.5),
new("Value", 6.0, 8.9),
new("Battery", 8.5, 9.1),
];
}Add this example to a page with the izzy CLI:
izzy add component RadarChart --at <file>:<line>Spokes run clockwise from the top in item order. The shape depends on that order, so put related measures side by side: here camera, display, speed and build together, then value and battery.
Max="10" sets the outer ring to the scores' real top, so an outline's size means something. Without it, the scale ends at the round number at or above the largest value.
Hover a spoke, or Tab to the chart and use the arrow keys: the tooltip lists every series' value there, and a screen reader hears it.
A series per key
When each item holds one value, such as a panel's rating of one candidate in one competency, split them into series with SeriesBy. Each candidate gets an outline, a color and a marker shape, in the order they first appear.
Static
Preview
- Ana
- Ben
- Chen
| Competency | Ana | Ben | Chen |
|---|---|---|---|
| Problem solving | 4.5 | 3.6 | 4.1 |
| Technical depth | 4.7 | 3.4 | 4.4 |
| Ownership | 4.0 | 3.9 | 4.6 |
| Leadership | 3.2 | 4.1 | 3.8 |
| Communication | 3.8 | 4.6 | 3.5 |
| Collaboration | 4.2 | 4.4 | 3.7 |
Code
@* A hiring panel's average ratings, 1 to 5, for three candidates in six competencies. *@
<RadarChart Items="_ratings" Argument="r => r.Competency" Min="1" Max="5" ValueFormat="0.0"
Title="Panel ratings, senior engineer">
<RadarSeries Value="r => r.Rating" SeriesBy="r => r.Candidate" />
</RadarChart>
{
private record PanelRating(string Candidate, string Competency, double Rating);
private static readonly string[] Competencies = ["Problem solving", "Technical depth", "Ownership", "Leadership", "Communication", "Collaboration"];
private static readonly (string Candidate, double[] Ratings)[] Panel =
[
("Ana", [4.5, 4.7, 4.0, 3.2, 3.8, 4.2]),
("Ben", [3.6, 3.4, 3.9, 4.1, 4.6, 4.4]),
("Chen", [4.1, 4.4, 4.6, 3.8, 3.5, 3.7]),
];
private readonly PanelRating[] _ratings =
[.. Panel.SelectMany(p => Competencies.Select((c, i) => new PanelRating(p.Candidate, c, p.Ratings[i])))];
}The ratings run from 1 to 5, so Min="1" puts 1 at the center and Max="5" at the edge.
Three outlines are about as many as a radar holds. For more, draw a radar per candidate, or compare them in a Chart with bars.
Circular grid and fill
Months around a circle make a year's cycle visible, such as two cities' rainfall. Grid="RadarGrid.Circle" draws the rings as circles, and Fill shades each outline lightly.
Static
Preview
- Seattle
- Phoenix
| Month | Seattle | Phoenix |
|---|---|---|
| Jan | 5.8 | 0.9 |
| Feb | 3.8 | 0.9 |
| Mar | 4.2 | 0.8 |
| Apr | 3.2 | 0.3 |
| May | 1.9 | 0.2 |
| Jun | 1.5 | 0.0 |
| Jul | 0.6 | 1.1 |
| Aug | 1.0 | 1.0 |
| Sep | 1.6 | 0.6 |
| Oct | 3.9 | 0.6 |
| Nov | 6.3 | 0.7 |
| Dec | 5.9 | 0.9 |
Code
@* Average rainfall by month, in inches (1991–2020 normals). *@
<RadarChart Items="_months" Argument="m => m.Month" Grid="RadarGrid.Circle" ValueFormat="0.0"
Title="Average rainfall (inches)">
<RadarSeries Value="m => m.Seattle" Fill="true" />
<RadarSeries Value="m => m.Phoenix" Fill="true" />
</RadarChart>
{
private record MonthRain(string Month, double Seattle, double Phoenix);
private readonly MonthRain[] _months =
[
new("Jan", 5.78, 0.87), new("Feb", 3.76, 0.87), new("Mar", 4.17, 0.83), new("Apr", 3.18, 0.25),
new("May", 1.89, 0.16), new("Jun", 1.49, 0.02), new("Jul", 0.57, 1.05), new("Aug", 0.97, 1.00),
new("Sep", 1.58, 0.64), new("Oct", 3.86, 0.58), new("Nov", 6.31, 0.65), new("Dec", 5.94, 0.88),
];
}A fill makes differences look larger than they are, since area grows with the square of the values, and fills cover each other. Use it for one or two series. An outline with a missing value has a gap, so it isn't filled.
Details
Spokes keep the order the items first name them in, the first at the top and the rest clockwise (StartAngle turns them): the shape depends on that order, so put related measures side by side. Items can each be a spoke with a value per series, or each hold one value, with SeriesBy splitting them into a series per key. Every spoke shares one scale from Min (0 by default) to a round Max; for measures in different units, scale them to the same range first. A missing value leaves a gap in its outline, never a point at the center. A radar reads best with 4 to 8 spokes and up to three series; for one series, or to compare exact values, a bar chart reads better.
Parts
Written inside RadarChart. The API page lists their parameters.
RadarSeries<TItem>: one outline on aRadarChart<T>: a value at each spoke, joined around the circle, with a marker at each.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| An outline per series with markers that differ by shape, or a light fill | Yes | Yes |
| One shared scale from 0 to a round maximum, or your own Min and Max | Yes | Yes |
| Polygon or circular rings, with their values up the first spoke | Yes | Yes |
| Series from separate values or split from rows with SeriesBy | Yes | Yes |
| Gaps for missing values, never a point at the center | Yes | Yes |
| Legend items that hide and show series | Yes | Yes |
| A table of the values, spokes by series, in a "Show data" disclosure | Yes | Yes |
| Tooltips with every series' value at a spoke, on hover and from the keyboard | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Without JavaScript
Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off.
- Legend items that hide and show series: waits for the script
- Tooltips with every series' value at a spoke, on hover and from the keyboard: waits for the script
Accessibility
- The chart is a figure captioned by
Title, or named by a heading on the page withTitledBy. - The plot is one image named by the caption, described by its scale.
- "Show data" under the chart opens a table of every value, spokes by series (
DataTable). - Outlines differ by marker shape as well as color.
- With script, the plot is one Tab stop: the arrow keys move from spoke to spoke and say every series' value there.
Keyboard navigation
On the plot
| Press this key | To do this |
|---|---|
| Right or Down | Move to the next spoke, clockwise |
| Left or Up | Move to the spoke before |
| Home or End | Go to the first or last spoke |
| Escape | Hide the tooltip |
Parameters
| Prop | Type | Default |
|---|---|---|
RefreshHow often the chart reads its data again, at least a second, such as Refresh="TimeSpan.FromSeconds(30)". | TimeSpan? | |
RefreshFromOn a static page with Refresh: a lighter page to fetch than this one, which renders the same chart with the same id. | string? | |
ItemsThe items: each a spoke with a value per series, or with SeriesBy one value each. | IEnumerable<TItem>? | Required |
ArgumentEach item's spoke, such as s => s.Quality. | Expression<Func<TItem, object?>> | Required |
TitleThe chart's title, such as "Review scores", shown above it as its caption. | string? | |
HideTitleHides the title, which still names the chart for screen readers. | bool | false |
DownloadShows a button across from the title that saves the chart as a PNG, named after its title, in the color scheme on screen. | bool | false |
TitleAlignWhere the title sits: at the start by default (the left, in a left-to-right page); ChartAlign.Center or ChartAlign.End. | ChartAlign | ChartAlign.Start |
TitledByThe id of a heading already on the page that titles the chart, such as a card's, in place of Title: the chart takes its name from it and shows no title of its own. | string? | |
ValueFormatA .NET format string for the values, such as N0 or P0: on the rings, in the tooltips and the table. | string? | |
ArgumentFormatA .NET format string for the spokes' names, when they're numbers or dates. | string? | |
MinThe value at the center: 0 by default, or the round tick at or below the lowest value when that's below 0. | double? | |
MaxThe value at the outer ring: the round number at or above the largest value by default. | double? | |
GridThe rings' shape: RadarGrid.Polygon (the default), straight between spokes as the outlines are, or RadarGrid.Circle. | RadarGrid | RadarGrid.Polygon |
StartAngleWhere the first spoke points, in degrees clockwise from the top: 90 points it right. | double | 0 |
SizeThe circle's largest size. | Length? | computed |
PaletteThe colors in order: Colors (the theme's eight, the default), Shades of one color, or your own with Of. | ChartPalette? | |
LegendWhere the legend goes: above the plot with two or more series by default (ChartLegend.Auto), ChartLegend.Top, ChartLegend.Bottom, beside it with ChartLegend.Start or ChartLegend.End, or ChartLegend.None. | ChartLegend | ChartLegend.Auto |
LegendAlignThe legend's place along its edge: the start by default, the center or the end. | ChartAlign | ChartAlign.Start |
TooltipThe tooltip for the spoke under the pointer or the keyboard, with every series' value there (with script). | bool? | |
DataTableThe values as a table, spokes by series: by default behind a "Show data" button that opens it over the chart; ChartDataTable.Collapsed puts it in a disclosure under the chart. | ChartDataTable | ChartDataTable.Popover |
ChildContentRadarSeries<T>s, and a ChartTooltip<T> for your own tooltip. | RenderFragment? | |
OnRefreshOn an interactive page with Refresh: raised at each interval, to load new data. | EventCallback |
Plus 17 item props and 4 common props.
Full APISee also
- Chart: draws a chart on the server from a list of items, with axes, value labels, reference lines, trends and a table of the values, for every chart type.
- PieChart: shows how one total splits into a few shares, such as customers by plan, each labeled with its share.