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

253
Views
No puedo actualizar el gráfico de ApexChart con JavaScript...>

Estoy tratando de actualizar un gráfico después de obtener datos de MySQL, pero mi función updateChart no se está ejecutando.

Sé que no se está ejecutando porque console.logs (que muestra Boo! y muestra la matriz driversChartData no se muestran en la consola. Sé que hay datos en la matriz porque los consola si hago el console.log desde fuera de la función.

¿Alguna idea de por qué mi función no se ejecuta después de la instrucción if?

(He intentado eliminar toda la declaración if en caso de que interfiriera, pero fue en vano). Debe ser una sola cosa, pero soy nuevo en JS, por lo que cualquier ayuda sería muy apreciada :)

Gracias. METRO.

 document.addEventListener('DOMContentLoaded', function () { fetch('http://127.0.0.1:3000/driversChart') .then(response => response.json()) .then(data => loadDriversChart(data['data'])); }); function loadDriversChart(driversChartData) { const driversChartArea = document.querySelector("#driversChart"); if (driversChartData.length === 0) { var options = { chart: { height: 350, type: 'line', }, dataLabels: { enabled: false }, series: [], title: { text: 'F1 Drivers Points Repartition', }, noData: { text: 'Loading Drivers Chart...' } } var chart = new ApexCharts( document.querySelector("#driversChart"), options ); chart.render(); } // Data is fetched so update the Drivers' Chart function updateChart(driversChartData) { console.log('Boo!'); console.log(driversChartData); driversChartArea.updateSeries( [ { name: 'F1 Drivers Points Repartition', data: driversChartData } ] ); }; }
about 4 years ago · Santiago Trujillo
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!