etui/widgets/chart
Types
pub type Chart {
Chart(
data: List(Int),
max_val: Int,
fill: ChartFill,
bar_width: Int,
gap: Int,
bar_char: String,
bg: style.Color,
period: Int,
)
}
Constructors
-
Chart( data: List(Int), max_val: Int, fill: ChartFill, bar_width: Int, gap: Int, bar_char: String, bg: style.Color, period: Int, )Arguments
- max_val
-
0 = auto-compute from data.
- bar_width
-
Width in chars of each bar.
- gap
-
Width in chars of gap between bars.
- bar_char
-
Character used for filled cells.
- period
-
Animation period in frames.
pub type ChartFill {
ChartSolid(colors: List(style.Color))
ChartGradient(stops: List(style.Color))
ChartRainbow
ChartAnimatedRainbow
ChartVerticalGradient(stops: List(style.Color))
}
Constructors
-
ChartSolid(colors: List(style.Color))One color per bar; wraps if more bars than colors.
-
ChartGradient(stops: List(style.Color))Gradient applied left-to-right across all bars.
-
ChartRainbowRainbow, one hue per bar.
-
ChartAnimatedRainbowRainbow that rotates hue over time.
-
ChartVerticalGradient(stops: List(style.Color))Gradient from bottom (cold) to top (warm), per cell.
Values
pub fn chart_new(data: List(Int)) -> Chart
A chart with rainbow fill, 2-cell bars, and auto scale.
pub fn render(
buf: buffer.Buffer,
area: geometry.Rect,
c: Chart,
frame: Int,
) -> buffer.Buffer
Render chart into area. frame drives animated fills.
pub fn with_max(c: Chart, max: Int) -> Chart
Pin the scale so charts are comparable across frames. Clamped to ≥ 1.
pub fn with_period(c: Chart, period: Int) -> Chart
Frames an animated rainbow needs to cycle. Clamped to ≥ 1.
pub fn with_style(c: Chart, s: style.Style) -> Chart
Take only the background from a Style.