I'm trying to display data to a user with a LineChart
in JavaFX. I have an array of Float (not the primitive, the object, as in Float[]
) that is ready to be added that could be anywhere from 512 to 4096 points long.
All the examples and help for LineChart
show that data has to be added point by point using XYChart.Series.getData().add(new XYChart.Data(X, Y))
where X would be the index and Y would be the value at Float[index]. This is really, really slow since this approach requires looping through the array, but it works. I'd like the LineChart
to update at 30FPS but it as less than 1FPS right now :/
Is there a faster way where I can just toss an array at the JavaFX LineChart
class and have it draw without looping through and adding each point?
EDIT (Solution Found):
srm, that concept works!
On the first run, just fill the XYChart.Series
with new XYChart.Data(X,Y)
. Then loop through and fetch and update using XYChart.Series.get(index).setYData(NewValue)