Created
February 3, 2017 16:10
-
-
Save alivcor/1a6c4fbf6c39e418f52590e585f6ab1d to your computer and use it in GitHub Desktop.
BubblesView - A Bubbles View Generator Using D3
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
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