BarChartWidget<T>
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that displays a horizontal bar chart with support for simple, stacked, and grouped modes.
public sealed record BarChartWidget<T> : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<BarChartWidget<T>>Inheritance
Object → Hex1bWidget → BarChartWidget<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: BarChartWidget`1
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:
groupSelector(Func<<T>, String>):
Returns: BarChartWidget`1
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:
selector(Func<<T>, String>):
Returns: BarChartWidget`1
public BarChartWidget<T> Label(Func<T, string> selector)Layout(ChartLayout)
Sets the chart display mode.
Parameters:
layout(ChartLayout):
Returns: BarChartWidget`1
public BarChartWidget<T> Layout(ChartLayout layout)Max(double)
Sets the explicit maximum value for the chart axis.
Parameters:
max(Double):
Returns: BarChartWidget`1
public BarChartWidget<T> Max(double max)Min(double)
Sets the explicit minimum value for the chart axis.
Parameters:
min(Double):
Returns: BarChartWidget`1
public BarChartWidget<T> Min(double min)Range(double, double)
Sets explicit minimum and maximum values for the chart axis.
Parameters:
Returns: BarChartWidget`1
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:
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: BarChartWidget`1
public BarChartWidget<T> Series(string name, Func<T, double> selector, Hex1bColor? color = null)ShowGridLines(bool)
Sets whether to display horizontal grid lines.
Parameters:
show(Boolean):
Returns: BarChartWidget`1
public BarChartWidget<T> ShowGridLines(bool show = true)ShowValues(bool)
Sets whether to display numeric values above each column.
Parameters:
show(Boolean):
Returns: BarChartWidget`1
public BarChartWidget<T> ShowValues(bool show = true)Title(string)
Sets the chart title displayed above the chart area.
Parameters:
title(String):
Returns: BarChartWidget`1
public BarChartWidget<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: BarChartWidget`1
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:
ctx.BarChart([new("Alpha", 8), new("Beta", 5), new("Gamma", 2)])
.ShowValues()