Got renderint.

Change-Id: I6235581d36271c54a8381a946d0046a68f6a0472
diff --git a/services/debug/debug/browse.go b/services/debug/debug/browse.go
index 2826698..54695ed 100644
--- a/services/debug/debug/browse.go
+++ b/services/debug/debug/browse.go
@@ -498,7 +498,6 @@
 	ctx, tracer := newTracer(a.ctx)
 	stub := svtrace.StoreClient(name)
 
-	fmt.Println("calling out to", name)
 	call, err := stub.AllTraces(ctx)
 	if err != nil {
 		w.WriteHeader(http.StatusInternalServerError)
@@ -509,7 +508,6 @@
 	var traces []string
 	for stream.Advance() {
 		id := stream.Value().Id
-		fmt.Printf("Got back: %x", id)
 		traces = append(traces, hex.EncodeToString(id[:]))
 	}
 
@@ -529,18 +527,16 @@
 		Vtrace: tracer,
 	}
 	executeTemplate(a.ctx, w, r, tmplBrowseAllTraces, data)
-	fmt.Println("Done with template")
 }
 
 type divTree struct {
+	Id string
 	// Start is a value from 0-100 which is the percentage of time into the parent span's duration
 	// that this span started.
 	Start int
-	// End is a value from 0-100 which is the percentage of time into the parent span's duration
-	// that this span ended.
+	// Width is a value from 0-100 which is the percentage of time in the parent span's duration this span
+	// took
 	Width int
-	// VerticalOffset is the number of pixels from the top of the parent div this div should appear.
-	VerticalOffset int
 	Name string
 	Annotations []annotation
 	Children []divTree
@@ -553,7 +549,7 @@
 	Msg string
 }
 
-func convertToTree(n *vtrace.Node, parentStart time.Time, parentEnd time.Time, verticalPosition int) *divTree {
+func convertToTree(n *vtrace.Node, parentStart time.Time, parentEnd time.Time) *divTree {
 	startTime := n.Span.Start
 	if startTime.IsZero() {
 		startTime = parentStart
@@ -565,15 +561,13 @@
 	}
 
 	parentDuration := parentEnd.Sub(parentStart).Seconds()
-	fmt.Println("parent start is", parentStart, "start", startTime, "parentEnd", parentEnd, "end", endTime)
 	start := int(100 * startTime.Sub(parentStart).Seconds() / parentDuration)
 	width := int(100 * endTime.Sub(parentStart).Seconds() / parentDuration) - start
-	fmt.Println("start:", start, "end", width)
 	top := &divTree{
+		Id: n.Span.Id.String(),
 		Start: start,
 		Width: width,
 		Name: n.Span.Name,
-		VerticalOffset: verticalPosition,
 	}
 	top.Annotations = make([]annotation, len(n.Span.Annotations))
 	for i, a := range n.Span.Annotations {
@@ -585,10 +579,8 @@
 		top.Annotations[i].Position = int(100 * a.When.Sub(parentStart).Seconds() / parentDuration) - start
 	}
 	top.Children = make([]divTree, len(n.Children))
-	pos := 2
 	for i, c := range n.Children {
-		top.Children[i] = *convertToTree(c, startTime, endTime, pos)
-		pos += 2
+		top.Children[i] = *convertToTree(c, startTime, endTime)
 	}
 	return top
 
@@ -686,7 +678,7 @@
 		return
 	}
 
-	tree := convertToTree(node, findStartTime(node), findEndTime(node), 0)
+	tree := convertToTree(node, findStartTime(node), findEndTime(node))
 	data := struct{
 		Id  string
 		Root *divTree
@@ -1030,20 +1022,35 @@
 `)
 	tmplBrowseVtrace = makeTemplate("vtrace",`
 {{define ".span"}}
-<div style="position:relative;left:{{.Start}}%;width:{{.Width}}%;top:{{.VerticalOffset}}px;margin:0px;padding:0px">
+<div style="position:relative;left:{{.Start}}%;width:{{.Width}}%;margin:0px;padding-top:2px;" id="{{.Id}}">
   <!-- Root span -->
-  <div title="{{.Name}}" style="position:relative;left:0%;width:100%;background:{{nextColor}};height:15px;display:block;margin:0px;padding:0px"></div>
+  <div id="root" title="{{.Name}}" style="position:relative;width:100%;background:{{nextColor}};height:15px;display:block;margin:0px;padding:0px"></div>
   {{range $i, $child := .Children}}
   {{template ".span" $child}}
   {{end}}
 </div>
 {{end}}
+{{define ".collapse-nav"}}
+<div id="{{.Id}}" style="position:relative;left:5px">
+<div style="position:relative;height:15px;font:10pt" >{{len .Children}}</div>
+{{range .Children}}
+{{template ".collapse-nav" .}}
+{{end}}
+</div>
+{{end}}
 <section class="section--center mdl-grid">
   <h5>Vtrace for {{.Id}}</h5>
   <pre>{{.DebugTrace}}</pre>
-  <div id="parent" class="mdl-cell mdl-cell--12-col">
+  <div class="mdl-cell mdl-cell--12-col">
+  <div style="display:flex;flex-direction:row">
+  <div style="min-width:10%">
+  {{template ".collapse-nav" .Root}}
+  </div>
+  <div id="parent" style="width:80%">
   {{template ".span" .Root}}
   </div>
+  </div>
+  </div>
 </section>
 `)