From 96e77a939a9beb80c0f6f171a9279a7e918aaa6c Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Tue, 19 Jan 2021 13:31:02 +0100 Subject: [PATCH] Add a pie chart (with dummy data) Co-Authored-By: Tom Sydney Kerckhove --- hledger-web/Hledger/Web/Foundation.hs | 1 + hledger-web/Hledger/Web/Handler/RegisterR.hs | 6 +++++ hledger-web/templates/piechart.hamlet | 23 ++++++++++++++++++++ hledger-web/templates/register.hamlet | 1 + 4 files changed, 31 insertions(+) create mode 100644 hledger-web/templates/piechart.hamlet diff --git a/hledger-web/Hledger/Web/Foundation.hs b/hledger-web/Hledger/Web/Foundation.hs index 93ce3bc204d..38e12c0aefa 100644 --- a/hledger-web/Hledger/Web/Foundation.hs +++ b/hledger-web/Hledger/Web/Foundation.hs @@ -160,6 +160,7 @@ instance Yesod App where addScript $ StaticR js_jquery_cookie_js addScript $ StaticR js_jquery_hotkeys_js addScript $ StaticR js_jquery_flot_min_js + addScript $ StaticR js_jquery_flot_pie_min_js addScript $ StaticR js_jquery_flot_time_min_js addScript $ StaticR js_jquery_flot_tooltip_min_js toWidget [hamlet| \ |] diff --git a/hledger-web/Hledger/Web/Handler/RegisterR.hs b/hledger-web/Hledger/Web/Handler/RegisterR.hs index b8daf19e45c..d61f75a20a5 100644 --- a/hledger-web/Hledger/Web/Handler/RegisterR.hs +++ b/hledger-web/Hledger/Web/Handler/RegisterR.hs @@ -110,6 +110,12 @@ registerChartHtml title percommoditytxnreports = $(hamletFile "templates/chart.h simpleMixedAmountQuantity = maybe 0 aquantity . listToMaybe . amounts shownull c = if null c then " " else c +-- | Generate javascript/html for a mockup pie chart +registerPieChartHtml :: HtmlUrl AppRoute +registerPieChartHtml title = $(hamletFile "templates/piechart.hamlet") + where + charttitle = "Pie Chart" :: String + dayToJsTimestamp :: Day -> Integer dayToJsTimestamp d = read (formatTime defaultTimeLocale "%s" t) * 1000 -- XXX read diff --git a/hledger-web/templates/piechart.hamlet b/hledger-web/templates/piechart.hamlet new file mode 100644 index 00000000000..d15d5c73670 --- /dev/null +++ b/hledger-web/templates/piechart.hamlet @@ -0,0 +1,23 @@ +