Skip to content

Commit

Permalink
Merge branch 'master' into issue-44-configurable-header-links
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffon committed Sep 21, 2017
2 parents 4e2e98b + 5162309 commit c2b800a
Showing 1 changed file with 13 additions and 4 deletions.
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
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);
}
}

0 comments on commit c2b800a

Please sign in to comment.