Skip to content

Instantly share code, notes, and snippets.

@walterm
Created July 10, 2014 05:04
Show Gist options
  • Save walterm/321a1ed05e27c4c95595 to your computer and use it in GitHub Desktop.
Save walterm/321a1ed05e27c4c95595 to your computer and use it in GitHub Desktop.
Simple barchart, with a linear scale
$(function(){
var data = [4, 8, 15, 16, 23, 42];
var x = d3.scale.linear()
.domain([0, d3.max(data)])
.range([0, 420]);
d3.select(".chart")
.selectAll("div")
.data(data)
.enter().append("div")
.style("width", function(d) { return x(d) + "px"; })
.text(function(d) { return d; });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment