(table)
| 11 | } |
| 12 | |
| 13 | function layoutTable(table) { |
| 14 | let alloc = {}; |
| 15 | table.forEach(function (row, rowIndex) { |
| 16 | let col = 0; |
| 17 | row.forEach(function (cell) { |
| 18 | cell.y = rowIndex; |
| 19 | // Avoid erroneous call to next() on first row |
| 20 | cell.x = rowIndex ? next(alloc, col) : col; |
| 21 | const rowSpan = cell.rowSpan || 1; |
| 22 | const colSpan = cell.colSpan || 1; |
| 23 | if (rowSpan > 1) { |
| 24 | for (let cs = 0; cs < colSpan; cs++) { |
| 25 | alloc[cell.x + cs] = rowSpan; |
| 26 | } |
| 27 | } |
| 28 | col = cell.x + colSpan; |
| 29 | }); |
| 30 | Object.keys(alloc).forEach((idx) => { |
| 31 | alloc[idx]--; |
| 32 | if (alloc[idx] < 1) delete alloc[idx]; |
| 33 | }); |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | function maxWidth(table) { |
| 38 | let mw = 0; |
no test coverage detected
searching dependent graphs…