Created
June 7, 2014 12:53
-
-
Save anonymous/ad787a0018f4aed98d2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#test{ | |
outline: 1px solid red; | |
} |
This file contains hidden or 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> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<svg id="test"> | |
</body> | |
</html> |
This file contains hidden or 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
var _data = [ | |
{123:12341}, | |
{321:21424}, | |
{643:156742}, | |
{1232:2677243}, | |
{132:39491} | |
]; | |
var parent = d3.select('#test'); | |
parent | |
.attr({ | |
width: 400, | |
height: 400 | |
}); | |
parent | |
.append('circle') | |
.attr({ | |
cx: 200, | |
cy: 200, | |
r: 150, | |
stroke:'blue', | |
'stroke-width':1, | |
fill:'none' | |
}); | |
var circularScale = d3.scale.linear().domain([0,_data.length]).range([0,2*Math.PI]); | |
parent | |
.append('g') | |
.attr('class','data') | |
.selectAll('circle') | |
.data(_data) | |
.enter() | |
.append('circle') | |
.attr({ | |
cx: function(d,i){ | |
console.log(i,circularScale(i)); | |
return 200+ 150 * Math.cos(circularScale(i)); | |
}, | |
cy: function(d,i){ | |
return 200+ 150 * Math.sin(circularScale(i)); | |
}, | |
r: 10, | |
stroke:'green', | |
'stroke-width':1, | |
fill:'none' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment