From aefe4e729b2d14efe6e8c0db359cb0e9aa6aae52 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Tue, 2 Apr 2013 17:34:29 -0400 Subject: [PATCH] Round text coordinates consistently. The core implementation used parseInt, which was originally to catch text values, but really only stayed due to its side-effect of flooring the values. The canvas implementation has never rounded coordinates. This led to various one-pixel rendering glitches between the two implementations. I've fixed the problem by consistently rounding coordinates to the nearest whole number. --- jquery.flot.canvas.js | 2 +- jquery.flot.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.flot.canvas.js b/jquery.flot.canvas.js index 8a9557a..d9671d5 100644 --- a/jquery.flot.canvas.js +++ b/jquery.flot.canvas.js @@ -140,7 +140,7 @@ browser, but needs to redraw with canvas text when exporting as an image. y = Math.ceil(y - 2); } - context.fillText(line.text, linex, y); + context.fillText(line.text, Math.round(linex), Math.round(y)); y += line.height; } } diff --git a/jquery.flot.js b/jquery.flot.js index 4f21497..c5f11f9 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -385,8 +385,8 @@ Licensed under the MIT license. // Move the element to its final position within the container info.element.css({ - top: parseInt(y, 10), - left: parseInt(x, 10) + top: Math.round(y), + left: Math.round(x) }); };