Built on top of this example yet transferred to canvas and v4. Also added some colours and an option to change them as the little grey squares looked a little sad.
Built with blockbuilder.org
Modified http://d3js.org/d3.v4.js to a secure url
https://d3js.org/d3.v4.js
https://d3js.org/d3-scale-chromatic.v1.min.js