Skip to content

Instantly share code, notes, and snippets.

@afcondon
Created October 7, 2016 09:13
Show Gist options
  • Save afcondon/d17a4ea3ca1ef24cc333508d8dad24ee to your computer and use it in GitHub Desktop.
Save afcondon/d17a4ea3ca1ef24cc333508d8dad24ee to your computer and use it in GitHub Desktop.
foreign import onTickFn :: ∀ eff. EffFn2 (d3::D3|eff)
(Eff (d3::D3|eff) Unit)
D3Simulation
D3Simulation
onTick :: ∀ eff. Eff (d3::D3|eff) Unit -> D3Simulation -> Eff (d3::D3|eff) D3Simulation
onTick = runEffFn2 onTickFn
ticked :: ∀ eff. Selection ForceNode -> Selection ForceLink -> Eff (d3::D3|eff) (Eff (d3::D3|eff) Unit)
ticked node link = pure inner where
inner :: Eff (d3::D3|eff) Unit
inner = do
-- link ... attr "x1" (AttrFn (\d i n e -> pure d.source.x))
-- .. attr "y1" (AttrFn (\d i n e -> pure d.source.y))
-- .. attr "x2" (AttrFn (\d i n e -> pure d.source.x))
-- .. attr "y2" (AttrFn (\d i n e -> pure d.source.y))
--
-- node ... attr "cx" (AttrFn (\d i n e -> pure d.x))
-- .. attr "cy" (AttrFn (\d i n e -> pure d.y))
pure unit
main :: ∀ e. Eff (d3::D3,console::CONSOLE|e) Unit
main = do
.
.
.
callback <- ticked node link
sim <- simulation ... initNodes jsondata.nodes -- this is the magic spot where jsondata.nodes changes type to jsondata.forcenodes
... onTick callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment