Skip to content

Commit

Permalink
Merge pull request jaegertracing#372 from rubenvp8510/Issue-370
Browse files Browse the repository at this point in the history
Limit the thickness of spans in the minimap
Signed-off-by: vvvprabhakar <[email protected]>
  • Loading branch information
tiffon authored Apr 24, 2019
2 parents 171cbb0 + a5c5ba9 commit de7ea8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import renderIntoCanvas, {
MAX_TOTAL_HEIGHT,
MIN_ITEM_WIDTH,
MIN_TOTAL_HEIGHT,
MAX_ITEM_HEIGHT,
} from './render-into-canvas';

const getCanvasWidth = () => window.innerWidth * 2;
Expand Down Expand Up @@ -124,16 +125,19 @@ describe('renderIntoCanvas()', () => {
{ input: items[1].serviceName, output: [1, 1, 1] },
{ input: items[2].serviceName, output: [2, 2, 2] },
];
const cHeight =
items.length < MIN_TOTAL_HEIGHT ? MIN_TOTAL_HEIGHT : Math.min(items.length, MAX_TOTAL_HEIGHT);

const expectedDrawings = [
getBgFillRect(),
...items.map((item, i) => {
const { valueWidth, valueOffset } = item;
const color = expectedColors[i].output;
const fillStyle = `rgba(${color.concat(ITEM_ALPHA).join()})`;
const height = MIN_TOTAL_HEIGHT / items.length;
const height = Math.min(MAX_ITEM_HEIGHT, Math.max(MIN_ITEM_HEIGHT, cHeight / items.length));
const width = valueWidth / totalValueWidth * getCanvasWidth();
const x = valueOffset / totalValueWidth * getCanvasWidth();
const y = height * i;
const y = cHeight / items.length * i;
return { fillStyle, height, width, x, y };
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const MIN_ITEM_HEIGHT = 2;
export const MAX_TOTAL_HEIGHT = 200;
export const MIN_ITEM_WIDTH = 10;
export const MIN_TOTAL_HEIGHT = 60;
export const MAX_ITEM_HEIGHT = 6;

export default function renderIntoCanvas(
canvas: HTMLCanvasElement,
Expand All @@ -36,7 +37,7 @@ export default function renderIntoCanvas(
canvas.width = cWidth;
// eslint-disable-next-line no-param-reassign
canvas.height = cHeight;
const itemHeight = Math.max(MIN_ITEM_HEIGHT, cHeight / items.length);
const itemHeight = Math.min(MAX_ITEM_HEIGHT, Math.max(MIN_ITEM_HEIGHT, cHeight / items.length));
const itemYChange = cHeight / items.length;

const ctx = canvas.getContext('2d', { alpha: false }) as CanvasRenderingContext2D;
Expand Down

0 comments on commit de7ea8a

Please sign in to comment.