I've been racking my brain trying to solve this error I keep encountering while working with a force layout. The problem arose when I switched to reading nodes from a JSON file. When I comment out certain lines, the error disappears. But if I leave them as they are, I receive a "Cannot call method 'push' of undefined" message. It's baffling me and I can't seem to pinpoint the issue. Is there something obvious that I'm overlooking?
<html>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script>
d3.json("http://katejustin.com/autosys1.json", function(data) {
//var nodes = {};
//data.links.forEach(function(link) {
// link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
// link.target = nodes[link.target] || (nodes[link.target] = {name: link.target}); });
var width = 200,
height = 200;
var svg = d3.select("body").append("svg:svg")
.attr("width", width)
.attr("height", height);
var force = d3.layout.force()
//.nodes(d3.values(nodes))
.nodes(data.nodes)
.links(data.links)
.size([width, height])
.distance(100)
.charge(-1000)
.start();
});
</script>
</html>