fix: improve anti-clipping for graphs

This commit is contained in:
electria 2026-08-16 20:34:21 -07:00
commit d3f94b4acc
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -55,7 +55,8 @@ impl canvas::Program<app::Message, Theme, Renderer> for Graph {
&canvas::Path::new(|builder| {
for (index, value) in self.timeline.iter().enumerate() {
let x = index as f32 / self.timeline.len() as f32 * bounds.width;
let y = bounds.height - value / 100. * bounds.height - 1.;
let y = (bounds.height - value / 100. * bounds.height)
.clamp(1., bounds.height - 1.);
builder.line_to(Point::new(x, y))
}
}),