-
Notifications
You must be signed in to change notification settings - Fork 1.5k
check for mass value of zero on vis.js Network nodes. #3133
Comments
There's two years between But really I have to agree with you. The value zero should be tested in some way and reported. I'll be paranoid and have a look if negative values should be disqualified as well. Thanks for reporting. Background info: Then, as now,
Methinks that zero qualifies. |
It turns out that setting negative mass is a really bad idea. The nodes make a sincere attempt at escaping and disappear into the distance, never to stop. I'm inclined to block negative mass as well. |
The question now is how to handle this. Should Update: I'm going for warning and reset to 1. |
Fix for almende#3133 Option-field 'node.mass` must be >= 0. Checks have been added at the nodes level, for both nodes-global and nodes specific options. In addition, an internal check has been added for `NodeHandler.defaultOptions`. The documentation has been adjusted for this change.
I've added the checks, they should be in the next release. Thanks for reporting! Please close the issue if you're happy with this. |
* Protect Network from zero and negative mass values Fix for #3133 Option-field 'node.mass` must be >= 0. Checks have been added at the nodes level, for both nodes-global and nodes specific options. In addition, an internal check has been added for `NodeHandler.defaultOptions`. The documentation has been adjusted for this change. * Fix whitespace
* Protect Network from zero and negative mass values Fix for almende#3133 Option-field 'node.mass` must be >= 0. Checks have been added at the nodes level, for both nodes-global and nodes specific options. In addition, an internal check has been added for `NodeHandler.defaultOptions`. The documentation has been adjusted for this change. * Fix whitespace
I was updating an old library to the latest vis.js network, when I spotted quite an odd behaviour, where only one node out of hundreds would appear. After a fair amount of debugging, I noticed that I was accidentally setting the mass some of the nodes to zero. This was causing havoc, with a NaN eventually as the x and y coords.
I've created the following jsfiddle to demonstrate it:
http://jsfiddle.net/1y8L119L/
Setting the mass to 1 or higher solves the issue; however, the code used to work with a mass of 0 back in version 4.3.0.
Please add the extra safety check to prevent the pain I have just had to go through on other distracted silly programmers that set the mass to zero.
The text was updated successfully, but these errors were encountered: