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
ShowLabel(bool)
Sets whether to show the label.
public BarGraphBuilder ShowLabel(bool show = true)
Parameters
showbool
Returns
ShowValue(bool)
Sets whether to show the value.
public BarGraphBuilder ShowValue(bool show = true)
Parameters
showbool
Returns
Visible(bool)
Sets the visibility.
public BarGraphBuilder Visible(bool visible)
Parameters
visiblebool
Returns
WithAlignment(HorizontalAlignment)
Sets the horizontal alignment.
public BarGraphBuilder WithAlignment(HorizontalAlignment alignment)
Parameters
alignmentHorizontalAlignment
Returns
WithBackgroundColor(Color)
Sets the background color.
public BarGraphBuilder WithBackgroundColor(Color color)
Parameters
colorColor
Returns
WithBarWidth(int)
Sets the bar width in characters.
public BarGraphBuilder WithBarWidth(int width)
Parameters
widthint
Returns
WithColors(Color, Color)
Sets both filled and unfilled colors.
public BarGraphBuilder WithColors(Color filled, Color unfilled)
Parameters
filledColorunfilledColor
Returns
WithFilledColor(Color)
Sets the filled color.
public BarGraphBuilder WithFilledColor(Color color)
Parameters
colorColor
Returns
WithForegroundColor(Color)
Sets the foreground color for labels and values.
public BarGraphBuilder WithForegroundColor(Color color)
Parameters
colorColor
Returns
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
thresholdsColorThreshold[]
Returns
WithLabel(string)
Sets the label text.
public BarGraphBuilder WithLabel(string label)
Parameters
labelstring
Returns
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
widthint
Returns
WithMargin(Margin)
Sets the margin.
public BarGraphBuilder WithMargin(Margin margin)
Parameters
marginMargin
Returns
WithMargin(int, int, int, int)
Sets the margin.
public BarGraphBuilder WithMargin(int left, int top, int right, int bottom)
Parameters
Returns
WithMaxValue(double)
Sets the maximum value (100% fill).
public BarGraphBuilder WithMaxValue(double maxValue)
Parameters
maxValuedouble
Returns
WithName(string)
Sets the control name.
public BarGraphBuilder WithName(string name)
Parameters
namestring
Returns
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
gradientColorGradient
Returns
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
colorsColor[]
Returns
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
gradientSpecstring
Returns
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
WithUnfilledColor(Color)
Sets the unfilled color.
public BarGraphBuilder WithUnfilledColor(Color color)
Parameters
colorColor
Returns
WithValue(double)
Sets the current value.
public BarGraphBuilder WithValue(double value)
Parameters
valuedouble
Returns
WithValueFormat(string)
Sets the value format string.
public BarGraphBuilder WithValueFormat(string format)
Parameters
formatstring
Returns
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment.
public BarGraphBuilder WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignment
Returns
WithWidth(int)
Sets the width.
public BarGraphBuilder WithWidth(int width)
Parameters
widthint