Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 92f1f36

Browse files
committed
Merge pull request #11 from garyb/dom
Update dependencies, use purescript-dom
2 parents 8f788c8 + caf3c64 commit 92f1f36

File tree

9 files changed

+126
-121
lines changed

9 files changed

+126
-121
lines changed

bower.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
"dist"
2020
],
2121
"dependencies": {
22-
"purescript-base": "^0.1.0",
23-
"purescript-argonaut": "^0.8.0",
24-
"purescript-globals": "^0.2.0",
25-
"purescript-datetime": "^0.6.0",
26-
"purescript-simple-dom": "6358414013eb3106d695e3e19488609f82d903e9",
27-
"echarts": "~2.1.10"
22+
"echarts": "~2.1.10",
23+
"purescript-argonaut-codecs": "^0.2.0",
24+
"purescript-argonaut-core": "^0.2.0",
25+
"purescript-datetime": "^0.9.0",
26+
"purescript-dom": "^0.2.6",
27+
"purescript-globals": "^0.2.0"
2828
},
2929
"devDependencies": {
30-
"purescript-signal": "^4.1.0",
31-
"purescript-random": "^0.2.0"
30+
"purescript-console": "^0.1.1",
31+
"purescript-random": "^0.2.0",
32+
"purescript-signal": "^4.1.0"
3233
},
3334
"resolutions": {
34-
"purescript-lens": "^0.8.0"
35+
"purescript-dom": "^0.2.4"
3536
}
3637
}

example/DynamicLineBar.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ foreign import toLocaleTimeString :: JSDate -> String
5252
xTimeAxis = do
5353
curTime <- now
5454
let start = toEpochMilliseconds curTime
55-
let mapfn = \i -> fromMaybe "" $
56-
replace onlyDigRgx "" <$>
55+
let mapfn = \i -> fromMaybe "" $
56+
replace onlyDigRgx "" <$>
5757
toLocaleTimeString <$>
5858
toJSDate <$>
59-
fromEpochMilliseconds (start - (Milliseconds (i * 2000)))
59+
fromEpochMilliseconds (start - (Milliseconds (toNumber i * 2000.0)))
6060

6161
return $ mapfn <$> (1..10)
6262

@@ -165,7 +165,7 @@ options = do
165165
d1 <- data1
166166
d2 <- data2
167167
return $ options_ xAxs d1 d2
168-
168+
169169

170170
dataStream =
171171
every 2000.0 ~> const do
@@ -175,10 +175,10 @@ dataStream =
175175
let lastData = precise 1.0 $
176176
rnd1 * if round ((rnd2 * 10.0) `mod` 2.0) == 0.0
177177
then 1.0 else -1.0
178-
curTime <- now
179-
let axisData =
180-
replace onlyDigRgx "" $
181-
toLocaleTimeString $
178+
curTime <- now
179+
let axisData =
180+
replace onlyDigRgx "" $
181+
toLocaleTimeString $
182182
toJSDate curTime
183183

184184

example/Force4.purs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type EFNode =
4040
initial :: Tuple Number Number,
4141
fixY :: Boolean,
4242
fixX :: Boolean,
43-
category :: Int
43+
category :: Int
4444
}
4545

4646

@@ -55,7 +55,7 @@ foreign import clientHeight :: forall e. String -> Eff e Number
5555

5656
data MockData = MockData (Array EFNode) (Array EFLink)
5757

58-
randomInRange :: Number -> Number -> Eff _ Number
58+
randomInRange :: Number -> Number -> Eff _ Number
5959
randomInRange min max = do
6060
x <- random
6161
pure $ (max - min) * x + min
@@ -68,7 +68,7 @@ createRootNode depth = do
6868
rValue <- randomInRange constMinRadius constMaxRadius
6969
let x = width / 2.0 + (0.5 - rnd) * 200.0
7070
let y = (height - 20.0) * toNumber depth / (toNumber constMaxDepth + 1.0) + 20.0
71-
71+
7272
pure { name: "ROOT_NODE"
7373
, value: rValue
7474
, id: "root"
@@ -79,20 +79,20 @@ createRootNode depth = do
7979
, category: 2
8080
}
8181

