]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix bumpy line on smooth data set (#4944)
authorjcopperfield <33193571+jcopperfield@users.noreply.github.com>
Tue, 14 Nov 2017 12:56:45 +0000 (13:56 +0100)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Tue, 14 Nov 2017 12:56:45 +0000 (13:56 +0100)
Linear scale getPixelForValue() method doesn't round the returned value anymore.

src/scales/scale.linear.js
test/specs/core.controller.tests.js
test/specs/core.tooltip.tests.js

index 94ebd12a5a01a819c4a0ac4ddd8f6d8198454741..aa723004fb7327f85ffdcec9bbf975e0e71f4bd8 100644 (file)
@@ -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;
index 3ec8da50b76c5d9f67276b05395a4f7f484614f8..b2615f14eec78bb7ff2199760b9d618ae4daf885 100644 (file)
@@ -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);
 
index c0a162968b183c00326e6a7fe11e1265a5602b29..8878d9d9dbcc2ceaa6fa666f68cf775d2753cbc5 100755 (executable)
@@ -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',