From: jcopperfield <33193571+jcopperfield@users.noreply.github.com> Date: Tue, 14 Nov 2017 12:56:45 +0000 (+0100) Subject: Fix bumpy line on smooth data set (#4944) X-Git-Tag: v2.7.2~1^2~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e080e782ab44f34d2bcd63ad6255f48bac2292ea;p=thirdparty%2FChart.js.git Fix bumpy line on smooth data set (#4944) Linear scale getPixelForValue() method doesn't round the returned value anymore. --- diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 94ebd12a5..aa723004f 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -170,11 +170,10 @@ module.exports = function(Chart) { if (me.isHorizontal()) { pixel = me.left + (me.width / range * (rightValue - start)); - return Math.round(pixel); + } else { + pixel = me.bottom - (me.height / range * (rightValue - start)); } - - pixel = me.bottom - (me.height / range * (rightValue - start)); - return Math.round(pixel); + return pixel; }, getValueForPixel: function(pixel) { var me = this; diff --git a/test/specs/core.controller.tests.js b/test/specs/core.controller.tests.js index 3ec8da50b..b2615f14e 100644 --- a/test/specs/core.controller.tests.js +++ b/test/specs/core.controller.tests.js @@ -759,8 +759,8 @@ describe('Chart', function() { // Verify that points are at their initial correct location, // then we will reset and see that they moved - expect(meta.data[0]._model.y).toBe(333); - expect(meta.data[1]._model.y).toBe(183); + expect(meta.data[0]._model.y).toBeCloseToPixel(333); + expect(meta.data[1]._model.y).toBeCloseToPixel(183); expect(meta.data[2]._model.y).toBe(32); expect(meta.data[3]._model.y).toBe(484); diff --git a/test/specs/core.tooltip.tests.js b/test/specs/core.tooltip.tests.js index c0a162968..8878d9d9d 100755 --- a/test/specs/core.tooltip.tests.js +++ b/test/specs/core.tooltip.tests.js @@ -764,7 +764,7 @@ describe('Core.Tooltip', function() { it('Should not update if active element has not changed', function() { var chart = window.acquireChart({ - type: 'bar', + type: 'line', data: { datasets: [{ label: 'Dataset 1',