Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda