Skip to content

Commit

Permalink
Incorrect conversion of number to boolean
Browse files Browse the repository at this point in the history
Check for min/max/stepSize coerces numbers to truthy values. A min setting of 0 is therefore interpreted as not being set.

Checking against undefined means settings are correctly detected.
  • Loading branch information
teroman authored Jan 30, 2018
1 parent e61392a commit 7a6183c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/scales/scale.linearbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function generateTicks(generationOptions, dataRange) {
var niceMax = Math.ceil(dataRange.max / spacing) * spacing;

// If min, max and stepSize is set and they make an evenly spaced scale use it.
if (generationOptions.min && generationOptions.max && generationOptions.stepSize) {
if (generationOptions.min !== undefined && generationOptions.max !== undefined && generationOptions.stepSize !== undefined) {
// If very close to our whole number, use it.
if (helpers.almostWhole((generationOptions.max - generationOptions.min) / generationOptions.stepSize, spacing / 1000)) {
niceMin = generationOptions.min;
Expand Down

0 comments on commit 7a6183c

Please sign in to comment.