Charts

Four dependency-free SVG chart types: LineChart, BarChart, AreaChart, and PieChart. All four share a common base that handles the responsive SVG surface, the series/palette model, observable-driven re-rendering, tippy tooltips, and the role="img" accessibility summary. Rendering style mirrors [[Sparkline]].

Each chart fills its container via a ResizeObserver and re-paints on every size change. Data can be supplied as plain double[] arrays or as observables that push updates; subscriptions are released automatically when the component leaves the DOM.

Chart types

Type Factory Use for
LineChart UI.LineChart() Trends over ordered categories; fits data range (no forced zero baseline)
BarChart UI.BarChart() Category comparisons; grouped bars; always reads against a zero baseline
AreaChart UI.AreaChart() Filled trend regions with a gradient under the line; zero baseline
PieChart UI.PieChart() Part-to-whole; can render as a donut via .Donut()

Common API (all chart types)

All charts expose the methods below through ChartBase<T> and, for the cartesian types, CartesianChartBase<T>.

Data and series

  • .Data(double[] values) — single unnamed series.
  • .Series(params ChartSeries[] series) — replace all series at once.
  • .Series(string name, double[] values, string color = null) — append one named series.
  • .Series(IObservable<double[]> values, string name = null, string color = null) — bind a single series to an observable.
  • .Series(IObservable<ChartSeries[]> series) — bind all series to an observable.

Appearance

  • .Colors(params string[] palette) — replace the default eight-color theme palette. Colors are CSS values; the default palette uses Theme.Colors.* variables that adapt to light/dark mode.
  • .Tooltips(bool show = true) — enable or disable tippy popovers on each data point/bar/slice. Native <title> elements are always written regardless of this flag.
  • .Legend(bool show = true) — show a swatch + label legend.
  • .Title(string title) — set an explicit aria-label on the chart container; used as the accessibility summary instead of the auto-generated description.
  • .FormatValues(Func<double, string> formatter) — override how values are displayed in tooltips and axis labels. Default: "0.##".

Cartesian charts only (LineChart, BarChart, AreaChart)

  • .XAxis(params string[] categories) — category labels along the X axis.
  • .XAxisTitle(string title) — X axis title, shown below the category labels.
  • .YAxisTitle(string title) — Y axis title.
  • .Grid(bool show = true) — horizontal gridlines (default: on).
  • .Axes(bool show = true) — axis lines and value/category labels (default: on).

LineChart and AreaChart

  • .Points(bool show = true) — show or hide the per-point circle markers (default: on).

BarChart

  • .Rounded(double radius = 2) — corner radius on each bar rectangle.

PieChart

  • .Labels(params string[] labels) — per-slice labels, used in the legend and tooltips.
  • .Donut(double holeRatio = 0.6) — render as a donut with a cutout sized as a fraction (0–0.95) of the radius.

ChartSeries

ChartSeries carries one named data series:

new ChartSeries(string name, double[] values, string color = null)
  • name — display name shown in the legend and tooltips. Pass null for an unnamed series.
  • values — one value per category/point.
  • color — explicit CSS color; when null the chart assigns a palette color by index.

Usage examples

Line chart with two series and category labels

Bar chart with grouped series

Area chart with observable data

Pie chart and donut chart

API reference

enum

ChartLegendPosition

public enum ChartLegendPosition

Where a chart draws its legend.

Namespace
Tesserae

Values

NameDescription
TopA horizontal row of swatches above the plot.
BottomA horizontal row of swatches below the plot.
LeftA vertical column of swatches to the left of the plot.
RightA vertical column of swatches to the right of the plot.
Value
ChartLegendPosition.Top
Top

A horizontal row of swatches above the plot.

Value
ChartLegendPosition.Bottom
Bottom

A horizontal row of swatches below the plot.

Value
ChartLegendPosition.Left
Left

A vertical column of swatches to the left of the plot.

Value
ChartLegendPosition.Right
Right

A vertical column of swatches to the right of the plot.

class

ChartRange

public sealed class ChartRange

The visible X range of a cartesian chart, reported when the user zooms or pans.

Namespace
Tesserae

Constructors

NameDescription
ChartRangeInitializes a new instance of the ChartRange class.
Constructor
ChartRange
public ChartRange(double min, double max, bool isAutoRange)

Initializes a new instance of the ChartRange class.

Properties

NameDescription
MinThe lowest visible X value.
MaxThe highest visible X value.
IsAutoRangeTrue when the chart is back to fitting its data instead of showing an explicit range.
Property
ChartRange.Min
public double Min { get; set; }

The lowest visible X value.

Property
ChartRange.Max
public double Max { get; set; }

The highest visible X value.

Property
ChartRange.IsAutoRange
public bool IsAutoRange { get; set; }

True when the chart is back to fitting its data instead of showing an explicit range.

class

ChartSeries

public sealed class ChartSeries

A single named data series for a chart, with an optional explicit color (falling back to the chart palette).

Namespace
Tesserae

Constructors

NameDescription
ChartSeriesInitializes a new instance of the ChartSeries class.
Constructor
ChartSeries
Overload
ChartSeries(string, double[], string)Initializes a new instance of the ChartSeries class.
ChartSeries(string, double[], double[], string)Initializes a new instance of the ChartSeries class with explicit X positions, putting the chart on a continuous X scale.
ChartSeries(string, double[], string)
public ChartSeries(string name, double[] values, string color = null)

Initializes a new instance of the ChartSeries class.

Parameters

name string
values double[]
color string
ChartSeries(string, double[], double[], string)
public ChartSeries(string name, double[] xValues, double[] values, string color = null)

Initializes a new instance of the ChartSeries class with explicit X positions, putting the chart on a continuous X scale.

Parameters

name string
xValues double[]
values double[]
color string

Properties

NameDescription
NameThe series display name, used in the legend, tooltips and accessibility summary.
ValuesThe series values, one per category/point. NaN marks a missing sample.
ColorAn optional explicit CSS color; when null the chart assigns a palette color by index.
XValuesOptional X positions for this series' values, one per entry in Values. Setting these on any series switches the chart to a continuous X scale, which lets each series carry its own X positions (irregular sampling, differing time windows, differing point counts) instead of sharing one category list.
LineWidthThe stroke width of this series' line, in pixels (line and area charts).
FillOpacityThe opacity of this series' area fill at its peak, fading to near-transparent at the baseline (area charts).
Property
ChartSeries.Name
public string Name { get; set; }

The series display name, used in the legend, tooltips and accessibility summary.

Property
ChartSeries.Values
public double[] Values { get; set; }

The series values, one per category/point. NaN marks a missing sample.

Property
ChartSeries.Color
public string Color { get; set; }

An optional explicit CSS color; when null the chart assigns a palette color by index.

Property
ChartSeries.XValues
public double[] XValues { get; set; }

Optional X positions for this series' values, one per entry in Values. Setting these on any series switches the chart to a continuous X scale, which lets each series carry its own X positions (irregular sampling, differing time windows, differing point counts) instead of sharing one category list.

Property
ChartSeries.LineWidth
public double LineWidth { get; set; }

The stroke width of this series' line, in pixels (line and area charts).

Property
ChartSeries.FillOpacity
public double FillOpacity { get; set; }

The opacity of this series' area fill at its peak, fading to near-transparent at the baseline (area charts).

class

ChartBase<T>

public abstract class ChartBase<T> : IComponent where T : ChartBase<T>

Shared base for Tesserae's lightweight, dependency-free SVG charts. Handles the responsive SVG surface (sized 1:1 to its container via a ResizeObserver), the series/palette model, observable-driven re-rendering, theme colors, tooltips (reusing tippy), PNG export and the role="img" accessibility summary. Mirrors Sparkline's SVG rendering style.

Namespace
Tesserae
Implements
IComponent

Constructors

NameDescription
ChartBaseInitializes a new instance of the ChartBase{T} class.
Constructor
ChartBase
protected ChartBase(double minWidth = 120, double minHeight = 80)

Initializes a new instance of the ChartBase{T} class.

Methods

NameDescription
FormatValueCompactThe default value format: large magnitudes are abbreviated with an SI prefix, because an axis of byte counts or token totals is unreadable at full length. Small values are left alone. Override with FormatValues.
DataReplaces the chart's series with a single unnamed series of plain values.
SeriesReplaces the chart's series.
ColorsSets the series color palette (used for series without an explicit color).
TooltipsEnables or disables per-element tooltips.
LegendEnables or disables the legend.
ConnectGapsWhen true (the default) a line or area series draws straight across a NaN value; when false the line breaks, leaving the gap visible.
TitleSets an accessibility caption / summary for the chart.
FormatValuesSets the formatter used for values in tooltips and labels.
ExportButtonShows a small download button in the chart's top-right corner (revealed on hover) that saves the chart as a PNG.
ExportPngSaves the chart as a PNG. CSS-variable colors are resolved to concrete values first, so the exported image matches the theme the chart is currently rendered in.
ColorForReturns the color for the series at the given index (explicit color or palette by index).
ElCreates an SVG element in the SVG namespace.
AttrSets an attribute on an SVG element (double values are invariant-formatted).
AttachPointTooltipAttaches a hover tooltip to an SVG element: a native <title> child (for accessibility / no-JS fallback) and, when enabled, a tippy popover reusing the bundled tippy.js.
ClearSvgRemoves every child of the SVG surface.
QueueRenderSchedules a render on the next animation frame, coalescing bursts of changes.
RenderChartDraws the chart into the SVG surface at the given pixel dimensions.
BuildAriaLabelBuilds the accessibility summary describing the chart's data.
ResetLegendInsetsClears the space reserved for the legend, before a fresh render measures it again.
RenderLegendRenders the legend for the chart's series, recording the space it consumed in the legend insets.
RenderRenders the component's root HTML element.
Method
ChartBase.FormatValueCompact
protected static string FormatValueCompact(double value)

The default value format: large magnitudes are abbreviated with an SI prefix, because an axis of byte counts or token totals is unreadable at full length. Small values are left alone. Override with FormatValues.

Method
ChartBase.Data
public T Data(double[] values)

Replaces the chart's series with a single unnamed series of plain values.

Method
ChartBase.Series
Overload
Series(ChartSeries[])Replaces the chart's series.
Series(string, double[], string)Appends a single named series of plain values.
Series(IObservable<double[]>, string, string)Binds a single series to an observable sequence of values: the chart re-renders whenever the observable changes. The subscription is released when the chart leaves the DOM.
Series(IObservable<ChartSeries[]>)Binds the chart to an observable list of series, re-rendering on every change.
Series(ChartSeries[])
public T Series(params ChartSeries[] series)

Replaces the chart's series.

Parameters

series ChartSeries[]
Series(string, double[], string)
public T Series(string name, double[] values, string color = null)

Appends a single named series of plain values.

Parameters

name string
values double[]
color string
Series(IObservable<double[]>, string, string)
public T Series(IObservable<double[]> values, string name = null, string color = null)

Binds a single series to an observable sequence of values: the chart re-renders whenever the observable changes. The subscription is released when the chart leaves the DOM.

Parameters

values IObservable<double[]>
name string
color string
Series(IObservable<ChartSeries[]>)
public T Series(IObservable<ChartSeries[]> series)

Binds the chart to an observable list of series, re-rendering on every change.

Parameters

series IObservable<ChartSeries[]>
Method
ChartBase.Colors
public T Colors(params string[] palette)

Sets the series color palette (used for series without an explicit color).

Method
ChartBase.Tooltips
public T Tooltips(bool show = true)

Enables or disables per-element tooltips.

Method
ChartBase.Legend
Overload
Legend(bool)Enables or disables the legend.
Legend(ChartLegendPosition)Sets which edge of the chart the legend is drawn on (and enables it).
Legend(bool)
public T Legend(bool show = true)

Enables or disables the legend.

Parameters

show bool
Legend(ChartLegendPosition)
public T Legend(ChartLegendPosition position)

Sets which edge of the chart the legend is drawn on (and enables it).

Parameters

position ChartLegendPosition
Method
ChartBase.ConnectGaps
public T ConnectGaps(bool connect = true)

When true (the default) a line or area series draws straight across a NaN value; when false the line breaks, leaving the gap visible.

Method
ChartBase.Title
public T Title(string title)

Sets an accessibility caption / summary for the chart.

Method
ChartBase.FormatValues
public T FormatValues(Func<double, string> formatter)

Sets the formatter used for values in tooltips and labels.

Method
ChartBase.ExportButton
public T ExportButton(bool show = true, string fileName = null)

Shows a small download button in the chart's top-right corner (revealed on hover) that saves the chart as a PNG.

Method
ChartBase.ExportPng
public void ExportPng(string fileName = null)

Saves the chart as a PNG. CSS-variable colors are resolved to concrete values first, so the exported image matches the theme the chart is currently rendered in.

Method
ChartBase.ColorFor
protected string ColorFor(int index, ChartSeries series)

Returns the color for the series at the given index (explicit color or palette by index).

Method
ChartBase.El
protected Element El(string name)

Creates an SVG element in the SVG namespace.

Method
ChartBase.Attr
Overload
Attr(Element, string, double)Sets an attribute on an SVG element (double values are invariant-formatted).
Attr(Element, string, string)Sets an attribute on an SVG element.
Attr(Element, string, double)
protected static void Attr(Element el, string name, double value)

Sets an attribute on an SVG element (double values are invariant-formatted).

Parameters

el Element
name string
value double
Attr(Element, string, string)
protected static void Attr(Element el, string name, string value)

Sets an attribute on an SVG element.

Parameters

el Element
name string
value string
Method
ChartBase.AttachPointTooltip
protected void AttachPointTooltip(Element el, string content)

