Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore invalid log scale min and max #6058

Merged
merged 7 commits into from Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/scales/scale.logarithmic.js
Expand Up @@ -174,8 +174,8 @@ module.exports = Scale.extend({
var DEFAULT_MIN = 1;
var DEFAULT_MAX = 10;

me.min = valueOrDefault(tickOpts.min, me.min);
me.max = valueOrDefault(tickOpts.max, me.max);
me.min = tickOpts.min >= 0 ? tickOpts.min : me.min;
benmccann marked this conversation as resolved.
Show resolved Hide resolved
me.max = tickOpts.max >= 0 ? tickOpts.max : me.max;

if (me.min === me.max) {
if (me.min !== 0 && me.min !== null) {
Expand Down Expand Up @@ -211,8 +211,8 @@ module.exports = Scale.extend({
var reverse = !me.isHorizontal();

var generationOptions = {
min: tickOpts.min,
max: tickOpts.max
min: tickOpts.min >= 0 ? tickOpts.min : undefined,
max: tickOpts.max >= 0 ? tickOpts.max : undefined
};
var ticks = me.ticks = generateTicks(generationOptions, me);

Expand Down
31 changes: 31 additions & 0 deletions test/specs/scale.logarithmic.tests.js
Expand Up @@ -477,6 +477,37 @@ describe('Logarithmic Scale tests', function() {
expect(yScale.ticks[tickCount - 1]).toBe(10);
});

it('should ignore invalid min and max options', function() {
var chart = window.acquireChart({
type: 'bar',
data: {
datasets: [{
data: [1, 1, 1, 2, 1, 0]
}],
labels: []
},
options: {
scales: {
yAxes: [{
id: 'yScale',
type: 'logarithmic',
ticks: {
min: -10,
max: -1010,
callback: function(value) {
return value;
}
}
}]
}
}
});

var yScale = chart.scales.yScale;
expect(yScale.min).toBe(0);
expect(yScale.max).toBe(2);
});

it('should generate tick marks', function() {
var chart = window.acquireChart({
type: 'bar',
Expand Down