Skip to content

Instantly share code, notes, and snippets.

@alivcor
Created February 3, 2017 16:10
Show Gist options
  • Save alivcor/1a6c4fbf6c39e418f52590e585f6ab1d to your computer and use it in GitHub Desktop.
Save alivcor/1a6c4fbf6c39e418f52590e585f6ab1d to your computer and use it in GitHub Desktop.
BubblesView - A Bubbles View Generator Using D3
var sampleSVG = d3.select("#bubbles")
.append("svg")
.attr("width", 960)
.attr("height", 960);
var mydata = [];
d3.csv("/baseball_data.csv", function(data) {
data.forEach(function(d) {
d["HR"] = +d["HR"];
mydata.push(+d["HR"]);
});
console.log(mydata);
var svg = d3.select("svg");
var circle = svg.selectAll("circle").data(mydata);
var circleEnter = circle.enter().append("svg:circle");
circle.style("fill", "steelblue");
circleEnter.attr("cy", 60);
circleEnter.attr("cx", function(d, i) { return i * 10 + 30; });
circleEnter.attr("r", function(d) { return Math.sqrt(d); });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment