Maximizing canvas space when traversing a Spacetree

46 views
Skip to first unread message

mdegaris

unread,
Nov 17, 2009, 6:12:46 AM11/17/09
to JavaScript Information Visualization Toolkit
Hi all,

I was wondering if its possible, when traversing a spacetree, for a it
to use the maximum space available within a canvas.

I have a space tree that has a maximum depth of 5 levels, with node
selections opening 1 level at a time (levelsToShow = 1). When
selecting nodes the space tree shifts to the left, opening the next
level, and centering the selected node (as expected). However, there
always appears to be unused space on the right side of the canvas -
enough to display another level of the tree. As I traverse the tree
and the root node reaches the left edge of the canvas, I would like
the subsequent node selection to make use of the free space available
on the right side of the canvas (if need be) - and not move the space
tree to the left. I realise that in this case the selected node will
not be centered on the canvas. I fear I'm breaking the fundamental
behaviour of the spacetree here, so I perfectly understand if its not
possible.

Anyway, I hope I've explained that well :)

Cheers for any help,
Marc.

Nico Garcia Belmonte

unread,
Nov 17, 2009, 6:52:47 AM11/17/09
to javascript-information...@googlegroups.com
Hi,


   However, there
always appears to be unused space on the right side of the canvas -
enough to display another level of the tree.  

Besides making levelsToShow=2 for non leaves I'm not sure what other advice I can give you :)
 
As I traverse the tree
and the root node reaches the left edge of the canvas, I would like
the subsequent node selection to make use of the free space available
on the right side of the canvas (if need be) - and not move the space
tree to the left.  I realise that in this case the selected node will
not be centered on the canvas. 

You can add an offset to the tree when a node is clicked. I think this can help here:

http://thejit.org/docs/files/Spacetree-js.html#ST.onClick

You should probably evaluate the clicked node first to know if you have to add that offset or not. For example

if(Graph.Util.anySubnode(node, "exist")) {
  //do stuff for non leaves
  st.levelsToShow = 2;
  st.onClick(node); 
} else {
  //do stuff for leaves
  st.onClick(node, {
    offsetX: somenumber,
    offsetY: someothernumber
  });
}
 
(I haven't tested the code)


For more information about Graph.Util.anySubnode please see this section of the documentation:

http://thejit.org/docs/files/Graph-js.html#Graph.Util.anySubnode

Hope it helps,




Anyway, I hope I've explained that well :)

Cheers for any help,
Marc.

--

You received this message because you are subscribed to the Google Groups "JavaScript Information Visualization Toolkit" group.
To post to this group, send email to javascript-information...@googlegroups.com.
To unsubscribe from this group, send email to javascript-information-visua...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javascript-information-visualization-toolkit?hl=.


Hi all,



--
I would never die for my beliefs because I might be wrong.

Bertrand Russell

mdegaris

unread,
Nov 17, 2009, 12:13:10 PM11/17/09
to JavaScript Information Visualization Toolkit
Thanks Nico. I'll give this a try and see if it does the trick :)
> > javascript-information-visua...@googlegroups.com<javascript-information-visualization-toolkit%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/javascript-information-visualization-t...
> > .
Reply all
Reply to author
Forward
0 new messages