This twin force graph prototype is originally two different namespaces, which we have condensed and simplified into a single function, but there must be some fundamental logic error in it since this different version both create the same x, y is a NaN error. We seem to have a fundamental logic flaw in our thinking somewhere, can you help spot it please?
In our function, we setup up parallel copies of everything, so they can be acted on at some later stage with potential features, rather than having a single function iterated through with data. Since the algorithm normally sits in a namespace, everything is copied along as you can see. In the JS version we have to deal with promises, but in Observable that seems to be handled nicely, thanks.
We run through a four step process:
initSVG(): → setup the svg’s and markers etc.
updateGraph() → split the input graph (node array, edge array) into two independent sub-graphs (Promo and Scratch) based on a condition, using an Adjacency list.
showGraph() → setup the links and the nodes for both charts in parallel,
simGraph() → setup and run both simulations.
The first two steps both execute flawlessly, but somehow there is a flaw in our thinking with the rest. Originally the code was swapped with the initialisation of the simulation objects occurring before showGraph step 3, with only the .on("tick", "ticked")
function occurring after the nodes and edges were setup.
But that configuration created the NaN errors as well, so it has to be some limitation in our understanding, perhaps about the sequencing of calls. Can you help please?
I can see the notebook but I can’t find the source of the bug. One issue I saw is that in the zoom event handlers you’re not using the function’s event, but this is not the core issue.
Hmmm, pretty much the only way i could simplify it and maintain the original concept is to comment out half the code, and just try to do one force graph, but using the same process.
However, it does seem that there must be some logic gap, that i hoped would be obvious to the D3 gurus. Some flaw in the way i step through the logic