Attaches a hover tooltip to an SVG element: a native <title> child (for accessibility / no-JS fallback) and, when enabled, a tippy popover reusing the bundled tippy.js.

Remarks

The tippy instance is created the first time the point is hovered rather than at render time. A chart is drawn point by point, so building one instance per point up front cost a tippy object, its listeners and a full-document z-index scan for every value in the series — all of it before the user has pointed at anything. One delegated listener on the SVG surface replaces them; the created instance keeps tippy's own trigger from then on, so hover behaviour and the show delay are unchanged.

Method
ChartBase.ClearSvg
protected void ClearSvg()

Removes every child of the SVG surface.

Method
ChartBase.QueueRender
protected void QueueRender()

Schedules a render on the next animation frame, coalescing bursts of changes.

Method
ChartBase.RenderChart
protected abstract void RenderChart(double width, double height)

Draws the chart into the SVG surface at the given pixel dimensions.

Method
ChartBase.BuildAriaLabel
protected virtual string BuildAriaLabel()

Builds the accessibility summary describing the chart's data.

Method
ChartBase.ResetLegendInsets
protected void ResetLegendInsets()

Clears the space reserved for the legend, before a fresh render measures it again.

Method
ChartBase.RenderLegend
Overload
RenderLegend(double, double)Renders the legend for the chart's series, recording the space it consumed in the legend insets.
RenderLegend(string[], string[], double, double)Renders a legend of the given labels and colors on the configured edge, recording the space it consumed in _legendInsetTop and friends so the caller can lay the plot out around it.
RenderLegend(double, double)
protected void RenderLegend(double width, double height)

Renders the legend for the chart's series, recording the space it consumed in the legend insets.

Parameters

width double
height double
RenderLegend(string[], string[], double, double)
protected void RenderLegend(string[] labels, string[] colors, double width, double height)

Renders a legend of the given labels and colors on the configured edge, recording the space it consumed in _legendInsetTop and friends so the caller can lay the plot out around it.

Parameters

labels string[]
colors string[]
width double
height double
Method
ChartBase.Render
public HTMLElement Render()

Renders the component's root HTML element.

Fields

NameDescription
SvgNsThe SVG namespace used for every chart element.
MaxMarkersPerSeriesAbove this many points in a series, per-point markers (and their tooltips) are suppressed: one DOM node plus one tooltip per sample stops being readable long before it stops being expensive. Use the spikeline readout instead of markers for dense series.
DefaultPaletteThe default theme-aware palette (CSS variables that adapt to light/dark mode).
_containerThe root container element.
_svgThe SVG surface that the chart draws into.
_seriesThe chart's series.
_paletteThe active color palette.
_showTooltipsWhether to render per-element tippy + native <title> tooltips.
_showLegendWhether to render the legend.
_legendPositionWhere the legend is drawn.
_connectGapsWhether a line/area series draws straight across a NaN gap instead of breaking.
_titleAn optional caption used as the accessibility summary; falls back to a generated description.
_valueFormatterOptional formatter for values shown in tooltips / axis labels.
_plotSurfaceThe element subclasses draw their series into; clipped to the plot rectangle on cartesian charts.
_legendInsetTopSpace the legend claimed at the top of the surface, in pixels.
_legendInsetBottomSpace the legend claimed at the bottom of the surface, in pixels.
_legendInsetLeftSpace the legend claimed on the left of the surface, in pixels.
_legendInsetRightSpace the legend claimed on the right of the surface, in pixels.
Field
ChartBase.SvgNs
protected const string SvgNs = "http://www.w3.org/2000/svg"

The SVG namespace used for every chart element.

Field
ChartBase.MaxMarkersPerSeries
protected const int MaxMarkersPerSeries = 300

Above this many points in a series, per-point markers (and their tooltips) are suppressed: one DOM node plus one tooltip per sample stops being readable long before it stops being expensive. Use the spikeline readout instead of markers for dense series.

Field
ChartBase.DefaultPalette
protected static readonly string[] DefaultPalette = { Theme.Colors.Blue600, Theme.Colors.Green600, Theme.Colors.Orange600, Theme.Colors.Purple600, Theme.Colors.Red600, Theme.Colors.Teal600, Theme.Colors.Yellow600, Theme.Colors.Neutral600 }

The default theme-aware palette (CSS variables that adapt to light/dark mode).

Field
ChartBase._container
protected readonly HTMLElement _container

The root container element.

Field
ChartBase._svg
protected readonly Element _svg

The SVG surface that the chart draws into.

Field
ChartBase._series
protected readonly List<ChartSeries> _series = new List<ChartSeries>()

The chart's series.

