aboutsummaryrefslogtreecommitdiff
path: root/src/client/Chart/Api.elm
diff options
context:
space:
mode:
authorJoris2017-04-02 17:51:12 +0200
committerJoris2017-04-02 21:07:08 +0200
commit5c110716cfda6e616a795edd12f2012b132dca9f (patch)
tree71c3d04780302edf0648bec1cd914757cdbb2883 /src/client/Chart/Api.elm
parent64ff4707fdcd81c27c6be9903c3c82bc543ef016 (diff)
downloadbudget-5c110716cfda6e616a795edd12f2012b132dca9f.tar.gz
budget-5c110716cfda6e616a795edd12f2012b132dca9f.tar.bz2
budget-5c110716cfda6e616a795edd12f2012b132dca9f.zip
Add a chart on payments by month by categories
Diffstat (limited to 'src/client/Chart/Api.elm')
-rw-r--r--src/client/Chart/Api.elm41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/client/Chart/Api.elm b/src/client/Chart/Api.elm
new file mode 100644
index 0000000..693f362
--- /dev/null
+++ b/src/client/Chart/Api.elm
@@ -0,0 +1,41 @@
+module Chart.Api exposing
+ ( from
+ , withSize
+ , withTitle
+ , withOrdinate
+ , toHtml
+ )
+
+import Html exposing (Html)
+import Svg exposing (..)
+import Svg.Attributes exposing (..)
+
+import Chart.Model as Chart exposing (Chart, Serie, Vec2, View)
+import Chart.View as Chart
+
+from : List String -> List Serie -> Chart
+from keys series =
+ { keys = keys
+ , series = series
+ , size = { x = 600, y = 400 }
+ , title = ""
+ , scaleColor = "#DDDDDD"
+ , formatOrdinate = toString
+ , ordinateLines = 5
+ }
+
+withSize : Vec2 -> Chart -> Chart
+withSize size chart = { chart | size = size }
+
+withTitle : String -> Chart -> Chart
+withTitle title chart = { chart | title = title }
+
+withOrdinate : Int -> (Float -> String) -> Chart -> Chart
+withOrdinate lines format chart =
+ { chart
+ | formatOrdinate = format
+ , ordinateLines = lines
+ }
+
+toHtml : Chart -> Html msg
+toHtml chart = Chart.view chart