Skip to content
ConsoleMonster
Class

Sparkline

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

A compact trend of recent values: ▁▂▄▆█▇▅ on Full, shades on Basic, an ASCII ramp on Ascii. With Sparkline.Height above 1 it becomes a small area chart. The newest value is on the right and can be shown as a number. Live operation: add (Value).

Inheritance

Usage

Explore 44 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 22

Accepted by parameters 22

Constructors

public Sparkline(string widgetId = "sparkline") #

Creates a sparkline.

Parameters

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

Methods

public Sparkline Add(double value) #

Appends a value.

Parameters

value double required
The value.

Returns

Sparkline 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<double> Values { get; } #

The values, oldest first.

public string? Title { get; set; } #

A caption shown on the left (markup), or null.

public IList<string> Labels { get; } #

Optional point labels in value order; labelled trends show an axis and their peak.

public int Height { get; set; } #

Rows (default 1).

public int Capacity { get; set; } #

How many values are kept (default 1024).

public ThemeToken Role { get; set; } #

The colour role (default ThemeToken.Accent).

public bool ShowLatest { get; set; } #

Whether the latest value is shown on the right (default true).

public string? Unit { get; set; } #

A unit appended to the latest value.

public double? Maximum { get; set; } #

A fixed maximum, or null to scale to the visible values.

Extension Methods

public static Sparkline Capacity(Sparkline sparkline, int value) #

Sets Sparkline.Capacity: How many values are kept (default 1024).

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value int required
The value.

Returns

Sparkline The same instance.

Examples

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

Sets Sparkline.Height: Rows (default 1).

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value int required
The value.

Returns

Sparkline The same instance.

Examples

// C# initializer or property                                       // C# fluent
new global::ConsoleMonster.Widgets.Sparkline { Height = value };    Ui.Sparkline().Height(value);
public static Sparkline Label(Sparkline sparkline, string item) #

Adds an item to Sparkline.Labels: Optional point labels in value order; labelled trends show an axis and their peak.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
item string required
The item.

Returns

Sparkline The same instance.
public static Sparkline Labels(Sparkline sparkline, IEnumerable<string> items) #

Adds items to Sparkline.Labels: Optional point labels in value order; labelled trends show an axis and their peak.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
items System.Collections.Generic.IEnumerable<string> required
The items, in order.

Returns

Sparkline The same instance.
public static Sparkline Maximum(Sparkline sparkline, double? value) #

Sets Sparkline.Maximum: A fixed maximum, or null to scale to the visible values.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value double? required
The value.

Returns

Sparkline The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.Sparkline { Maximum = value };    Ui.Sparkline().Maximum(value);
public static Sparkline Role(Sparkline sparkline, ThemeToken value) #

Sets Sparkline.Role: The colour role (default ThemeToken.Accent).

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value ConsoleMonster.Styling.ThemeToken required
The value.

Returns

Sparkline The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.Sparkline { Role = value };    Ui.Sparkline().Role(value);
public static Sparkline ShowLatest(Sparkline sparkline, bool value = true) #

Sets Sparkline.ShowLatest: Whether the latest value is shown on the right (default true).

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value bool = true optional
The value; true when omitted.

Returns

Sparkline The same instance.

Examples

// C# initializer or property                                           // C# fluent
new global::ConsoleMonster.Widgets.Sparkline { ShowLatest = value };    Ui.Sparkline().ShowLatest(value);
public static Sparkline Title(Sparkline sparkline, string? value) #

Sets Sparkline.Title: A caption shown on the left (markup), or null.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value string? required
The value.

Returns

Sparkline The same instance.

Examples

// C# initializer or property                                      // C# fluent
new global::ConsoleMonster.Widgets.Sparkline { Title = value };    Ui.Sparkline().Title(value);
public static Sparkline Unit(Sparkline sparkline, string? value) #

Sets Sparkline.Unit: A unit appended to the latest value.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The instance.
value string? required
The value.

Returns

Sparkline The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.Sparkline { Unit = value };    Ui.Sparkline().Unit(value);
public static Sparkline Values(Sparkline sparkline, IEnumerable<double> values) #

Appends several values.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline required
The sparkline.
values System.Collections.Generic.IEnumerable<double> required
The values.

Returns

Sparkline The same sparkline.