Field
ChartBase._palette
protected string[] _palette = DefaultPalette

The active color palette.

Field
ChartBase._showTooltips
protected bool _showTooltips = true

Whether to render per-element tippy + native <title> tooltips.

Field
ChartBase._showLegend
protected bool _showLegend = false

Whether to render the legend.

Field
ChartBase._legendPosition
protected ChartLegendPosition _legendPosition = ChartLegendPosition.Top

Where the legend is drawn.

Field
ChartBase._connectGaps
protected bool _connectGaps = true

Whether a line/area series draws straight across a NaN gap instead of breaking.

Field
ChartBase._title
protected string _title

An optional caption used as the accessibility summary; falls back to a generated description.

Field
ChartBase._valueFormatter
protected Func<double, string> _valueFormatter = FormatValueCompact

Optional formatter for values shown in tooltips / axis labels.

Field
ChartBase._plotSurface
protected Element _plotSurface

The element subclasses draw their series into; clipped to the plot rectangle on cartesian charts.

Field
ChartBase._legendInsetTop
protected double _legendInsetTop

Space the legend claimed at the top of the surface, in pixels.

Field
ChartBase._legendInsetBottom
protected double _legendInsetBottom

Space the legend claimed at the bottom of the surface, in pixels.

Field
ChartBase._legendInsetLeft
protected double _legendInsetLeft

Space the legend claimed on the left of the surface, in pixels.

Field
ChartBase._legendInsetRight
protected double _legendInsetRight

Space the legend claimed on the right of the surface, in pixels.

class

CartesianChartBase<T>

public abstract class CartesianChartBase<T> : ChartBase<T> where T : CartesianChartBase<T>

Base for cartesian (x/y) charts — line, bar and area. Draws the value (Y) gridlines and labels, the category (X) axis labels, the axis lines, and computes the plot rectangle and value-to-pixel scale that subclasses use to plot their series. Also owns the continuous X scale, tick thinning, zoom/pan and the spikeline readout.

Namespace
Tesserae
Inheritance
ChartBase<T> → CartesianChartBase<T>

Constructors

NameDescription
CartesianChartBaseInitializes a new instance of the CartesianChartBase{T} class.
Constructor
CartesianChartBase
protected CartesianChartBase(double minWidth = 200, double minHeight = 120) : base(minWidth, minHeight)

Initializes a new instance of the CartesianChartBase{T} class.

Properties

NameDescription
IsXRangePinnedTrue when the visible X range came from a zoom / pan rather than fitting the data.
DefaultIncludeZeroBaselineThe chart type's default: true when the value axis should always include zero as a baseline.
IncludeZeroBaselineWhether the value axis includes zero, honouring ZeroBaseline over the type default.
ConnectsPointsAcrossXTrue when the chart draws a continuous line between consecutive points, so a segment crossing the visible window sizes the value axis even with neither of its ends inside it.
Property
CartesianChartBase.IsXRangePinned
public bool IsXRangePinned

True when the visible X range came from a zoom / pan rather than fitting the data.

Property
CartesianChartBase.DefaultIncludeZeroBaseline
protected virtual bool DefaultIncludeZeroBaseline

The chart type's default: true when the value axis should always include zero as a baseline.

Property
CartesianChartBase.IncludeZeroBaseline
protected bool IncludeZeroBaseline

Whether the value axis includes zero, honouring ZeroBaseline over the type default.

Property
CartesianChartBase.ConnectsPointsAcrossX
protected virtual bool ConnectsPointsAcrossX

True when the chart draws a continuous line between consecutive points, so a segment crossing the visible window sizes the value axis even with neither of its ends inside it.

Methods

NameDescription
XAxisSets the category labels along the X axis.
XValuesSets shared X positions for every series, putting the chart on a continuous X scale so points sit at their real distance apart instead of being evenly spaced. Per-series positions (XValues) win over these.
FormatXAxisSets the formatter used for continuous X axis tick labels (and the spikeline readout).
XAxisTimeFormats continuous X values as local times, treating them as Unix timestamps in seconds. With no format the labels adapt to the visible span — seconds when zoomed into a minute, dates when showing months — and the ticks land on whole seconds, minutes, hours or days rather than on powers of ten.
MaxXTicksCaps how many X axis tick labels are drawn; categories beyond the cap are skipped evenly. Pass 0 (the default) to derive the cap from the available width, which keeps dense axes readable.
XAxisTitleSets the X axis title.
YAxisTitleSets the Y axis title.
GridShows or hides the horizontal gridlines.
AxesShows or hides the axes and their labels.
ZoomableAllows the user to zoom the X axis with the wheel, pan it by dragging, and reset to the full data range by double-clicking. Only meaningful on a continuous X scale.
ZoomLimitsBounds how far the wheel may zoom the X axis, as the smallest and largest visible span. Pass 0 for either to keep the default, which is a fraction (and a multiple) of the data's own X extent. A chart that loads its data to match the visible range wants an explicit maximum: the widest span the user can reach is what decides how much has to be fetched.
SpikelinesDraws a vertical spikeline that follows the cursor across the plot, with a readout of the X position and each series' nearest value. The readable alternative to a marker per sample on a dense series.
XRangePins the visible X range on a continuous scale. Setting the range does not raise OnRangeChanged, so charts can be kept in sync with each other without a re-entrancy guard.
AutoRangeXReturns the chart to fitting the full X extent of its data, undoing any zoom or pan.
TryGetXRangeGets the X range the chart is currently showing. False when the chart has no continuous X data yet.
OnRangeChangedRaised when the user zooms, pans or resets the X axis — not when XRange is called, so a handler that pushes the range onto sibling charts cannot loop.
ZeroBaselineOverrides whether the value axis includes zero, regardless of the chart type's default. An area chart of a metric that hovers far from zero reads better fitted to its data, with the fill still running to the bottom of the plot.
PixelYMaps a value to its pixel Y coordinate within the plot area.
PixelXForValueMaps a continuous X value to its pixel X coordinate within the plot area.
XOfReturns the X position of point index of a series on a continuous scale.
SeriesPointXReturns the pixel X coordinate for point index of series, using the continuous scale when the chart has X values and evenly spaced slots otherwise.
SeriesRunsSplits a series into runs of consecutive plottable points, breaking at NaN gaps. Returns a single run covering every non-gap point when gaps are connected.
RenderChart
CollectRangeValuesCollects the values the Y axis must accommodate. Only what is inside the visible X window counts on a continuous scale, so zooming rescales the value axis to what is on screen.
FormatXValueFormats a continuous X value using the configured X formatter, falling back to a plain number.
NiceStepRounds a rough interval up to the nearest 1, 2 or 5 times a power of ten, which is what makes an axis read as 0 / 200 / 400 rather than 0 / 168.4 / 336.8. Returns 0 for an interval it cannot represent.
CategoryCenterXReturns the pixel X coordinate of the center of category slot index.
PointXReturns the pixel X coordinate for point index of a line/area series.
RenderSeriesPlots the series into the computed plot rectangle.
Method
CartesianChartBase.XAxis
public T XAxis(params string[] categories)

Sets the category labels along the X axis.

Method
CartesianChartBase.XValues
public T XValues(double[] values)

Sets shared X positions for every series, putting the chart on a continuous X scale so points sit at their real distance apart instead of being evenly spaced. Per-series positions (XValues) win over these.

Method
CartesianChartBase.FormatXAxis
public T FormatXAxis(Func<double, string> formatter)

Sets the formatter used for continuous X axis tick labels (and the spikeline readout).

Method
CartesianChartBase.XAxisTime
public T XAxisTime(string format = null)

Formats continuous X values as local times, treating them as Unix timestamps in seconds. With no format the labels adapt to the visible span — seconds when zoomed into a minute, dates when showing months — and the ticks land on whole seconds, minutes, hours or days rather than on powers of ten.

Method
CartesianChartBase.MaxXTicks
public T MaxXTicks(int count)

Caps how many X axis tick labels are drawn; categories beyond the cap are skipped evenly. Pass 0 (the default) to derive the cap from the available width, which keeps dense axes readable.

Method
CartesianChartBase.XAxisTitle
public T XAxisTitle(string title)

Sets the X axis title.

Method
CartesianChartBase.YAxisTitle
public T YAxisTitle(string title)

Sets the Y axis title.

Method
CartesianChartBase.Grid
public T Grid(bool show = true)

Shows or hides the horizontal gridlines.

Method
CartesianChartBase.Axes
public T Axes(bool show = true)

Shows or hides the axes and their labels.

Method
CartesianChartBase.Zoomable
public T Zoomable(bool enable = true)

Allows the user to zoom the X axis with the wheel, pan it by dragging, and reset to the full data range by double-clicking. Only meaningful on a continuous X scale.

Method
CartesianChartBase.ZoomLimits
public T ZoomLimits(double minSpan, double maxSpan)

Bounds how far the wheel may zoom the X axis, as the smallest and largest visible span. Pass 0 for either to keep the default, which is a fraction (and a multiple) of the data's own X extent. A chart that loads its data to match the visible range wants an explicit maximum: the widest span the user can reach is what decides how much has to be fetched.

Method
CartesianChartBase.Spikelines
public T Spikelines(bool enable = true)

