Skip to content
ConsoleMonster
Class

LineChart

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

A line or scatter chart. With colour, the canvas uses braille (2x4 dots per cell) on Full, half blocks on Basic and characters on Ascii. Without colour, ASCII marks identify each series in the plot and legend. A y axis with min/max labels sits on the left, a legend below when there are several series or a semantic status to identify. Live operation: add (Key = series, Value).

Inheritance

Usage

Explore 31 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 14

Accepted by parameters 17

Constructors

public LineChart(string widgetId = "chart") #

Creates a chart.

Parameters

widgetId string = "chart" optional
The live name (default chart).

Methods

public LineChart Add(string series, double value) #

Appends a value to a series (created when missing).

Parameters

series string required
The series name.
value double required
The value.

Returns

LineChart This instance.
public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
public SparklineHandle Handle(ILiveDispatcher dispatcher) #

Returns a handle that appends values through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

SparklineHandle The handle.
public override Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public override void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Properties

public IReadOnlyList<ChartSeries> Series { get; } #

The series.

public int Height { get; set; } #

Rows for the plot including the x axis (default 8).

public bool Scatter { get; set; } #

Whether points are joined by lines (default) or drawn as a scatter.

public int Capacity { get; set; } #

How many values each series keeps (default 512).

public double? Minimum { get; set; } #

A fixed minimum for the y axis, or null (0 when all values are positive).

public double? Maximum { get; set; } #

A fixed maximum for the y axis, or null.

public string? Unit { get; set; } #

A unit appended to axis labels.

Extension Methods

public static LineChart Capacity(LineChart lineChart, int value) #

Sets LineChart.Capacity: How many values each series keeps (default 512).

Parameters

lineChart ConsoleMonster.Widgets.LineChart required
The instance.
value int required
The value.

Returns

LineChart The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.LineChart { Capacity = value };    Ui.LineChart().Capacity(value);
public static LineChart Height(LineChart lineChart, int value) #

Sets LineChart.Height: Rows for the plot including the x axis (default 8).

Parameters

lineChart ConsoleMonster.Widgets.LineChart required
The instance.
value int required
The value.

Returns

LineChart The same instance.

Examples

// C# initializer or property                                       // C# fluent
new global::ConsoleMonster.Widgets.LineChart { Height = value };    Ui.LineChart().Height(value);
public static LineChart Maximum(LineChart lineChart, double? value) #

Sets LineChart.Maximum: A fixed maximum for the y axis, or null.

Parameters

lineChart ConsoleMonster.Widgets.LineChart required
The instance.
value double? required
The value.

Returns

LineChart The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.LineChart { Maximum = value };    Ui.LineChart().Maximum(value);
public static LineChart Minimum(LineChart lineChart, double? value) #

Sets LineChart.Minimum: A fixed minimum for the y axis, or null (0 when all values are positive).

Parameters

lineChart ConsoleMonster.Widgets.LineChart required
The instance.
value double? required
The value.

Returns

LineChart The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.LineChart { Minimum = value };    Ui.LineChart().Minimum(value);
public static LineChart Scatter(LineChart lineChart, bool value = true) #

Sets LineChart.Scatter: Whether points are joined by lines (default) or drawn as a scatter.

Parameters

lineChart ConsoleMonster.Widgets.LineChart required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LineChart The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.LineChart { Scatter = value };    Ui.LineChart().Scatter(value);
Series 2 overloads
public static ChartSeries Series(LineChart chart, RichText key, ThemeToken? role = null) #

Adds a series with a multicolour legend name (its plain text is the key), or returns the existing one.

Parameters

chart ConsoleMonster.Widgets.LineChart required
The chart.
key ConsoleMonster.Text.RichText required
The rich name.
role ConsoleMonster.Styling.ThemeToken? = null optional
The colour role, or null for the next series colour.

Returns

ChartSeries The series.
public static ChartSeries Series(LineChart chart, string key, ThemeToken? role = null) #

Adds a series, or returns the existing one with that name.

Parameters

chart ConsoleMonster.Widgets.LineChart required
The chart.
key string required
The name.
role ConsoleMonster.Styling.ThemeToken? = null optional
The colour role, or null for the next series colour.

Returns

ChartSeries The series.
public static LineChart Unit(LineChart lineChart, string? value) #

Sets LineChart.Unit: A unit appended to axis labels.

Parameters

lineChart ConsoleMonster.Widgets.LineChart required
The instance.
value string? required
The value.

Returns

LineChart The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.LineChart { Unit = value };    Ui.LineChart().Unit(value);