Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created June 24, 2012 04:13
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 roundrobin/2981559 to your computer and use it in GitHub Desktop.
Save roundrobin/2981559 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var x_scale = d3.scale.linear().domain([0,100]).range([0,500]);
var h=20;
//x-origin
var o=30;
//y-origin
var l=30;
var color = d3.scale.category20();
var array1 = [16,25,9,12,38];
var selection = g.selectAll('rect')
.data(array1)
.enter()
.append('rect')
.attr('fill',function(d,i){return color(i)})
.attr('height',h)
.attr('width',function(d,i){
return x_scale(d);
})
.attr('x',function(d,i){
var cw = x_scale(d);
var temp = o;
o = o + cw
return temp;
})
.attr('y',l)
.transition()
.duration(2000)
.attr('x',0)
.attr('y',function(d,i){
return i * 50;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment