Built with blockbuilder.org
Created
February 23, 2016 15:38
-
-
Save lambrex/11ebf3a851e6ad31bd17 to your computer and use it in GitHub Desktop.
circles
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
</head> | |
<script> | |
var spaceCircles = [30, 70, 110]; | |
var svgContainer = d3.select("body").append("svg") | |
.attr("width", 200) | |
.attr("height", 200); | |
var circles = svgContainer.selectAll("circle") | |
.data(spaceCircles) | |
.enter() | |
.append("circle"); | |
var circleAttributes = circles | |
.attr("cx", function (d) { return d; }) | |
.attr("cy", function (d) { return d; }) | |
.attr("r", 20 ) | |
.style("fill", function(d) { | |
var returnColor; | |
if (d === 30) { returnColor = "green"; | |
} else if (d === 70) { returnColor = "purple"; | |
} else if (d === 110) { returnColor = "red"; } | |
return returnColor; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment