Gauge #
PhpTui\Tui\Extension\Core\Widget\GaugeWidget
A widget to display a progress bar.
A GaugeWidget
renders a bar filled according to the value given to the specified ratio. The bar width and height are defined by the area it is in.
The associated label is always centered horizontally and vertically. If not set with
The label is the percentage of the bar filled by default but can be overridden.
Example #
Show code
<?php
declare(strict_types=1);
use PhpTui\Tui\Color\AnsiColor;
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Widget\GaugeWidget;
use PhpTui\Tui\Style\Style;
require 'vendor/autoload.php';
$display = DisplayBuilder::default()->build();
$display->draw(
GaugeWidget::default()->ratio(0.25)->style(Style::default()->fg(AnsiColor::Yellow))
);
Parameters #
Configure the widget using the builder methods named as follows:
Name | Type | Description |
---|---|---|
ratio | float | Ratio from 0.0 to 1.0 |
label | PhpTui\Tui\Text\Span|null | Optional label, will default to percentage (0.00%) |
style | PhpTui\Tui\Style\Style | Style of the gauge |