Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. // you've selected a bunch of text elements that already exist on the page
  2. var text = svg.selectAll("text")
  3. .data(data); //<-- you've now bound data to them
  4.  
  5. // text here is the elements already on the page, we just update them
  6. text.attr("class", "update");
  7.  
  8. // if there's more data then previous existing elements
  9. // these are returned by .enter()
  10. text.enter().append("text")
  11.  
  12. // now you are operating on both existing and new elements
  13. text.text(function(d) { return d; });
  14.  
  15. var myCoolRect = svg.append('rect')
  16. .attr('id', 'myCoolRect')
  17. .attr('x', 100)
  18. ....;
  19.  
  20. myCoolRect.attr('x', 250);
  21.  
  22. svg.select('#myCoolRect')
  23. .attr('x', 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement