Skip to content
daisyBlazor

LineChart

One or more ChartSeries drawn as lines over a gridded, labelled axis, as inline SVG laid out by the bundled D3 module at the chart's real size. Series colours cycle through the theme palette, so the chart re-skins with every theme.
Essentials
Cover · <LineChart>

371 k

page views in September

Line chart with 2 series Web: J 182, F 196, M 240, A 228, M 265, J 310, J 342, A 298, S 371; Mobile: J 90, F 112, M 105, A 140, M 151, J 148, J 190, A 205, S 226JFMAMJJAS0100200300400Web · J: 182Web · F: 196Web · M: 240Web · A: 228Web · M: 265Web · J: 310Web · J: 342Web · A: 298Web · S: 371Mobile · J: 90Mobile · F: 112Mobile · M: 105Mobile · A: 140Mobile · M: 151Mobile · J: 148Mobile · J: 190Mobile · A: 205Mobile · S: 226

Examples

Basic

Labels name the x positions; each series' Data lines up with them by index. Points are shown by default.

Monthly signups
Monthly signups Signups: Jan 182, Feb 196, Mar 240, Apr 228, May 265, Jun 310, Jul 342, Aug 298, Sep 371JanFebMarAprMayJunJulAugSep0100200300400Jan: 182Feb: 196Mar: 240Apr: 228May: 265Jun: 310Jul: 342Aug: 298Sep: 371
website/Examples/Charts/LineChartBasicExample.razor Source

Each series takes the next palette colour and appears in the legend; Smooth draws curves.

Active users by region (thousands)
Active users by region (thousands) Europe: Jan 92, Feb 104, Mar 118, Apr 111, May 136, Jun 158; North America: Jan 64, Feb 71, Mar 88, Apr 97, May 94, Jun 121; Asia Pacific: Jan 40, Feb 38, Mar 52, Apr 61, May 70, Jun 66JanFebMarAprMayJun050100150200Europe · Jan: 92Europe · Feb: 104Europe · Mar: 118Europe · Apr: 111Europe · May: 136Europe · Jun: 158North America · Jan: 64North America · Feb: 71North America · Mar: 88North America · Apr: 97North America · May: 94North America · Jun: 121Asia Pacific · Jan: 40Asia Pacific · Feb: 38Asia Pacific · Mar: 52Asia Pacific · Apr: 61Asia Pacific · May: 70Asia Pacific · Jun: 66
Europe North America Asia Pacific
website/Examples/Charts/LineChartSeriesExample.razor Source

Minimal

Turn off ShowGrid and ShowLegend, set a Height, and give a series its own Color.

Line chart with 1 series Active users: W1 42, W2 58, W3 71, W4 86, W5 94, W6 100, W7 99, W8 93W1W2W3W4W5W6W7W8W1: 42W2: 58W3: 71W4: 86W5: 94W6: 100W7: 99W8: 93
website/Examples/Charts/LineChartMinimalExample.razor Source

Step

Step draws each value as a step that holds until the next one (step-after), for counts that change in jumps; it wins over Smooth.

Seats on the Team plan
Seats on the Team plan Seats: W1 25, W2 25, W3 40, W4 40, W5 40, W6 60, W7 60, W8 75W1W2W3W4W5W6W7W8020406080W1: 25W2: 25W3: 40W4: 40W5: 40W6: 60W7: 60W8: 75
website/Examples/Charts/LineChartStepExample.razor Source

Rotated

Horizontal puts the labels down the side and the values along the bottom, each line reading top to bottom; it works with Smooth, Step, Stacked, Percent and Area.

Build time by pipeline stage (minutes)
Build time by pipeline stage (minutes) main: Checkout 0.4, Restore 1.8, Compile 3.2, Unit tests 2.6, Integration 5.1, Package 1.2, Deploy 2.4; release: Checkout 0.5, Restore 2.1, Compile 4, Unit tests 3.1, Integration 6.3, Package 1.6, Deploy 301234567CheckoutRestoreCompileUnit testsIntegrationPackageDeploymain · Checkout: 0.4main · Restore: 1.8main · Compile: 3.2main · Unit tests: 2.6main · Integration: 5.1main · Package: 1.2main · Deploy: 2.4release · Checkout: 0.5release · Restore: 2.1release · Compile: 4release · Unit tests: 3.1release · Integration: 6.3release · Package: 1.6release · Deploy: 3
main release
website/Examples/Charts/LineChartRotatedExample.razor Source

References draws a ChartReference line across the plot at a value (dashed unless Dashed is false) and Bands shades a ChartBand range behind the data; labels sit inside the plot, and the axis grows to show every line.

p95 API latency (ms)
p95 API latency (ms) p95: Mon 182, Tue 195, Wed 240, Thu 310, Fri 228, Sat 160, Sun 150MonTueWedThuFriSatSun050100150200250300350Normal: 150 to 200Mon: 182Tue: 195Wed: 240Thu: 310Fri: 228Sat: 160Sun: 150Objective: 250Alert: 300NormalObjectiveAlert
website/Examples/Charts/LineChartReferencesExample.razor Source

Category markers

Markers draws a ChartMarker line at a label (the month a pricing change shipped), or with To a shaded span over a run of labels; labels sit above the plot. A marker naming a label the chart does not have is ignored. AreaChart and BarChart take Markers too; on a horizontal chart they run across.

New sign-ups per month
New sign-ups per month Sign-ups: Jan 420, Feb 445, Mar 430, Apr 610, May 680, Jun 720, Jul 655, Aug 700, Sep 760JanFebMarAprMayJunJulAugSep0200400600800Summer campaign: Jun to AugJan: 420Feb: 445Mar: 430Apr: 610May: 680Jun: 720Jul: 655Aug: 700Sep: 760New pricing: AprSummer campaignNew pricing
website/Examples/Charts/LineChartMarkersExample.razor Source

Trend lines

Trendline fits a dashed trend to each series over the label index (Linear, Exponential, Logarithmic, Power, Polynomial of TrendlineOrder 2 to 6, or a MovingAverage of TrendlinePeriod points) and draws it through the label positions; here a three-day moving average. Hover it for the equation and R², or the period. Ignored when Stacked or Percent.

Deploys per day
Deploys per day Production: Mon 14, Tue 18, Wed 16, Thu 21, Fri 12, Sat 3, Sun 2, Mon 19, Tue 22, Wed 20, Thu 25, Fri 15, Sat 4, Sun 3; Staging: Mon 31, Tue 36, Wed 34, Thu 40, Fri 28, Sat 6, Sun 5, Mon 38, Tue 41, Wed 39, Thu 46, Fri 30, Sat 8, Sun 6MonTueWedThuFriSatSunMonTueWedThuFriSatSun01020304050Production · Mon: 14Production · Tue: 18Production · Wed: 16Production · Thu: 21Production · Fri: 12Production · Sat: 3Production · Sun: 2Production · Mon: 19Production · Tue: 22Production · Wed: 20Production · Thu: 25Production · Fri: 15Production · Sat: 4Production · Sun: 3Staging · Mon: 31Staging · Tue: 36Staging · Wed: 34Staging · Thu: 40Staging · Fri: 28Staging · Sat: 6Staging · Sun: 5Staging · Mon: 38Staging · Tue: 41Staging · Wed: 39Staging · Thu: 46Staging · Fri: 30Staging · Sat: 8Staging · Sun: 6Production moving average trend: 3-point moving average Staging moving average trend: 3-point moving average
Production Staging
website/Examples/Charts/LineChartTrendlineExample.razor Source

Playground

Monthly signups
Monthly signups Signups: Jan 182, Feb 196, Mar 240, Apr 228, May 265, Jun 310, Jul 342, Aug 298, Sep 371JanFebMarAprMayJunJulAugSep0100200300400Jan: 182Feb: 196Mar: 240Apr: 228May: 265Jun: 310Jul: 342Aug: 298Sep: 371
Trendline ChartTrendline
<LineChart
           Title="Monthly signups"
           Labels="@_months"
           Series="@_signups" />

@code {
    private readonly string[] _months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"];

    private readonly ChartSeries[] _signups =
    [
        new("Signups", [182, 196, 240, 228, 265, 310, 342, 298, 371]),
    ];
}

API

<LineChart>

DaisyBlazor.Charts

Parameters

  • Area bool
    = false

    Fill the area under each line.

  • Bands IReadOnlyList<ChartBand>
    = null

    Shaded value ranges (plot bands) drawn behind the data, cut to the plot, each with an optional label in its corner.

  • Height string
    = "16rem"

    CSS height of the SVG plot area.

  • Horizontal bool
    = false

    Rotate the chart: the labels run down the vertical axis and the values along the horizontal one, each line reading top to bottom. Works with every other option (Smooth, Step, Stacked, Percent, Area); a step then holds its value down to the next label.

  • Labels IReadOnlyList<string>
    = null

    X-axis category labels (index-aligned with each series' values).

  • Markers IReadOnlyList<ChartMarker>
    = null

    Markers on the category axis: a line at a category (the month a pricing change shipped), or with To a shaded span over a run of categories, each with an optional label outside the plot. They run across the chart when it is Horizontal. A marker naming a category the chart does not have is ignored.

  • Percent bool
    = false

    100% stacked lines (implies Stacked): each value is drawn as its share of the total at its index, on a percent axis. Negative or missing values count as 0. Tooltips show the value and the share.

  • References IReadOnlyList<ChartReference>
    = null

    Reference lines across the plot at a value (a target, a limit, a break-even point), drawn over the data with their label inside the plot. The value axis grows to show every line.

  • Series IReadOnlyList<ChartSeries>
    = []

    One or more named series to plot.

  • ShowGrid bool
    = true

    Draw value gridlines and value labels.

  • ShowLegend bool
    = true

    Show a legend when more than one series is present.

  • ShowPoints bool
    = true

    Draw a marker at each data point.

  • ShowTitle bool
    = true

    Draw Title as a visible heading above the chart (the default); false keeps it only as the chart's accessible name, for a chart inside a card that already has a heading.

  • Smooth bool
    = false

    Smooth the line with cubic curves instead of straight segments.

  • Stacked bool
    = false

    Stack the series: each one is drawn on top of the running total of the previous ones, and with Area each fill spans only its own band. Missing or non-finite values count as 0; tooltips still show each series' own value.

  • Step bool
    = false

    Draw the line as steps (step-after: each value holds until the next one). If both Step and Smooth are set, Step wins.

  • Title string
    = null

    Optional heading rendered above the chart.

  • Trendline ChartTrendline
    = ChartTrendline.None

    Fit and draw a dashed trend line per series, over the category index (0, 1, …) on the series' own values, through the category positions (also when Horizontal); its tooltip gives the equation and R², or the period of a moving average. Ignored when Stacked or Percent is on: a fit of the own values would not follow the stacked points.

  • TrendlineOrder int
    = 2

    Degree of a Polynomial trend line, from 2 to 6 (other values are clamped).

  • TrendlinePeriod int
    = 3

    Number of points a MovingAverage trend line averages (at least 2).

  • Width string
    = "100%"

    CSS width of the chart wrapper.

  • Class string
    = null

    Extra CSS classes merged onto the chart wrapper.

  • Style string
    = null

    Inline CSS styles appended to the chart wrapper after the width.

Something went wrong while running the docs. Reload