Fix bumpy line on smooth data set (#4944)

Linear scale getPixelForValue() method doesn't round the returned value anymore.
This commit is contained in:
jcopperfield 2017-11-14 13:56:45 +01:00 committed by Simon Brunel
parent 447ca40a7f
commit e080e782ab
3 changed files with 6 additions and 7 deletions

View 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;

View 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);

View File

@ -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',