This document specifies the current behavior and design of the BarChart control as implemented.
For end-user usage and examples, see BarChart.
Title, per-item Label, per-item ValueLabel) without requiring custom drawing.BarChartItems : BindableList<BarChartItem>Title : Visual?TitlePlacement : ChartTitlePlacement (Above / Below)Minimum : double? (optional; defaults to 0 when unset)Maximum : double? (optional; when unset, computed from the max item value)ShowValues : bool (default true)ShowPercentages : bool (default false)BarChartItemBarChartItem is not a Visual. It is a bindable state container (DispatcherObject, IVisualElement) that provides visuals and values used by the owning chart.
Label : Visual? (left column)Value : double (used for normalization and default value text)ValueLabel : Visual? (optional; rendered over the bar near the filled end)BarColor : Color? (optional; per-row color override)BarChart is composed from a Grid with two columns:
Auto width)Star width; stretches to fill remaining space)LabelHost: a ComputedVisual(() => item.Label)Bar: a custom Visual that renders the bar (internally also hosts ComputedVisual(() => item.ValueLabel))Items.Version changes (add/remove operations).Title (when non-null), then measures the internal grid with the remaining height.min/natural width is max(titleWidth, gridWidth)max width is infinite (allows horizontal stretching)titleHeight + gridHeightTitlePlacement is Above, Title is arranged at the top and the grid below it.TitlePlacement is Below, the grid is arranged above and Title at the bottom.Title is null, the grid takes the whole rect.Normalization range is resolved as:
Min = Minimum ?? 0Max = Maximum ?? max(Items[i].Value) over finite valuesMax <= Min, Max is forced to Min + 1 to avoid division by zero.NaN/Infinity values are treated as Min.The normalized progress t is computed as (value - Min) / (Max - Min) and clamped to [0..1].
Each bar row is rendered using BarChartStyle.BarStyle (a ProgressBarStyle):
TrackGlyph for unfilled cells and FillGlyph for filled cells.Variant affects the fill algorithm:
Solid: filled cell count is Round(width * t).Segmented: uses 1/8 block glyphs for the fractional cell.Shaded: uses shaded blocks (░/▓) for track/fill.ShowFrame is enabled (or the variant implies a frame), the bar consumes 1 cell on each side for frame glyphs.There are two ways to display value text:
item.ValueLabel is null and either ShowValues or ShowPercentages is enabled.
t and rendered as NN%."<value> <pct>".item.ValueLabel is non-null.
The default value text is written directly into the CellBuffer and is positioned near the bar’s filled end, clamped to remain within the bar rect.
BarChartStyleBarChart styling is controlled via BarChartStyle:
Padding and RowSpacing are applied to the internal grid.BarStyle : ProgressBarStyle controls glyphs, frame, and track/fill styles for each row.LabelTextStyle (optional) is applied to the label host via TextBlockStyle.ValueTextStyle (optional) is applied to the value host / default value text.
The bar color is chosen per row as:
item.BarColor when setBarChartStyle.DefaultBarColors[index % n] when providedPrimary/Success/Warning/Error rotation)For “solid-like” variants, the chosen color is applied to the background. For other variants, it is applied to the foreground.
BarChart is display-only:
Label and/or ValueLabel.src/XenoAtom.Terminal.UI.Tests/VisualizationTests.cs (bar fill + value placement).samples/ControlsDemo/Demos/BarChartDemo.cs.