Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/components/TracePage/SpanGraph/render-into-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@

const CV_WIDTH = 4000;
const MIN_WIDTH = 50;
const MIN_TOTAL_HEIGHT = 60;

export default function renderIntoCanvas(
canvas: HTMLCanvasElement,
items: { valueWidth: number, valueOffset: number, serviceName: string }[],
totalValueWidth: number,
getFillColor: string => string
) {
// eslint-disable-next-line no-param-reassign
// eslint-disable-next-line no-param-reassign
canvas.width = CV_WIDTH;
// eslint-disable-next-line no-param-reassign
canvas.height = items.length;
let itemHeight = 1;
if (items.length < MIN_TOTAL_HEIGHT) {
// eslint-disable-next-line no-param-reassign
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just relax this rule in eslint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually like this rule quite a lot.

canvas.height = MIN_TOTAL_HEIGHT;
itemHeight = MIN_TOTAL_HEIGHT / items.length;
} else {
// eslint-disable-next-line no-param-reassign
canvas.height = items.length;
itemHeight = 1;
}
const ctx = canvas.getContext('2d');
for (let i = 0; i < items.length; i++) {
const { valueWidth, valueOffset, serviceName } = items[i];
Expand All @@ -44,6 +53,6 @@ export default function renderIntoCanvas(
width = MIN_WIDTH;
}
ctx.fillStyle = getFillColor(serviceName);
ctx.fillRect(x, i, width, 1);
ctx.fillRect(x, i * itemHeight, width, itemHeight);
}
}