Use the correct base for linear scales. This gives the correct fill for lines and animations start at the correct point

This commit is contained in:
Evert Timberg
2015-06-08 19:03:47 -04:00
parent 24d32e9321
commit 2bddccaaf0
3 changed files with 31 additions and 3 deletions

View File

@@ -232,6 +232,15 @@
// Update the lines
this.eachDataset(function(dataset, datasetIndex) {
var yScale = this.scales[dataset.yAxisID];
var scaleBase;
if (yScale.min < 0 && yScale.max < 0) {
scaleBase = yScale.getPixelForValue(yScale.max);
} else if (yScale.min > 0 && yScale.max > 0) {
scaleBase = yScale.getPixelForValue(yScale.min);
} else {
scaleBase = yScale.getPixelForValue(0);
}
helpers.extend(dataset.metaDataset, {
// Utility
@@ -252,7 +261,7 @@
// Scale
scaleTop: yScale.top,
scaleBottom: yScale.bottom,
scaleZero: yScale.getPixelForValue(0),
scaleZero: scaleBase,
},
});

View File

@@ -192,6 +192,16 @@
// Update the lines
this.eachDataset(function(dataset, datasetIndex) {
var scaleBase;
if (this.scale.min < 0 && this.scale.max < 0) {
scaleBase = this.scale.getPointPosition(0, this.scale.max);
} else if (this.scale.min > 0 && this.scale.max > 0) {
scaleBase = this.scale.getPointPosition(0, this.scale.min);
} else {
scaleBase = this.scale.getPointPosition(0, 0);
}
helpers.extend(dataset.metaDataset, {
// Utility
_datasetIndex: datasetIndex,
@@ -213,7 +223,7 @@
// Scale
scaleTop: this.scale.top,
scaleBottom: this.scale.bottom,
scaleZero: this.scale.getPointPosition(0),
scaleZero: scaleBase,
},
});

View File

@@ -241,6 +241,15 @@
// Update the lines
this.eachDataset(function(dataset, datasetIndex) {
var yScale = this.scales[dataset.yAxisID];
var scaleBase;
if (yScale.min < 0 && yScale.max < 0) {
scaleBase = yScale.getPixelForValue(yScale.max);
} else if (yScale.min > 0 && yScale.max > 0) {
scaleBase = yScale.getPixelForValue(yScale.min);
} else {
scaleBase = yScale.getPixelForValue(0);
}
helpers.extend(dataset.metaDataset, {
// Utility
@@ -261,7 +270,7 @@
// Scale
scaleTop: yScale.top,
scaleBottom: yScale.bottom,
scaleZero: yScale.getPixelForValue(0),
scaleZero: scaleBase,
},
});