Sparkline

Description

A compact inline trend chart

Sparkline renders a compact SVG area chart designed to be embedded alongside metric values, table cells, or dashboard cards. It conveys the shape of a trend at a glance without axes, labels, or interactive controls.

The chart accepts a data array of doubles and optional width, height, and color parameters, making it easy to match any layout or brand color.

Samples

Upward Trend

Downward Trend

Flat / Stable

Volatile / Random

Primary Color (default)

Larger Chart

Dashboard Card with Metric and Sparkline

Sparklines are most useful when paired with a headline metric. The cards below combine a primary number, the period-over-period delta, and a sparkline for shape — each tile uses a different palette to highlight the trend direction.

Dynamic Sparkline (Refresh on Click)

Sparkline re-renders whenever it is added to a container, so you can drive interactivity by swapping the chart for a new instance on a user action. The button below replaces the current chart with a freshly-randomised data set.

API reference

class

Sparkline

public class Sparkline : IComponent

A tiny inline line chart used to show a trend without occupying chart-sized real-estate.

Namespace
Tesserae
Implements
IComponent

Constructors

NameDescription
SparklineInitializes a new instance of this class.
Constructor
Sparkline
public Sparkline(double[] data, double width = 100, double height = 30, string color = "")

Initializes a new instance of this class.

Methods

NameDescription
StrokeWidthSets the width of the line, in pixels. The line keeps that width when the chart is stretched to fill its row, rather than being scaled with the drawing.
FillTurns the tinted area under the line on or off. On by default.
EndMarkerMarks the last point of the series with a dot in the line's colour - the "this week" end of a trend that runs up to now.
ReferenceLineDraws a dotted horizontal line across the chart at the given value - a target, a threshold or a baseline the trend should be read against. A value outside the range of the series is clamped to the nearest edge of the chart.
RenderRenders the component's root HTML element.
Method
Sparkline.StrokeWidth
public Sparkline StrokeWidth(double width)

Sets the width of the line, in pixels. The line keeps that width when the chart is stretched to fill its row, rather than being scaled with the drawing.

Method
Sparkline.Fill
public Sparkline Fill(bool value = true)

Turns the tinted area under the line on or off. On by default.

Method
Sparkline.EndMarker
public Sparkline EndMarker(bool value = true)

Marks the last point of the series with a dot in the line's colour - the "this week" end of a trend that runs up to now.

Method
Sparkline.ReferenceLine
Overload
ReferenceLine(double)Draws a dotted horizontal line across the chart at the given value - a target, a threshold or a baseline the trend should be read against. A value outside the range of the series is clamped to the nearest edge of the chart.
ReferenceLine()Draws a dotted horizontal line across the chart at the mean of the series.
ReferenceLine(double)
public Sparkline ReferenceLine(double value)

Draws a dotted horizontal line across the chart at the given value - a target, a threshold or a baseline the trend should be read against. A value outside the range of the series is clamped to the nearest edge of the chart.

Parameters

value double
ReferenceLine()
public Sparkline ReferenceLine()

Draws a dotted horizontal line across the chart at the mean of the series.

Method
Sparkline.Render
public HTMLElement Render()

Renders the component's root HTML element.

See also