Advertisement
Guest User

Untitled

a guest
May 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. var width = 300;
  2. var height = 400;
  3. var padding = 2;
  4. var dataset = [50, 100, 150, 200, 250];
  5.  
  6. var svg = d3.select("body")
  7. .append("svg")
  8. .attr("width", width)
  9. .attr("height", height);
  10.  
  11. svg.selectAll("rect")
  12. .data(dataset)
  13. .enter()
  14. .append("rect")
  15. .attr("x", function(d, i) { return i * (width / dataset.length); })
  16. .attr("y", function(d) { return height - d; })
  17. .attr("width", width / dataset.length - padding)
  18. .attr("height", function(d) { return d; })
  19. .attr("fill", function(d){ return "rgb(" + d + ", 0,0)"; })
  20. .append("title")
  21. .text(function(d) { return d; })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement