This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
/
Chart.purs
120 lines (95 loc) · 2.84 KB
/
Chart.purs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
module ECharts.Chart
( init
, initWithTheme
, registerTheme
, setOption
, resetOption
, resize
, dispose
, clear
, getOption
) where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class (class MonadEff, liftEff)
import Control.Monad.Eff.Exception (EXCEPTION)
import Data.Foreign (Foreign, toForeign)
import DOM (DOM)
import DOM.HTML.Types (HTMLElement)
import ECharts.Internal (undefinedValue)
import ECharts.Monad (DSL, buildObj)
import ECharts.Theme (Theme(..))
import ECharts.Types.Phantom (OptionI)
import ECharts.Types (Chart, ECHARTS)
foreign import initImpl
∷ ∀ e. Foreign
→ HTMLElement
→ Eff (dom ∷ DOM, echarts ∷ ECHARTS, err ∷ EXCEPTION|e) Chart
init
∷ ∀ m e
. MonadEff (dom ∷ DOM, echarts ∷ ECHARTS, err ∷ EXCEPTION|e) m
⇒ HTMLElement
→ m Chart
init el = liftEff $ initImpl undefinedValue el
initWithTheme
∷ ∀ m e
. MonadEff (dom ∷ DOM, echarts ∷ ECHARTS, err ∷ EXCEPTION|e) m
⇒ Theme
→ HTMLElement
→ m Chart
initWithTheme (ByName name) el = liftEff $ initImpl (toForeign name) el
initWithTheme (FromObject theme) el = liftEff $ initImpl (toForeign theme) el
foreign import registerTheme
∷ ∀ e. String
→ Foreign
→ Eff (echarts ∷ ECHARTS|e) Unit
foreign import setOptionImpl
∷ ∀ e. Foreign → Chart → Eff (echarts ∷ ECHARTS, err ∷ EXCEPTION|e) Unit
setOption
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS, err ∷ EXCEPTION|e) m
⇒ DSL OptionI
→ Chart
→ m Unit
setOption opts chart = liftEff $ setOptionImpl (buildObj opts) chart
foreign import resetOptionImpl
∷ ∀ e. Foreign → Chart → Eff (echarts ∷ ECHARTS, err ∷ EXCEPTION|e) Unit
resetOption
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS, err ∷ EXCEPTION|e) m
⇒ DSL OptionI
→ Chart
→ m Unit
resetOption opts chart = liftEff $ resetOptionImpl (buildObj opts) chart
foreign import resizeImpl
∷ ∀ e. Chart → Eff (echarts ∷ ECHARTS|e) Unit
resize
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS|e) m
⇒ Chart
→ m Unit
resize chart = liftEff $ resizeImpl chart
foreign import clearImpl
∷ ∀ e. Chart → Eff (echarts ∷ ECHARTS|e) Unit
clear
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS|e) m
⇒ Chart
→ m Unit
clear chart = liftEff $ clearImpl chart
foreign import disposeImpl
∷ ∀ e. Chart → Eff (echarts ∷ ECHARTS|e) Unit
dispose
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS|e) m
⇒ Chart
→ m Unit
dispose chart = liftEff $ disposeImpl chart
foreign import getOptionImpl
∷ ∀ e. Chart → Eff (echarts ∷ ECHARTS|e) Foreign
getOption
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS|e) m
⇒ Chart
→ m Foreign
getOption chart = liftEff $ getOptionImpl chart