Graphics Reference
In-Depth Information
var nodecolor = d3.scale.linear()
.domain([minRecent,maxRecent])
.range(["yellow","red"]);
// set up the graph drawing area
var width = 500;
var height = 500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
// set up the force system
var force = d3.layout.force()
.charge(-250)
.linkDistance(100)
.size([width, height]);
force.nodes(graph.nodes)
.links(graph.links)
.start();
// create the links
var link =
svg.selectAll("line").data(graph.links).enter().append
("line")
.style("stroke", "blue")
.style("stroke-opacity", 0.25)
.style("stroke-width", function(d) { return d.weight
*0.2; });
// create the nodes as circles
var node =
svg.selectAll("circle").data(graph.nodes).enter().append
("circle")
.attr("r", function(d) { return
nodesize(d.numEmail); })
.attr("fill", function(d) { return
nodecolor(d.recency); })
.attr("stroke", "white");
Search WWH ::




Custom Search