ShellUI Logo
ShellUI

Line Chart

Smooth line charts for showing trends over time

The LineChart component renders smooth line charts ideal for showing trends, progress, and changes over time. Built on ApexCharts.Blazor with Curve.Smooth and rounded line caps.

Installation

shellui add chart line-chart
dotnet add package Blazor-ApexCharts

chart and chart-variants are auto-installed as dependencies.

Basic Usage

<LineChart TItem="TrafficData"
    Data="@trafficData"
    Title="Website Traffic"
    Name="Visitors"
    XValue="@(e => e.Date)"
    YValue="@(e => (decimal?)e.Visitors)"
    Theme="ChartTheme.Default"
    Height="350px" />

@code {
    private List<TrafficData> trafficData = new()
    {
        new("Mon", 1200), new("Tue", 1900),
        new("Wed", 1500), new("Thu", 2100),
        new("Fri", 1800), new("Sat", 900),
        new("Sun", 750)
    };

    record TrafficData(string Date, int Visitors);
}

Performance Metrics

<LineChart TItem="PerformanceData"
    Data="@perfData"
    Title="API Response Times"
    Subtitle="Last 7 days (ms)"
    Name="Avg Response Time"
    XValue="@(e => e.Day)"
    YValue="@(e => (decimal?)e.ResponseMs)"
    Theme="ChartTheme.Default"
    Height="350px" />

@code {
    private List<PerformanceData> perfData = new()
    {
        new("Mon", 120), new("Tue", 95), new("Wed", 180),
        new("Thu", 110), new("Fri", 88), new("Sat", 65), new("Sun", 72)
    };

    record PerformanceData(string Day, int ResponseMs);
}

Stock Price Trend

<LineChart TItem="StockPrice"
    Data="@stockData"
    Title="Stock Price (ACME)"
    Subtitle="30-day trend"
    Name="Price (USD)"
    XValue="@(e => e.Date)"
    YValue="@(e => (decimal?)e.Price)"
    Theme="ChartTheme.Colorful"
    Height="400px" />

@code {
    private List<StockPrice> stockData = new()
    {
        new("Week 1", 142.50m), new("Week 2", 148.20m),
        new("Week 3", 145.80m), new("Week 4", 155.30m),
        new("Week 5", 152.10m), new("Week 6", 161.40m)
    };

    record StockPrice(string Date, decimal Price);
}

Multiple Lines

For multiple lines, use Multi-Series Chart with SeriesType.Line.

API Reference

PropertyTypeDefaultDescription
TItemGeneric typeThe data item type
DataIEnumerable<TItem>?nullData collection to visualize
Namestring"Data"Series name shown in tooltip
XValueFunc<TItem, object>?nullFunction to extract X-axis value
YValueFunc<TItem, decimal?>?nullFunction to extract Y-axis value
ThemeChartThemeDefaultColor theme (Default, Colorful, Monochrome)
Titlestring?nullChart title
Subtitlestring?nullChart subtitle
Heightstring?"400px"Chart height
Widthstring?"100%"Chart width
Classstring?nullAdditional CSS classes

On this page