Skip to content

Instantly share code, notes, and snippets.

@sfrdmn
Created September 21, 2011 20:48
Show Gist options
  • Save sfrdmn/1233257 to your computer and use it in GitHub Desktop.
Save sfrdmn/1233257 to your computer and use it in GitHub Desktop.
DAI523 - D3 - Binding data and creating graphs
d3.select("body").append("svg:svg").attr("width", 3000).attr("height",500);
var chart = d3.select("svg");
var fill = d3.scale.category20();
d3.json("data/dataset1.json", function(json) {
var size = function(d,i) {
return d.size;
}
var x = function(d,i) {
return 200*i;
}
chart.selectAll("circle").data(json.circles)
.enter().append("svg:circle")
.attr("cx", x)
.attr("cy", 250)
.attr("fill", function(d,i) {
return fill(i);
})
.attr("r", size);
});
/*var numbers = [ 5, 4, 3, 2, 1];*/
/*var x = function(d, i) {
return d * 100;
}
chart.selectAll("circle").data(numbers)
.enter().append("svg:circle")
.attr("r", 100)
.attr("cx", x )
.attr("cy", 250);*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment