Graph
extends Element
Multi-series graph rendered with terminal-cell symbols and colors.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| minValue | number | 0 | Lower bound of the value axis |
| maxValue | number | 100 | Upper bound of the value axis |
| background | number|false | colors.black | Background color (false = transparent) |
| width | number | 20 | Width in terminal cells |
| height | number | 8 | Height in terminal cells |
Methods
Graph:setup()
Initializes per-instance state and input handlers.
Graph:addSeries(name, opts)
opts: symbol (default " "), fg, bg, pointCount (default width), visible (default true) Adds a named graph series.
name (
string) Series nameopts (
table, optional) symbol/fg/bg/pointCount/visible optionsreturns (
self)
Graph:getSeries(name)
Returns a named series definition.
name (
string) Series namereturns series (
table|nil)
Graph:removeSeries(name)
Removes a named series.
name (
string) Series namereturns (
self)
Graph:setSeriesVisible(name, visible)
Changes visibility of one series.
name (
string) Series namevisible (
boolean) Visibilityreturns (
self)
Graph:addPoint(name, value)
Appends a point; the series scrolls once pointCount is reached.
name (
string) Series namevalue (
number) Point valuereturns (
self)
Graph:clear(name)
Clears one series or every series when name is nil.
name (
string, optional) Series namereturns (
self)
Graph:render(buf)
Renders the element into the buffer.
- buf (
Render) The render buffer (local coordinates, pre-clipped)