From 3f22d353ac7e48e27c3244390a8f80c8bfa33e82 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Wed, 2 Jan 2019 00:38:01 +0200 Subject: [PATCH] add comment --- src/scales/scale.linearbase.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scales/scale.linearbase.js b/src/scales/scale.linearbase.js index db678c3c46b..732e6572076 100644 --- a/src/scales/scale.linearbase.js +++ b/src/scales/scale.linearbase.js @@ -41,6 +41,10 @@ function generateTicks(generationOptions, dataRange) { factor = Math.pow(10, precision); spacing = Math.ceil(spacing * factor) / factor; } + + // Loop here is for the case when min / spacing === max / spacing + // This happens due to float inccuracy when min and max are really close to each other + // One case: min = 1.8548483304974972 and max = 1.8548483304974974 do { niceMin = Math.floor(dataRange.min / spacing) * spacing; niceMax = Math.ceil(dataRange.max / spacing) * spacing;