Skip to content

Commit 16643fc

Browse files
- FIX: Fixed small issues in print/overview canvas for sparse trials.
1 parent faa71dd commit 16643fc

1 file changed

Lines changed: 32 additions & 29 deletions

File tree

src/components/data/PrintCanvas.vue

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
136136
function plotCells (ctx: CanvasRenderingContext2D, trialData: { [key: string]: CellPlus }) {
137137
ctx.fillStyle = '#ffffff'
138-
ctx.fillRect(0, 0, config.totalWidth, config.totalHeight)
138+
ctx.fillRect(0, 0, config.totalWidth + config.paddingLeft, config.totalHeight + config.paddingTop)
139139
140140
for (let r = 0; r < compProps.trial.layout.rows; r++) {
141141
ctx.fillStyle = '#ffffff'
@@ -165,36 +165,39 @@
165165
ctx.fillText(str, x + config.cellWidth / 2, config.paddingTop / 2)
166166
}
167167
168-
Object.values(trialData).forEach(td => {
169-
const row = td.row || 0
170-
const column = td.column || 0
168+
for (let row = 0; row < compProps.trial.layout.rows; row++) {
169+
for (let column = 0; column < compProps.trial.layout.columns; column++) {
170+
let count = 0
171+
// Determine the background color
172+
if (row % 2 === 0) {
173+
count++
174+
}
175+
if (column % 2 === 0) {
176+
count++
177+
}
178+
switch (count) {
179+
case 0:
180+
ctx.fillStyle = '#ffffff'
181+
break
182+
case 1:
183+
ctx.fillStyle = '#f2f2f2'
184+
break
185+
default:
186+
ctx.fillStyle = '#e0e0e0'
187+
break
188+
}
171189
172-
let count = 0
173-
// Determine the background color
174-
if (row % 2 === 0) {
175-
count++
176-
}
177-
if (column % 2 === 0) {
178-
count++
179-
}
180-
switch (count) {
181-
case 0:
182-
ctx.fillStyle = '#ffffff'
183-
break
184-
case 1:
185-
ctx.fillStyle = '#f2f2f2'
186-
break
187-
default:
188-
ctx.fillStyle = '#e0e0e0'
189-
break
190-
}
190+
const x = column * config.cellWidth + config.paddingLeft
191+
const y = row * config.cellHeight + config.paddingTop
192+
ctx.fillRect(x, y, config.cellWidth, config.cellHeight)
191193
192-
const x = column * config.cellWidth + config.paddingLeft
193-
const y = row * config.cellHeight + config.paddingTop
194-
ctx.fillRect(x, y, config.cellWidth, config.cellHeight)
195-
ctx.fillStyle = 'black'
196-
ctx.fillText(td.displayName || '', x + config.cellWidth / 2, y + config.cellHeight / 2)
197-
})
194+
const td = trialData[`${row}|${column}`]
195+
if (td) {
196+
ctx.fillStyle = 'black'
197+
ctx.fillText(td.displayName || '', x + config.cellWidth / 2, y + config.cellHeight / 2)
198+
}
199+
}
200+
}
198201
199202
ctx.strokeRect(0, 0, config.totalWidth + config.paddingLeft - 1, config.totalHeight + config.paddingTop - 1)
200203
}

0 commit comments

Comments
 (0)