ColumnChartWidget<T>
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that displays a vertical column chart with support for simple, stacked, and grouped modes.
public sealed record ColumnChartWidget<T> : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<ColumnChartWidget<T>>Inheritance
Object → Hex1bWidget → ColumnChartWidget<T>
Implements
Properties
Data
Gets the data source for the chart.
Returns: IReadOnlyList<<T>>
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>
public double? Maximum { get; init; }Minimum
Gets the explicit minimum value for the chart axis. When null, auto-derived from data.
Returns: Nullable<Double>
public double? Minimum { get; init; }ValueFormatter
Gets the optional custom formatter for displaying numeric values.
Returns: Func<Double, String>
public Func<double, string>? ValueFormatter { get; init; }Methods
FormatValue(Func<double, string>)
Sets a custom formatter for displaying numeric values.
Parameters:
formatter(Func<Double, String>):
Returns: ColumnChartWidget`1
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:
groupSelector(Func<<T>, String>):
Returns: ColumnChartWidget`1
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:
selector(Func<<T>, String>):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> Label(Func<T, string> selector)Layout(ChartLayout)
Sets the chart display mode.
Parameters:
layout(ChartLayout):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> Layout(ChartLayout layout)Max(double)
Sets the explicit maximum value for the chart axis.
Parameters:
max(Double):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> Max(double max)Min(double)
Sets the explicit minimum value for the chart axis.
Parameters:
min(Double):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> Min(double min)Range(double, double)
Sets explicit minimum and maximum values for the chart axis.
Parameters:
Returns: ColumnChartWidget`1
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:
name(String): The display name for this series.selector(Func<<T>, Double>): Function to extract the numeric value from each data item.color(Nullable<Hex1bColor>): Optional color override for this series.
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> Series(string name, Func<T, double> selector, Hex1bColor? color = null)ShowGridLines(bool)
Sets whether to display horizontal grid lines.
Parameters:
show(Boolean):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> ShowGridLines(bool show = true)ShowValues(bool)
Sets whether to display numeric values above each column.
Parameters:
show(Boolean):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> ShowValues(bool show = true)Title(string)
Sets the chart title displayed above the chart area.
Parameters:
title(String):
Returns: ColumnChartWidget`1
public ColumnChartWidget<T> Title(string title)Value(Func<T, double>)
Sets the function that extracts the numeric value for single-series mode.
Parameters:
selector(Func<<T>, Double>):
Returns: ColumnChartWidget`1
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:
ctx.ColumnChart([new("Jan", 42), new("Feb", 58), new("Mar", 35)])
.ShowValues()Multi-series grouped chart:
ctx.ColumnChart(sales)
.Label(s => s.Month)
.Series("Electronics", s => s.Electronics, Colors.Blue)
.Series("Clothing", s => s.Clothing, Colors.Red)
.Mode(ChartLayout.Grouped)