I don't like constantly doing math to figure out dimensions when I'm building a dashboard of charts, so I made this helper function. It takes a matrix (array of arrays) as an argument, and divides the svg in the same manner as the matrix is divided by unique cell values.
Built with blockbuilder.org
https://d3js.org/d3.v4.min.js