0

I am new to D3 and I have a graph like this example: http://bl.ocks.org/jhb/5955887 I have some buttons to add/delete nodes and edges and the json file where I take the dataset from is updated but not the visualisation. How can I update the graph to reflect the changes?

To get the data I am using:

d3.json("dataset.json", function(error,json) {
      if (error) return console.warn(error);
      dataset = json;
    });
user1855165
  • 289
  • 1
  • 8
  • 22
  • You have to incorporate the new data into the nodes and edges of the force layout and then add the new visual elements. – Lars Kotthoff Apr 25 '14 at 14:53
  • @LarsKotthoff isn't that happen with the above code? Each time the json file is updated? – user1855165 Apr 25 '14 at 14:59
  • No. You have to go through all the steps you went through before -- add the new nodes and links to the data structures used in the force layout, select and match the DOM elements, add the ones that are present in the data but not the DOM. [This question](http://stackoverflow.com/questions/9539294/adding-new-nodes-to-force-directed-layout) may help. – Lars Kotthoff Apr 25 '14 at 15:07

0 Answers0