Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Chart.js how to make chart only show the most recent data

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!