Built with blockbuilder.org
Created
July 11, 2018 03:35
-
-
Save jrzief/c16edf6d977d1ee3a472f77844960f2f to your computer and use it in GitHub Desktop.
Selections && 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
license: mit |
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://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
</style> | |
</head> | |
<body> | |
<div id=circlefun> | |
</div> | |
<script> | |
var data = [25, 20, 10, 12, 15]; | |
var svg = d3.select("#circlefun").append("svg") | |
.attr("width", 600) | |
.attr("height", 400); | |
var circles = svg.selectAll("circle") | |
.data(data); | |
circles.enter() | |
.append("circle") | |
.attr("cx", function(d, i){ | |
console.log("Item: "+ d, "Index: " + i); | |
return (i * 50) + 50; | |
}) | |
.attr("cy", function(d, i){ | |
return (i * 50)+ 50 | |
}) | |
.attr("r", function(d){ | |
console.log("Item: "+ d); | |
return d; | |
}) | |
.attr("fill", "red"); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment