graphique qui a plus d'allure

This commit is contained in:
thatscringebro
2026-03-23 19:43:49 -04:00
parent 1e91c88ba6
commit 366283f87e
2 changed files with 5 additions and 5 deletions

View File

@@ -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::<f64, _>("x").unwrap();
let y = statement.read::<f64, _>("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;

View File

@@ -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)