Strange behavior of graduatedSkip with large floats as min/max

We have graduated Panels with editable Min/Max values that our users can freely customize. We dynamically generate a tickUnit that will result in a linear scale between the min/max and use graduatedSkip to skip the first and last tick since we want to add them manually. The problem is if the user sets a really large (or small !?) float like 0.0000000001 as the maximum or minimum the graduatedSkip will get fired thousands of time instead of 10 or 11. Here’s a Codesandbox demonstrating this:

In this exemple you can see that:
Min is 0
Max is 0.000001.
tickUnit is: 1e-7 (max - min / 10) so it should generate 10 ticks
tickUnitBase is simply 0

I’ve already added console.logs at specific locations so you can see in the console what I want to demonstrate here:

If you run this code as it is you should see that the graduatedSkip is called 11 times as expected since we have 11 ticks.

But if you modify the max and add a 0 you should now see 16 calls which is not good and the more you add zeros the more the graduatedSkip gets called.

min: 0,

max: 0.000001, // 11 graduatedSkip calls - Good !
max: 0.0000001, // 16 graduatedSkip calls - Not good...
max: 0.00000001, // 60 graduatedSkip calls - Not good...
max: 0.000000001, // 511 graduatedSkip calls - Not good...
max: 0.0000000001, // thousands+ graduatedSkip calls - Not good...
// From this point, the Diagram gets super laggy and eventually make the browser crash

Any idea whats causing this ?
Sounds like a floating point issue but not sure: https://floating-point-gui.de/

Thanks in advance :)

My first question is: precisely which version of GoJS are you using?
Evaluate go.Diagram.version.

1 Like

Thanks for reporting this, we’re working on a fix for very high precision floating point numbers.

1 Like

@walter we are using the 2.2.12 version. I know there is a newer version (2.2.13) but looking at the change log I don’t think it solves this problem.

@jhardy thanks ! When are you planning to release this fix ?

Thanks for the quick replies !

It will be part of the 2.2.14 release, which should be later this week or some time next week.

1 Like

Could you try the 2.2.14 beta, at: GoJS ?
You can get the library from https://gojs.net/beta/release/go.js or https://gojs.net/beta/release/go-module.js

1 Like

@walter Yes ! That seems to fix the problem. I tried with really high precision (up to 1e-60) and graduatedSkip gets called 11 times as expected.

When are you planning to release this fix ?

Thanks !

Soon? I’d expect this week, assuming no hiccups along the way.

1 Like
1 Like