Skip to content

Commit 7ec5120

Browse files
authored
Fix jaegertracing#76 trace mini-map blurry when < 60 spans (jaegertracing#77)
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
1 parent eeead13 commit 7ec5120

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/components/TracePage/SpanGraph/render-into-canvas.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,26 @@
2222

2323
const CV_WIDTH = 4000;
2424
const MIN_WIDTH = 50;
25+
const MIN_TOTAL_HEIGHT = 60;
2526

2627
export default function renderIntoCanvas(
2728
canvas: HTMLCanvasElement,
2829
items: { valueWidth: number, valueOffset: number, serviceName: string }[],
2930
totalValueWidth: number,
3031
getFillColor: string => string
3132
) {
32-
// eslint-disable-next-line no-param-reassign
33+
// eslint-disable-next-line no-param-reassign
3334
canvas.width = CV_WIDTH;
34-
// eslint-disable-next-line no-param-reassign
35-
canvas.height = items.length;
35+
let itemHeight = 1;
36+
if (items.length < MIN_TOTAL_HEIGHT) {
37+
// eslint-disable-next-line no-param-reassign
38+
canvas.height = MIN_TOTAL_HEIGHT;
39+
itemHeight = MIN_TOTAL_HEIGHT / items.length;
40+
} else {
41+
// eslint-disable-next-line no-param-reassign
42+
canvas.height = items.length;
43+
itemHeight = 1;
44+
}
3645
const ctx = canvas.getContext('2d');
3746
for (let i = 0; i < items.length; i++) {
3847
const { valueWidth, valueOffset, serviceName } = items[i];
@@ -44,6 +53,6 @@ export default function renderIntoCanvas(
4453
width = MIN_WIDTH;
4554
}
4655
ctx.fillStyle = getFillColor(serviceName);
47-
ctx.fillRect(x, i, width, 1);
56+
ctx.fillRect(x, i * itemHeight, width, itemHeight);
4857
}
4958
}

0 commit comments

Comments
 (0)