Skip to content

Instantly share code, notes, and snippets.

/_.md

Created December 15, 2012 01:46
Show Gist options
  • Save anonymous/4290448 to your computer and use it in GitHub Desktop.
Save anonymous/4290448 to your computer and use it in GitHub Desktop.
Another Inlet
{"description":"Another Inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.6386879215205398,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false}
var lineData=[];
var a=0;
var data=[],i,num=26;
var step= (360/(num))/180 *Math.PI;
var svg = d3.select("svg");
var lineFunction = d3.svg.line()
.x(function(d) { return d.x; })
.y(function(d) { return d.y; })
.interpolate("basis-closed");
svg.selectAll("rect").data(data)
.enter()
.append("rect")
.attr("x",3)
.attr("y",function(d,i){return i*15})
.attr("width",function(d){return d*100})
.attr("height",13)
.style("fill", "#FF2900")
for( i = 0; i < num; i++ ){
data[i]=Math.ceil(Math.random()*6);
var r=50+data[i]*20;
a+=step;
lineData.push( {"x": 546+Math.sin(a)*r, "y": 407+Math.cos(a)*r} );
}
svg.append("path")
.attr("d", lineFunction(lineData))
.attr("stroke", "#000")
.attr("fill", "none");
lineData=[];
for( i = 0; i < num; i++ ){
data[i]=Math.ceil(Math.random()*6);
var r=50+data[i]*20;
a+=step;
lineData.push( {"x": 546+Math.sin(a)*r, "y": 407+Math.cos(a)*r} );
}
svg.append("path")
.attr("d", lineFunction(lineData))
.attr("stroke", "#FF0000")
.attr("fill", "none");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment