Skip to content

Commit 9fff27a

Browse files
authored
Merge pull request #1708 from lqd/future-region
Show future dates in noise chart as shaded region
2 parents 2f20131 + 3434d44 commit 9fff27a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

site/frontend/src/pages/compare/compile/table/benchmark-detail.vue

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,21 @@ function getGraphRange(artifact: ArtifactDescription): GraphRange {
7474
}
7575
7676
/**
77-
* Hook into the uPlot drawing machinery to draw a vertical line at the
78-
* position of the given `date`.
77+
* Hook into the uPlot drawing machinery to draw a rectangle from the `date` to
78+
* the end of the plot, representing the region that is the date's future.
7979
*/
8080
function drawCurrentDate(opts: GraphRenderOpts, date: Date) {
8181
opts.hooks = {
8282
drawSeries: (u: uPlot) => {
8383
let ctx = u.ctx;
84-
ctx.save();
85-
86-
const y0 = u.bbox.top;
87-
const y1 = y0 + u.bbox.height;
8884
const x = u.valToPos(date.getTime() / 1000, "x", true);
8985
90-
ctx.beginPath();
91-
ctx.moveTo(x, y0);
92-
ctx.strokeStyle = "red";
93-
ctx.setLineDash([5, 5]);
94-
ctx.lineTo(x, y1);
95-
ctx.stroke();
96-
86+
// Draw a translucent rectangle representing the region that is more
87+
// recent than `date`.
88+
ctx.save();
89+
ctx.fillStyle = "rgba(0, 0, 0, 0.07)";
90+
ctx.rect(x, u.bbox.top, u.bbox.width - x + u.bbox.left, u.bbox.height);
91+
ctx.fill();
9792
ctx.restore();
9893
},
9994
};
@@ -127,7 +122,7 @@ function getGraphTitle() {
127122
const {start, end, date} = graphRange.value;
128123
const msg = `${DAY_RANGE} day history`;
129124
if (date !== null) {
130-
return `${msg} (${start} - ${end})`;
125+
return `${msg} (${start} ${end})`;
131126
} else {
132127
return `${msg} (up to benchmarked commit)`;
133128
}
@@ -212,6 +207,10 @@ onMounted(() => renderGraph());
212207
<div style="font-size: 0.8em">
213208
Each plotted value is relative to its previous commit
214209
</div>
210+
<div style="font-size: 0.8em">
211+
The shaded region shows values that are more recent than the
212+
benchmarked commit
213+
</div>
215214
</div>
216215
<div ref="chartElement"></div>
217216
</div>

0 commit comments

Comments
 (0)