From f8bb78103f4434d7fa3ad15d30c5bfee41cf1154 Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Thu, 17 Sep 2026 19:06:53 +0200 Subject: [PATCH] Stop the ranked charts from spilling over the tables below them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bars were wrapped in
, and .chart was already the fixed-height box the time-series charts are drawn in: 120px, with a border and a background. A chart that grows a row at a time does not fit in a cage, so the SVG overflowed it and landed on the table underneath. Renamed to .ranked, which is a wrapper rather than the mark itself, and capped at the design width so a wide window scales the box instead of inflating the 12px labels. The test reads the class back out of the markup and checks the stylesheet does not cap it, because the collision was invisible in both files on their own — each rule was reasonable, and only the shared name was wrong. Co-Authored-By: Claude Opus 5 (1M context) --- internal/web/charts2.go | 2 +- internal/web/charts2_test.go | 31 +++++++++++++++++++++++++++++++ internal/web/static/base.css | 8 ++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/internal/web/charts2.go b/internal/web/charts2.go index 48d42a7..41e2bf3 100644 --- a/internal/web/charts2.go +++ b/internal/web/charts2.go @@ -54,7 +54,7 @@ func HBarChart(rows []Row, colour, unit string) template.HTML { plotW := width - labelW - valueW var b strings.Builder - fmt.Fprintf(&b, `
`, width, height) for i, r := range rows { diff --git a/internal/web/charts2_test.go b/internal/web/charts2_test.go index 42efd46..fabb221 100644 --- a/internal/web/charts2_test.go +++ b/internal/web/charts2_test.go @@ -115,3 +115,34 @@ func TestTheChartScalesToItsContainer(t *testing.T) { t.Error("a fixed pixel width was set on the chart") } } + +func TestTheRankedWrapperIsNotGivenAFixedHeight(t *testing.T) { + // This chart grows a row at a time, so whatever class it wears must not be + // one the stylesheet caps. It wore "chart", which is the fixed-height box + // the time-series charts live in, and the bars spilled over the table + // underneath them. + out := string(HBarChart([]Row{{Label: "a", Value: 1}}, "", "")) + class := "" // the wrapper's class, read back out of the markup + if i := strings.Index(out, `