Skip to content

Instantly share code, notes, and snippets.

@ptvans
Created July 4, 2012 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ptvans/3045674 to your computer and use it in GitHub Desktop.
Save ptvans/3045674 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]);
//bar height
var h=30;
//x-origin
var o=20;
//y-origin
var l=30;
var color = d3.scale.category20();
var array = [16,25,9,12,38];
var group = g.append('g').attr('id','barsGroup')
var selection = group.selectAll('rect')
.data(array)
.enter()
.append('rect')
.attr('class','bars')
.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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment