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

121
Views
¿Cómo actualizar un gráfico de Google periódicamente?

Actualmente, estoy tratando de actualizar el valor de mi gráfico de líneas de Google. Mi objetivo es actualizarlo periódicamente, para poder obtener el resultado de un gráfico dinámico. En este momento necesito actualizar toda la página, pero esta no es una buena solución.

Probé con la función setTimeout() , pero recordar la función drawChart() no parece funcionar. Aquí está mi código JavaScript:

 <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { // The intervals data as narrow lines (useful for showing raw source data) var options = { title: 'Valores de LDR1', vAxis: { ticks: [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]}, curveType: 'function', lineWidth: 4, legend: 'none' } var ldr1 = new google.visualization.LineChart(document.getElementById('ldr1')); var ldr2 = new google.visualization.LineChart(document.getElementById('ldr2')); var ldr3 = new google.visualization.LineChart(document.getElementById('ldr3')); var ldr4 = new google.visualization.LineChart(document.getElementById('ldr4')); var data = google.visualization.arrayToDataTable(<?php prueba('ldr1') ?>); var data2 = google.visualization.arrayToDataTable(<?php prueba('ldr2') ?>); var data3 = google.visualization.arrayToDataTable(<?php prueba('ldr3') ?>); var data4 = google.visualization.arrayToDataTable(<?php prueba('ldr4') ?>); ldr1.draw(data, options); options["title"] = "Valores de LDR2"; ldr2.draw(data2, options); options["title"] = "Valores de LDR3"; ldr3.draw(data3, options); options["title"] = "Valores de LDR4"; ldr4.draw(data4, options); updateChart(); setTimeout(drawChart, 1000); }

El código php obtiene valores de la base de datos, así como lo veo, solo tengo que repetir el código de la función drawChart() , pero esto no sucede.

about 4 years ago · Juan Pablo Isaza
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!