Skip to content

Bars

Renders a value/ceiling ratio as a fixed-width filled/empty block bar — the dashboard’s stand-in for a Gauge widget (symfony/tui has none; see Spark’s docblock for the same widget-gap note).

final class Bars

SourceBars.php
MethodDescription
ratio(float $value, float $ceiling): floatThe clamped [0.0, 1.0] fraction of $ceiling that $value represents.
render(float $value, float $ceiling, int $width = 20, string $fill = '█', string $empty = '░'): stringRenders $value against $ceiling as exactly $width characters: the clamped ratio (see Bars::ratio()) worth of $fill, padded out with $empty.

public static function ratio(float $value, float $ceiling): float

The clamped [0.0, 1.0] fraction of $ceiling that $value represents.

ParameterTypeDescription
$valuefloat
$ceilingfloat

Returns float

public static function render(float $value, float $ceiling, int $width = 20, string $fill = '█', string $empty = '░'): string

Renders $value against $ceiling as exactly $width characters: the clamped ratio (see Bars::ratio()) worth of $fill, padded out with $empty.

Returns the empty string for a non-positive $width. A non-positive ceiling or a non-finite input renders as an all-empty bar rather than failing.

ParameterTypeDescription
$valuefloat
$ceilingfloat
$widthint
$fillstring
$emptystring

Returns string