This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
/
Chart.purs
116 lines (94 loc) · 2.66 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
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.Either (either)
import Data.Foreign (Foreign, toForeign)
import DOM (DOM)
import DOM.HTML.Types (HTMLElement)
import ECharts.Internal (undefinedValue)
import ECharts.Theme (Theme, builtInThemeName)
import ECharts.Types (Chart, ECHARTS, Option)
foreign import initImpl
∷ ∀ e. Foreign
→ HTMLElement
→ Eff (dom ∷ DOM, echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) Chart
init
∷ ∀ m e
. MonadEff (dom ∷ DOM, echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) m
⇒ HTMLElement
→ m Chart
init el = liftEff $ initImpl undefinedValue el
initWithTheme
∷ ∀ m e
. MonadEff (dom ∷ DOM, echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) m
⇒ Theme
→ HTMLElement
→ m Chart
initWithTheme theme el =
liftEff $ initImpl (either (toForeign <<< builtInThemeName) toForeign theme) el
foreign import registerTheme
∷ ∀ e. String
→ Foreign
→ Eff (echarts ∷ ECHARTS|e) Unit
foreign import setOptionImpl
∷ ∀ e. Option → Chart → Eff (echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) Unit
setOption
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) m
⇒ Option
→ Chart
→ m Unit
setOption opts chart = liftEff $ setOptionImpl opts chart
foreign import resetOptionImpl
∷ ∀ e. Option → Chart → Eff (echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) Unit
resetOption
∷ ∀ m e
. MonadEff (echarts ∷ ECHARTS, exception ∷ EXCEPTION|e) m
⇒ Option
→ Chart
→ m Unit
resetOption opts chart = liftEff $ resetOptionImpl 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