Instead of appending circles, we can append a path. The data holds the "d" attribute that makes the shape
xxxxxxxxxx
<meta charset="utf-8">
<style>
.link {
stroke: black;
stroke-opacity: 0.5;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script>
var width = 1960,
height = 1800;
var color = d3.scale.category20();
var force = d3.layout.force()
.charge(-4000)
.linkDistance(450)
.size([width, height]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("raw.json", function(error, graph) {
force
.nodes(graph.nodes)
.links(graph.links)
.start();
var link = svg.selectAll(".link")
.data(graph.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) { return 10; });
var circle = svg.append("g").selectAll(".node")
.data(graph.nodes)
.enter().append("path").attr("d",function(d) {return d.shape;})
.style("stroke","black")
.style("stroke-width",3)
.style("fill","black")
.attr("class", "node")
//.attr("transform", function(d) { return "translate("+d.y + "," +d.x + ")" ;})
.call(force.drag);
/*var text = svg.append("g").selectAll(".text")
.data(graph.nodes)
.enter()
.append("text")
.attr("x",0)
.attr("y",".31em")
.text(function(d) {return d.name;})
.style("fill","black")
.style("font-family","helvetica")
.style("font-size",function(d) {return 15;})*/
force.on("tick", function() {
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
circle.attr("transform", function(d) { return "translate("+(d.x -d.offx)+ "," +(d.y-d.offy) + ")" ;});
/*text.attr("x", function(d) { return d.x; })
.attr("y", function(d) { return d.y+(d.size*10); });*/
});
});
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js