Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Trends

Since 0.1.0-alpha.22
A dashed line through any series' values: the straight line or curve that fits them best, or a moving average that smooths out the ups and downs.

A linear trend

To draw a series' trend as a dashed line, set Trend on the series: Linear, the straight line that fits best, or Polynomial, a curve of TrendOrder (2, a parabola, by default).

Static

Preview

Revenue by month, 2026
  • Revenue
  • Revenue trend
Arrow keys move between values; Escape hides the tooltip.

Code

Trend.razor
@* Monthly revenue with its linear trend. *@
<Chart Items="_months" Argument="m => m.Month" Title="Revenue by month, 2026">
    <ChartValueAxis Format="C0" />
    <ChartBarSeries Value="m => m.Revenue" Name="Revenue" Trend="ChartTrend.Linear" />
</Chart>

@code {
    private record MonthRevenue(string Month, decimal Revenue);

    private readonly MonthRevenue[] _months =
    [
        new("Jan", 84_200), new("Feb", 91_500), new("Mar", 102_300), new("Apr", 98_700),
        new("May", 110_400), new("Jun", 121_900), new("Jul", 117_600), new("Aug", 126_300),
        new("Sep", 133_800), new("Oct", 141_200), new("Nov", 156_900), new("Dec", 172_400),
    ];
}

The trend is named after the series, here "Revenue trend", in the legend, the tooltip and Show data. The legend hides it like any series.

It's drawn in the series' color mixed toward the text color, so it reads over the series' own bars. TrendColor sets a color of your own.

A moving average

MovingAverage makes each point the average of the last TrendPeriod values, here 7 days, which smooths out the weekend dips. It starts once the first window is full.

Static

Preview

Site visits, last 60 days
  • Visits
  • Visits, 7-day average
Arrow keys move between values; Escape hides the tooltip.

Code

MovingAverage.razor
@* Daily site visits, which dip every weekend, with a 7-day moving average. *@
<Chart Items="_days" Argument="d => d.Date" Title="Site visits, last 60 days">
    <ChartLineSeries Value="d => d.Visits" Name="Visits" Markers="false" Trend="ChartTrend.MovingAverage" TrendPeriod="7" />
</Chart>

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

    private readonly Day[] _days = Enumerable.Range(0, 60).Select(i =>
    {
        var date = new DateOnly(2026, 9, 8).AddDays(i);
        var weekend = date.DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday;
        return new Day(date, 2_400 + i * 18 + (int)(160 * Math.Sin(i / 5.0)) - (weekend ? 900 : 0));
    }).ToArray();
}

Connection lost

Rejoining the server…