function gridModulo (data, value, {
dataLength = data.length,
columnLength = 0,
squareSize = 50,
squareCol = smalt,
squareBgd = lightGrey,
strokeCol = smalt,
strokeWidth = 2,
textFill = "#fff",
showValues = true
} = {}) {
const size = (squareSize + (strokeWidth * 2));
const columns = (columnLength !== null && columnLength > 1 ) ? columnLength : Math.round(width / size) ;
const height = (dataLength / columns) * size;
console.log('columns', columns)
const svg = DOM.svg(width, height+ size);
const sel = d3.select(svg);
const scaleCol = d3.scaleLinear()
.domain([0, columns])
.range([0, columns * size]);
const scaleRow = d3.scaleLinear()
.domain([0, dataLength / columns])
.range([0, height]);
const join = sel.selectAll('g')
.data(data)
.join('g').append('g')
.attr('transform', (d, i) => {
const x = i % columns
const y = Math.floor(i / columns)
return `translate(${scaleCol(x)}, ${scaleRow(y)})`
});
join.append('path')
.attr("d", (d, i) => (value < (i+1)/dataLength) ? crossPath : manPath)
.attr('width', squareSize)
.attr('height', squareSize)
.attr('stroke-width', strokeWidth)
.attr('stroke', (d, i) => (value < (i+1)/dataLength) ? squareBgd : squareCol)
.attr('fill', (d, i) => (value < (i+1)/dataLength) ? squareBgd : squareCol)
.attr('transform', (d, i) => "scale("+shapeScale+")");
return svg;
}