sparklinekit/unicode
Unicode-block sparklines for terminal output.
import sparklinekit/unicode
pub fn shape() -> String {
unicode.render([1.0, 5.0, 22.0, 13.0, 5.0, 2.0, 7.0])
// -> "▁▂█▅▂▁▃"
}
The eight block characters ▁▂▃▄▅▆▇█ partition the value range
into eight equal levels. Empty input returns "". A single value,
or a series where every value is the same, renders as a flat line
at the middle level (▄).
Values
pub fn render(values: List(Float)) -> String
Render values as a string of Unicode block characters.
[]produces"".[v]produces a single middle-level block (▄).- All-equal inputs produce a string of middle-level blocks.
- Otherwise each value is mapped into one of eight levels by normalising against the observed minimum and maximum.
Use render_ints if your data series is List(Int).
pub fn render_ints(values: List(Int)) -> String
Convenience wrapper around render/1 for List(Int)
inputs. Equivalent to render(list.map(values, int.to_float)).