Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / src / tvcm / ui / sunburst_chart.html
index 8dbff1b..c341793 100644 (file)
@@ -40,7 +40,6 @@ tvcm.exportTo('tvcm.ui', function() {
       this.radius_ = undefined;
       this.arc_ = undefined;
       this.selectedNode_ = null;
-      this.clickStack_ = undefined;
       this.vis_ = undefined;
       this.nodes_ = undefined;
       this.minX_ = 0.0;
@@ -167,10 +166,20 @@ tvcm.exportTo('tvcm.ui', function() {
     },
 
     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) {
@@ -225,10 +234,11 @@ tvcm.exportTo('tvcm.ui', function() {
         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
@@ -377,8 +387,6 @@ tvcm.exportTo('tvcm.ui', function() {
           '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;