Range series

A range series draws each point from a low value to a high value, instead of from zero to a single value. A RangeLineSeries draws two curves, one through the high values and one through the low values, and fills the band between them. A RangeColumnSeries draws a vertical bar from the low value to the high value, and a RangeRowSeries draws a horizontal one. All three take the same data, so this article covers them together.

This article highlights the most used features. Every property is listed in the API explorer: RangeLineSeries, RangeColumnSeries and RangeRowSeries.

Range values

The RangeValue class, in the LiveChartsCore.Defaults namespace, holds the two ends of each point in its Low and High properties. The X coordinate of a point is its index in Values, like a plain number in a line or column series.

Series = new ISeries[]
{
    new RangeLineSeries<RangeValue>
    {
        Values = new RangeValue[]
        {
            new(low: 8, high: 16), // mark
            new(low: 9, high: 17), // mark
            new(low: 11, high: 20) // mark
        }
    }
};

RangeValue notifies when Low or High change, and the chart updates the point. When either of them is null, the point is empty: a range line breaks there, and a range bar is not drawn.

To plot your own type, set a Mapping that puts the high value in the PrimaryValue of the coordinate and the low value in the TertiaryValue, which are the slots RangeValue uses:

new RangeLineSeries<Reading>
{
    Values = readings,
    // PrimaryValue = high, SecondaryValue = X, TertiaryValue = low
    Mapping = (reading, index) =>
        new Coordinate(reading.Max, index, reading.Min, 0, 0, 0, Error.Empty) // mark
}

When the axis limits are not set, the value axis grows to fit both the low and the high values.

Range line

Stroke draws both curves and Fill paints the band between them. GeometryFill, GeometryStroke and GeometrySize style the point drawn at both ends of every value. Set Fill to null to draw only the two curves, or set Stroke to null to draw only the band. When the paints are not set, the default theme styles the series like a line series: a 4 pixel stroke, the same color with transparency for the band, and 12 pixel points.

This sample plots the monthly low and high temperatures. The X axis uses Labels for the months, and the Y axis a Labeler that adds the unit.

Range band: Monthly lows and highs as a band.

The hover area of each value covers the whole band at that X, from the low point to the high point, so the tooltip opens anywhere inside the band, not only over the points.

Range columns

A RangeColumnSeries draws each bar from Low to High on the Y axis. Low does not need to be the smaller value, the bar always covers the space between both.

A waterfall chart uses that: each bar goes from the previous total (Low) to the new total (High), so a step that lowers the total has a Low greater than its High. The first and last bars start at zero to show the totals.

The X axis names each step with Labels, and YToolTipLabelFormatter shows the change of each step in the tooltip, from Low to High:

Cash flow: Each step adds to the total or takes from it.

Range rows

A RangeRowSeries draws each bar from Low to High on the X axis. A Gantt chart uses it with dates: each task stores the Ticks of its start and end dates, a DateTimeAxis on the X axis turns the ticks back into dates, and the Y axis names the tasks with Labels.

The tooltip formatter turns both ends of the bar back into dates, so the first task reads "from Jun 01 to Jun 06":

Project plan: Tasks as ranges on a date time axis.

Tooltips

By default, the tooltip shows each point as low → high, both formatted by the value axis: its Labels when it has them, otherwise its Labeler. The value axis is the Y axis for range lines and columns, and the X axis for range rows, so in the Gantt chart above the tooltip already shows dates.

YToolTipLabelFormatter replaces that text. In the formatter, point.Coordinate.TertiaryValue is the low value and point.Coordinate.PrimaryValue is the high value. The range line sample above adds the unit to both values, and the waterfall sample shows the change of each step:

new RangeColumnSeries<RangeValue>
{
    Values = steps,
    YToolTipLabelFormatter = point => // mark
    {
        var from = point.Coordinate.TertiaryValue; // mark
        var to = point.Coordinate.PrimaryValue; // mark
        var delta = to - from;
        var sign = delta >= 0 ? "+" : "−";
        return $"{from:N0} → {to:N0} ({sign}{Math.Abs(delta):N0})";
    }
}

The Gantt sample turns both values back into dates with new DateTime((long)point.Coordinate.TertiaryValue).

On a range row, YToolTipLabelFormatter still sets this text, even though the values are on the X axis. The title of the tooltip is the label of the Y axis for that row, and XToolTipLabelFormatter replaces it.

Shared with line and column series

Range series take most properties of the series they are based on, so these articles apply to them too:

  • The range line has the paints, LineSmoothness, GeometrySize, EnableNullSplitting and data labels of the line series. LineSmoothness applies to both curves.
  • Range columns and rows have the paints, Rx, Ry, MaxBarWidth, Padding and IgnoresBarPosition of the column and row series. The theme styles them like the other bars.

Range series cannot be stacked. When a point is added, it grows from the middle of its range to both ends.

Data, names and updates

  • Values takes any IEnumerable<T>. Use an ObservableCollection<T> and the chart animates every added, removed or replaced value, see automatic updates.
  • To plot your own types, see mappers.
  • Name is shown in tooltips and legends. When it is not set, the tooltip shows the values without a series name.
  • ZIndex sets which series draws on top, and IsVisible shows or hides the series.
~/cartesianChart/rangeseries.md