Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var width = 300;
- var height = 400;
- var padding = 2;
- var dataset = [50, 100, 150, 200, 250];
- var svg = d3.select("body")
- .append("svg")
- .attr("width", width)
- .attr("height", height);
- svg.selectAll("rect")
- .data(dataset)
- .enter()
- .append("rect")
- .attr("x", function(d, i) { return i * (width / dataset.length); })
- .attr("y", function(d) { return height - d; })
- .attr("width", width / dataset.length - padding)
- .attr("height", function(d) { return d; })
- .attr("fill", function(d){ return "rgb(" + d + ", 0,0)"; })
- .append("title")
- .text(function(d) { return d; })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement