Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Created December 10, 2012 18:16
Show Gist options
  • Select an option

  • Save biovisualize/4252255 to your computer and use it in GitHub Desktop.

Select an option

Save biovisualize/4252255 to your computer and use it in GitHub Desktop.
assing arguments
{"description":"assing arguments","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.7,"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 svg = d3.select('svg');
var sumArray = [];
/*svg.selectAll('rect')
.data([10, 20, 30, 40])
.enter().append('rect')
.attr('width', function(d){return d;})
.attr('height', 80)
.attr('x', function(d, i){
var prevX = sumArray[i-1] || 0;
var x = d + prevX;
sumArray.push(x);
console.log(x);
return x;
})
.attr('y', function(d, i, j){return j*100;})
.style('fill', 'skyblue');
*/
svg.selectAll('g')
.data([[10, 20], [30, 40]])
.enter().append('g')
.attr('transform', 'translate(50, 50)')
.selectAll('rect')
.data(function(d){return d;})
.enter().append('rect')
.attr('width', function(d){return d;})
.attr('height', 80)
.attr('x', function(d, i, j){
var prevX = sumArray[i-1] || 0;
var x = d + prevX;
sumArray.push(x);
return x;
})
.attr('y', function(d, i, j){return j*100;})
.style('fill', 'skyblue');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment