summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenedict Börger <benedict@0xb8000.de>2019-06-22 23:56:25 +0200
committerBenedict Börger <benedict@0xb8000.de>2019-06-22 23:56:25 +0200
commitb7a7d1d9512357bb2309fff50afaebd4082f9dd8 (patch)
tree69d61fa4142a5ba263743b058b90928e7d3134e9 /src
parenteef5efc67b9f0b2eeede9a6d89d2de796634acb7 (diff)
[web_frontend][chart] link chart to transactions
when a category in the pie chart is selected load the corresponding transaction site with the right filter set.
Diffstat (limited to 'src')
-rw-r--r--src/web_frontend/chart.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/web_frontend/chart.rs b/src/web_frontend/chart.rs
index 43ec3eb..0992e99 100644
--- a/src/web_frontend/chart.rs
+++ b/src/web_frontend/chart.rs
@@ -13,9 +13,15 @@ use chrono::{NaiveDate, Utc};
use chrono::Datelike;
#[derive(Serialize)]
+struct GroupValues {
+ amount : f32,
+ filter : String
+}
+
+#[derive(Serialize)]
struct ChartContext {
account_name : String,
- groups : HashMap<String, f32>,
+ groups : HashMap<String, GroupValues>,
total_sum : f32,
total_chart : f32,
date_start : String,
@@ -71,9 +77,14 @@ pub fn chart_handler(account : &RawStr, start : Option<&RawStr>, end : Option<&R
println!("total sum: {}", total_sum);
let mut total_chart = 0.0;
for (section_name, entries) in ini_file.sections {
+ let mut filter_string = String::from("");
let mut complete = 0.0;
for (key, values) in entries {
for val in values {
+ filter_string.push_str(&key);
+ filter_string.push_str("-");
+ filter_string.push_str(&val);
+ filter_string.push_str(".");
let mut t_filtered_cloned = t_filtered.clone();
if val.is_empty() || val.is_empty() {
continue
@@ -85,7 +96,7 @@ pub fn chart_handler(account : &RawStr, start : Option<&RawStr>, end : Option<&R
complete = complete + tmp.abs();
}
}
- groups.insert(section_name, complete);
+ groups.insert(section_name, GroupValues{ amount: complete, filter : filter_string } );
total_chart = total_chart + complete;
// ALSO INSERT OTHER, AKA THE REST
}