This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
tattyseal's profile picture

GraphAPI

Started by tattyseal, 08 August 2015 - 02:44 PM
tattyseal #1
Posted 08 August 2015 - 04:44 PM
GraphAPI by tattyseal


What is it?

GraphAPI provides an easy way to render progress bars and graphs.


How do I use it?

This code example shows everything that can be done at present and what it does:

--This will load the API
os.loadAPI("graphAPI") --Change graphAPI to what you have save it as
--This adds a graph. name, x, y, width, height, color, value, maxValue
graphAPI.addGraph("graph", 1, 1, 20, 3, colors.red, 0, 100)
--This function updates the value
graphAPI.updateValue("graph", 20)
]--This function updates the maximum value
graphAPI.updateMaxValue("graph", 200)
--This function will set if the graph is drawn horizontally. Default: false
graphAPI.setHorizontal("graph", true)
--This function will set if the graph draws its progress 0% - 100%. Default: true
graphAPI.setShowText("graph", true)
--This function will set if the the graph draws its outline. Default: true
graphAPI.setShowOutline("graph", true)
--This function will set the color of the graph.
graphAPI.updateColor("graph", colors.lime)
--This will set what monitor to draw on. NOTE: This will redirect to the monitor specified before drawing
graphAPI.setMonitor(peripheral.wrap("top"))
--This is required to draw all graphs.
graphAPI.draw()


How do I get it?



Screenshot

Edited on 08 August 2015 - 02:45 PM
Yarillo #2
Posted 22 March 2016 - 07:33 PM
Litterally copied the example code and got
Error line 35 attempt to compare number and nil

This obviously hasn't been tested enough
Edited on 22 March 2016 - 06:38 PM
LMongoose #3
Posted 18 January 2018 - 01:53 AM
Hi, i added a outline color in graph and modified this in draw method:

if drawOutline == true then
paintutils.drawBox(x, y, endX, endY, outlineColor)
term.setBackgroundColor(color)
end