Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreating scene without reloading - dispose or clear? #234

Open
gg4u opened this issue Sep 26, 2018 · 0 comments
Open

Recreating scene without reloading - dispose or clear? #234

gg4u opened this issue Sep 26, 2018 · 0 comments

Comments

@gg4u
Copy link

gg4u commented Sep 26, 2018

Hi! I was reading - #57

@simov I put in copy, not sure if my issue is duplicate of yours, maybe you can help me.

Could you help in finding out how to flush current visualisation and draw the same graph again, keeping all references to nodes listeners intact?

My goal is to enable the user in changing visualisation of how its graph is rendered.

The graph structure and the layout object will be the same.

Which should I call: renderer.dispose() or graph.clear() ?

I would like to render again the same graph, I don't want to clear it out:
so I tried to dispose() the renderer object, and call renderer.run() again.

It almost works, but breaks interactivity for missing object reference:

the layout is actually rendered again, but as soon as I tap on nodes (there are events to them), the renderer loose reference to links coordinates.

Going down the debugging, the first function to complain is actually the one calling for new nodes to be added to the graph, once a node is tapped - it seems cannot find a reference to the node that has been tapped.

I have something like:

graphics.node(function (node) {
     
    $(ui).on('tap', function (event) {  
        
        // this will break once the renderer was disposed and re run.
        addRelatedNodes(graph,node.id)
    }
}

screen shot 2018-09-26 at 12 46 48 pm

Should I copy the graph object first ?

I looked at #57 and @anvaka 's: example pointed out an error for pointing the new graph objects constructed as:

var newGraph = App.graphGenerator.grid(Math.random() * 20 |0 , Math.random() * 20 |0);

....but should I need to make a copy of my graph object, if it is actually the same ?
Also, making a shallow copy or deep copy sounds a bit cumbersome.

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

No branches or pull requests

1 participant