Toggling between standard tree and a radial tree

Hi, I’m trying to give the user the ability to switch between different kinds of views. The diagram shows a tree structure, but I want it to organize itself radially if the user so desires. I adapted the code from this example but while the nodes rearrange themselves, they immediately return to the standard tree view (with some changes, like rotated labels). How can I stop this from happening?

My guess is that TreeLayout forces automatic redraw to place everything according to its specs, so I thought that maybe I have to change the layout (like I’m already doing, when switching between Tree and Grid), but the example given above has no layout initialized.

I assume you want the kind of layout switching behavior seen in

Yes, it would be better if RadialLayout were a separate Layout class. I suppose we should make that an extension.

Yes, that’s pretty much what I’m after. Unfortunately- as I said before - when I switch to radial view I get a regular tree view with node positions a bit mixed up and their textblocks rotated. When I switch to radial view for the second time however, it works nicely (until I try to expand a subtree, which is when the regular tree layout returns). And then after a few more switches it breaks completely, (diagram becomes unresponsive) with no error messages.

initializing a new tree layout like in the fishbone example did at least give me a smooth transition between views, if nothing else.

I’ll see what I can do later today.

Thank you. In the meantime, is there a way to stop the diagram from rearranging itself?

That depends. Read about layout invalidation in

OK, we’ve split out the radial-layout code from that sample and the sample into a RadialLayout.js extension, a class that inherits from go.Layout. And of course we’ve updated those two samples to make use of the new class.

These changes will be in 1.7 beta, which is coming out very soon. I’m expecting next week.

Great, thank you for that. I did however manage to make it work after setting diagram.layout.isOngoing to false at the start of the switch, like you suggested… Now, save for a few bugs I should be able to handle, it works just as expected. Thanks for the help!