Fix: beginAtZero for logarighmic (#7899)

This commit is contained in:
Jukka Kurkela 2020-10-16 17:32:37 +03:00 committed by GitHub
parent c9b38b63dc
commit ff811aaddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -77,6 +77,10 @@ export default class LogarithmicScale extends Scale {
me.min = isFinite(min) ? Math.max(0, min) : null;
me.max = isFinite(max) ? Math.max(0, max) : null;
if (me.options.beginAtZero) {
me._zero = true;
}
me.handleTickRangeOptions();
}
@ -159,7 +163,6 @@ export default class LogarithmicScale extends Scale {
me._startValue = log10(start);
me._valueRange = log10(me.max) - log10(start);
me._zero = me.options.beginAtZero;
}
getPixelForValue(value) {

View File

@ -345,7 +345,7 @@ describe('Logarithmic Scale tests', function() {
}
});
expect(chart.scales.y.min).toBe(1);
expect(chart.scales.y.min).toBe(0.1);
expect(chart.scales.y.max).toBe(200);
});
@ -387,7 +387,7 @@ describe('Logarithmic Scale tests', function() {
}
});
expect(chart.scales.y.min).toBe(1);
expect(chart.scales.y.min).toBe(0.1);
expect(chart.scales.y.max).toBe(200);
});
@ -517,7 +517,7 @@ describe('Logarithmic Scale tests', function() {
type: 'bar',
data: {
datasets: [{
data: [10, 5, 1, 25, 78]
data: [10, 5, 2, 25, 78]
}],
labels: []
},
@ -659,7 +659,7 @@ describe('Logarithmic Scale tests', function() {
type: 'bar',
data: {
datasets: [{
data: [10, 5, 1, 25, 78]
data: [10, 5, 2, 25, 78]
}],
labels: []
},