Skip to content

Instantly share code, notes, and snippets.

@ABrouwer
Created April 1, 2014 09:57
Show Gist options
  • Save ABrouwer/9911221 to your computer and use it in GitHub Desktop.
Save ABrouwer/9911221 to your computer and use it in GitHub Desktop.
d3.json('https://astportfoliodata.firebaseio.com/.json', function(data) {
console.log(data); //Log output to console
//Width and height
var w = 500;
var h = 100;
//Create SVG element
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
svg.selectAll("circle")
.data(dataset)
.enter()
.append("circle")
.attr("cx", function(data) {
return data[0];
})
.attr("cy", function(data) {
return data[1];
})
.attr("r", function(data) {
return Math.sqrt(h - data[1]);
});
//Create labels
svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.text(function(data) {
return data[0] + "," + data[1];
})
.attr("x", function(data) {
return data[0];
})
.attr("y", function(data) {
return data[1];
})
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("fill", "red");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment