Skip to content

Instantly share code, notes, and snippets.

@fabiokandrade
Created July 28, 2019 23:33
Show Gist options
  • Save fabiokandrade/049b71412319486c05e847618f987d21 to your computer and use it in GitHub Desktop.
Save fabiokandrade/049b71412319486c05e847618f987d21 to your computer and use it in GitHub Desktop.
const viz = (margin={ top: 10, right: 20, bottom: 25, left: 25}, selection= d3.select('.viz'))=>{
const width = 425 - margin.left - margin.right;
const height = 625 - margin.top - margin.bottom;
const container = selection
.append('svg')
.attr('width', width + margin.left + margin.right)
.attr('height', height + margin.top + margin.bottom)
.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
return [container,margin, width, height]
}
[container,margin, width, height] = viz()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment