Lite, Reusable and customizable line charts for Transformice!
- Reusable
- Lightweight
- Customizable
- Real time!
- Class based
- Easy
- Now you can add multiple Series to the same graph. Check out the documentation for more information!
--insert the library code before the script--then call LineChart.init()LineChart.init()
--then call LineChart(id, x, y, w, h) to create a new chartchart=LineChart(1, 200, 50, 400, 200)
--create a new series to insert into the created chart.series1=Series({1,2,3}, {1,2,3}, "series1")
--add it to the chartchart:addSeries(series1)
--set the labels to display (optional)chart:showLabels()
--display the chartchart:show()
-- this should show a linear chart ...Check the documentation for more
LineChart.init() --initialzingx=range(-5, 5, 0.5)
y=map(x, function(x) returnmath.tan(x) end)
chart=LineChart(1, 200, 50, 400, 200) --instantiationseries1=Series(x, y, "y = tan x", 0xFFCC00) -- creates a new series with yellowish-orange colorchart:addSeries(series1)
chart:setGraphColor(0xFFFFFF, 0xFFFFFF) --sets graph color to whitechart:show() --display the chartLineChart.init() --initializingx=range(-5, 5, 0.5)
y=map(x, function(x) return2*x*xend)
chart=LineChart(1, 200, 50, 400, 200) --instantiationchart:addSeries(Series(x, y, "y = 2x^2", 0xCC89FF)) --adds a new series with color purplechart:setGraphColor(0xFFFFFF, 0xFFFFFF) --sets graph color to whitechart:show() --display the chartLineChart.init()
chart=LineChart(1, 200, 50, 400, 200) --instantiationseries1=Series({0}, {0}, "Real time", 0xDD32CC) --creates a new serieschart:setGraphColor(0xFFFFFF, 0xFFFFFF) --sets graph color to whitechart:addSeries(series1) --adds the new seriescurrX=0--the real time mageic is here!functioneventLoop(l, r)
localx=range(currX, currX+10, 0.1) --creates the x coordinateslocaly=map(x, function(x) returnmath.sin(x) *x*x*math.tanh(x) end ) --maps x values to the specified functionseries1:setData(x, y) --set new data to the serieschart:show() --displays itcurrX=currX+0.5--this cause x coordinate to move by 0.5 every 500msendMulti-Series Graphs!
LineChart.init()
chart=LineChart(1, 200, 50, 400, 200) --creates the chart (container for the series)chart:setGraphColor(0xFFFFFF, 0xFFFFFF) --sets graph color to whitexData=range(0, 20, 1) --creates a list of numbers from 0 to 20series1=Series(xData, xData, "linear") --creates a linear seriesseries2=Series(xData, map(xData, function(x) returnmath.cos(x) end), "y = cos x") --creates a series which maps 'y' values to the 'tan x' valueseries3=Series(xData, map(xData, function(x) returnmath.random(x) end), "random") --creates a series which maps 'y' values randomly to 'x'--add all the serieschart:addSeries(series1)
chart:addSeries(series2)
chart:addSeries(series3)
chart:showLabels() --show the labelschart:show() --show the plots!Thanks goes to these wonderful people (emoji key):
Seniru Pasan Indira 💻📖🎨 | Lautenschlager 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!




