Skip to content
ConsoleMonster
Class

BarChart

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
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 role 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 78 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 38

Constructors

public BarChart(string widgetId = "bars") #

Creates a bar chart.

Parameters

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

Methods

Add 2 overloads
public BarChart Add(RichText label, double value, ThemeToken? role = null, string? key = null) #

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

Parameters

label ConsoleMonster.Text.RichText required
The rich label.
value double required
The value.
role ConsoleMonster.Styling.ThemeToken? = null optional
An optional colour role.
key string? = null optional
Stable item identity, or null to use the label.

Returns

BarChart This instance.
public BarChart Add(string label, double value, ThemeToken? role = null, string? key = null) #

Adds or updates an item.

Parameters

label string required
The label.
value double required
The value.
role ConsoleMonster.Styling.ThemeToken? = null optional
An optional colour role.
key string? = null optional
Stable item identity, or null to use the label.

Returns

BarChart 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 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 BarChart Missing(string label, string? text = null, StatusKind? status = null, string? key = null) #

Adds an item without a measurement, preserving its status and explanatory text.

Parameters

label string required
The plain text label.
text string? = null optional
The missing-measurement explanation, or null for the chart default.
status ConsoleMonster.Styling.StatusKind? = null optional
An optional status.
key string? = null optional
Stable identity, or null to use the label.

Returns

BarChart This chart.
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.
public StatusKind? Threshold(double value) #

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

Parameters

value double required
The value.

Returns

StatusKind? Fail, Warn or null.

Properties

public IReadOnlyList<ChartItem> Items { get; } #

The items.

public double? Maximum { get; set; } #

The value of a full bar, or null for the largest item. Non-finite maxima use the largest finite item; a negative maximum is treated as zero, so signed bars always include their zero baseline.

public ThemeToken Role { get; set; } #

The default bar colour (default ThemeToken.Series1).

public bool ShowValues { get; set; } #

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

public bool Signed { get; set; } #

Draws negative values to the left of a shared zero baseline; default false preserves zero-based bars.

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 numeric width never shrinks during a session, so the bars keep their scale when a value grows from 9 to 10. Missing explanations use only the current frame's available space and do not reserve width after a measurement arrives.

public string? Unit { get; set; } #

A unit appended to values (for example ms).

public string? AxisLabel { get; set; } #

A shared plain text label below the bars, for example elapsed time since an observation.

public string? MissingText { get; set; } #

The plain text shown for non-finite values; null retains the tier-appropriate dash.

public bool SpanMissingValues { get; set; } #

Let a missing measurement's explanation span the bar and value columns.

public bool ShowTrack { get; set; } #

Draw the unused portion of each bar as a muted track.

public int? BarWidth { get; set; } #

Optional maximum bar width in cells; null uses all available room.

public ICellPresenter? ValuePresenter { get; set; } #

Optional presenter for measured values, such as compact durations.

public string? LabelHeader { get; set; } #

Optional label-column heading; any heading enables a segmented table header.

public string? BarHeader { get; set; } #

Optional bar-column heading.

public string? ValueHeader { get; set; } #

Optional value-column heading.

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 AxisLabel(BarChart barChart, string? value) #

Sets BarChart.AxisLabel: A shared plain text label below the bars, for example elapsed time since an observation.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value string? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.BarChart { AxisLabel = value };    Ui.BarChart().AxisLabel(value);
public static BarChart BarHeader(BarChart barChart, string? value) #

Sets BarChart.BarHeader: Optional bar-column heading.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value string? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.BarChart { BarHeader = value };    Ui.BarChart().BarHeader(value);
public static BarChart BarWidth(BarChart barChart, int? value) #

Sets BarChart.BarWidth: Optional maximum bar width in cells; null uses all available room.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value int? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.BarChart { BarWidth = value };    Ui.BarChart().BarWidth(value);
public static BarChart Critical(BarChart barChart, double? value) #

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

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value double? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.BarChart { Critical = value };    Ui.BarChart().Critical(value);
public static BarChart LabelHeader(BarChart barChart, string? value) #

Sets BarChart.LabelHeader: Optional label-column heading; any heading enables a segmented table header.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value string? required
The value.

Returns

BarChart The same instance.

Examples

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

