LuaGuiElement for graphs like production/electricity
Posted: Sun Sep 13, 2020 10:26 pm
I'd like to be able to present a multi-series line graph in a mod gui, like the built-in graphs for production and electricity. I imagine this would involve a new LuaGuiElement type, and a new method for updating the graph data.
The vertical axis would automatically scale and label based on the data, like the existing graphs.
Some way to provide horizontal axis labels would be needed, but I suspect the internal representation of the graph would lend itself to some specific lua representation that I don't want to guess at.
Code: Select all
data = {
foo={5,5,5,7,5,6,6,6,8},
bar={1,2,3,1,2,3,1,2,3},
}
graph = someframe.add{type="graph"}
graph.update_data(data)
... [one or many ticks later] ...
graph.update_data(new_data)
Some way to provide horizontal axis labels would be needed, but I suspect the internal representation of the graph would lend itself to some specific lua representation that I don't want to guess at.