sparkline: fix subpixel rounding gaps between bars
This commit is contained in:
parent
946c3a61d7
commit
85e62c6eeb
1 changed files with 3 additions and 1 deletions
|
|
@ -142,10 +142,12 @@ Canvas {
|
||||||
if (hasCF)
|
if (hasCF)
|
||||||
ctx.fillStyle = colorFunction(d[i]).toString();
|
ctx.fillStyle = colorFunction(d[i]).toString();
|
||||||
const [bx, bw] = xOf(i);
|
const [bx, bw] = xOf(i);
|
||||||
|
const x0 = Math.floor(bx);
|
||||||
|
const x1 = Math.floor(bx + bw);
|
||||||
const dy = yOf(d[i]);
|
const dy = yOf(d[i]);
|
||||||
const barTop = Math.min(dy, zy);
|
const barTop = Math.min(dy, zy);
|
||||||
const barH = Math.max(1, Math.abs(dy - zy));
|
const barH = Math.max(1, Math.abs(dy - zy));
|
||||||
ctx.fillRect(bx, barTop, Math.ceil(bw), barH);
|
ctx.fillRect(x0, barTop, Math.max(1, x1 - x0), barH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue