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

242
Views
Chart.js: no se puede actualizar la página

Tengo coordenadas X e Y que provienen de un robot. Quiero actualizar el gráfico para que los datos se muestren por separado a medida que se mueve un automóvil.

El error arroja: No se puede leer la propiedad "datos" de undefined.

¿Podría alguien ayudarme? ¿Cómo puedo hacer que la actualización tenga éxito?

 var ros = new ROSLIB.Ros({ url:'ws://10.0.2.5:9090' }); var tag5617 = new ROSLIB.Topic({ ros:ros, name:"/dwm1001/tag5617", messageType:"dwm1001/anchor" }); var myChart; var canvas = document.getElementById('myChart'); var ctx = canvas.getContext('2d'); function init(){ const myChart = new Chart(ctx, { type: 'scatter', data: { datasets: [{ label: 'GOKART MOVING', data: [{x:1,y:1}], backgroundColor: ['#087037'], }], }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true, suggestedMax: 20, } }] , xAxes: [{ ticks:{ suggestedMax:15, } }] } } }); } init(); tag5617.subscribe(function(message) { //console.log("X: " + message.x); //console.log("Y: " + message.y); let X = document.getElementById('posX'); X.innerHTML = message.x.toFixed(2); let Y = document.getElementById('posY'); Y.innerHTML = message.y.toFixed(2); myChart.data.datasets[0].push({X,Y}); myChart.update(); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usted define 2 myChart. Entonces, su primera declaración permanece vacía;) Vuelva a asignar su variable, no haga una nueva que permanezca en el alcance de su función de inicio.

 function init(){ myChart = new Chart(ctx, { ... }); }
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!