mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-11 18:56:49 +01:00
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:
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user