Spacetree, request controller, and general dynamic update issues

79 views
Skip to first unread message

dbrezinski

unread,
Dec 8, 2009, 4:35:11 PM12/8/09
to JavaScript Information Visualization Toolkit
Thanks for the awesomeness that is JIT. I am hacking away on my first
application of it, but I am having a few issues trying to do dynamic
expansion/extension of a space tree. I want exactly the same
functionality as the spacetree example2, but using the example code
with an AJAX request for a subtree in the request controller totally
does not work. I will paste the code below. I have also tried
extending the label.onclick in the onCreateLabel controller, but it is
also not working correctly (but working a bit).

Assume the js is nearly the same as the example2 spacetree, here is
what the request controller is:

request: function(nodeId, level, onComplete) {
var response_handler = (function() {
return function(request) {
var node_id = nodeId;
var on_complete = onComplete;
var graph = request.responseJSON.community_graph;
on_complete.onComplete(node_id, graph);
};
})();
call_ui_service('community/graph', 'put', 'node_id=' + nodeId,
response_handler);
},

The ajax call is returning a subtree that includes the root, its child
that was clicked and the leaves of the clicked child. When a node is
clicked, the onClick action is working (centering the node, changing
the color of the adjacency just as in the example2 code) but the new
subtree is not displayed.

The alternate approach of extending the label.onclick has tried
graph.op.sum, morph using the original json graph, the st.onClick
onComplete method, etc. In some cases it almost works, but the graph
repositions correctly for the onClick, but then the sum moves it back
to the starting position when it renders the new graph. Also, I am
using a fixed nodeId for the added leaf, since it is a psuedo node
containing community summary information. No matter if I removeNode,
morph the tree back to the original using original json, or anything
else I can think of, when I sum in the new subtree containing a node
with the same id as used in an earlier sum, the old node is displayed.
Clearly the generated graph is not being cleared completely. Here is
the code for the alternate approach (graph is the original json
graph):

onCreateLabel: function(label, node){
label.id = node.id;
label.innerHTML = node.name;
label.onclick = function(){
var edge_node = st.graph.getNode
("0000000000000000000000000000000000000000000000000000000000000000");
if (edge_node) {
st.op.morph(graph,{
type: 'fade:seq',
duration: 500,
hideLabels: false,
transition: Trans.Quart.easeInOut
});
};
var response_handler = (function() {
return function(request) {
var _st = st;
var sub_graph = request.responseJSON.community_graph;
_st.op.sum(sub_graph, {
type: 'fade:seq',
duration: 500,
hideLabels: false,
transition: Trans.Quart.easeInOut
});
};
})();
st.onClick(node.id, {Move: {
enable: true,
offsetX: 50,
offsetY: 0
},
onComplete: function(){call_ui_service('community/graph',
'put', 'node_id=' + node.id, response_handler);}
});
};

The only thing different about example2 is that it is using a local
string for the json and TreeUtils to manipulate it. Is it the case
that getTree is doing all the node pruning beyond level 2 and
providing what is a essentially a completely new graph rather than
just a shared root subtree? Is there code missing from the example? Or
is the request controller just a little buggy? Using jit 1.1.3.

Thanks!
Reply all
Reply to author
Forward
0 new messages