-
-
Save roundrobin/3399470 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":686,"height":671,"hide":false}} |
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
var cx = 430; | |
var cy = 263; | |
var circle = g.append("circle") | |
.attr("r",7) | |
.attr("cx",cx) | |
.attr("cy",cy) | |
.attr("fill","#FF00FF"); | |
var x = 356; | |
var y = 353; | |
createCircle(g,x,y,'arcCirc' ,'1',10); | |
createCircle(g,x,y,'arcCirc2','',4); | |
createCircle(g,x,y,'arcCirc3' ,'2',10); | |
createCircle(g,x,y,'arcCirc4','',4); | |
//createCircle(g,10,10,'arcCirc3','3'); | |
//createCircle(g,10,10,'arcCirc4','4'); | |
function createCircle(g,x,y,name,text,r){ | |
var group = g.append("g") | |
.attr("transform","translate("+[x,y]+")") | |
.attr("class","group") | |
.attr("id",name) | |
var circle = group.append("circle") | |
.attr("r",r) | |
.attr("fill","#0052FF"); | |
var circle = group.append("text") | |
.text(text) | |
.attr("fill","#000000"); | |
} | |
rotateGroup("arcCirc",-50,12,-122); | |
rotateGroup("arcCirc3",17,360 ,-195); | |
//rotateGroup("arcCirc2",38,62,84); | |
//rotateGroup("arcCirc3",100,462,155); | |
//rotateGroup("arcCirc4",0,462,228); | |
function rotateGroup(id,start,end,r){ | |
//change r for different radius | |
var r = r; | |
//change theta to see text rotate | |
var thetas = [start,end]; | |
//turn theta into radians | |
var degrees = Math.PI/180; | |
d3.select("#"+id) | |
.transition() | |
.duration(1500) | |
.attrTween("transform", function(d) { | |
//we interpolate between our start and end angle | |
//by creating an interpolation function | |
var theta = d3.interpolateNumber(thetas[0], thetas[1]); | |
return function(t) { | |
var x = cx + r * Math.cos(theta(t) * degrees); | |
var y = cy + r * Math.sin(theta(t) * degrees); | |
//function(t) is called for every step of the transition | |
//giving us a value of theta inbetween our start and end angle | |
//at each time step | |
return "translate(" + [x,y] + ")"; | |
} | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment