Skip to content
ConsoleMonster

API Reference

Class

Sparkline

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Implements
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 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.

Accepted by parameters 14

Constructors

public Sparkline(String name = "sparkline") #

Creates a sparkline.

Parameters

name System.String = "sparkline" optionalposition: 0
The live name (default sparkline).

Methods

public Sparkline Add(Double value) #
Returns: Sparkline

Appends a value.

Parameters

value System.Double requiredposition: 0
The value.

Returns

This instance.

public Sparkline AddRange(IEnumerable<Double> values) #
Returns: Sparkline

Appends several values.

Parameters

values System.Collections.Generic.IEnumerable<System.Double> requiredposition: 0
The values.

Returns

This instance.

public override Void Apply(LiveEvent liveEvent) #
Returns: Void

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent requiredposition: 0
The event.
public SparklineHandle Handle(ILiveDispatcher dispatcher) #
Returns: SparklineHandle

Returns a handle that appends values through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher requiredposition: 0
The dispatcher.

Returns

The handle.

public override Size Measure(Constraints constraints, RenderContext context) #
Returns: Size

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints requiredposition: 0
The space offered.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Returns

The desired size, never larger than the constraints.

public override Void Render(Region region, RenderContext context) #
Returns: Void

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

Parameters

region ConsoleMonster.Canvas.Region requiredposition: 0
The target region.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Properties

public IReadOnlyList<Double> Values { get; } #

The values, oldest first.

public String? Label { get; set; } #

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

public Int32 Height { get; set; } #

Rows (default 1).

public Int32 Capacity { get; set; } #

How many values are kept (default 1024).

public ThemeToken Token { get; set; } #

The colour token (default ThemeToken.Accent).

public Boolean 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? Max { get; set; } #

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

Extension Methods

public static Sparkline WithCapacity(Sparkline sparkline, Int32 value) #
Returns: Sparkline

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

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

public static Sparkline WithHeight(Sparkline sparkline, Int32 value) #
Returns: Sparkline

Sets Sparkline.Height: Rows (default 1).

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

public static Sparkline WithLabel(Sparkline sparkline, String? value) #
Returns: Sparkline

Sets Sparkline.Label: A label shown on the left (markup), or null.

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value System.String? requiredposition: 1
The value.

Returns

The same instance.

public static Sparkline WithMax(Sparkline sparkline, Double? value) #
Returns: Sparkline

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

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value System.Double? requiredposition: 1
The value.

Returns

The same instance.

public static Sparkline WithShowLatest(Sparkline sparkline, Boolean value = true) #
Returns: Sparkline

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

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value System.Boolean = true optionalposition: 1
The value (default true).

Returns

The same instance.

public static Sparkline WithToken(Sparkline sparkline, ThemeToken value) #
Returns: Sparkline

Sets Sparkline.Token: The colour token (default ThemeToken.Accent).

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value ConsoleMonster.Styling.ThemeToken requiredposition: 1
The value.

Returns

The same instance.

public static Sparkline WithUnit(Sparkline sparkline, String? value) #
Returns: Sparkline

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

Parameters

sparkline ConsoleMonster.Widgets.Sparkline requiredposition: 0
The instance.
value System.String? requiredposition: 1
The value.

Returns

The same instance.