Issue when opening a cluster containing other clusters #2561

Open
Pratik--Patel opened this Issue Jan 10, 2017 · 1 comment

Projects

None yet

2 participants

@Pratik--Patel

First of all, thanks for the great library!

I am using visjs network module.
When I try to programmaticaly open up a cluster containing other clusters, I get an exception from vis.js saying 'Cannot set property 'vx' of undefined'. The same issue is described here in this SO question

I modified the potentially problematic source code to avoid such error by adding a check around them and the problem was fixed but I am not sure that this change will not introduce other problems in visjs. I updated the part of openClusters() method from this

            // old code
            // inherit speed
            _containedNode3.vx = clusterNode.vx;
            _containedNode3.vy = clusterNode.vy;

            // we use these methods to avoid re-instantiating the shape, which happens with setOptions.
            _containedNode3.setOptions({ hidden: false, physics: true });

to this

                     // new code
                     // inherit speed
			if( clusterNode.vx != null && clusterNode.vy != null ){
				_containedNode3.vx = clusterNode.vx;
				_containedNode3.vy = clusterNode.vy;
			}

			if( _containedNode3 != null )
				// we use these methods to avoid re-instantiating the shape, which happens with  setOptions.
				_containedNode3.setOptions({ hidden: false, physics: true });

Is it a safe and clean way to fix this problem? Please let me know if there can be any better approach to this. Thanks!

@Pratik--Patel Pratik--Patel changed the title from Opening up the cluster containing other clusters to Issue when opening a cluster containing other clusters Jan 10, 2017
@Tooa
Member
Tooa commented Jan 23, 2017

I get the following error when trying the provided jsbin:

Uncaught ReferenceError: openClusters is not defined

Can you provide me a working example that shows the error? Then, I will look into the issue.

@Tooa Tooa self-assigned this Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment