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

351
Views
Flask and Plotly application - the chart doesn't work AT ALL

I was kinda trying to make a chart out of PyTrends and it seems like js code is working, but something just messes up in html and I was really conserned till the point, where there was no info in the internet. In a console it always shows an error 'Calling Plotly.plot as if redrawing but this container doesn't yet have a plot. <div id=​"myDiv" class=​"js-plotly-plot">​…​​'. Please, help. Here are the code parts, that seem to not work:

<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>

JS code for processing the data into the chart

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
  }
  
}

Thank you very much!

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!