Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. var node = svg.selectAll("circle")
  2. .data(nodes)
  3. .enter().append("circle")
  4. .attr("class", function(d) {return category[d.cluster];})
  5. .text(function(d) { return d.text; })
  6. .filter(function(d){ return d.count >= 1; })
  7. .style("fill", function(d) { return color(d.cluster); })
  8. .call(force.drag);
  9.  
  10. var legend = svg.selectAll(".legend")
  11. .data(color.domain())
  12. .enter().append("g")
  13. .attr("class", "legend")
  14. .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });
  15.  
  16. legend.append("rect")
  17. .attr("x", width - 18)
  18. .attr("width", 18)
  19. .attr("height", 18)
  20. .style("fill", color)
  21.  
  22. legend.append("text")
  23. .attr("x", width - 24)
  24. .attr("y", 9)
  25. .attr("dy", ".35em")
  26. .style("text-anchor", "end")
  27. .text(function(d) { return category[d]; })
  28.  
  29. .on("click", function(d){
  30. node.selectAll('.'+category[d]).style("visibility", "hidden");
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement