This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
/
Types.purs
178 lines (144 loc) · 3.94 KB
/
Types.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
module ECharts.Types where
import Prelude
import Control.Monad.Eff (kind Effect)
import Data.Foreign (Foreign, toForeign)
foreign import data Chart ∷ Type
-- | For Eff computation
foreign import data ECHARTS ∷ Effect
data TooltipTrigger
= ItemTrigger
| AxisTrigger
tooltipTriggerToForeign ∷ TooltipTrigger → Foreign
tooltipTriggerToForeign = toForeign <<< case _ of
ItemTrigger → "item"
AxisTrigger → "axis"
data PixelOrPercent
= Pixel Int
| Percent Number
pixelOrPercentToForeign ∷ PixelOrPercent → Foreign
pixelOrPercentToForeign = case _ of
Pixel i → toForeign i
Percent n → toForeign $ show n <> "%"
data Orient
= Vertical
| Horizontal
orientToForeign ∷ Orient → Foreign
orientToForeign = toForeign <<< case _ of
Vertical → "vertical"
Horizontal → "horizontal"
data AxisType
= Category
| Value
| Time
| Log
axisTypeToForeign ∷ AxisType → Foreign
axisTypeToForeign = toForeign <<< case _ of
Category → "category"
Value → "value"
Time → "time"
Log → "log"
data Symbol
= Circle
| Rect
| RoundRect
| Triangle
| Diamond
| Pin
| Arrow
| EmptyCircle
| None
symbolToForeign ∷ Symbol → Foreign
symbolToForeign = toForeign <<< case _ of
Circle → "circle"
Rect → "rect"
RoundRect → "roundRect"
Triangle → "triangle"
Diamond → "diamond"
Pin → "pin"
Arrow → "arrow"
EmptyCircle → "emptyCircle"
None → "none"
newtype Point = Point { x ∷ PixelOrPercent, y ∷ PixelOrPercent }
pointToForeign ∷ Point → Foreign
pointToForeign (Point {x, y}) =
toForeign [ pixelOrPercentToForeign x, pixelOrPercentToForeign y ]
newtype Radius = Radius { start ∷ PixelOrPercent, end ∷ PixelOrPercent }
radiusToForeign ∷ Radius → Foreign
radiusToForeign (Radius {start, end}) =
toForeign [ pixelOrPercentToForeign start, pixelOrPercentToForeign end ]
newtype SingleValueRadius = SingleValueRadius PixelOrPercent
singleValueRadiusToForeign ∷ SingleValueRadius → Foreign
singleValueRadiusToForeign (SingleValueRadius r) = pixelOrPercentToForeign r
numItem ∷ Number → Item
numItem = Item <<< toForeign
strItem ∷ String → Item
strItem = Item <<< toForeign
numArrItem ∷ Array Number → Item
numArrItem = Item <<< toForeign
strArrItem ∷ Array String → Item
strArrItem = Item <<< toForeign
data PointerType
= LinePointer
| CrossPointer
| ShadowPointer
pointerTypeToForeign ∷ PointerType → Foreign
pointerTypeToForeign = toForeign <<< case _ of
LinePointer → "line"
CrossPointer → "cross"
ShadowPointer → "shadow"
data LineType
= SolidLine
| DashedLine
| DottedLine
lineTypeToForeign ∷ LineType → Foreign
lineTypeToForeign = toForeign <<< case _ of
SolidLine → "solid"
DashedLine → "dashed"
DottedLine → "dotted"
pairItem ∷ Number → Number → Item
pairItem x y = Item $ toForeign [ x, y ]
type FormatterInput =
{ componentType ∷ String
, seriesIndex ∷ Int
, seriesName ∷ String
, name ∷ String
, dataIndex ∷ Int
, "data" ∷ Item -- ???
, value ∷ Foreign
, color ∷ String
, percent ∷ Number
, dataType ∷ String
}
type FormatterInputArrayValue =
{ componentType ∷ String
, seriesIndex ∷ Int
, seriesName ∷ String
, name ∷ String
, dataIndex ∷ Int
, "data" ∷ Item
, value ∷ Array Foreign
, color ∷ String
, percent ∷ Number
}
data SelectedMode
= Single
| Multiple
| Disabled
selectedModeToForeign ∷ SelectedMode → Foreign
selectedModeToForeign = case _ of
Single → toForeign "single"
Multiple → toForeign "multiple"
Disabled → toForeign false
data HorizontalPosition
= LeftHP
| RightHP
| CenterHP
horizontalPositionToForeign ∷ HorizontalPosition → Foreign
horizontalPositionToForeign = toForeign <<< case _ of
LeftHP → "left"
RightHP → "right"
CenterHP → "center"
newtype Item = Item Foreign
newtype Coord = Coord Foreign
coord ∷ Number → Number → Coord
coord x y = Coord $ toForeign [ x, y ]