Hi All,
We have 120 middle schoolers who were unable to use our app today because we are struggling with real-time graphing and the display.newLine function.
We were scheduled to implement a robot graphing activity in class today but had to postpone because we can’t get the newLine function to plot values properly.
Essentially we place a newLine object on the scene and append coordinates to it as the data streams from the robots.
Here is the relevant code:
priGraph = display.newLine(graphGroup, xposition, yposition, xposition, yposition)
function handleStream (data)
– data is a string “<1 or 2 which bot to graph> <x value> <y value>”
–EXAMPLE: “1 4.77399999997579 0.497735107421931”
– we have a function that splits this into a table
local table = {“1”, “4.77399999997579”, “0.497735107421931”}
priGraph:append(tonumber(table[2]), tonumber(table[3]))
end
We have been unable to get this to plot successfully with the tonumber() function. We print out the string value and the resulting number value and they match as expected. But when we append them to the Line object we get different results.
We need to take the above string and plot a new point on the graph to extend the line, basically real time graphing. We are doing this at a rate of about 10 times per second. Any help you can give would be much appreciated. We really need to use this app with 120 students tomorrow.
Thanks,
–Scot
Scot M. Sutherland
Ph.D. Candidate, Learning and Mind Sciences
UC Davis School of Education