Skip to content

Graph

extends Element

Multi-series graph rendered with terminal-cell symbols and colors.

Properties

PropertyTypeDefaultDescription
minValuenumber0Lower bound of the value axis
maxValuenumber100Upper bound of the value axis
backgroundnumber|falsecolors.blackBackground color (false = transparent)
widthnumber20Width in terminal cells
heightnumber8Height 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 name

  • opts (table, optional) symbol/fg/bg/pointCount/visible options

  • returns (self)

Graph:getSeries(name)

Returns a named series definition.

  • name (string) Series name

  • returns series (table|nil)

Graph:removeSeries(name)

Removes a named series.

  • name (string) Series name

  • returns (self)

Graph:setSeriesVisible(name, visible)

Changes visibility of one series.

  • name (string) Series name

  • visible (boolean) Visibility

  • returns (self)

Graph:addPoint(name, value)

Appends a point; the series scrolls once pointCount is reached.

  • name (string) Series name

  • value (number) Point value

  • returns (self)

Graph:clear(name)

Clears one series or every series when name is nil.

  • name (string, optional) Series name

  • returns (self)

Graph:render(buf)

Renders the element into the buffer.

  • buf (Render) The render buffer (local coordinates, pre-clipped)

Last updated:

Released under the MIT License.