Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@agconti
Created November 14, 2013 04:20
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 agconti/7461288 to your computer and use it in GitHub Desktop.
Save agconti/7461288 to your computer and use it in GitHub Desktop.
circles
{"description":"circles","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
var svg = d3.select('svg');
var h = 418;
var w = 700;
var bar_padding = 1;
var scale = 10;
svg.attr({height: h,
width: w,
});
//var data = d3.range(23);
//random data
var data = [];
for (var i=0; i<30; i++){
var num = Math.random() * 30;
data = data.concat(num);
}
// color scales
var colorscale = d3.scale.linear()
.domain([d3.min(data), d3.max(data)])
.interpolate(d3.interpolateHcl)
.range(["#59E294", "#214592"]);
var circles = svg.selectAll('circle').data(data);
circles.enter()
.append('circle')
.attr({
r: (w / data.length),
height:function(d){
return (d*scale);
},
cy: function(d){
return (h - (d * scale));
},
cx: function(d,i){
return ((i * w) / data.length) + 30;}, //plus 30 for sapcing need in Tributary
//fill: "#51C283"
fill: function(d,i){
return colorscale(d);} // plus 79 to morph color scale.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment