changeset 46:746d8278aa31

Fix chart color problem (preliminarily)
author Lewin Bormann <lbo@spheniscida.de>
date Tue, 19 Jul 2022 21:23:56 -0700
parents 90a4e4589d5e
children c2436a591e56
files src/main.rs
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.rs	Tue Jul 19 20:48:01 2022 -0700
+++ b/src/main.rs	Tue Jul 19 21:23:56 2022 -0700
@@ -139,6 +139,10 @@
     let colors = vec![
         "red", "blue", "orange", "green", "gray", "purple", "black", "brown",
     ];
+
+    let bordercolor = if opt.typ == "line" { colors.clone() } else { vec!["white"] };
+    let bgcolor = if opt.typ != "line" { colors.clone() } else { vec![] };
+
     if values.len() > colors.len() {
         error!("Not enough colors for line chart!");
     }
@@ -149,8 +153,8 @@
                 "label": name,
                 "data": val,
                 // TODO: these colors don't work well: differently for different chart types
-                "borderColor": colors,
-                "backgroundColor": colors,
+                "borderColor": bordercolor,
+                "backgroundColor": bgcolor,
             })
         })
         .collect();