Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Synchronized charts

Since 0.1.0-alpha.22
Charts that share a Sync name zoom together and show the same date, number or name when one is pointed at, with no round trip.

One range selector for several charts

To zoom several charts together, give each the same Sync name, and a RangeSelector on its own the name too. Here one strip zooms the revenue and orders charts, which open on the last quarter.

Static

Preview

Days shown
Plus and minus zoom, 0 zooms out, arrows pan.
Revenue
Arrow keys move between values; Escape hides the tooltip.
Orders
Arrow keys move between values; Escape hides the tooltip.

Code

SyncRange.razor
@* A store's revenue and orders by day, one range selector zooming both, opened on the last quarter. *@
<RangeSelector Items="_days" Argument="d => d.Date" Sync="store" View="_lastQuarter" Ranges Label="Days shown">
    <ChartAreaSeries Value="d => d.Revenue" />
</RangeSelector>

<Chart Items="_days" Argument="d => d.Date" Title="Revenue" Sync="store" View="_lastQuarter">
    <ChartValueAxis Format="C0" LabelWidth="Length.Rem(4)" />
    <ChartLineSeries Value="d => d.Revenue" Name="Revenue" />
</Chart>

<Chart Items="_days" Argument="d => d.Date" Title="Orders" Sync="store" View="_lastQuarter" Height="Length.Rem(12)">
    <ChartArgumentAxis Format="MMM d" />
    <ChartValueAxis Format="N0" LabelWidth="Length.Rem(4)" />
    <ChartBarSeries Value="d => d.Orders" Name="Orders" />
</Chart>

@code {
    private record Day(DateOnly Date, decimal Revenue, int Orders);

    private static readonly DateOnly Last = new(2026, 10, 31);

    // The last three months, as the 3M button shows them: null is the data's own end.
    private readonly ChartView _lastQuarter = new(Last.AddMonths(-3).AddDays(1), null);

    // A year of a web store's days: fewer orders at weekends, growing through the year, with a
    // bigger basket in the run-up to the holidays.
    private readonly Day[] _days = Enumerable.Range(0, 365).Select(i =>
    {
        var date = Last.AddDays(i - 364);
        var weekend = date.DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday;
        var orders = 120 + i / 4 + (int)(14 * Math.Sin(i / 9.0)) + i * 31 % 17 - (weekend ? 35 : 0);
        var basket = 58m + (date.Month >= 10 ? 9m : 0m) + i * 13 % 7;
        return new Day(date, orders * basket, orders);
    }).ToArray();
}

The charts match by argument, not by position, so a bar chart of days follows a line over the same days, and a chart that covers only part of the range shows its part.

A chart needs no Zoom of its own to follow the others. With Zoom on its ChartArgumentAxis, dragging or pinching it zooms the whole group too, and Reset zoom on any of them resets them all. To start them on the same part, give each the same View.

On interactive pages each chart reports @bind-View as a zoom ends. To keep a chart out of the zooming but still show the hovered item, set SyncView to false.

The same hour in two charts

Point at an hour in either chart to see that hour's tooltip in both, here requests and response time, which read together explain a slow afternoon.

Static

Preview

Requests per hour
Arrow keys move between values; Escape hides the tooltip.
Response time, 95th percentile (ms)
Arrow keys move between values; Escape hides the tooltip.

Code

SyncHover.razor
@* An API's requests and response time by hour: pointing at an hour in one chart shows it in both. *@
<Chart Items="_hours" Argument="h => h.Hour" Title="Requests per hour" Sync="api" Height="Length.Rem(12)">
    <ChartValueAxis Format="N0" LabelWidth="Length.Rem(3)" />
    <ChartBarSeries Value="h => h.Requests" Name="Requests" />
</Chart>

<Chart Items="_hours" Argument="h => h.Hour" Title="Response time, 95th percentile (ms)" Sync="api" Height="Length.Rem(12)">
    <ChartValueAxis Format="N0" LabelWidth="Length.Rem(3)" />
    <ChartLineSeries Value="h => h.P95" Name="95th percentile" />
</Chart>

@code {
    private record Load(string Hour, int Requests, int P95);

    // A working day: traffic peaks late morning and mid-afternoon, and response time climbs with it.
    private readonly Load[] _hours = Enumerable.Range(0, 24).Select(h =>
    {
        var load = Math.Max(0, Math.Sin((h - 6) / 14.0 * Math.PI)) + (h is 10 or 11 or 14 or 15 ? 0.25 : 0);
        var requests = (int)(1_800 + 21_000 * load);
        return new Load($"{h:00}:00", requests, (int)(140 + 0.000018 * requests * requests / 10 + h % 3 * 9));
    }).ToArray();
}

Arrow keys on a focused chart move the other charts too. Screen readers hear only the focused chart; the others' tooltips are hidden from them.

Charts match items by name, or by the nearest date or number within their range, and show nothing where they have no item. To keep a chart's tooltip to itself, set SyncHover to false.

LabelWidth on each ChartValueAxis gives the value labels the same room, so the plots line up and the hovered hour sits at the same place in both.

Connection lost

Rejoining the server…