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

182
Vistas
How can I create a dynamically assigned variable for a chart with chart.js?

I am trying to create a series of line chart dynamically and then update them once the data has been updated for a particular user in real-time.

I am running into difficulty because I can only get the most recent one to render.

I think this is because when the following code runs it overwrites the ctx variable and I lose the earlier charts.

I tried the following technique with dynamic variables so no two ctx variables would be the same, but it doesn't work.

Thanks in advance for your help.

window['ctx_'+userid] = document.getElementById("forceCurveGraph_"+userid).getContext("2d");
  
     window['myLineChart'+userid] = new Chart(window['ctx_'+userid], {
      type: 'line', data: {
        datasets: [{
          label: "Force Curve",
          data: forcecurvedata, backgroundColor: ['rgba(57,118,251, 0.8)']
        }],
        labels: labels
      }, options: {
        backgroundColor: ['rgba(40, 84, 141, 0.3)'],
        scales: {
          yAxes: [{
            ticks: {
              beginAtZero: true,
              max: graphMax
            }
          }],
          xAxes: [{
            ticks: {
              display: false
            }
          }]
        }
      }
    })
about 4 years ago · Juan Pablo Isaza
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