philogb / jit

The JavaScript InfoVis Toolkit provides tools for creating Interactive Data Visualizations for the Web
http://thejit.org
Other
1.51k stars 297 forks source link

undefined error after onBeforeCompute is called #116

Open DSoa opened 12 years ago

DSoa commented 12 years ago

In $jit.RGraph's onClick function, the line

  var thetaDiff = obj.theta - obj.parent.endPos.theta;

is failing because obj.parent = false. To make it work, I needed to move the call to

 this.controller.onBeforeCompute(this.graph.getNode(id));

down one line after

  var obj = this.getNodeAndParentAngle(id);

In my onBeforeCompute callback, I'm filtering nodes/edges based on certain criteria and setting the .ignore attribute on adjacencies as well as recomputing the node._depth starting from the new root node, which in this case results in the node that was clicked on having no parent nodes (because it is now the root).

I think it is harmless to make this change, if someone would like to incorporate it.

Thanks.

DSoa commented 12 years ago

Actually, it needs to be moved after this.parent = obj.parent; right before the line this.compute('end');