graphique qui a plus d'allure
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user