I have a treemap that I put together with d3.js. I populate the data via getJSON. It works great. However, I have this function in the setInterval method, and it does not seem to refresh itself.
var treemap = d3.layout.treemap() .padding(4) .size([w, h]) .value(function(d) { return d.size; }); var svg = d3.select("#chart").append("svg") .style("position", "relative") .style("width", w + "px") .style("height", h + "px"); function redraw3(json) { var cell = svg.data([json]).selectAll("g") .data(treemap) .enter().append("g") .attr("class", "cell") .attr("transform", function(d) { return "translate(" + dx + "," + dy + ")"; }); cell.append("rect") .attr("width", function(d) { return d.dx; }) .attr("height", function(d) { return d.dy; }) .style("fill", function(d) { return d.children ? color(d.data.name) : null; }); cell.append("text") .attr("x", function(d) { return d.dx / 2; }) .attr("y", function(d) { return d.dy / 2; }) .attr("dy", ".35em") .attr("text-anchor", "middle") .text(function(d) { return d.children ? null : d.data.name; }); } setInterval(function() { d3.json("http://localhost:8080/dev_tests/d3/examples/data/flare2.json", function(json) { redraw3(json); }); }, 3000);
My question is specifically, why, when I change the data in the json file, it does not appear after 3 seconds in the treemap?
Thanks in advance.
Chris source share