Reputation: 41
I am currently writing a program which retrieves data from a SQL database and uses the data to populate a pie-chart on a JavaFX scene. So far, this has been a success.
What I am wondering is if it is possible to repopulate and refresh the pie chart as new data is entered into the database. So far the only solution I have found is to close the program and reopen it, which is not really much of a solution.
I can provide my code if needed.
Grateful for any tips you can give, thanks!
Upvotes: 1
Views: 424
Reputation: 1044
What I am wondering is if it is possible to repopulate and refresh the pie chart as new data is entered into the database.
The beauty of graphs/Charts in FX is that they are all dynamic, and change.
if you add new data to your dataCollection, or set your entire database to PieChart.setData(data);
You would have to set up a listener to listen in on your DB and changes, or listen to the changes on whatever is changing your DB. Is it external or internal to your Application?
If it's Internal than you can set up the listener with a flag and do it then, if it's External then you will either
Upvotes: 1