data = {
const entriesByCol = []
_.range(0, numCols).map(j => {
const heights = distributeRandomly(maxSizeHeight, numRows, 0.01)
_.range(0, numRows).map(i => {
const entry = { id:`${i}${j}`, row: i, col: j, height: heights[i] }
entriesByCol.push(entry)
})
})
const entriesByRow = []
_.range(0, numRows).map(i => {
const widths = distributeRandomly(maxSizeWidth, numCols, 0.1)
_.range(0, numCols).map(j => {
const entry = { id:`${i}${j}`, row: i, col: j, width: widths[j] }
entriesByRow.push(entry)
})
})
let entries = _({})
.merge(
_(entriesByCol).groupBy("id").value(),
_(entriesByRow).groupBy("id").value()
)
.values()
.flatten()
.value();
entries = _.sortBy(entries, d => d.col)
entries.forEach((entry, i) => {
const row = entry.row
const col = entry.col
const fill = chromaColScale[i]
entry.fill = fill
if (col > 0) {
const x = _.sumBy(_.filter(entries, d => d.row === row && d.col < col), d => d.width)
entry.x = x
} else {
entry.x = 0
}
if (row > 0) {
const y = _.sumBy(_.filter(entries, d => d.col === col && d.row < row), d => d.height)
entry.y = y
} else {
entry.y = 0
}
})
return entries
}