Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trace mini-map blurry when < 60 spans #77

Merged
merged 1 commit into from
Sep 21, 2017
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
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
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);
}
}