thinkmap.graph.expand.ExpandManager

extends:
Jump To: Members Events

Examples:

Incrementally expand a simple tree layout display while also using a history manager // build three graphs var graph = new thinkmap.graph.Graph(); var display = new thinkmap.display.Display(document.getElementById('map')); var tree = new thinkmap.graph.Tree(); // attach a datasource to the main graph graph.datasource('/moviedb.tas'); // construct a history manager var historyManager = new thinkmap.graph.history.HistoryManager(graph) .add(display).add(tree); // make two expands - one for each direction var expander = new thinkmap.graph.expand.ExpandManager(graph,historyManager) .add(display).add(tree); function center(entity) { // return if entity is undefined or equal to the current root or not // a movie if (!entity || root === entity || !entity.isType('movie')) return; // set the root to the new entity root = entity; tree.root(root); // add the root to the display display.add(root); // clear the expand manager so we start from scratch expander.clear(); query(entity).then(function(results) { display.retainOnly(results); expander.expand(entity,results); historyManager.pushState(); return display.transition().scrollTo(treeLayout.targetPosition(entity)); }); } // handles expansion of ent - assumes expanded entity is in the display/tree function expand(ent) { graph.query(....).execute(ent) .onresult(tree.add) .onresult(display.add) .oncomplete(function(results) { expander.expand(ent,results); historyManager.pushState(); }); } function query(entity) { return graph.query({$choice:[ ['movie','edge', 'person'], ['person','edge', 'movie'] ]}) .execute(entity) .onresult(display.add) .onresult(tree.add) .oncomplete(function(results){ display.layout(); return results; }); } // handles when to center/expand/collapse display.on('click',function(evt) { var entity = evt.entity; if (evt.shiftKey) { center(entity); } else if(expander.isExpanded(entity)) { expand(entity); } else { expander.collapse(entity); historyManager.pushState(): } });

Constructor

Instance Methods

Defined in thinkmap.graph.expand.ExpandManager:

Events

this event is fired when an entity is expanded. The first parameter is the entity expanded and the second parameter are the results used for the expand

collapse : function ( thinkmap.graph.Entity )

this event is fired when collapse is called on an expanded entity

rebuild : function ( )

fired when the expand manager is rebuilding history for the graphs. This can typically be ignored by most developers as it is mainly used internally by the expand manager.