Draws a vertical spikeline that follows the cursor across the plot, with a readout of the X position and each series' nearest value. The readable alternative to a marker per sample on a dense series.

Method
CartesianChartBase.XRange
public T XRange(double min, double max)

Pins the visible X range on a continuous scale. Setting the range does not raise OnRangeChanged, so charts can be kept in sync with each other without a re-entrancy guard.

Method
CartesianChartBase.AutoRangeX
public T AutoRangeX()

Returns the chart to fitting the full X extent of its data, undoing any zoom or pan.

Method
CartesianChartBase.TryGetXRange
public bool TryGetXRange(out double min, out double max)

Gets the X range the chart is currently showing. False when the chart has no continuous X data yet.

Method
CartesianChartBase.OnRangeChanged
public T OnRangeChanged(Action<ChartRange> handler)

Raised when the user zooms, pans or resets the X axis — not when XRange is called, so a handler that pushes the range onto sibling charts cannot loop.

Method
CartesianChartBase.ZeroBaseline
public T ZeroBaseline(bool include = true)

Overrides whether the value axis includes zero, regardless of the chart type's default. An area chart of a metric that hovers far from zero reads better fitted to its data, with the fill still running to the bottom of the plot.

Method
CartesianChartBase.PixelY
protected double PixelY(double value)

Maps a value to its pixel Y coordinate within the plot area.

Method
CartesianChartBase.PixelXForValue
protected double PixelXForValue(double x)

Maps a continuous X value to its pixel X coordinate within the plot area.

Method
CartesianChartBase.XOf
protected double XOf(ChartSeries series, int index)

Returns the X position of point index of a series on a continuous scale.

Method
CartesianChartBase.SeriesPointX
protected double SeriesPointX(ChartSeries series, int index)

Returns the pixel X coordinate for point index of series, using the continuous scale when the chart has X values and evenly spaced slots otherwise.

Method
CartesianChartBase.SeriesRuns
protected List<List<int>> SeriesRuns(ChartSeries series)

Splits a series into runs of consecutive plottable points, breaking at NaN gaps. Returns a single run covering every non-gap point when gaps are connected.

Method
CartesianChartBase.RenderChart
protected override void RenderChart(double width, double height)
Method
CartesianChartBase.CollectRangeValues
protected virtual void CollectRangeValues(List<double> into)

Collects the values the Y axis must accommodate. Only what is inside the visible X window counts on a continuous scale, so zooming rescales the value axis to what is on screen.

Method
CartesianChartBase.FormatXValue
protected string FormatXValue(double value)

Formats a continuous X value using the configured X formatter, falling back to a plain number.

Method
CartesianChartBase.NiceStep
private static double NiceStep(double rough)

Rounds a rough interval up to the nearest 1, 2 or 5 times a power of ten, which is what makes an axis read as 0 / 200 / 400 rather than 0 / 168.4 / 336.8. Returns 0 for an interval it cannot represent.

Method
CartesianChartBase.CategoryCenterX
protected double CategoryCenterX(int index)

Returns the pixel X coordinate of the center of category slot index.

Method
CartesianChartBase.PointX
protected double PointX(int index)

Returns the pixel X coordinate for point index of a line/area series.

Method
CartesianChartBase.RenderSeries
protected abstract void RenderSeries()

Plots the series into the computed plot rectangle.

Fields

NameDescription
_categoriesCategory labels along the X axis.
_showGridWhether to draw horizontal gridlines.
_showAxesWhether to draw the axes and their labels.
_xAxisTitleOptional X axis title.
_yAxisTitleOptional Y axis title.
_plotLeftLeft edge of the plot area, in pixels.
_plotTopTop edge of the plot area, in pixels.
_plotWidthWidth of the plot area, in pixels.
_plotHeightHeight of the plot area, in pixels.
_minValueThe minimum value mapped to the bottom of the plot.
_maxValueThe maximum value mapped to the top of the plot.
_pointCountThe number of categories/points along the X axis.
_continuousXTrue when the chart plots against a continuous X scale rather than evenly spaced categories.
_viewXMinThe lowest visible X value on a continuous scale.
_viewXMaxThe highest visible X value on a continuous scale.
Field
CartesianChartBase._categories
protected string[] _categories = new string[0]

Category labels along the X axis.

Field
CartesianChartBase._showGrid
protected bool _showGrid = true

Whether to draw horizontal gridlines.

Field
CartesianChartBase._showAxes
protected bool _showAxes = true

Whether to draw the axes and their labels.

Field
CartesianChartBase._xAxisTitle
protected string _xAxisTitle

Optional X axis title.

