etui/widgets/hbar

Types

pub type HBar {
  HBar(
    items: List(HBarItem),
    max_val: Int,
    fill: HBarFill,
    label_width: Int,
    show_value: Bool,
    bar_char: String,
    empty_char: String,
    bg: style.Color,
    period: Int,
  )
}

Constructors

  • HBar(
      items: List(HBarItem),
      max_val: Int,
      fill: HBarFill,
      label_width: Int,
      show_value: Bool,
      bar_char: String,
      empty_char: String,
      bg: style.Color,
      period: Int,
    )

    Arguments

    max_val

    0 = auto-compute max from data.

    label_width

    Width reserved for labels. 0 = auto (longest label).

    show_value

    Whether to append the numeric value after the bar.

pub type HBarFill {
  HBarSolid(colors: List(style.Color))
  HBarGradient(stops: List(style.Color))
  HBarRainbow
  HBarAnimatedRainbow
}

Constructors

  • HBarSolid(colors: List(style.Color))

    Cycle through a list of solid colors, one per bar.

  • HBarGradient(stops: List(style.Color))

    Static left-to-right gradient applied to each bar’s filled cells.

  • HBarRainbow

    Each bar gets a different hue; static rainbow.

  • HBarAnimatedRainbow

    Rainbow that rotates hue over time.

One row of the chart: a label, its numeric value, and a proportional bar.

pub type HBarItem {
  HBarItem(label: String, value: Int)
}

Constructors

  • HBarItem(label: String, value: Int)

Values

pub fn hbar_new(items: List(HBarItem)) -> HBar

A new chart with rainbow fill, auto-computed scale, and values shown.

pub fn item(label: String, value: Int) -> HBarItem

Shorthand for building an HBarItem.

pub fn render(
  buf: buffer.Buffer,
  area: geometry.Rect,
  h: HBar,
  frame: Int,
) -> buffer.Buffer

Render one row per item, top-down, stopping at the area’s bottom edge. frame drives the animated rainbow; pass any constant when not animating.

pub fn with_bg(h: HBar, bg: style.Color) -> HBar

Color behind both the filled and the empty cells.

pub fn with_chars(h: HBar, bar: String, empty: String) -> HBar

Replace the block characters used for the filled and empty cells.

pub fn with_fill(h: HBar, fill: HBarFill) -> HBar

Choose how the filled cells get their color.

pub fn with_label_width(h: HBar, w: Int) -> HBar

Reserve a fixed label column instead of sizing it to the longest label.

pub fn with_max(h: HBar, max: Int) -> HBar

Pin the scale so bars are comparable across frames. Clamped to ≥ 1.

pub fn with_period(h: HBar, period: Int) -> HBar

Frames the animated rainbow needs to cycle through a full hue rotation.

pub fn with_show_value(h: HBar, show: Bool) -> HBar

Show or hide the numeric value after each bar.

pub fn with_style(h: HBar, s: style.Style) -> HBar

Take only the background from a Style.

✨ Search Document