fix: fill screen horizontally

before, the line graph would always be one step behind (left)
This commit is contained in:
electria 2026-11-09 17:10:59 -08:00
commit 1b814f9688
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

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