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));
+ var minVal = helpers.min(values);
+ var maxVal = helpers.max(values);
+ this.min = this.min === null ? minVal : Math.min(this.min, minVal);
+ this.max = this.max === null ? maxVal : Math.max(this.max, maxVal);
}, this);
} else {
this.min = null;
this.max = null;
- var values = [];
-
if (this.options.stacked) {
+ var valuesPerType = {};
+
helpers.each(this.data.datasets, function(dataset) {
if (helpers.isDatasetVisible(dataset) && (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id)) {
- helpers.each(dataset.data, function(rawValue, index) {
+ if (valuesPerType[dataset.type] === undefined) {
+ valuesPerType[dataset.type] = [];
+ }
+ helpers.each(dataset.data, function(rawValue, index) {
+ var values = valuesPerType[dataset.type];
var value = this.getRightValue(rawValue);
if (isNaN(value)) {
return;
}
}, this);
- this.min = helpers.min(values);
- this.max = helpers.max(values);
+ helpers.each(valuesPerType, function(valuesForType) {
+ var minVal = helpers.min(valuesForType);
+ var maxVal = helpers.max(valuesForType);
+ this.min = this.min === null ? minVal : Math.min(this.min, minVal);
+ this.max = this.max === null ? maxVal : Math.max(this.max, maxVal);
+ }, this);
} else {
helpers.each(this.data.datasets, function(dataset) {
var mockData = {
datasets: [{
yAxisID: scaleID,
- data: [10, 5, 1, 5, 78, 100]
+ data: [10, 5, 1, 5, 78, 100],
+ type: 'bar'
}, {
yAxisID: 'second scale',
data: [-1000, 1000],
}, {
yAxisID: scaleID,
- data: [150, 10, 10, 100, 10, 9]
+ data: [150, 10, 10, 100, 10, 9],
+ type: 'bar'
+ }, {
+ yAxisID: scaleID,
+ data: [100, 100, 100, 100, 100, 100],
+ type: 'line'
}]
};
var mockData = {
datasets: [{
yAxisID: scaleID,
- data: [10, 5, 1, 5, 78, 100]
+ data: [10, 5, 1, 5, 78, 100],
+ type: 'bar'
}, {
yAxisID: 'second scale',
data: [-1000, 1000],
+ type: 'bar'
}, {
yAxisID: scaleID,
- data: [150, 10, 10, 100, 10, 9]
+ data: [150, 10, 10, 100, 10, 9],
+ type: 'bar'
}, {
yAxisID: scaleID,
data: [10000, 10000, 10000, 10000, 10000, 10000],
- hidden: true
+ hidden: true,
+ type: 'bar'
}]
};