Force directed graph: node getting set to NaN?

1,346 views
Skip to first unread message

Reid Rivenburgh

unread,
May 21, 2013, 7:28:22 PM5/21/13
to d3...@googlegroups.com
Hi.  I'm pretty new to d3.  I've been using a force-directed graph layout to display some data.  I'm following the basic pattern in the examples.  It works well, except I've run into one bizarre thing.  My page has links to various data files, and if I load one file then load another (clearing out all of the associated variables), one of the nodes will, sometimes, eventually in the tick function take on values of NaN for the x and y values, so it jumps to the upper-left corner.  Everything looks fine in my nodes and links arrays before calling start, and it all works properly aside from this.  I know an example would be ideal, but given it seems to only occur when loading a second data file and is part of a bigger code, it's hard to reduce to something small and postable.  So... does anyone happen to know what might be triggering this?  Thanks!

Reid

Reid Rivenburgh

unread,
Jun 12, 2013, 12:29:03 PM6/12/13
to d3...@googlegroups.com
Hi all.  I'm bumping this in the hope that someone might have some clue why I'm sometimes getting these NaNs for coordinates.  It's a tough one to track down!

TIA,
Reid


On Tue, May 21, 2013 at 5:28 PM, Reid Rivenburgh <riven...@gmail.com> wrote:
Hi.  I'm pretty new to d3.  I've been using a force-directed graph layout to display some data.  I'm following the basic pattern in the examples.  It works well, except I've run into one bizarre thing.  My page has links to various data files, and if I load one file then load another (clearing out all of the associated variables), one of the nodes will, sometimes, eventually in the tick function take on values of NaN for the x and y values, so it jumps to the upper-left corner.  Everything looks fine in my nodes and links arrays before calling start, and it all works properly aside from this.  I know an example would be ideal, but given it seems to only occur when loading a second data file and is part of a bigger code, it's hard to reduce to something small and postable.  So... does anyone happen to know what might be triggering this?  Thanks!


Reid

--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reid Rivenburgh

unread,
Jun 14, 2013, 4:00:13 PM6/14/13
to d3...@googlegroups.com
In case someone else runs into something similar, I solved this by stepping into the d3 code.  I'm re-using my force layout object when I load a second dataset.  I thought I was purging all of the data related to the layout of the previous dataset, but it turns out that the tick timer was still firing.  Calling layout.stop() to turn it off when loading the new dataset has fixed my NaN problem.

Reid

Casper van Leeuwen

unread,
Aug 11, 2014, 5:03:08 AM8/11/14
to d3...@googlegroups.com, re...@pobox.com
You sir saved my day! I had the same problem with an intense network and in some occurrences the debugger started to hang because of all the NaN computations. Thnx!

Op vrijdag 14 juni 2013 22:00:13 UTC+2 schreef Reid Rivenburgh:

Sergey Chikirev

unread,
Jun 2, 2019, 7:28:01 PM6/2/19
to d3-js
Thank you so much man. Can't find decision why this works so unstable until found this thread. You saved me, I own you a beer definitely.

суббота, 15 июня 2013 г., 0:00:13 UTC+4 пользователь Reid Rivenburgh написал:
To unsubscribe from this group and stop receiving emails from it, send an email to d3...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages