Skip to content

ColumnChartWidget<T>

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

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

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

Inheritance

ObjectHex1bWidgetColumnChartWidget<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: ColumnChartWidget`1

csharp
public ColumnChartWidget<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: ColumnChartWidget`1

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

Label(Func<T, string>)

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

Parameters:

Returns: ColumnChartWidget`1

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

Layout(ChartLayout)

Sets the chart display mode.

Parameters:

Returns: ColumnChartWidget`1

csharp
public ColumnChartWidget<T> Layout(ChartLayout layout)

Max(double)

Sets the explicit maximum value for the chart axis.

Parameters:

Returns: ColumnChartWidget`1

csharp
public ColumnChartWidget<T> Max(double max)

Min(double)

Sets the explicit minimum value for the chart axis.

Parameters:

Returns: ColumnChartWidget`1

csharp
public ColumnChartWidget<T> Min(double min)

Range(double, double)

Sets explicit minimum and maximum values for the chart axis.

Parameters:

Returns: ColumnChartWidget`1

csharp
public ColumnChartWidget<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: ColumnChartWidget`1

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

ShowGridLines(bool)

Sets whether to display horizontal grid lines.

Parameters:

Returns: ColumnChartWidget`1

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

ShowValues(bool)

Sets whether to display numeric values above each column.

Parameters:

Returns: ColumnChartWidget`1

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

Title(string)

Sets the chart title displayed above the chart area.

Parameters:

Returns: ColumnChartWidget`1

csharp
public ColumnChartWidget<T> Title(string title)

Value(Func<T, double>)

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

Parameters:

Returns: ColumnChartWidget`1

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

Remarks

ColumnChartWidget follows the generic data-binding pattern: provide your data and selector functions to extract labels and values. For ad-hoc data, use the convenience type with pre-wired selectors.

Three data-binding approaches are supported: .Value() — Single series (simple mode).Series() — Multiple named series from flat data (grouped/stacked).GroupBy() — Pivot long-form data into series at runtime

Examples

Simple chart with ad-hoc data:

csharp
ctx.ColumnChart([new("Jan", 42), new("Feb", 58), new("Mar", 35)])
    .ShowValues()

Multi-series grouped chart:

csharp
ctx.ColumnChart(sales)
    .Label(s => s.Month)
    .Series("Electronics", s => s.Electronics, Colors.Blue)
    .Series("Clothing", s => s.Clothing, Colors.Red)
    .Mode(ChartLayout.Grouped)

Released under the MIT License.