function barChartLayout(points, pointWidth, pointMargin = 1) {
const pointWithMargin = pointWidth + pointMargin
const pointsPerLayer = 28
let xOffset = 0
for (let color of distinctColors) {
const currentPoints = points.filter(p => p.color === color)
let rowIndex = 0
let verticalIndex = 0
for (let i = 0; i < currentPoints.length; i++) {
const point = currentPoints[i]
if (i !== 0 && i % pointsPerLayer === 0) {
rowIndex = 0
verticalIndex++
}
point.x = xOffset + (rowIndex * pointWithMargin)
point.y = verticalIndex * pointWithMargin
rowIndex++
}
const barWidth = pointWithMargin * pointsPerLayer
xOffset += barWidth + 5
}
}