How to reload a chart to show updated data every time a column in the database is updated

I use chart-kick to generate charts in my Ruby on Rails application. I can display charts without any problems. The problem is that I need to refresh the page with the schedule every time the data is added to see the updated schedule. How can I make sure that only one graph is updated every time I update new data in my database? Is it possible?


Note. Screen charts are not an option. I give this to a commercial site and they cannot afford Highcharts.

+4
source share
4 answers

I ended up using Chart.js and used Ajax requests to poll the database and update the chart to change it. I was unable to implement Websockets.

+2
source

To achieve what you want, you will need bidirectional communication between your server and your client. I suggest you use websockets, it suffers from the fact that it is not supported by all browsers, but as a backup you can use server polling to get new results (if you are careful enough for backups). To check the current support status check this page .

Follow this example on a websocket-rails gem until you get started .

+1

- pusher , .

0
source

Use turbolinks to reload the graph

0
source

All Articles