Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. d3.select("body")
  2. .on({
  3. "click": function() {
  4. d3.csv("../data/interpro.csv", function(d) {
  5.  
  6. // update data
  7. var newdata = d.e20;
  8. if (newdata == d.e20) {
  9. return newdata = d.e10;
  10. } else if (newdata == d.e10) {
  11. return newdata = d.e5;
  12. } else {
  13. return newdata = d.e20;
  14. }
  15.  
  16. // update scales
  17. yScale.domain([0, d3.max(dat, function(d) {
  18. return newdata;
  19. })]).range([h - 10, 0]);
  20.  
  21. bar.data(data)
  22. .attr({
  23. height: function(d) {
  24. return h - yScale(newdata);
  25. },
  26. y: function(d) {
  27. return yScale(newdata);
  28. }
  29. });
  30.  
  31. bar.transition()
  32. .delay(500)
  33. .duration(1000)
  34. .attr({
  35. height: function(d) {
  36. return h - yScale(newdata);
  37. },
  38. y: function(d) {
  39. return yScale(newdata);
  40. }
  41. });
  42.  
  43. });
  44. }
  45.  
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement