Skip to content

Commit 54ef564

Browse files
committed
ci: refactor: Create textY
1 parent f6e9358 commit 54ef564

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ci/github-actions/illustrate-benchmark-reports.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ function renderReport(report: Report) {
3535
const shapes = report.results.map((unit, index) => ({
3636
...unit,
3737
index,
38-
y: index * rowHeight,
3938
labelX: padding,
4039
barX: padding + labelColumnWidth + padding,
4140
numberX: padding + labelColumnWidth + padding + barColumnWidth + padding,
41+
textY: (index + 0.8) * rowHeight,
42+
barY: index * rowHeight,
4243
labelWidth: unit.command.length * charWidth,
4344
barWidth: Math.round(unit.mean * barColumnWidth / maxValue),
4445
numberContent: String(unit.mean).slice(0, numberLength - 1) + 's',
4546
}))
46-
const labels = shapes.map(({ command, y, labelX, labelWidth }) =>
47+
const labels = shapes.map(({ command, labelX, textY, labelWidth }) =>
4748
svg`<text
4849
x=${labelX}
49-
y=${y + rowHeight * 0.8}
50+
y=${textY}
5051
width=${labelWidth}
5152
height=${rowHeight}
5253
textLength=${labelWidth}
@@ -55,19 +56,19 @@ function renderReport(report: Report) {
5556
font-family=${fontFamily}
5657
>${command}</text>`
5758
)
58-
const bars = shapes.map(({ y, index, barX, barWidth }) =>
59+
const bars = shapes.map(({ index, barX, barY, barWidth }) =>
5960
svg`<rect
6061
x=${barX}
61-
y=${y}
62+
y=${barY}
6263
width=${barWidth}
6364
height=${rowHeight}
6465
fill=${getBarColor(index)}
6566
/>`
6667
)
67-
const numbers = shapes.map(({ y, numberX, numberContent }) =>
68+
const numbers = shapes.map(({ numberX, textY, numberContent }) =>
6869
svg`<text
6970
x=${numberX}
70-
y=${y + rowHeight * 0.8}
71+
y=${textY}
7172
width=${numberColumnWidth}
7273
height=${rowHeight}
7374
fill=${textColor}

0 commit comments

Comments
 (0)