Skip to content

Instantly share code, notes, and snippets.

@sranso
Created February 4, 2014 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sranso/8798286 to your computer and use it in GitHub Desktop.
Save sranso/8798286 to your computer and use it in GitHub Desktop.
// 1. selection an element
var chart = d3.select(".chart");
var bar = chart.selectAll("div");
// 2. then we have to join data to that element
var data = [4,3,5,33,5,67]
var barUpdate = bar.data(data);
// 3. enter/update/exit
var barEnter = barUpdate.enter().append();
// 4. add/update/remove attr, content, styles, etc
barEnter.style("width", function(d){
return d * 10 + "px";
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment