Fix linear scale stacked mode

This commit is contained in:
Evert Timberg 2016-01-24 09:22:28 -05:00
parent 0ed39c9fd7
commit 68ab74a46d

View File

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