// colour according to data _.forEach(data, function(n, key) { svg.select('.row-' + n.r + '.col-' + n.c) .attr('fill', '#130C0E'); }); // custom accents (for squares outside the grid) function accents(row, col) { svg.append('rect') .attr({ class: 'accent', width: square, height: square, x: row, y: col, fill: '#130C0E', stroke: 'none' }); } accents(345, 230); accents(345, 780); accents(345, 810); accents(495, 810); accents(555, 810); accents(150, 1030); accents(210, 1065); accents(105, 1180); accents(165, 1245); accents(345, 1125);