StackedBar
ConsoleMonster.Widgets
One bar split into proportional segments with a legend (label, value, share). Problem segments take their status colour; healthy and unclassified segments stay neutral. Adjacent indistinguishable fills have a one-cell gap when space allows. An explicit role selects another colour. Without colour, segments use distinct fill glyphs so the split stays readable. Live operations (Key = segment): set (Value), add (Value).
Inheritance
- LiveWidget
- StackedBar
Usage
Explore 36 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 18
- Method Ui.StackedBar
- Extension method StackedBar.ColorPassing
- Extension method StackedBar.CountColumn
- Extension method StackedBar.LabelColumn
- Extension method StackedBar.MaxLegendColumns
- Extension method StackedBar.PercentColumn
- Extension method StackedBar.ShowLegend
- Extension method StackedBar.ShowSwatches
- Extension method StackedBar.ShowTotal
- Method StackedBar.Add
- Method StackedBarFluent.ColorPassing
- Method StackedBarFluent.CountColumn
- Method StackedBarFluent.LabelColumn
- Method StackedBarFluent.MaxLegendColumns
- Method StackedBarFluent.PercentColumn
- Method StackedBarFluent.ShowLegend
- Method StackedBarFluent.ShowSwatches
- Method StackedBarFluent.ShowTotal
Accepted by parameters 18
- Method ContentBuilder.StackedBar
- Method ContentBuilder.StackedBar
- Extension method StackedBar.ColorPassing
- Extension method StackedBar.CountColumn
- Extension method StackedBar.LabelColumn
- Extension method StackedBar.MaxLegendColumns
- Extension method StackedBar.PercentColumn
- Extension method StackedBar.ShowLegend
- Extension method StackedBar.ShowSwatches
- Extension method StackedBar.ShowTotal
- Method StackedBarFluent.ColorPassing
- Method StackedBarFluent.CountColumn
- Method StackedBarFluent.LabelColumn
- Method StackedBarFluent.MaxLegendColumns
- Method StackedBarFluent.PercentColumn
- Method StackedBarFluent.ShowLegend
- Method StackedBarFluent.ShowSwatches
- Method StackedBarFluent.ShowTotal
Constructors
public StackedBar(string widgetId = "stacked") #Creates a stacked bar.
Parameters
- widgetId string = "stacked"
- The live name (default stacked).
Methods
public StackedBar Add(RichText label, double value, ThemeToken? role = null, string? key = null) #Adds or updates a segment with a multicolour legend label (its plain text is the key).
Parameters
- label ConsoleMonster.Text.RichText
- The rich label.
- value double
- The value.
- role ConsoleMonster.Styling.ThemeToken? = null
- The colour role, or null for the next series colour.
- key string? = null
- Stable item identity, or null to use the label.
public StackedBar Add(string label, double value, ThemeToken? role = null, string? key = null) #Adds or updates a segment.
Parameters
- label string
- The label.
- value double
- The value.
- role ConsoleMonster.Styling.ThemeToken? = null
- The colour role, or null for the next series colour.
- key string? = null
- Stable item identity, or null to use the label.
public override void Apply(LiveEvent liveEvent) #Applies an event to the widget's state.
Parameters
- liveEvent ConsoleMonster.Live.LiveEvent
- The event.
public string GetFillMarker(int segmentIndex, RenderContext context) #Gets the exact unpadded fill glyph used for a segment in the supplied rendering context. Custom legends can use this marker at every colour depth to identify the corresponding bar fill. The built-in bar and legend use this same mapping.
Parameters
- segmentIndex int
- Zero-based index in StackedBar.Segments, including zero-valued segments.
- context ConsoleMonster.Canvas.RenderContext
- The rendering context, including its glyph set and color capability.
Returns
string The segment's fill glyph, with no surrounding spaces.Exceptions
ArgumentOutOfRangeExceptionโ The index does not identify a segment.ArgumentNullExceptionโ The context is null.
public override Size Measure(Constraints constraints, RenderContext context) #Returns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public override void Render(Region region, RenderContext context) #Renders into a region. The region may be smaller or larger than the measured size.
Parameters
- region ConsoleMonster.Canvas.Region
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Inherited Methods
public virtual string? Describe(LiveEvent liveEvent) #Parameters
- liveEvent LiveEvent
Returns
string?Properties
public bool ShowLegend { get; set; } #Whether the legend line is shown (default true).
public int MaxLegendColumns { get; set; } #The most legend columns per row, or 0 (default) to fit as many as the width allows. Entries fill rows left to right and every row shares one grid fitted to each column, so labels, counts and percentages line up.
public bool ShowTotal { get; set; } #Whether the total is written after the bar (default true). Turn it off where a title or caption already gives it.
public bool ShowSwatches { get; set; } #Whether each legend entry starts with a swatch of its bar fill (default true). Without swatches, an entry with a status shows only its coloured status symbol, so every row has one marker; entries without a status, and every entry when there is no colour, keep their swatch.
public bool ColorPassing { get; set; } #Whether a passing share keeps the pass colour (default false: it is drawn neutral so the problem shares stand out). Turn it on where passing items are coloured elsewhere on the same screen, such as in a cell map.
public ColumnFormat LabelColumn { get; set; } #Layout of the legend label column (default left-aligned).
public ColumnFormat CountColumn { get; set; } #Layout of the legend count column (default right-aligned; reserves the digits of the overall total).
public ColumnFormat PercentColumn { get; set; } #Layout of the legend percentage column (default right-aligned, four cells).
Inherited Properties
Extension Methods
public static StackedBar ColorPassing(StackedBar stackedBar, bool value = true) #Sets StackedBar.ColorPassing: Whether a passing share keeps the pass colour (default false: it is drawn neutral so the problem shares stand out). Turn it on where passing items are coloured elsewhere on the same screen, such as in a cell map.
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { ColorPassing = value }; Ui.StackedBar().ColorPassing(value);public static StackedBar CountColumn(StackedBar stackedBar, ColumnFormat value) #Sets StackedBar.CountColumn: Layout of the legend count column (default right-aligned; reserves the digits of the overall total).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value ConsoleMonster.Layout.ColumnFormat
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { CountColumn = value }; Ui.StackedBar().CountColumn(value);public static StackedBar CountColumn(StackedBar stackedBar, Action<ColumnFormat> configure) #Configures StackedBar.CountColumn in place: Layout of the legend count column (default right-aligned; reserves the digits of the overall total).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- configure System.Action<ConsoleMonster.Layout.ColumnFormat>
- Configures the value.
public static StackedBar LabelColumn(StackedBar stackedBar, ColumnFormat value) #Sets StackedBar.LabelColumn: Layout of the legend label column (default left-aligned).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value ConsoleMonster.Layout.ColumnFormat
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { LabelColumn = value }; Ui.StackedBar().LabelColumn(value);public static StackedBar LabelColumn(StackedBar stackedBar, Action<ColumnFormat> configure) #Configures StackedBar.LabelColumn in place: Layout of the legend label column (default left-aligned).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- configure System.Action<ConsoleMonster.Layout.ColumnFormat>
- Configures the value.
public static StackedBar MaxLegendColumns(StackedBar stackedBar, int value) #Sets StackedBar.MaxLegendColumns: The most legend columns per row, or 0 (default) to fit as many as the width allows. Entries fill rows left to right and every row shares one grid fitted to each column, so labels, counts and percentages line up.
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value int
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { MaxLegendColumns = value }; Ui.StackedBar().MaxLegendColumns(value);public static StackedBar PercentColumn(StackedBar stackedBar, ColumnFormat value) #Sets StackedBar.PercentColumn: Layout of the legend percentage column (default right-aligned, four cells).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value ConsoleMonster.Layout.ColumnFormat
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { PercentColumn = value }; Ui.StackedBar().PercentColumn(value);public static StackedBar PercentColumn(StackedBar stackedBar, Action<ColumnFormat> configure) #Configures StackedBar.PercentColumn in place: Layout of the legend percentage column (default right-aligned, four cells).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- configure System.Action<ConsoleMonster.Layout.ColumnFormat>
- Configures the value.
public static StackedBar ShowLegend(StackedBar stackedBar, bool value = true) #Sets StackedBar.ShowLegend: Whether the legend line is shown (default true).
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { ShowLegend = value }; Ui.StackedBar().ShowLegend(value);public static StackedBar ShowSwatches(StackedBar stackedBar, bool value = true) #Sets StackedBar.ShowSwatches: Whether each legend entry starts with a swatch of its bar fill (default true). Without swatches, an entry with a status shows only its coloured status symbol, so every row has one marker; entries without a status, and every entry when there is no colour, keep their swatch.
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { ShowSwatches = value }; Ui.StackedBar().ShowSwatches(value);public static StackedBar ShowTotal(StackedBar stackedBar, bool value = true) #Sets StackedBar.ShowTotal: Whether the total is written after the bar (default true). Turn it off where a title or caption already gives it.
Parameters
- stackedBar ConsoleMonster.Widgets.StackedBar
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.StackedBar { ShowTotal = value }; Ui.StackedBar().ShowTotal(value);