Graph
This is the base class for all graph elements. It is a point based graph.
Extends: VisualElement
Usage
lua
local graph = main:addGraph()
:addSeries("input", " ", colors.green, colors.green, 10)
:addSeries("output", " ", colors.red, colors.red, 10)
basalt.schedule(function()
while true do
graph:addPoint("input", math.random(1,100))
graph:addPoint("output", math.random(1,100))
sleep(2)
end
end)Properties
| Property | Type | Default | Description |
|---|---|---|---|
| minValue | number | 0 | The minimum value of the graph |
| maxValue | number | 100 | The maximum value of the graph |
| series | table | {} | The series of the graph |
Functions
| Method | Returns | Description |
|---|---|---|
| Graph:addSeries | Graph | Adds a series to the graph |
| Graph:removeSeries | Graph | Removes a series from the graph |
| Graph:getSeries | series | Gets a series from the graph |
| Graph:changeSeriesVisibility | Graph | Changes the visibility of a series |
| Graph:addPoint | Graph | Adds a point to a series |
| Graph:focusSeries | Graph | Focuses a series |
| Graph:setSeriesPointCount | Graph | Sets the point count of a series |
| Graph:clear | Graph | Clears all points from a series |
Graph:addSeries(name, symbol, bgCol, fgCol, pointCount)
Parameters
namestringThe name of the seriessymbolstringThe symbol of the seriesbgColnumberThe background color of the seriesfgColnumberThe foreground color of the seriespointCountnumberThe number of points in the series
Returns
GraphselfThe graph instance
Graph:removeSeries(name)
Parameters
namestringThe name of the series
Returns
GraphselfThe graph instance
Graph:getSeries(name)
Parameters
namestringThe name of the series
Returns
seriesTheseries
Graph:changeSeriesVisibility(name, visible)
Parameters
namestringThe name of the seriesvisiblebooleanWhether the series should be visible
Returns
GraphselfThe graph instance
Graph:addPoint(name, value)
Parameters
namestringThe name of the seriesvaluenumberThe value of the point
Returns
GraphselfThe graph instance
Graph:focusSeries(name)
Parameters
namestringThe name of the series
Returns
GraphselfThe graph instance
Graph:setSeriesPointCount(name, count)
Parameters
namestringThe name of the seriescountnumberThe number of points in the series
Returns
GraphselfThe graph instance
Graph:clear(name?)
Clears all points from a series
Parameters
name(optional)stringThe name of the series
Returns
GraphselfThe graph instance