Created
November 13, 2017 21:33
-
-
Save marshallformula/2784a4d130154f7d09937d5730feb120 to your computer and use it in GitHub Desktop.
d3 margin convention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const totalWidth = 960 | |
const totalHeight = 600 | |
const margin = { top: 20, right: 20, bottom: 20, left: 20} | |
const width = totalWidth - margin.left - margin.right | |
const height = totalHeight - margin.top - margin.bottom | |
const svg = d3.select('#chart').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})`) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment