From 92b51251c006f3851638eaceea6e8636cb4accca Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Thu, 24 Aug 2017 14:17:37 +0300 Subject: [PATCH] Show 2 decimals for tokens on comment image --- src/clj/commiteth/util/png_rendering.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/clj/commiteth/util/png_rendering.clj b/src/clj/commiteth/util/png_rendering.clj index 12f2a17..1344685 100644 --- a/src/clj/commiteth/util/png_rendering.clj +++ b/src/clj/commiteth/util/png_rendering.clj @@ -26,9 +26,10 @@ (defn token-map->list [tokens] - (mapv (fn [[tla balance]] {:tla (subs (str tla) 1) - :balance balance}) - tokens)) + (let [fmt-balance (fn [x] (format "%.02f" (double x)))] + (mapv (fn [[tla balance]] {:tla (subs (str tla) 1) + :balance (fmt-balance balance)}) + tokens))) (defn image-height [tokens] (+ 300 (* 32 (count (keys tokens))))) @@ -73,4 +74,4 @@ (comment (with-open [w (io/output-stream "foo.png")] - (.write w (gen-comment-image "0xf00barbeeff00barbeeff00barbeeff00barbeef" "12.2" {:SNT 250 :GNO 100 :WTF 3452.42} "http://github.com/someorg/somerepo/issues/42")))) + (.write w (gen-comment-image "0xf00barbeeff00barbeeff00barbeeff00barbeef" "12.2" {:SNT 250.2000000343 :GNO 100 :WTF 3452.42} "http://github.com/someorg/somerepo/issues/42"))))