1
0
mirror of https://github.com/golang/go synced 2024-11-18 04:14:49 -07:00

cmd/trace: skip links for buckets with 0 count

Change-Id: Ib1c2f7cc8e8f631ed9e74161699332f492d4cb0d
Reviewed-on: https://go-review.googlesource.com/112196
Reviewed-by: Peter Weinberger <pjw@google.com>
This commit is contained in:
Hana (Hyang-Ah) Kim 2018-05-09 02:43:08 +08:00 committed by Hyang-Ah Hana Kim
parent d96221f206
commit 9eface7077

View File

@ -861,12 +861,16 @@ func (h *durationHistogram) ToHTML(urlmaker func(min, max time.Duration) string)
fmt.Fprintf(w, `<table>`)
for i := h.MinBucket; i <= h.MaxBucket; i++ {
// Tick label.
if h.Buckets[i] > 0 {
fmt.Fprintf(w, `<tr><td class="histoTime" align="right"><a href=%s>%s</a></td>`, urlmaker(h.BucketMin(i), h.BucketMin(i+1)), niceDuration(h.BucketMin(i)))
} else {
fmt.Fprintf(w, `<tr><td class="histoTime" align="right">%s</td>`, niceDuration(h.BucketMin(i)))
}
// Bucket bar.
width := h.Buckets[i] * barWidth / maxCount
fmt.Fprintf(w, `<td><div style="width:%dpx;background:blue;top:.6em;position:relative">&nbsp;</div></td>`, width)
fmt.Fprintf(w, `<td><div style="width:%dpx;background:blue;position:relative">&nbsp;</div></td>`, width)
// Bucket count.
fmt.Fprintf(w, `<td align="right"><div style="top:.6em;position:relative">%d</div></td>`, h.Buckets[i])
fmt.Fprintf(w, `<td align="right"><div style="position:relative">%d</div></td>`, h.Buckets[i])
fmt.Fprintf(w, "</tr>\n")
}