Skip to content

Instantly share code, notes, and snippets.

/_.md

Created December 15, 2012 02:12
Show Gist options
  • Save anonymous/4290667 to your computer and use it in GitHub Desktop.
Save anonymous/4290667 to your computer and use it in GitHub Desktop.
Another Inlet
{"description":"Another Inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":false,"vim":true,"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.5877988963825879,"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=[], a=0, data=[], i, num=26,
r, 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");
for( i = 0; i < num; i++ ){
data[i]=Math.ceil(Math.random()*6);
r = 183 + data[i] * 43;
a += step;
lineData.push( {"x": 557+Math.sin(a)*r, "y": 525+Math.cos(a)*r} );
}
svg.append("path")
.attr({"d": lineFunction(lineData),"fill": "#FF0000", "opacity": 0.6 });
lineData=[];
for( i = 0; i < num; i++ ){
data[i]=Math.ceil(Math.random()*6);
r = 188+data[i]*45;
a += step;
lineData.push( {"x": 546+Math.sin(a)*r, "y": 527+Math.cos(a)*r} );
}
svg.append("path")
.attr({"d": lineFunction(lineData),"fill": "#333", "opacity":0.7});
svg.selectAll("rect").data(data)
.enter()
.append("rect")
.attr("x",13)
.attr("y",function(d,i){return i*4+10})
.attr("width",function(d){return d*8})
.attr("height",3)
.style("fill", "#25CAF3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment