Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Error with adding a node to the dataset after setOptions #3025

Open
AlexDM0 opened this issue May 2, 2017 · 11 comments
Open

Error with adding a node to the dataset after setOptions #3025

AlexDM0 opened this issue May 2, 2017 · 11 comments

Comments

@AlexDM0
Copy link
Contributor

AlexDM0 commented May 2, 2017

You can see the issue here:
https://jsbin.com/hesexidaxi/edit?html,console,output

@rasmusblockzero
Copy link

To me it looks like the main oddity is this.nodeOptions = options; in nodesHandler.setOptions.
It's set to incoming options without any parsing, instead of reflecting nodeOptions it becomes a snapshot what ever was the latest option to be set. It beats me why this is important to pass to new nodes but I also must say that there is a fair bit in the options complex that beats me.

In either case when this becomes undefined this cause a raise condition in the labelHandler

It was added fairly recently maybe @eymiha or @mojoaxel has some input there as they added the parameter ?

@wimrijnders
Copy link
Contributor

Analysis of @rasmusblockzero is valid. The node options get reset completely when NodesHandles.setOptions() is called.

This also happens in:

  • EdgesHandler

This does not happen in:

  • Canvas
  • CanvasRenderer
  • Groups
  • InteractionHandler
  • KamadaKawai
  • LayoutEngine
  • ManipulationSystem
  • NavigationHandler
  • PhysicsEngine
  • SelectionHandler

...in other words, in all the other modules with options.

So there is a discrepancy between the handling of options for Nodes & Edges, and the rest of the code.

I admit this is confusing; while it is understandable that sometimes options need to get initialized from scratch, it is not possible to update just a subset of the options. IMHO this would be a useful feature. Will think about this.

@wimrijnders
Copy link
Contributor

wimrijnders commented May 14, 2017

As a workaround, the easiest way to avoid the error in the example is to set options.nodes.font.multi: false. This will skip the code in which the error occurs (Label.propagateFonts()). The example doesn't use the multi-font options anyway.

@wimrijnders
Copy link
Contributor

wimrijnders commented May 14, 2017

Added PR #3055 to fix the occurrence of the reported error. The example will now work as expected.

It should be noted that this is a partial fix; the issue with the resetting of the Nodes & Edges options is not addressed.

@AlexDM0
Copy link
Contributor Author

AlexDM0 commented May 21, 2017 via email

@wimrijnders
Copy link
Contributor

Reopening because the fix was partial; all it did was hide the error. This issue still needs some work.

@wimrijnders wimrijnders reopened this May 22, 2017
@AlexDM0
Copy link
Contributor Author

AlexDM0 commented May 22, 2017 via email

@mojoaxel mojoaxel modified the milestones: Minor Release v4.21, Minor Release v4.20 May 22, 2017
@mojoaxel mojoaxel modified the milestones: Patch Release v4.20.1, Minor Release v4.21 May 22, 2017
@wimrijnders
Copy link
Contributor

wimrijnders commented May 22, 2017

@AlexDM0 Thanks for the explanation.

However, what you say does not conflict the current working in any way. The node options are copied into the Node instances, not used directly from the DataSet instance. I'm not sure if this functionality was added after your time, but it is how it works now.

Also, I think it is important to note the several levels of the options. The chain is as follows (from #3060):

node options -> group options -> nodesHandler options -> default options

... where node options are specific per node. Ultimately, these are options stored in the DataSet.

What is currently happening, is that the NodesHandler options are zapped whenever setOptions() is called. These are not options from the DataSet.

Finally, I'd like to mention that @rasmusblockzero and I opened #3060 to thoroughly review and overhaul the handling of options in network. It's confusing as it is now.

@rasmusblockzero
Copy link

Agree, I think the original architecture as I understand it from your explanation is still active and valid. The somewhat messy parts are things that as far as I can tell is going against the clean fusion and that is what we intend to straighten out.

@AlexDM0
Copy link
Contributor Author

AlexDM0 commented May 22, 2017 via email

@wimrijnders
Copy link
Contributor

wimrijnders commented May 22, 2017

the core of the options propegation were the brige methods in the util class.

Yep, they're still there. That was my main insight today. TIL.
On top of that, there's a lot of cruft which seriously complicates the understanding of options. My hope is to reduce it once again to judicious use of util.bridgeObject().


Update: maintaining the prototype inheritance is not feasible, see #3486. There are several reasons for that, groups is one of them and the order of font propagation is another. I'm going to slowly phase it out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants