this.min = null;
this.max = null;
- var positiveValues = [];
- var negativeValues = [];
-
if (this.options.stacked) {
+ var valuesPerType = {};
+
helpers.each(this.data.datasets, function(dataset) {
+ if (valuesPerType[dataset.type] === undefined) {
+ valuesPerType[dataset.type] = {
+ positiveValues: [],
+ negativeValues: [],
+ };
+ }
+
+ // Store these per type
+ var positiveValues = valuesPerType[dataset.type].positiveValues;
+ var negativeValues = valuesPerType[dataset.type].negativeValues;
+
if (helpers.isDatasetVisible(dataset) && (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id)) {
helpers.each(dataset.data, function(rawValue, index) {
}
}, this);
- var values = positiveValues.concat(negativeValues);
- this.min = helpers.min(values);
- this.max = helpers.max(values);
+ helpers.each(valuesPerType, function(valuesForType) {
+ var values = valuesForType.positiveValues.concat(valuesForType.negativeValues);
+ this.min = Math.min(this.min, helpers.min(values));
+ this.max = Math.max(this.max, helpers.max(values));
+ }, this);
} else {
helpers.each(this.data.datasets, function(dataset) {
var mockData = {
datasets: [{
yAxisID: scaleID,
- data: [10, 5, 0, -5, 78, -100]
+ data: [10, 5, 0, -5, 78, -100],
+ type: 'bar'
}, {
yAxisID: 'second scale',
data: [-1000, 1000],
}, {
yAxisID: scaleID,
- data: [150, 0, 0, -100, -10, 9]
+ data: [150, 0, 0, -100, -10, 9],
+ type: 'bar'
+ }, {
+ yAxisID: scaleID,
+ data: [10, 10, 10, 10, 10, 10],
+ type: 'line'
}]
};