Field
CartesianChartBase._yAxisTitle
protected string _yAxisTitle

Optional Y axis title.

Field
CartesianChartBase._plotLeft
protected double _plotLeft

Left edge of the plot area, in pixels.

Field
CartesianChartBase._plotTop
protected double _plotTop

Top edge of the plot area, in pixels.

Field
CartesianChartBase._plotWidth
protected double _plotWidth

Width of the plot area, in pixels.

Field
CartesianChartBase._plotHeight
protected double _plotHeight

Height of the plot area, in pixels.

Field
CartesianChartBase._minValue
protected double _minValue

The minimum value mapped to the bottom of the plot.

Field
CartesianChartBase._maxValue
protected double _maxValue

The maximum value mapped to the top of the plot.

Field
CartesianChartBase._pointCount
protected int _pointCount

The number of categories/points along the X axis.

Field
CartesianChartBase._continuousX
protected bool _continuousX

True when the chart plots against a continuous X scale rather than evenly spaced categories.

Field
CartesianChartBase._viewXMin
protected double _viewXMin

The lowest visible X value on a continuous scale.

Field
CartesianChartBase._viewXMax
protected double _viewXMax

The highest visible X value on a continuous scale.

class

LineChart

public sealed class LineChart : CartesianChartBase<LineChart>

A lightweight, dependency-free SVG line chart. Plots one or more series as connected lines with hoverable points, value gridlines, category labels and a theme-aware palette. Fluent and responsive.

Namespace
Tesserae
Inheritance
CartesianChartBase<LineChart> → LineChart

Constructors

NameDescription
LineChartInitializes a new instance of the LineChart class.
Constructor
LineChart
public LineChart() : base()

Initializes a new instance of the LineChart class.

Methods

NameDescription
PointsShows or hides the per-point markers.
Method
LineChart.Points
public LineChart Points(bool show = true)

Shows or hides the per-point markers.

class

BarChart

public sealed class BarChart : CartesianChartBase<BarChart>

A lightweight, dependency-free SVG bar chart. Renders grouped bars per category (one bar per series) or, with Stacked, one stacked column per category, with a zero baseline, value gridlines, category labels, hover tooltips and a theme-aware palette.

Namespace
Tesserae
Inheritance
CartesianChartBase<BarChart> → BarChart

Constructors

NameDescription
BarChartInitializes a new instance of the BarChart class.
Constructor
BarChart
public BarChart() : base()

Initializes a new instance of the BarChart class.

Methods

NameDescription
RoundedSets the corner radius of the bars.
StackedStacks the series into one column per category instead of drawing them side by side. Positive and negative values stack away from the baseline independently.
CollectRangeValues
Method
BarChart.Rounded
public BarChart Rounded(double radius = 2)

Sets the corner radius of the bars.

Method
BarChart.Stacked
public BarChart Stacked(bool stacked = true)

Stacks the series into one column per category instead of drawing them side by side. Positive and negative values stack away from the baseline independently.

Method
BarChart.CollectRangeValues
protected override void CollectRangeValues(List<double> into)
class

AreaChart

public sealed class AreaChart : CartesianChartBase<AreaChart>

A lightweight, dependency-free SVG area chart. Renders each series as a gradient-filled region under its line (matching Sparkline's fill style), with hoverable points, gridlines and category labels.

Namespace
Tesserae
Inheritance
CartesianChartBase<AreaChart> → AreaChart

Constructors

NameDescription
AreaChartInitializes a new instance of the AreaChart class.
Constructor
AreaChart
public AreaChart() : base()

Initializes a new instance of the AreaChart class.

Methods

NameDescription
PointsShows or hides the per-point markers.
Method
AreaChart.Points
public AreaChart Points(bool show = true)

Shows or hides the per-point markers.

class

PieChart

public sealed class PieChart : ChartBase<PieChart>

A lightweight, dependency-free SVG pie / donut chart. Renders the first series' values as slices, labelled by the configured category labels, with hover tooltips, an optional legend and a theme-aware palette.

Namespace
Tesserae
Inheritance
ChartBase<PieChart> → PieChart

Constructors

NameDescription
PieChartInitializes a new instance of the PieChart class.
Constructor
PieChart
public PieChart() : base()

Initializes a new instance of the PieChart class.

Methods

NameDescription
LabelsSets the per-slice labels.
DonutRenders the chart as a donut with a hole sized as a fraction (0..1) of the radius.
Method
PieChart.Labels
public PieChart Labels(params string[] labels)

Sets the per-slice labels.

Method
PieChart.Donut
public PieChart Donut(double holeRatio = 0.6)

Renders the chart as a donut with a hole sized as a fraction (0..1) of the radius.

See also