jit icon indicating copy to clipboard operation
jit copied to clipboard

Treemap: enter() to a parent node doesn't work

Open bmesuere opened this issue 13 years ago • 3 comments

If you are zoomed in to a node and want to restore your view to a (not the) parent of that node, you're stuck with calling out() multiple times.

It would be great if

  • you could use the enter() function to zoom out to a given node or
  • the out() function took a parameter x to zoom out x levels

The problem with calling out() multiple times is that it plays the animation for every step.

bmesuere avatar Jul 08 '11 13:07 bmesuere

i had the same problem with entering specific nodes with animations on. i solved the issue by using the following code:

treemap.treemap_object.loadJSON(jtree, "tm" + r2_treeid); //clickedNode must be reset //or compute() computes the old subtree //(which doesnt exist after loadJSON()) treemap.treemap_object.clickedNode = null; //compute the sizes and positions of the selcted subtree tm.compute(); //and enter the new tree var node = treemap.treemap_object.graph.getNode("tm"+r2_treeid); tm.enter(node);

bazziman avatar Sep 27 '12 15:09 bazziman

I had exactly the same problem, and bazziman's reminder that "clickedNode must be reset" is tremendously helpful! Otherwise the animation won't appear correctly. Actually, I found a small issue using tm.enter(node) for this purpose though--using tm.enter(node) to zoom out, the animation will expand from the specified node rather than the commonly expected shrinking from the child node and then show the parent level nodes. So, for zooming out one level, I still used tm.out(), although this method doesn't take any parameter, you can just reset tm.clickedNode to the node that you are zooming out from. For zoom out more than one level, I used tm.refresh(), for the animation to fade in from the center. When using tm.refresh(), also need to reset tm.clickedNode as the parent node you are expanding from, also you need to do tm.loadJSON(json) before tm.refresh(). Simply put:

tm.clickedNode=null; tm.enter(theNodeYouWouldLIkeToEnterFrom); OR tm.clickedNode=theNodeYouWouldLiketoZoomOutFrom;//it is very important to set tm.clickedNode tm.out(); OR tm.clickedNode=theNodeYouWouldLikeToExpandFrom;// it is very important to set tm.clickedNode tm.loadJSON(json); tm.refresh();

XinCindyChen avatar Jan 13 '13 01:01 XinCindyChen

Thats great! I always wondered why the animation was broken when zooming out was broken (that is, not zooming out from that node). Simply setting clickedNode to the node where to zoom out from seems like the solution. I will try that monday at work :) Thx XinCindyChen!

bazziman avatar Jan 13 '13 02:01 bazziman