82-
82+
8383
createNodeWithIndex :: forall e. String -> Int -> Eff (random :: RANDOM|e) EFNode
84-
createNodeWithIndex idx depth =
84+
createNodeWithIndex idx depth =
8585
_{ id = idx
8686
, name = "NODE_" <> idx
8787
, category = if depth == constMaxDepth
8888
then 1
8989
else 0
9090
} <$> createRootNode depth
91-
91+
9292

9393
mkChild :: forall e. EFNode -> String ->
9494
Eff (random::RANDOM|e) (Tuple EFNode EFLink)
95-
mkChild node idx = do
95+
mkChild node idx = do
9696
child <- createNodeWithIndex idx (node.depth + one)
9797
let link = {source: node.name, target: child.name, weight: 1.0}
9898
return $ Tuple child link
@@ -104,7 +104,7 @@ mkChildren node = do
104104
mkChild node $ node.id <> ":" <> show i
105105

106106
forceMockThreeDataI :: Array (Tuple EFNode EFLink) -> MockData ->
107-
Int -> Eff _ MockData
107+
Int -> Eff _ MockData
108108
forceMockThreeDataI current accum 0 = return accum
109109
forceMockThreeDataI current accum n = do
110110
let nextAccum = foldl (\(MockData nodes links) (Tuple node link) ->
@@ -120,7 +120,7 @@ forceMockThreeData = do
120120
children <- mkChildren root
121121
forceMockThreeDataI children (MockData [root] []) constMaxDepth
122122

123-
nodes :: Eff _ _
123+
nodes :: Eff _ _
124124
nodes = return []
125125
links :: Eff _ _
126126
links = return []
@@ -148,7 +148,7 @@ itemColor color = Just $ ItemStyle itemStyleDefault {
148148
}
149149
}
150150

151-
mkOptions nodes links = Option $ optionDefault {
151+
mkOptions nodes' links' = Option $ optionDefault {
152152
series = Just $ Just <$> [
153153
ForceSeries {
154154
common: universalSeriesDefault{
@@ -170,25 +170,25 @@ mkOptions nodes links = Option $ optionDefault {
170170
itemStyle = itemColor "#af0000"
171171
}
172172
],
173-
nodes = Just $ nodeNormalize <$> nodes,
174-
links = Just $ linkNormalize <$> links,
173+
nodes = Just $ nodeNormalize <$> nodes',
174+
links = Just $ linkNormalize <$> links',
175175
minRadius = Just constMinRadius,
176176
maxRadius = Just constMaxRadius
177177
}
178-
178+
179179
}
180180
]
181181
}
182182

183-
183+
184184

185185

186186
options :: forall e. Eff (random::RANDOM|e) _
187187
options = do
188-
mockdata <- forceMockThreeData
188+
mockdata <- forceMockThreeData
189189
case mockdata of
190-
MockData nodes links -> do
191-
return $ mkOptions nodes links
190+
MockData nodes' links' -> do
191+
return $ mkOptions nodes' links'
192192

193193
force4 id = do
194194
mbEl <- getElementById id
@@ -198,4 +198,4 @@ force4 id = do
198198
opts <- options
199199
chart <- init Nothing el >>= setOption opts true
200200
return unit
201-
201+

example/Loading.purs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Prelude
44
import Control.Monad.Eff.Console (print)
55
import Data.Array hiding (init, zip)
66
import Data.Maybe
7-
import Data.Tuple
7+
import Data.Tuple
88
import Control.Monad.Eff
99
import Control.Monad.Eff.Random
1010

@@ -38,7 +38,7 @@ allEffects :: Array L.LoadingEffect
3838
allEffects = [L.Spin, L.Bar, L.Ring, L.Whirling, L.DynamicLine, L.Bubble]
3939

