Line Chart

Single or multi-series line chart with area fill, trendlines, data points, and null data handling.

Basic Usage

<ArcadiaLineChart TItem="SalesRecord" Data="@data"
                XField="@(d => (object)d.Month)"
                Series="@series"
                Height="300" Width="600" />

@code {
    record SalesRecord(string Month, double Revenue);

    var data = new List<SalesRecord>
    {
        new("Jan", 45000), new("Feb", 52000),
        new("Mar", 48000), new("Apr", 61000),
    };

    var series = new List<SeriesConfig<SalesRecord>>
    {
        new() { Name = "Revenue", Field = d => d.Revenue }
    };
}

Multi-Series with Area Fill

var series = new List<SeriesConfig<SalesRecord>>
{
    new() { Name = "Revenue", Field = d => d.Revenue,
            Color = "primary", ShowArea = true },
    new() { Name = "Target", Field = d => d.Target,
            Color = "secondary", Dashed = true },
};

With Trendline

new() {
    Name = "Revenue", Field = d => d.Revenue,
    Trendline = new()
    {
        Type = TrendlineType.Linear,
        Color = "danger",
        Dashed = true,
    }
}

Line Chart Parameters

ParameterTypeDefaultDescription
XFieldFunc<T, object>requiredX-axis label selector
SeriesList<SeriesConfig<T>>requiredSeries configurations
ShowPointsbooltrueShow data point dots on lines (overridden per-series by SeriesConfig.ShowPoints)
NullHandlingNullHandlingGapHow to handle null/missing data values: Gap, Connect, or Zero
StackedboolfalseWhen true, area fills stack on top of each other instead of starting from zero
SlidingWindowint0Maximum number of points to keep in sliding window mode (0 = no limit)
XAxisTypestring"category"X-axis mode: "category" (equal spacing) or "time" (continuous DateTime positioning)

Plus all shared ChartBase parameters.

Events

EventTypeDescription
OnPointClickEventCallback<PointClickEventArgs<T>>Fired when a data point is clicked. Receives item, data index, and series context
OnSeriesClickEventCallback<int>Fired when a series is clicked. Receives the series index

Wiring OnPointClick from Razor

The Razor source generator occasionally has trouble inferring the type argument of EventCallback<PointClickEventArgs<T>> when you assign a typed method group directly. If you see CS1503 errors like “cannot convert from ‘method group’ to ‘Microsoft.AspNetCore.Components.EventCallback’”, use the explicit factory form:

<ArcadiaLineChart TItem="SalesRecord" ...
    OnPointClick="@(EventCallback.Factory.Create<PointClickEventArgs<SalesRecord>>(this, HandleClick))" />

@code {
    private void HandleClick(PointClickEventArgs<SalesRecord> args)
    {
        // args.Item, args.Index, args.SeriesIndex, args.SeriesName, args.Value
    }
}

The same workaround applies to every chart’s OnPointClick.

Null Data Handling

// Gap — break the line at missing points
<ArcadiaLineChart NullHandling="NullHandling.Gap" />

// Connect — skip missing, connect neighbors
<ArcadiaLineChart NullHandling="NullHandling.Connect" />

// Zero — treat missing as 0
<ArcadiaLineChart NullHandling="NullHandling.Zero" />

Axis Formatting

<ArcadiaLineChart YAxisFormatString="C0"
                XAxisFormatString="MMM"
                FormatProvider="@CultureInfo.GetCultureInfo("en-US")" />