diff --git a/internal/web/charts2.go b/internal/web/charts2.go index 41e2bf38..3f918208 100644 --- a/internal/web/charts2.go +++ b/internal/web/charts2.go @@ -33,15 +33,6 @@ func HBarChart(rows []Row, colour, unit string) template.HTML { return template.HTML(`
Nothing recorded yet.
`) //nolint:gosec // constant } - const ( - rowH = 26.0 // the band - barH = 14.0 // the mark, capped well under the band so the rest is air - labelW = 190.0 - valueW = 96.0 - width = 720.0 - ) - height := float64(len(rows))*rowH + 8 - maxV := 0.0 for _, r := range rows { if r.Value > maxV { @@ -51,41 +42,32 @@ func HBarChart(rows []Row, colour, unit string) template.HTML { if maxV <= 0 { maxV = 1 } - plotW := width - labelW - valueW + // HTML rather than an SVG of fixed width. The SVG gave the value 96 units + // and "34.2k tok 114 req" did not fit, so the one figure a reader came for + // was the one cut off. A grid lets the label and the value take the room + // they need and gives the bar whatever is left. var b strings.Builder - fmt.Fprintf(&b, ``) return template.HTML(b.String()) //nolint:gosec // every interpolation is escaped above } diff --git a/internal/web/charts2_test.go b/internal/web/charts2_test.go index fabb2212..00d51575 100644 --- a/internal/web/charts2_test.go +++ b/internal/web/charts2_test.go @@ -28,10 +28,13 @@ func TestASmallValueStillDrawsAMark(t *testing.T) { {Label: "huge", Value: 1_000_000}, {Label: "tiny", Value: 1}, }, "--viz-1", "")) - // Two paths, one per row: the tiny one is still drawn. - if n := strings.Count(out, "