4040
effect :: L.LoadingEffect -> L.LoadingOption
41-
effect eff = L.LoadingOption $
41+
effect eff = L.LoadingOption $
4242
L.loadingOptionDefault{
4343
text = Just $ "effect",
4444
effect = Just eff,
@@ -60,7 +60,7 @@ series true = [
6060
name = Just "second"
6161
},
6262
lineSeries: lineSeriesDefault {
63-
"data" = Just $ simpleData <$> [2.6, 5.9, 9.0,
63+
"data" = Just $ simpleData <$> [2.6, 5.9, 9.0,
6464
26.4, 28.7, 70.7, 175.6, 182.2, 48.7,
6565
18.8, 6.0, 2.3]
6666
}
@@ -81,7 +81,7 @@ series false = [
8181
name = Just "second"
8282
},
8383
barSeries: barSeriesDefault {
84-
"data" = Just $ simpleData <$> [2.6, 5.9, 9.0,
84+
"data" = Just $ simpleData <$> [2.6, 5.9, 9.0,
8585
26.4, 28.7, 70.7, 175.6, 182.2, 48.7,
8686
18.8, 6.0, 2.3]
8787
}
@@ -130,15 +130,15 @@ options i = Option $ optionDefault {
130130
data ChartSignal a = StartLoading L.LoadingOption | StopLoading a
131131

132132

133-
dataStream :: Signal (Eff _ (ChartSignal _))
133+
dataStream :: forall eff. Signal (Eff (random :: Control.Monad.Eff.Random.RANDOM | eff) (ChartSignal Option))
134134
dataStream =
135135
foldp (\_ curstateE -> do
136136
curstate <- curstateE
137137
case curstate of
138138
StartLoading _ -> do
139139
effAndI <- randomInList allEffects
140140
case effAndI of
141-
Tuple eff i ->
141+
Tuple eff i ->
142142
return $ StopLoading $ options i
143143
StopLoading _ -> do
144144
effAndI <- randomInList allEffects
@@ -148,7 +148,7 @@ dataStream =
148148
(return $ StartLoading (effect L.Spin))
149149
(every 2000.0)
150150

151-
151+
152152
loading id = do
153153
mbEl <- getElementById id
154154
case mbEl of
@@ -161,6 +161,6 @@ loading id = do
161161
case content of
162162
StartLoading loadOptions -> L.showLoading loadOptions chart
163163
>>= \_ -> return unit
164-
StopLoading options ->
165-
setOption options true chart >>= L.hideLoading
164+
StopLoading options' ->
165+
setOption options' true chart >>= L.hideLoading
166166
>>= \_ -> return unit

example/Main.purs

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
module Main where
22

33
import Prelude
4-
import Utils
5-
import Line4 (line4)
6-
import Scatter3 (scatter3)
7-
import K (k)
8-
import Radar3 (radar3)
4+
5+
import DOM.Node.Types (ElementId(..))
6+
97
import Chord2 (chord2)
8+
import Connect (connectM)
9+
import Control.Monad.Eff (Eff())
10+
import DynamicLineBar (dynamicLineBar)
11+
import ECharts.Effects
12+
import EventRiver1 (eventRiver)
13+
import Events (events)
1014
import Force4 (force4)
11-
import Map11 (map11)
15+
import Funnel2 (funnel2)
1216
import Gauge4 (gauge4)
13-
import Funnel2 (funnel2)
14-
import EventRiver1 (eventRiver)
15-
import DynamicLineBar (dynamicLineBar)
17+
import K (k)
18+
import Line4 (line4)
1619
import Loading (loading)
17-
import Events (events)
18-
import Connect (connectM)
20+
import Map11 (map11)
1921
import Mix2Safe (mix2safe)
22+
import Radar3 (radar3)
23+
import Scatter3 (scatter3)
24+
import Utils
2025

2126
main = onLoad $ do
22-
line4 "line4"
23-
scatter3 "scatter3"
24-
k "k"
25-
radar3 "radar3"
26-
chord2 "chord2"
27-
force4 "force4"
28-
map11 "map11"
29-
gauge4 "gauge4"
30-
funnel2 "funnel2"
31-
eventRiver "event-river"
32-
33-
dynamicLineBar "dynamic-line-bar"
34-
loading "loading"
35-
events "events"
36-
connectM "connect1" "connect2"
37-
mix2safe "mix2safe"
27+
line4 (ElementId "line4")
28+
scatter3 (ElementId "scatter3")
29+
k (ElementId "k")
30+
radar3 (ElementId "radar3")
31+
chord2 (ElementId "chord2")
32+
force4 (ElementId "force4")
33+
map11 (ElementId "map11")
34+
gauge4 (ElementId "gauge4")
35+
funnel2 (ElementId "funnel2")
36+
eventRiver (ElementId "event-river")
3837

38+
dynamicLineBar (ElementId "dynamic-line-bar")
39+
loading (ElementId "loading")
40+
events (ElementId "events")
41+
connectM (ElementId "connect1") (ElementId "connect2")
42+
mix2safe (ElementId "mix2safe")

0 commit comments

Comments
 (0)