var width = 960,
height = 500,
- color = d3.scale.category20c();
+ color = d3.scale.category10();
var svg = d3.select("#table_graph").append("svg")
.attr("width", width)
var node = svg.selectAll(".node")
.data(json.nodes)
- .enter().append("g")
+ .enter().append("g")
.attr("class", "node")
- .call(force.drag);
+ .call(force.drag)
+ .on("click", click);
//node.append("image")
// .attr("xlink:href", "https://github.com/favicon.ico")
// .attr("height", 16);
node.append("circle")
.attr("r", 10)
- .style("fill", function(d) { return color(d.name); });
+ .style("fill", function(d) { return color(d.group); });
node.append("text")
.attr("dx", 12)
node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
});
+
+ // action to take on mouse click
+ function click() {
+ d3.select(this).select("text").transition()
+ .duration(750)
+ .attr("x", 22)
+ .style("stroke", "lightsteelblue")
+ .style("stroke-width", ".5px")
+ .style("font", "20px sans-serif");
+ d3.select(this).select("circle").transition()
+ .duration(750)
+ .attr("r", 16);
+ }
+
});
\ No newline at end of file