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

357
Views
Aplicación Flask y Plotly: el gráfico no funciona EN ABSOLUTO

Estaba tratando de hacer un gráfico con PyTrends y parece que el código js está funcionando, pero algo se estropea en html y estaba realmente preocupado hasta el punto en que no había información en Internet. En una consola, siempre muestra un error 'Llamando a Plotly.plot como si se estuviera redibujando, pero este contenedor aún no tiene un gráfico. <div id=​"myDiv" class=​"js-plotly-plot">​…​​'. Por favor ayuda. Aquí están las partes del código, que parecen no funcionar:

 <html> <head> <title>DungeonMaster</title> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script src="{{url_for('static', filename='charts.js')}}"></script> <style> body, #charts{ height: 100%; } </style> </head> <body onload="loadChart();"> <div id="myDiv"></div> </body> </html>

Código JS para procesar los datos en el gráfico

 function loadChart() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(){ if (this.readyState === 4 && this.status === 200){ console.log(this.response); var chartData = getChartParams(this.response); Plotly.plot('myDiv', chartData, chartLayout); } }; xhttp.open("GET", "/data"); xhttp.send(); var chartLayout = { title:"Popularity dynamics of Skateboarding" } function getChartParams(jsonstr) { var file = JSON.parse(jsonstr) var chartObject = { x : file[1], y : file[0], type:'scatter' } return chartObject } }

¡Muchos gracias!

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!