-
-
Save emmanuelflores/87e917625fd55b3d95c3 to your computer and use it in GitHub Desktop.
circles with distance
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> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Hello D3</title> | |
<script type="text/javascript" src="d3/d3.min.js"></script> | |
<style type="text/css"> | |
</style> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var w = 500; | |
var h = 250; | |
//var dataset = [10,20,30,40]; | |
dataset = []; | |
for(var i=0;i<5;i++){ | |
var _number = (Math.random()*29)+1; | |
dataset.push(_number); | |
} | |
var svg = d3.select("body") | |
.append("svg") | |
.attr("width",w) | |
.attr("height",h); | |
var circles = svg.selectAll("circle") | |
.data(dataset) | |
.enter() | |
.append("circle"); | |
circles.attr("cx", function(d,i){ | |
return (i*100) + 30; | |
}) | |
.attr("cy", h/2) | |
.attr("r", function(d){ | |
return d; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment