this.radius_ = undefined;
this.arc_ = undefined;
this.selectedNode_ = null;
- this.clickStack_ = undefined;
this.vis_ = undefined;
this.nodes_ = undefined;
this.minX_ = 0.0;
},
zoomOut_: function() {
- if (this.clickStack_.length > 1) {
- this.clickStack_.pop();
- this.selectedNodeID = this.clickStack_[this.clickStack_.length - 1];
+ window.history.back();
+ },
+
+ // This function assumes that, till the given depth,
+ // the tree is linear. (i.e, a single string with no branches.)
+ zoomToDepth: function(depth) {
+ var node = this.data_.nodes;
+ while (node.depth !== depth) {
+ if (node.children.length !== 1)
+ throw new Error("zoomToDepth requires the tree to be linear " +
+ "till the specified depth.");
+ node = node.children[0];
}
+ return this.zoomToID_(node.id);
},
zoomToID_: function(id) {
return;
}
- if (this.clickStack_[this.clickStack_.length - 1] != d.id) {
- this.clickStack_.push(d.id);
- this.selectedNodeID = d.id;
- }
+ this.selectedNodeID = d.id;
+
+ var e = new Event('node-clicked');
+ e.node = d;
+ this.dispatchEvent(e);
},
// Given a node in a partition layout, return an array of all of its
'translate(' + width / 2 + ',' + height / 2 + ')');
that.selectedNode_ = null;
- that.clickStack_ = new Array();
- that.clickStack_.push(0);
var depth = 1.0 + d3.max(that.nodes_, function(d) { return d.depth; });
that.yDomainMin_ = 1.0 / depth;