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

[Network] GUI Manipulation, node level doesn't update visually #3220

Closed
cridus opened this issue Jun 30, 2017 · 3 comments
Closed

[Network] GUI Manipulation, node level doesn't update visually #3220

cridus opened this issue Jun 30, 2017 · 3 comments

Comments

@cridus
Copy link

cridus commented Jun 30, 2017

I have a Network with a hierarchical tree. I added the GUI buttons to add and edit the nodes, however when I edit a node and I change its level, the node doesn't move to that level, visually. As a workaround I call network.clustering.updateClusteredNode(data.id, {level : theNewLevel}); after the callback to update the node and that does make the node appear in its new position.

Here's a fiddle that shows the issue: https://jsfiddle.net/y2kwv76v/3/
Edit a node changing its level and you'll see it won't move.
After that, click on the button "Use workaround" and the node will go to the right level.

For some reason the fiddle only works on Chrome...

@wimrijnders
Copy link
Contributor

wimrijnders commented Jul 4, 2017

It didn't work for me either in chromium. When I remove this line from options:

  locale: navigator.language, 

...all is well, also in firefox.

Hey, I know that network! Great example BTW.

@wimrijnders
Copy link
Contributor

Adding a new node appears to work fine. So the problem is in the update. Digging in...

I believe it's the following:

  • when adding a node, LayoutEngine.setupHierarchicalLayout() is called, which re-initializes the layout, thus determining the position of the new node.
  • This method is not called when updating a node, thus a new position is not calculated. The workaround forces the recalculation.

Thus, the logical thing to do is to force the recalculation on the update as well. However, it's a bit overkill to do this on every arbitrary change in the node data; LayoutEngine.setupHierarchicalLayout() is a pretty hefty method to run.

I propose to add a check on update if option level has changed; if so, do the recalculation. There may be other node data that have an effect; I can't think of any right now but these can be added as needed.

wimrijnders added a commit to wimrijnders/vis that referenced this issue Jul 6, 2017
Fix for almende#3220

On change of data of an existing node, the level is checked for changes.
If changed, for a recalculation of the hierarchical layout.

The fix does not explicitly check for hierarchical layout; this should not be a problem.
The added code can be used to add further node fields which may trigger recalculation of layout.
@wimrijnders
Copy link
Contributor

Fix has been submitted. It was pretty straightforward after preceding analysis.

yotamberk pushed a commit that referenced this issue Jul 21, 2017
* Update hierarchy when node level changes

Fix for #3220

On change of data of an existing node, the level is checked for changes.
If changed, for a recalculation of the hierarchical layout.

The fix does not explicitly check for hierarchical layout; this should not be a problem.
The added code can be used to add further node fields which may trigger recalculation of layout.

* Changes due to review
primozs pushed a commit to primozs/vis that referenced this issue Jan 3, 2019
* Update hierarchy when node level changes

Fix for almende#3220

On change of data of an existing node, the level is checked for changes.
If changed, for a recalculation of the hierarchical layout.

The fix does not explicitly check for hierarchical layout; this should not be a problem.
The added code can be used to add further node fields which may trigger recalculation of layout.

* Changes due to review
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

3 participants