how to update a graph by using the $.load() method

Asked

Viewed 60 times

0

I have a graph that is created from the id div "#Chart", the problem is that I have a modal that registers more information on the graph and when clicking "back" I want to update it with this new data through the $.load() method. Any idea how to do that ?

<html> 
 <body>
  <div id="grafico" style="width:99.5%">
    <div id="chart"></div>
    <div id="info" style="display:none"></div>
  </div>
 </body>
</html>

if (window.location.hash === "") {
  d3.json("Paineis/gerencias.json", function(err, res) {
      if (!err) {
          console.log(res);
          var data = d3.nest().key(function(d) { return d.gerencia; }).key(function(d) { return d.key; }).entries(res);
          main({title: "Demandas em andamento"}, {key: "Total de demandas", values: data});
      }
  });
 } 
  • can you please put the code that initializes the D3.js. Generally libraries of the kind always have methods to update etc...

  • ready. I edited the code above

  • the graph is a Zoomable treemap

  • 1

    After inserting new data into the chart, try calling again the d3.json("Paineis/gerencias.json", function(err, res) {...

  • This worked, pórem, the old chart still remains on the page. And if I call the function " $("#Chart"). remove() " before calling the new json, no chart appears on the screen. Have any idea what might be happening ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.