Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Zoom

Since 0.1.0-alpha.22
Zooming shows part of the arguments up close, such as a month of a year of days, from a drag, the wheel, a pinch or the keys, with no round trip.

A range selector and a starting view

To zoom a chart from a strip under its plot, put a ChartRangeSelector in it. The strip draws the whole range small, with a window over the part in view: drag the window to pan, or a handle to widen or narrow it. View opens the chart zoomed, here on the last three months.

Static

Preview

Daily visits, last 12 months
Arrow keys move between values; plus and minus zoom, 0 zooms out; Escape hides the tooltip.

Code

ZoomRange.razor
@* A year of daily visits, opened on the last three months, with a range selector under the plot
   and buttons for common spans. *@
<Chart Items="_days" Argument="d => d.Date" Title="Daily visits, last 12 months" View="_lastQuarter">
    <ChartValueAxis Format="N0" />
    <ChartLineSeries Value="d => d.Visits" Name="Visits" />
    <ChartRangeSelector Ranges />
</Chart>

@code {
    private record Day(DateOnly Date, int Visits);

    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 visits to a store's site: lower at weekends, growing through the year, with a
    // peak around Black Friday.
    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 holiday = date.Month == 11 && date.Day is >= 26 and <= 30 ? 2_600 : date.Month == 12 && date.Day < 22 ? 900 : 0;
        return new Day(date, 3_200 + i * 6 + (int)(260 * Math.Sin(i / 11.0)) + (i * 37 % 23) * 12 - (weekend ? 900 : 0) + holiday);
    }).ToArray();
}

A ChartView takes the first and last argument in view, such as two dates, and null for the data's own end. Ranges adds buttons for the last 1, 3 and 6 months, the year to date, a year, and everything. A button whose span would show everything is left out.

The value axis refits to the values in view, so a quiet month fills the plot. On interactive pages, @bind-View reports the part in view as each zoom ends, not while dragging; null means everything is in view.

A range selector needs an upright chart. See RangeSelector for spans of your own and for choosing a range apart from a chart.

Zoom to a box

To zoom with no range selector, set Zoom on the ChartArgumentAxis. Drag across the plot to zoom into that span, here the afternoon slowdown, or use the Zoom in and Zoom out buttons by the title; Reset zoom shows the whole day again.

Static

Preview

API response time (p95), November 5
Arrow keys move between values; plus and minus zoom, 0 zooms out; Escape hides the tooltip.Target 400 ms: 400 ms

Code

ZoomBox.razor
@* An API's response time every 5 minutes for a day, with a slowdown in the afternoon to zoom into. *@
<Chart Items="_readings" Argument="r => r.Time" Title="API response time (p95), November 5">
    <ChartArgumentAxis Zoom />
    <ChartValueAxis Format="#,##0' ms'" />
    <ChartLineSeries Value="r => r.Milliseconds" Name="p95" />
    <ChartReferenceLine Value="400" Label="Target 400 ms" />
</Chart>

@code {
    private record Reading(DateTime Time, int Milliseconds);

    // 288 readings: quiet overnight, busier by day, and a slowdown from 2:35 to 3:10 PM.
    private readonly Reading[] _readings = Enumerable.Range(0, 288).Select(i =>
    {
        var time = new DateTime(2026, 11, 5).AddMinutes(i * 5);
        var load = 60 * Math.Max(0, Math.Sin((time.Hour + time.Minute / 60.0 - 6) / 16 * Math.PI));
        var slowdown = i is >= 175 and <= 182 ? new[] { 240, 520, 780, 910, 860, 640, 380, 160 }[i - 175] : 0;
        return new Reading(time, 180 + (int)load + (i * 37 % 29) + slowdown);
    }).ToArray();
}

Hold Ctrl (⌘ on a Mac) and turn the wheel, or pinch on a trackpad, to zoom at the pointer; Shift and the wheel pan. On a touch screen, two fingers pinch and pan. One finger and the plain wheel still scroll the page.

From the keyboard, Tab to the chart: + and − zoom around the item shown, 0 zooms out, and an arrow key pans to an item out of view. Screen readers hear the range now in view after each zoom.

A zoom stops at 2 items; MinZoomSpan sets another least span. Bars across zoom down the side. Waterfall charts don't zoom in the browser, but View works on them.

Connection lost

Rejoining the server…