From 32a49e8bf66c7552432df5783b22f3d951c17026 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 14 Oct 2026 13:47:08 -0400 Subject: [PATCH] Fix up merged PRs: a trendline caption in a tiny chart no longer panics f64::clamp panics when the plot is narrower than the caption's minimum width; use main's clamp_soft, as the rest of the chart code now does. Co-Authored-By: Claude Opus 5.5 --- crates/render/src/chart.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/render/src/chart.rs b/crates/render/src/chart.rs index f90ab549..1e481510 100644 --- a/crates/render/src/chart.rs +++ b/crates/render/src/chart.rs @@ -860,7 +860,7 @@ fn draw_trendlines( let lines = caption.chars().filter(|ch| *ch == '\n').count() + 1; let box_h = base * 1.3 * lines as f64 + 2.0; let widest = caption.lines().map(|l| l.chars().count()).max().unwrap_or(1) as f64; - let box_w = (widest * base * 0.62).clamp(48.0, plot.width() * 0.72); + let box_w = clamp_soft(widest * base * 0.62, 48.0, plot.width() * 0.72); let (x, y) = caption_at(plot, box_w, box_h, &ink_pts, label_n); ctx.set_transform(m); ctx.set_paint(color(Rgba::WHITE, 1.0));