Hello all
I've been using this fantastic library from @klaus to plot live data.
Everything goes well if i add all the variables i need to track at the start, calling "LineChart.AddLine2" many times.
But, i now need to allow the user to add and remove tracked variables mid-run, while the graph is going...
i call drawchart on a timer, making it 'advance'
And the user can add tracked variables mid-run, like this:
But it crashes on Drawchart at the next tick, with an OutOfBounds exception (bounds being the number of lines i added at the start)...
is this because the chart, once drawn with N variables, can't handle new ones that lack the same history (past values) ?
is there any way to solve it without having to add 'fake points' to the new line?
...And how can i even do that? i see LineChart.Points, but i'm not sure what's the object laying underneath it, or how to manipulate it to add a 'fake history'?
Sorry for the many questions, and thanks for your time!
I've been using this fantastic library from @klaus to plot live data.
Everything goes well if i add all the variables i need to track at the start, calling "LineChart.AddLine2" many times.
But, i now need to allow the user to add and remove tracked variables mid-run, while the graph is going...
i call drawchart on a timer, making it 'advance'
B4X:
Public Sub Ticker_tick
Dim valuesToPlot(TrackedParameters.Size) As Double
'gets the value for each tracked variable into an array of doubles
For i=0 To TrackedParameters.Size-1
Dim p As Parameter = TrackedParameters.Get(i)
valuesToPlot(i)=p.VALUE
Next
LineChart.AddLineMultiplePoints(ElapsedTime,valuesToPlot, True)
LineChart.DrawChart
end sub
And the user can add tracked variables mid-run, like this:
B4X:
Public Sub TrackParameter(p As Parameter, parcolor As Int) As Boolean
TrackedParameters.Add(p)
LineChart.AddLine2(p.PNAME, parcolor, 2dip, "CIRCLE", False, parcolor)
end sub
But it crashes on Drawchart at the next tick, with an OutOfBounds exception (bounds being the number of lines i added at the start)...
is this because the chart, once drawn with N variables, can't handle new ones that lack the same history (past values) ?
is there any way to solve it without having to add 'fake points' to the new line?
...And how can i even do that? i see LineChart.Points, but i'm not sure what's the object laying underneath it, or how to manipulate it to add a 'fake history'?
Sorry for the many questions, and thanks for your time!