aboutsummaryrefslogtreecommitdiff
path: root/src/client/Chart/Api.elm
blob: 693f362f09a132689923fb3c8bed9b7ad358b907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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