Skip to content
ConsoleMonster
Class

Histogram

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

Vertical bars for a distribution: values are counted into buckets defined by edges, bars grow with eighth-block precision, the largest count labels the top and bucket labels sit under the bars. Live operation: add (Value).

Inheritance

Usage

Explore 25 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 13

Accepted by parameters 12

Constructors

public Histogram(IReadOnlyList<double> edges, string widgetId = "histogram") #

Creates a histogram.

Parameters

edges System.Collections.Generic.IReadOnlyList<double> required
Ascending bucket edges; values below the first edge go to the first bucket, values at or above the last edge to the last.
widgetId string = "histogram" optional
The live name (default histogram).

Methods

public Histogram Add(double value) #

Counts a value.

Parameters

value double required
The value.

Returns

Histogram 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 adds 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<int> Counts { get; } #

Bucket counts.

public IList<string> Labels { get; } #

Optional bucket-edge labels, in edge order; omitted edges retain their numeric labels.

public int Height { get; set; } #

Rows for the bars (default 6).

public ThemeToken Role { get; set; } #

The bar colour role (default ThemeToken.Series1).

public string? Unit { get; set; } #

A unit for bucket labels (for example s).

public Func<double, string>? EdgeFormat { get; set; } #
Fluent("EdgeFormatBy")

Formats the bucket edge labels (for example milliseconds as 250ms and 1s), or null for the compact number and Histogram.Unit.

Extension Methods

public static Histogram EdgeFormatBy(Histogram histogram, Func<double, string>? value) #

Sets Histogram.EdgeFormat: Formats the bucket edge labels (for example milliseconds as 250ms and 1s), or null for the compact number and Histogram.Unit.

Parameters

histogram ConsoleMonster.Widgets.Histogram required
The instance.
value System.Func<double, string>? required
The callback.

Returns

Histogram The same instance.

Examples

// C# initializer or property    // C# fluent
histogram.EdgeFormat = value;    histogram.EdgeFormatBy(value);
public static Histogram Height(Histogram histogram, int value) #

Sets Histogram.Height: Rows for the bars (default 6).

Parameters

histogram ConsoleMonster.Widgets.Histogram required
The instance.
value int required
The value.

Returns

Histogram The same instance.

Examples

// C# initializer or property    // C# fluent
histogram.Height = value;        histogram.Height(value);
public static Histogram Label(Histogram histogram, string item) #

Adds an item to Histogram.Labels: Optional bucket-edge labels, in edge order; omitted edges retain their numeric labels.

Parameters

histogram ConsoleMonster.Widgets.Histogram required
The instance.
item string required
The item.

Returns

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

Adds items to Histogram.Labels: Optional bucket-edge labels, in edge order; omitted edges retain their numeric labels.

Parameters

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

Returns

Histogram The same instance.
public static Histogram Role(Histogram histogram, ThemeToken value) #

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

Parameters

histogram ConsoleMonster.Widgets.Histogram required
The instance.
value ConsoleMonster.Styling.ThemeToken required
The value.

Returns

Histogram The same instance.

Examples

// C# initializer or property    // C# fluent
histogram.Role = value;          histogram.Role(value);
public static Histogram Unit(Histogram histogram, string? value) #

Sets Histogram.Unit: A unit for bucket labels (for example s).

Parameters

histogram ConsoleMonster.Widgets.Histogram required
The instance.
value string? required
The value.

Returns

Histogram The same instance.

Examples

// C# initializer or property    // C# fluent
histogram.Unit = value;          histogram.Unit(value);