Skip to content

Commit

Permalink
Fix bumpy line on smooth data set (#4944)
Browse files Browse the repository at this point in the history
Linear scale getPixelForValue() method doesn't round the returned value anymore.
  • Loading branch information
jcopperfield authored and simonbrunel committed Nov 14, 2017
1 parent 447ca40 commit e080e78
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/scales/scale.linear.js
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/specs/core.controller.tests.js
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/specs/core.tooltip.tests.js
Expand Up @@ -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',
Expand Down

0 comments on commit e080e78

Please sign in to comment.