function getHexPos(index, total, w, h, r, spacing, margin) {
const verticalHexSeparation = Math.sqrt(0.75)
let colCount = Math.floor((w - margin.left - margin.right) / (2 * r + spacing))
colCount = colCount - 1
if (colCount === 0) colCount = 1
const row = Math.floor(index / colCount)
const reset = (colCount * ((2 * r) + spacing)) * row
const center = margin.left
let xPos = (margin.left + ((2 * r) * index + r) + (spacing * index)) - reset
const yPos = margin.top + r + (row * ((r * 2) + spacing) * verticalHexSeparation)
if (row % 2 != 0) xPos = xPos - (r + (spacing / 2))
const rows = Math.ceil(total / colCount)
const stackHeight = (margin.top + margin.bottom + (2 * r) + (rows * ((2 * r) + spacing))) * verticalHexSeparation
return {"x": xPos + center, "y": yPos, "h": stackHeight}
}