Skip to content

BarChartWidget<T>

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that displays a horizontal bar chart with support for simple, stacked, and grouped modes.

csharp
public sealed record BarChartWidget<T> : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<BarChartWidget<T>>

Inheritance

ObjectHex1bWidgetBarChartWidget<T>

Implements

Properties

Data

Gets the data source for the chart.

Returns: IReadOnlyList<<T>>

csharp
public IReadOnlyList<T>? Data { get; init; }

Maximum

Gets the explicit maximum value for the chart axis. When null, auto-derived from data.

Returns: Nullable<Double>

csharp
public double? Maximum { get; init; }

Minimum

Gets the explicit minimum value for the chart axis. When null, auto-derived from data.

Returns: Nullable<Double>

csharp
public double? Minimum { get; init; }

ValueFormatter

Gets the optional custom formatter for displaying numeric values.

Returns: Func<Double, String>

csharp
public Func<double, string>? ValueFormatter { get; init; }

Methods

FormatValue(Func<double, string>)

Sets a custom formatter for displaying numeric values.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> FormatValue(Func<double, string> formatter)

GroupBy(Func<T, string>)

Sets the group-by selector for pivoting long-form data into series at runtime.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> GroupBy(Func<T, string> groupSelector)

Label(Func<T, string>)

Sets the function that extracts a category label from each data item.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Label(Func<T, string> selector)

Layout(ChartLayout)

Sets the chart display mode.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Layout(ChartLayout layout)

Max(double)

Sets the explicit maximum value for the chart axis.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Max(double max)

Min(double)

Sets the explicit minimum value for the chart axis.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Min(double min)

Range(double, double)

Sets explicit minimum and maximum values for the chart axis.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Range(double min, double max)

Series(string, Func<T, double>, Hex1bColor?)

Adds a named series definition for multi-series mode (flat/wide data).

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Series(string name, Func<T, double> selector, Hex1bColor? color = null)

ShowGridLines(bool)

Sets whether to display horizontal grid lines.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> ShowGridLines(bool show = true)

ShowValues(bool)

Sets whether to display numeric values above each column.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> ShowValues(bool show = true)

Title(string)

Sets the chart title displayed above the chart area.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Title(string title)

Value(Func<T, double>)

Sets the function that extracts the numeric value for single-series mode.

Parameters:

Returns: BarChartWidget`1

csharp
public BarChartWidget<T> Value(Func<T, double> selector)

Remarks

BarChartWidget follows the same generic data-binding pattern as , but renders horizontal bars growing left-to-right.

Examples

Simple chart with ad-hoc data:

csharp
ctx.BarChart([new("Alpha", 8), new("Beta", 5), new("Gamma", 2)])
    .ShowValues()

Released under the MIT License.