Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var node = svg.selectAll("circle")
- .data(nodes)
- .enter().append("circle")
- .attr("class", function(d) {return category[d.cluster];})
- .text(function(d) { return d.text; })
- .filter(function(d){ return d.count >= 1; })
- .style("fill", function(d) { return color(d.cluster); })
- .call(force.drag);
- var legend = svg.selectAll(".legend")
- .data(color.domain())
- .enter().append("g")
- .attr("class", "legend")
- .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });
- legend.append("rect")
- .attr("x", width - 18)
- .attr("width", 18)
- .attr("height", 18)
- .style("fill", color)
- legend.append("text")
- .attr("x", width - 24)
- .attr("y", 9)
- .attr("dy", ".35em")
- .style("text-anchor", "end")
- .text(function(d) { return category[d]; })
- .on("click", function(d){
- node.selectAll('.'+category[d]).style("visibility", "hidden");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement