How to Chart real time streaming data using AreaChart in JAVAFX 2 - Concurrency, Animation, Charting

后端 未结 2 2086
广开言路
广开言路 2021-02-19 04:46

Requirement- Build an animated AreaChart with real time streaming data. Maybe plot 300 data points every 1 sec.

Details- So I need to read real time streaming data from

相关标签:
2条回答
  • 2021-02-19 04:57

    As jewelsea stated in his/her comment:

    This question was cross posted (and answered well) on an Oracle JavaFX forum thread.

    To summarize, the solution consisted in:

    • Turning animation off as it is designed for slower changing data so that it is animated on arrival;
    • Changing the Timeline to a AnimationTimer as it is desired to update the chart every frame in order to keep in sync with incoming data and move as smoothly as possible;
    • Fixing threading as OP did not need to extend Thread when using a Executor. Changing the creation of the executor service.
    0 讨论(0)
  • 2021-02-19 04:57

    A big performence drop could come from your data gathering. There is no reason to use an ExecutorService and continuosly add new Threads for execution by it in order to get repetitive data adding. You could settle for a single thread which reads/receives the data and adds it to the queue and start it by calling addToQueue.start(). For it to work properly, you want a loop to run continously in the thread with a delay at the end of each iteration.

    0 讨论(0)
提交回复
热议问题