fix canvas clearRect size calculation (#8328)

Co-authored-by: Marcel Samyn <marcel.samyn@lab900.com>
This commit is contained in:
Marcel Samyn 2021-01-18 14:59:13 +01:00 committed by GitHub
parent 06fa8a4c98
commit ff19ea4be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,7 +113,13 @@ export function _alignPixel(chart, pixel, width) {
*/
export function clearCanvas(canvas, ctx) {
ctx = ctx || canvas.getContext('2d');
ctx.save();
// canvas.width and canvas.height do not consider the canvas transform,
// while clearRect does
ctx.resetTransform();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.restore();
}
export function drawPoint(ctx, options, x, y) {