Skip to content

Instantly share code, notes, and snippets.

@spencercarnage
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencercarnage/375fb2a12c66b03b5469 to your computer and use it in GitHub Desktop.
Save spencercarnage/375fb2a12c66b03b5469 to your computer and use it in GitHub Desktop.
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