package matrix
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/matrix.charts/Matrix_charts/Sparkline/index.html
Module Matrix_charts.SparklineSource
Compact sparkline charts. See Sparkline.
Compact sparkline charts.
Sparklines render recent data points in a fixed-width buffer using bar glyphs or Braille dots. The rendering adapts to the available grid dimensions.
The type for sparklines. A sparkline holds a circular buffer of recent values with fixed capacity. Old values are automatically evicted when the buffer is full.
The type for sparkline rendering styles.
`Bars: vertical bars using block glyphs (▁▂▃▄▅▆▇█) with fractional heights.`Braille: connected line segments using 2×4 Braille dot grids per cell.
Constructors
val create :
?style:Ansi.Style.t ->
?auto_max:bool ->
?max_value:float ->
capacity:int ->
unit ->
tcreate ~capacity () is a sparkline buffer.
styleis the rendering style. Defaults toAnsi.Style.default.auto_max, whentrue(the default), updatesmax_valuedynamically when larger values are pushed.max_valueis the initial maximum for scaling. Values exceeding it are clipped unlessauto_maxistrue. Defaults to1.0ifNoneor negative.capacityis the buffer size. Clamped to>= 1.
Negative values are clamped to 0.0 on push.
Mutating
push t v appends v to the buffer, evicting the oldest value if the buffer is full. Negative v is clamped to 0.0. If auto_max is true and v exceeds max_value, max_value is updated.
set_max t m sets the scaling maximum. If m <= 0 it is set to 1.0.
Rendering
val draw :
t ->
kind:kind ->
?columns_only:bool ->
?x:int ->
?y:int ->
Grid.t ->
width:int ->
height:int ->
unitdraw t ~kind grid ~width ~height renders the sparkline to grid. Only the most recent width values are shown, right-aligned, scaled by max_value.
columns_only, whentrue, skips the background fill. Defaults tofalse.xandyare grid offsets. Default0.widthandheightare clamped to>= 1.
val draw_values :
?style:Ansi.Style.t ->
kind:kind ->
?x:int ->
?y:int ->
float list ->
Grid.t ->
width:int ->
height:int ->
unitdraw_values ~kind vs grid ~width ~height renders vs directly without persistent state. Creates a temporary sparkline with capacity equal to width, pushes all vs, and draws.
styledefaults toAnsi.Style.default.xandyare grid offsets. Default0.