pub struct LinearGauge { /* private fields */ }Expand description
Horizontal meter with optional threshold bands and labels.
Differs from ProgressBar in three ways:
threshold zones drive the fill colour (success / warning / danger),
faint bands paint behind the fill at zone boundaries, and a thumb
marker pins the current position over the bar. Threshold ticks and
labels above the bar are opt-in via LinearGauge::threshold_label
or LinearGauge::show_zone_labels.
ui.add(
LinearGauge::new(0.42)
.zones(GaugeZones::new(0.6, 0.85))
.show_zone_labels(),
);Implementations§
Source§impl LinearGauge
impl LinearGauge
Sourcepub fn new(fraction: f32) -> Self
pub fn new(fraction: f32) -> Self
Create a meter at fraction (0..=1). NaN and out-of-range values
are clamped.
Sourcepub fn desired_width(self, width: f32) -> Self
pub fn desired_width(self, width: f32) -> Self
Override the bar width. Defaults to ui.available_width().
Sourcepub fn zones(self, zones: GaugeZones) -> Self
pub fn zones(self, zones: GaugeZones) -> Self
Configure threshold zones. Faint bands paint behind the fill at the boundaries and the fill colour auto-derives from the active zone (success / warning / danger).
Sourcepub fn threshold_label(self, position: f32, label: impl Into<String>) -> Self
pub fn threshold_label(self, position: f32, label: impl Into<String>) -> Self
Add a tick + label above the bar at position (0..=1). Stack
multiple calls to register more.
Sourcepub fn show_zone_labels(self) -> Self
pub fn show_zone_labels(self) -> Self
Convenience: add ticks + labels at the configured zone boundaries,
formatting each as a percent. Has no effect unless zones is
also set.
Trait Implementations§
Source§impl Clone for LinearGauge
impl Clone for LinearGauge
Source§fn clone(&self) -> LinearGauge
fn clone(&self) -> LinearGauge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more