Skip to content

Instantly share code, notes, and snippets.

@spencercarnage spencercarnage/index.html
Last active Aug 29, 2015

Embed
What would you like to do?
D3 Ring Stuff
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<style>
svg {
width: 500px;
height: 500px;
}
circle {
stroke: 1px solid red;
}
</style>
</head>
<body>
<svg id="main">
<g id="group"></g>
</svg>
<script>
var nodes = 10;
var group = $('#group');
function createRings () {
for(var i = 0; i < nodes; i++) {
var x = 100 - 12 + 124 * Math.cos(2 * Math.PI * i / nodes);
var y = 100 - 12 + 124 * Math.sin(2 * Math.PI * i / nodes);
group.append("<circle class='point' x="+ x +" y="+ y +"></circle>");
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.