From bc0bafcee7d8193bc534a08ddc274871c04dbfd3 Mon Sep 17 00:00:00 2001 From: jcopperfield <33193571+jcopperfield@users.noreply.github.com> Date: Tue, 14 Nov 2017 13:56:45 +0100 Subject: [PATCH] Fix bumpy line on smooth data set (#4944) Linear scale getPixelForValue() method doesn't round the returned value anymore. --- src/scales/scale.linear.js | 7 +++---- test/specs/core.controller.tests.js | 4 ++-- test/specs/core.tooltip.tests.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 94ebd12a5a0..aa723004fb7 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 3ec8da50b76..b2615f14eec 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 c0a162968b1..8878d9d9dbc 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',