Table of Contents

Class BarGraphBuilder

Namespace
SharpConsoleUI.Builders
Assembly
SharpConsoleUI.dll

Fluent builder for creating BarGraphControl instances.

public class BarGraphBuilder
Inheritance
BarGraphBuilder
Inherited Members

Constructors

BarGraphBuilder()

Initializes a new instance of the BarGraphBuilder class.

public BarGraphBuilder()

Methods

Build()

Builds the BarGraphControl instance.

public BarGraphControl Build()

Returns

BarGraphControl

ShowLabel(bool)

Sets whether to show the label.

public BarGraphBuilder ShowLabel(bool show = true)

Parameters

show bool

Returns

BarGraphBuilder

ShowValue(bool)

Sets whether to show the value.

public BarGraphBuilder ShowValue(bool show = true)

Parameters

show bool

Returns

BarGraphBuilder

Visible(bool)

Sets the visibility.

public BarGraphBuilder Visible(bool visible)

Parameters

visible bool

Returns

BarGraphBuilder

WithAlignment(HorizontalAlignment)

Sets the horizontal alignment.

public BarGraphBuilder WithAlignment(HorizontalAlignment alignment)

Parameters

alignment HorizontalAlignment

Returns

BarGraphBuilder

WithBackgroundColor(Color)

Sets the background color.

public BarGraphBuilder WithBackgroundColor(Color color)

Parameters

color Color

Returns

BarGraphBuilder

WithBarWidth(int)

Sets the bar width in characters.

public BarGraphBuilder WithBarWidth(int width)

Parameters

width int

Returns

BarGraphBuilder

WithColors(Color, Color)

Sets both filled and unfilled colors.

public BarGraphBuilder WithColors(Color filled, Color unfilled)

Parameters

filled Color
unfilled Color

Returns

BarGraphBuilder

WithFilledColor(Color)

Sets the filled color.

public BarGraphBuilder WithFilledColor(Color color)

Parameters

color Color

Returns

BarGraphBuilder

WithForegroundColor(Color)

Sets the foreground color for labels and values.

public BarGraphBuilder WithForegroundColor(Color color)

Parameters

color Color

Returns

BarGraphBuilder

WithGradient(params ColorThreshold[])

Sets color thresholds for gradient effect. Colors apply when bar percentage meets or exceeds the threshold.

public BarGraphBuilder WithGradient(params ColorThreshold[] thresholds)

Parameters

thresholds ColorThreshold[]

Returns

BarGraphBuilder

WithLabel(string)

Sets the label text.

public BarGraphBuilder WithLabel(string label)

Parameters

label string

Returns

BarGraphBuilder

WithLabelWidth(int)

Sets the fixed width for the label column in characters. When set, all labels are padded or truncated to this width, ensuring bars align vertically. Use this when displaying multiple bar graphs to align them.

public BarGraphBuilder WithLabelWidth(int width)

Parameters

width int

Returns

BarGraphBuilder

WithMargin(Margin)

Sets the margin.

public BarGraphBuilder WithMargin(Margin margin)

Parameters

margin Margin

Returns

BarGraphBuilder

WithMargin(int, int, int, int)

Sets the margin.

public BarGraphBuilder WithMargin(int left, int top, int right, int bottom)

Parameters

left int
top int
right int
bottom int

Returns

BarGraphBuilder

WithMaxValue(double)

Sets the maximum value (100% fill).

public BarGraphBuilder WithMaxValue(double maxValue)

Parameters

maxValue double

Returns

BarGraphBuilder

WithName(string)

Sets the control name.

public BarGraphBuilder WithName(string name)

Parameters

name string

Returns

BarGraphBuilder

WithSmoothGradient(ColorGradient)

Sets the smooth color gradient for horizontal color interpolation. When set, the bar smoothly transitions from start to end color based on fill percentage. Note: Threshold-based gradients (WithGradient) take precedence over smooth gradients.

public BarGraphBuilder WithSmoothGradient(ColorGradient gradient)

Parameters

gradient ColorGradient

Returns

BarGraphBuilder

WithSmoothGradient(params Color[])

Sets the smooth color gradient from an array of colors. Note: Threshold-based gradients (WithGradient) take precedence over smooth gradients.

public BarGraphBuilder WithSmoothGradient(params Color[] colors)

Parameters

colors Color[]

Returns

BarGraphBuilder

WithSmoothGradient(string)

Sets the smooth color gradient from a gradient specification string. Supports predefined gradients (cool, warm, spectrum, grayscale), arrow notation (blue→cyan→green), and :reverse suffix. Note: Threshold-based gradients (WithGradient) take precedence over smooth gradients.

public BarGraphBuilder WithSmoothGradient(string gradientSpec)

Parameters

gradientSpec string

Returns

BarGraphBuilder

WithStandardGradient()

Sets a standard green/yellow/red gradient at 0%, 50%, and 80% thresholds. Green for 0-49%, Yellow for 50-79%, Red for 80%+.

public BarGraphBuilder WithStandardGradient()

Returns

BarGraphBuilder

WithUnfilledColor(Color)

Sets the unfilled color.

public BarGraphBuilder WithUnfilledColor(Color color)

Parameters

color Color

Returns

BarGraphBuilder

WithValue(double)

Sets the current value.

public BarGraphBuilder WithValue(double value)

Parameters

value double

Returns

BarGraphBuilder

WithValueFormat(string)

Sets the value format string.

public BarGraphBuilder WithValueFormat(string format)

Parameters

format string

Returns

BarGraphBuilder

WithVerticalAlignment(VerticalAlignment)

Sets the vertical alignment.

public BarGraphBuilder WithVerticalAlignment(VerticalAlignment alignment)

Parameters

alignment VerticalAlignment

Returns

BarGraphBuilder

WithWidth(int)

Sets the width.

public BarGraphBuilder WithWidth(int width)

Parameters

width int

Returns

BarGraphBuilder