Sets BarChart.Maximum: The value of a full bar, or null for the largest item. Non-finite maxima use the largest finite item; a negative maximum is treated as zero, so signed bars always include their zero baseline.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value double? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                       // C# fluent
new global::ConsoleMonster.Widgets.BarChart { Maximum = value };    Ui.BarChart().Maximum(value);
public static BarChart MissingText(BarChart barChart, string? value) #

Sets BarChart.MissingText: The plain text shown for non-finite values; null retains the tier-appropriate dash.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value string? required
The value.

Returns

BarChart The same instance.

Examples

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

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

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value ConsoleMonster.Styling.ThemeToken required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                    // C# fluent
new global::ConsoleMonster.Widgets.BarChart { Role = value };    Ui.BarChart().Role(value);
public static BarChart Shape(BarChart barChart, BarShape value) #

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 required
The instance.
value ConsoleMonster.Widgets.BarShape required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.BarChart { Shape = value };    Ui.BarChart().Shape(value);
public static BarChart ShowTrack(BarChart barChart, bool value = true) #

Sets BarChart.ShowTrack: Draw the unused portion of each bar as a muted track.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value bool = true optional
The value; true when omitted.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.BarChart { ShowTrack = value };    Ui.BarChart().ShowTrack(value);
public static BarChart ShowValues(BarChart barChart, bool value = true) #

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

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value bool = true optional
The value; true when omitted.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                          // C# fluent
new global::ConsoleMonster.Widgets.BarChart { ShowValues = value };    Ui.BarChart().ShowValues(value);
public static BarChart Signed(BarChart barChart, bool value = true) #

Sets BarChart.Signed: Draws negative values to the left of a shared zero baseline; default false preserves zero-based bars.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value bool = true optional
The value; true when omitted.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                      // C# fluent
new global::ConsoleMonster.Widgets.BarChart { Signed = value };    Ui.BarChart().Signed(value);
public static BarChart SpanMissingValues(BarChart barChart, bool value = true) #

Sets BarChart.SpanMissingValues: Let a missing measurement's explanation span the bar and value columns.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value bool = true optional
The value; true when omitted.

Returns

BarChart The same instance.

Examples

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

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

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value string? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                    // C# fluent
new global::ConsoleMonster.Widgets.BarChart { Unit = value };    Ui.BarChart().Unit(value);
ValueColumn 2 overloads
public static BarChart ValueColumn(BarChart barChart, ColumnFormat value) #

Sets BarChart.ValueColumn: Layout of the value column on the right (default right-aligned). Its numeric width never shrinks during a session, so the bars keep their scale when a value grows from 9 to 10. Missing explanations use only the current frame's available space and do not reserve width after a measurement arrives.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value ConsoleMonster.Layout.ColumnFormat required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                           // C# fluent
new global::ConsoleMonster.Widgets.BarChart { ValueColumn = value };    Ui.BarChart().ValueColumn(value);
public static BarChart ValueColumn(BarChart barChart, Action<ColumnFormat> configure) #

Configures BarChart.ValueColumn in place: Layout of the value column on the right (default right-aligned). Its numeric width never shrinks during a session, so the bars keep their scale when a value grows from 9 to 10. Missing explanations use only the current frame's available space and do not reserve width after a measurement arrives.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> required
Configures the value.

Returns

BarChart The same instance.
public static BarChart ValueHeader(BarChart barChart, string? value) #

Sets BarChart.ValueHeader: Optional value-column heading.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value string? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                           // C# fluent
new global::ConsoleMonster.Widgets.BarChart { ValueHeader = value };    Ui.BarChart().ValueHeader(value);
public static BarChart ValuePresenter(BarChart barChart, ICellPresenter? value) #

Sets BarChart.ValuePresenter: Optional presenter for measured values, such as compact durations.

Parameters

barChart ConsoleMonster.Widgets.BarChart required
The instance.
value ConsoleMonster.Presenters.ICellPresenter? required
The value.

Returns

BarChart The same instance.

Examples

// C# initializer or property                                              // C# fluent
new global::ConsoleMonster.Widgets.BarChart { ValuePresenter = value };    Ui.BarChart().ValuePresenter(value);
public static BarChart Warning(BarChart barChart, double? value) #

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 required
The instance.
value double? required
The value.

Returns

BarChart The same instance.

Examples

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