Note that there are some explanatory texts on larger screens.

plurals
  1. PO$.getJSON returns [object Object]
    primarykey
    data
    text
    <p>All- I am using the TreeMap example of D3 to try and dynamically update it every 30 seconds via $.getJSON. I went to <a href="http://jsonlint.com/" rel="nofollow">http://jsonlint.com/</a> to make sure my json was validated. I kick off the TreeMap with a local json string that immediately builds the TreeMap. However, I cannot figure out why when I go to update the treemap 30 seconds later via localhost, I get: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object] from my json string instead of the newly updated text String. How can I change [object Object] to actual tokens that can repopulate and draw out a new table? Many thanks in advance for taking a look.</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt; &lt;title&gt;Update Tree Map&lt;/title&gt; &lt;link rel="Stylesheet" type="text/css" href="http://localhost:8080/dev_tests/d3/examples/treemap/treemap-svg.css" /&gt; &lt;script type="text/javascript" src="http://localhost:8080/dev_tests/d3/d3.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://localhost:8080/dev_tests/d3/d3.layout.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://localhost:8080/dev_tests/latest.jquery/jquery-latest.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="chart"&gt; &lt;script type='text/javascript'&gt; var jdata = { "children": [ { "name": "quant_mechanics", "size": "1243" }, { "name": "graph_theory", "size": "4343" }, { "name": "algebra", "size": "1936" }, { "name": "calc", "size": "3936" }, { "name": "geom", "size": "2136" }, { "name": "stats", "size": "4136" } ] }; var w = 350, h = 200, color = d3.scale.category20c(); 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"); redraw3(); function redraw3() { var cell = svg.data([jdata]).selectAll("g") .data(treemap) .enter().append("g") .attr("class", "cell") .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); 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; }); } var interval = setInterval(function() { $.getJSON("http://localhost:8080/dev_tests/d3/examples/data/flare2.json", function(json) { alert(json.children); jdata.push({value: json.children}); redraw3(); }); }, 30000); &lt;/script&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload