2.9 KiB
2.9 KiB
Graph : VisualElement
This is the base class for all graph elements. It is a point based graph.
Usage
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:addPoint | Graph | Adds a point to a series |
| Graph:addSeries | - | Adds a series to the graph |
| Graph:changeSeriesVisibility | Graph | Changes the visibility of a series |
| Graph:clear | Graph | Clears all points from a series |
| Graph:focusSeries | Graph | Focuses a series |
| Graph:getSeries | table? | Gets a series from the graph |
| Graph:removeSeries | Graph | Removes a series from the graph |
| Graph:setSeriesPointCount | Graph | Sets the point count of a series |
Protected Functions
| Method | Returns | Description |
|---|---|---|
| Graph:init | Graph | Initializes the Graph instance |
| Graph:render | - | Renders the graph |
Graph:addPoint(name, value)
Parameters
namestringThe name of the seriesvaluenumberThe value of the point
Returns
GraphselfThe graph instance
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
Graph:changeSeriesVisibility(name, visible)
Parameters
namestringThe name of the seriesvisiblebooleanWhether the series should be visible
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
Graph:focusSeries(name)
Parameters
namestringThe name of the series
Returns
GraphselfThe graph instance
Graph:getSeries(name)
Parameters
namestringThe name of the series
Returns
table?seriesThe series
Graph:removeSeries(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