@@ -4,6 +4,7 @@ var helpers = require('../helpers/index');
4
4
var Scale = require ( '../core/core.scale' ) ;
5
5
6
6
var noop = helpers . noop ;
7
+ var isNullOrUndef = helpers . isNullOrUndef ;
7
8
8
9
/**
9
10
* Generate a set of linear ticks
@@ -17,25 +18,20 @@ function generateTicks(generationOptions, dataRange) {
17
18
// "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
18
19
// for details.
19
20
20
- // Minimum spacing between ticks
21
21
var MIN_SPACING = 1e-14 ;
22
22
var stepSize = generationOptions . stepSize ;
23
23
var unit = stepSize || 1 ;
24
24
var maxNumSpaces = generationOptions . maxTicks - 1 ;
25
25
var min = generationOptions . min ;
26
26
var max = generationOptions . max ;
27
27
var precision = generationOptions . precision ;
28
- var spacing , factor , niceMin , niceMax , numSpaces ;
29
-
30
28
var rmin = dataRange . min ;
31
29
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 ;
37
32
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
39
35
if ( spacing < MIN_SPACING && isNullOrUndef ( min ) && isNullOrUndef ( max ) ) {
40
36
return [ rmin , rmax ] ;
41
37
}
0 commit comments