Skip to content
ConsoleMonster

API Reference

Class

BarChart

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Implements
Modifiers sealed

Horizontal bars with labels and values, sub-cell precise per glyph tier. All bars share one colour unless an item sets its own token or a value crosses BarChart.Warning or BarChart.Critical, so the chart does not shout. Live operations (Key = label): set (Value), add (Value).

Inheritance

Usage

Explore 34 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 16

Constructors

public BarChart(String name = "bars") #

Creates a bar chart.

Parameters

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

Methods

Add 2 overloads
public BarChart Add(RichText label, Double value, ThemeToken? token = null) #
Returns: BarChart

Adds or updates an item with a multicolour label (its plain text is the key).

Parameters

label ConsoleMonster.Text.RichText requiredposition: 0
The rich label.
value System.Double requiredposition: 1
The value.
token ConsoleMonster.Styling.ThemeToken? = null optionalposition: 2
An optional colour token.

Returns

This instance.

public BarChart Add(String label, Double value, ThemeToken? token = null) #
Returns: BarChart

Adds or updates an item.

Parameters

label System.String requiredposition: 0
The label.
value System.Double requiredposition: 1
The value.
token ConsoleMonster.Styling.ThemeToken? = null optionalposition: 2
An optional colour token.

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 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.
public StatusKind? Threshold(Double value) #
Returns: StatusKind?

The status a value reaches against BarChart.Warning and BarChart.Critical, or null below both.

Parameters

value System.Double requiredposition: 0
The value.

Returns

Fail, Warn or null.

Properties

public IReadOnlyList<ChartItem> Items { get; } #

The items.

public Double? Max { get; set; } #

The value of a full bar, or null for the largest item.

public ThemeToken BarToken { get; set; } #

The default bar colour (default ThemeToken.Series1).

public Boolean ShowValues { get; set; } #

Whether values are shown after the bars (default true).

public BarShape Shape { get; set; } #

The bar shape: BarShape.Block (default, solid three-quarter-height bars that keep a gap between rows) or BarShape.Line.

public ColumnFormat ValueColumn { get; set; } #

Layout of the value column on the right (default right-aligned). Its width never shrinks during a session, so the bars keep their scale when a value grows from 9 to 10.

public String? Unit { get; set; } #

A unit appended to values (for example ms).

public Double? Warning { get; set; } #

The value from which a bar is a warning (warning colour), or null. With BarChart.Critical below it, lower values are worse (free space); otherwise higher values are (disk use). An item's own colour wins.

public Double? Critical { get; set; } #

The value from which a bar is critical (fail colour), or null. See BarChart.Warning.

Extension Methods

public static BarChart WithBarToken(BarChart barChart, ThemeToken value) #
Returns: BarChart

Sets BarChart.BarToken: The default bar colour (default ThemeToken.Series1).

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value ConsoleMonster.Styling.ThemeToken requiredposition: 1
The value.

Returns

The same instance.

public static BarChart WithCritical(BarChart barChart, Double? value) #
Returns: BarChart

Sets BarChart.Critical: The value from which a bar is critical (fail colour), or null. See BarChart.Warning.

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value System.Double? requiredposition: 1
The value.

Returns

The same instance.

public static BarChart WithMax(BarChart barChart, Double? value) #
Returns: BarChart

Sets BarChart.Max: The value of a full bar, or null for the largest item.

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value System.Double? requiredposition: 1
The value.

Returns

The same instance.

public static BarChart WithShape(BarChart barChart, BarShape value) #
Returns: BarChart

Sets BarChart.Shape: The bar shape: BarShape.Block (default, solid three-quarter-height bars that keep a gap between rows) or BarShape.Line.

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value ConsoleMonster.Widgets.BarShape requiredposition: 1
The value.

Returns

The same instance.

public static BarChart WithShowValues(BarChart barChart, Boolean value = true) #
Returns: BarChart

Sets BarChart.ShowValues: Whether values are shown after the bars (default true).

Parameters

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

Returns

The same instance.

public static BarChart WithUnit(BarChart barChart, String? value) #
Returns: BarChart

Sets BarChart.Unit: A unit appended to values (for example ms).

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value System.String? requiredposition: 1
The value.

Returns

The same instance.

WithValueColumn 2 overloads
public static BarChart WithValueColumn(BarChart barChart, ColumnFormat value) #
Returns: BarChart

Sets BarChart.ValueColumn: Layout of the value column on the right (default right-aligned). Its width never shrinks during a session, so the bars keep their scale when a value grows from 9 to 10.

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value ConsoleMonster.Layout.ColumnFormat requiredposition: 1
The value.

Returns

The same instance.

public static BarChart WithValueColumn(BarChart barChart, Action<ColumnFormat> configure) #
Returns: BarChart

Configures BarChart.ValueColumn in place: Layout of the value column on the right (default right-aligned). Its width never shrinks during a session, so the bars keep their scale when a value grows from 9 to 10.

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> requiredposition: 1
Configures the value.

Returns

The same instance.

public static BarChart WithWarning(BarChart barChart, Double? value) #
Returns: BarChart

Sets BarChart.Warning: The value from which a bar is a warning (warning colour), or null. With BarChart.Critical below it, lower values are worse (free space); otherwise higher values are (disk use). An item's own colour wins.

Parameters

barChart ConsoleMonster.Widgets.BarChart requiredposition: 0
The instance.
value System.Double? requiredposition: 1
The value.

Returns

The same instance.