looking for a code example of a dot matrix chart, created with the latest version of D3. Essentially trying to achieve something like the attached image.

What you are looking for is already implemented by Arpit Narechania. You can use his javascript library to render Dot Martix Charts out of the box or look at his code snippet to write your own.
Using the library is as simple as can be:
<script src="/path/to/d3.min.js"></script>
<script src="/path/to/dist/DotMatrix.css"></script>
<script src="/path/to/dist/DotMatrix.js"></script>
<div id="DotMatrix"></div>
...
var chartOptions = {
dot_radius: 5,
no_of_circles_in_a_row: 40,
dot_padding_left: 5,
dot_padding_right: 5,
dot_padding_top: 5,
dot_padding_bottom: 5
};
DotMatrixChart(yourDataset, chartOptions);