Using chart.js, html, php. I have a chart already set up and its displaying data from a database using mySQL.
My issue is, how do i only display the most recent data on the chart. I would like to only show 20 values. So if a new set of data is added to the database. Then the chart needs to update by removing the oldest value from display to make room for the new value. I dont want to delete data from the database to do this.
any ideas on how to make this happen.
CodePudding user response:
You should get the last 10 values from the database like this
SELECT * FROM big_table ORDER BY A DESC LIMIT 10
And call update (https://www.chartjs.org/docs/latest/developers/updates.html)
chart.update()