From 366283f87ee7a35e5c2bdd84d9071afb9c87a943 Mon Sep 17 00:00:00 2001 From: thatscringebro Date: Mon, 23 Mar 2026 19:43:49 -0400 Subject: [PATCH] graphique qui a plus d'allure --- src/data_layer.rs | 7 ++++--- src/ui.rs | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data_layer.rs b/src/data_layer.rs index c5365e3..c23d0a6 100644 --- a/src/data_layer.rs +++ b/src/data_layer.rs @@ -328,7 +328,7 @@ pub fn get_tr_type_price_over_time( tr_type_id: i64, ) -> Vec<(f64, f64)> { let mut query = " -SELECT strftime('%Y%m', datetime(date, 'unixepoch')) as x, SUM(amount) as y +SELECT strftime('%Y%m', datetime(date, 'unixepoch')) as z, SUM(amount) as y FROM Transactions WHERE type_id = :tr_type " @@ -336,7 +336,7 @@ WHERE type_id = :tr_type if ac_id != 0 { query.push_str(" AND account_id = :ac_id"); } - query.push_str(" GROUP BY x;"); + query.push_str(" GROUP BY z;"); let mut statement = con.prepare(query).unwrap(); statement.bind((":tr_type", tr_type_id)).unwrap(); @@ -344,11 +344,12 @@ WHERE type_id = :tr_type statement.bind((":ac_id", ac_id)).unwrap(); } let mut data = Vec::<(f64, f64)>::new(); + let mut x = 0.0; while let Ok(State::Row) = statement.next() { - let x = statement.read::("x").unwrap(); let y = statement.read::("y").unwrap() * -1.0; // Pour passer de dépense dans le négatif à un graphique qui monte data.push((x, y)); + x += 1.0; } return data; diff --git a/src/ui.rs b/src/ui.rs index 5bc7fb1..da1c8f0 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -118,8 +118,7 @@ pub fn ui(frame: &mut Frame, app: &mut App) { .map(|&(x, _)| x) .min_by(|a, b| a.partial_cmp(b).unwrap()) .unwrap() - .round() - - 1.0; + .round(); let max_x = slice .into_iter() .map(|&(x, _)| x)