Created
September 21, 2011 20:48
-
-
Save sfrdmn/1233257 to your computer and use it in GitHub Desktop.
DAI523 - D3 - Binding data and creating graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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