Skip to content

Commit ef226c7

Browse files
committed
requested changes
1 parent 363c295 commit ef226c7

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/scales/scale.linearbase.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var helpers = require('../helpers/index');
44
var Scale = require('../core/core.scale');
55

66
var noop = helpers.noop;
7+
var isNullOrUndef = helpers.isNullOrUndef;
78

89
/**
910
* Generate a set of linear ticks
@@ -17,25 +18,20 @@ function generateTicks(generationOptions, dataRange) {
1718
// "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
1819
// for details.
1920

20-
// Minimum spacing between ticks
2121
var MIN_SPACING = 1e-14;
2222
var stepSize = generationOptions.stepSize;
2323
var unit = stepSize || 1;
2424
var maxNumSpaces = generationOptions.maxTicks - 1;
2525
var min = generationOptions.min;
2626
var max = generationOptions.max;
2727
var precision = generationOptions.precision;
28-
var spacing, factor, niceMin, niceMax, numSpaces;
29-
3028
var rmin = dataRange.min;
3129
var rmax = dataRange.max;
32-
var isNullOrUndef = helpers.isNullOrUndef;
33-
34-
// spacing is set to a nice number of the dataRange divided by maxNumSpaces.
35-
// stepSize is used as a minimum unit if it is specified.
36-
spacing = helpers.niceNum((rmax - rmin) / maxNumSpaces / unit) * unit;
30+
var spacing = helpers.niceNum((rmax - rmin) / maxNumSpaces / unit) * unit;
31+
var factor, niceMin, niceMax, numSpaces;
3732

38-
// In case of really small numbers and min / max are undefined, default to rmin / rmax
33+
// Beyond MIN_SPACING floating point numbers being to lose precision
34+
// such that we can't do the math necessary to generate ticks
3935
if (spacing < MIN_SPACING && isNullOrUndef(min) && isNullOrUndef(max)) {
4036
return [rmin, rmax];
4137
}

0 commit comments

Comments
 (0)