mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 20:59:08 +02:00
Fix linear scale stacked mode
This commit is contained in:
parent
0ed39c9fd7
commit
68ab74a46d
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
if (this.options.stacked) {
|
if (this.options.stacked) {
|
||||||
var valuesPerType = {};
|
var valuesPerType = {};
|
||||||
|
var hasPositiveValues = false;
|
||||||
var hasNegativeValues = false;
|
var hasNegativeValues = false;
|
||||||
|
|
||||||
helpers.each(this.chart.data.datasets, function(dataset) {
|
helpers.each(this.chart.data.datasets, function(dataset) {
|
||||||
@ -75,6 +76,7 @@
|
|||||||
hasNegativeValues = true;
|
hasNegativeValues = true;
|
||||||
negativeValues[index] += value;
|
negativeValues[index] += value;
|
||||||
} else {
|
} else {
|
||||||
|
hasPositiveValues = true;
|
||||||
positiveValues[index] += value;
|
positiveValues[index] += value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
helpers.each(valuesPerType, function(valuesForType) {
|
helpers.each(valuesPerType, function(valuesForType) {
|
||||||
var values = hasNegativeValues ? valuesForType.positiveValues.concat(valuesForType.negativeValues) : valuesForType.positiveValues;
|
var values = hasPositiveValues ? hasNegativeValues ? valuesForType.positiveValues.concat(valuesForType.negativeValues) : valuesForType.positiveValues : valuesForType.negativeValues;
|
||||||
var minVal = helpers.min(values);
|
var minVal = helpers.min(values);
|
||||||
var maxVal = helpers.max(values)
|
var maxVal = helpers.max(values)
|
||||||
this.min = this.min === null ? minVal : Math.min(this.min, minVal);
|
this.min = this.min === null ? minVal : Math.min(this.min, minVal);
|
||||||
|
Loading…
Reference in New Issue
Block a user