Skip to content

Graph : VisualElement

This is the base class for all graph elements. It is a point based graph.

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)
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

PropertyTypeDefaultDescription
minValuenumber0The minimum value of the graph
maxValuenumber100The maximum value of the graph
seriestable{}The series of the graph

Functions

MethodReturnsDescription
Graph:addPointGraphAdds a point to a series
Graph:addSeriesGraphAdds a series to the graph
Graph:changeSeriesVisibilityGraphChanges the visibility of a series
Graph:clearGraphClears all points from a series
Graph:focusSeriesGraphFocuses a series
Graph:getSeriestable?Gets a series from the graph
Graph:removeSeriesGraphRemoves a series from the graph
Graph:setSeriesPointCountGraphSets the point count of a series

Protected Functions

MethodReturnsDescription
Graph:initGraphInitializes the Graph instance
Graph:render-Renders the graph

Graph:addPoint(name, value)

Parameters

  • name string The name of the series
  • value number The value of the point

Returns

  • Graph self The graph instance

Graph:addSeries(name, symbol, bgCol, fgCol, pointCount)

Parameters

  • name string The name of the series
  • symbol string The symbol of the series
  • bgCol number The background color of the series
  • fgCol number The foreground color of the series
  • pointCount number The number of points in the series

Returns

  • Graph self The graph instance

Graph:changeSeriesVisibility(name, visible)

Parameters

  • name string The name of the series
  • visible boolean Whether the series should be visible

Returns

  • Graph self The graph instance

Graph:clear(name?)

Clears all points from a series

Parameters

  • name (optional) string The name of the series

Returns

  • Graph self The graph instance

Graph:focusSeries(name)

Parameters

  • name string The name of the series

Returns

  • Graph self The graph instance

Graph:getSeries(name)

Parameters

  • name string The name of the series

Returns

  • table? series The series

Graph:removeSeries(name)

Parameters

  • name string The name of the series

Returns

  • Graph self The graph instance

Graph:setSeriesPointCount(name, count)

Parameters

  • name string The name of the series
  • count number The number of points in the series

Returns

  • Graph self The graph instance

Released under the MIT License.