Skip to content

Instantly share code, notes, and snippets.

@ptvans
Created July 4, 2012 06:21
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 ptvans/3045703 to your computer and use it in GitHub Desktop.
Save ptvans/3045703 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 ox=30;
//y-origin
var oy=30;
var color = d3.scale.category10();
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 = ox;
ox = ox + cw
return temp;
})
.attr('y',function(d,i){
var temp1 = h*i*1.15 + oy;
return temp1;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment