Skip to content
daisyBlazor

Sparkline

A tiny trend line, column or win/loss chart with no axes, sized to sit inline in text, table cells or KPI tiles. Takes a plain list of numbers. D3 draws it at the box's real size.
Essentials
Cover · <Sparkline>

Active users

7.8 k Sparkline trend 7 values from 41 to 78; low 41, high 78.

Open tickets

47 Sparkline trend 7 values from 62 to 47; low 47, high 62.

Examples

Basic

Area fills under the line, ShowEndDot marks the latest value, StrokeWidth sets the weight.

Signups Sparkline trend 7 values from 12 to 31; low 12, high 31. With area Sparkline trend 7 values from 12 to 31; low 12, high 31. No end dot Sparkline trend 7 values from 12 to 31; low 12, high 31.
website/Examples/Charts/SparklineBasicExample.razor Source

In a table

Width and Color (any CSS colour) let each row show its own trend.

ServiceLast 7 daysRequests
Billing API Sparkline trend 7 values from 4,100 to 7,800; low 4,100, high 7,800. 40,150
Auth service Sparkline trend 7 values from 6,200 to 4,700; low 4,700, high 6,200. 38,400
Search Sparkline trend 7 values from 2,300 to 3,900; low 2,300, high 3,900. 20,550
website/Examples/Charts/SparklineTableExample.razor Source

Column and win/loss

Type="SparklineKind.Column" draws one bar per value from zero, negative ones down in NegativeColor (the error colour by default); SparklineKind.WinLoss draws equal bars up or down by sign, with a gap for zero.

Net new workspaces Sparkline trend 12 values from 14 to 21; low -6, high 21.149-31218-671116-2921 Nightly builds Nightly builds, passed or failed 10 up, 3 down, 1 even.11-11111-1-11111
website/Examples/Charts/SparklineKindsExample.razor Source

ShowTrendline adds the dashed least-squares line across the values; NormalMin and NormalMax shade the expected range behind them. Both work on lines and columns.

p95 latency Sparkline trend 10 values from 204 to 262; low 198, high 262.Normal range 180 to 240 Error rate Sparkline trend 10 values from 0.3 to 0.7; low 0.2, high 0.9.Normal range 0 to 0.50.30.40.20.60.50.70.40.80.90.7
website/Examples/Charts/SparklineTrendExample.razor Source

Playground

Sparkline trend 7 values from 12 to 31; low 12, high 31.
Type SparklineKind
<Sparkline Data="@_signups" />

@code {
    private readonly double[] _signups = [12, 18, 15, 22, 19, 27, 31];
}

API

<Sparkline>

DaisyBlazor.Charts

Parameters

  • Area bool
    = false

    Fill the area beneath the line.

  • Color string
    = null

    Optional explicit CSS color; defaults to the primary theme token.

  • Data IReadOnlyList<double>
    = []

    The values to plot, oldest-to-newest.

  • Height string
    = "1.5rem"

    CSS height (inline; defaults to a compact cell size).

  • NegativeColor string
    = null

    CSS colour of the bars of negative values (Column and WinLoss); defaults to the error theme token.

  • NormalMax double?
    = null

    High end of the normal range, shaded behind the values with NormalMin (Line and Column).

  • NormalMin double?
    = null

    Low end of the normal range, shaded behind the values with NormalMax (Line and Column).

  • ShowEndDot bool
    = true

    Draw a dot on the most recent value.

  • ShowTrendline bool
    = false

    Draw the least-squares line across the values, dashed (Line and Column).

  • StrokeWidth double
    = 2

    Line stroke width in user units.

  • Title string
    = null

    Accessible description; defaults to a generic sparkline label.

  • Type SparklineKind
    = SparklineKind.Line

    Draw a line (default), a column per value, or win/loss bars by sign.

  • Width string
    = "5rem"

    CSS width (inline; defaults to a compact cell size).

  • Class string
    = null

    Extra CSS classes merged onto the sparkline's inline box.

  • Style string
    = null

    Inline CSS style appended after the Width/Height declarations on the sparkline's inline box.

Something went wrong while running the docs. Reload