Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Forked from anonymous/water.css
Created July 24, 2012 16:35
Show Gist options
  • Save gabrielflorit/3171075 to your computer and use it in GitHub Desktop.
Save gabrielflorit/3171075 to your computer and use it in GitHub Desktop.
blue bar chart
.chart rect {
stroke: white;
fill: steelblue;
}
var width = $('svg').width();
var height = $('svg').height();
var svg = d3.select('svg');
svg
.attr('width', width)
.attr('height', height)
.attr('class', 'chart');
var data = [4, 8, 15, 16, 23, 42];
var x = d3.scale.linear()
.domain([0, d3.max(data)])
.range([0, width]);
svg.selectAll("rect")
.data(data)
.enter().append("rect")
.attr("y", function(d, i) { return i * 20; })
.attr("width", x)
.attr("height", 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment