Commit 3268a4c7 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] more forceAtlas work, still not done

parent 0a44304c
...@@ -8,6 +8,7 @@ import Prelude ...@@ -8,6 +8,7 @@ import Prelude
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, null) import Data.Nullable (Nullable, null)
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import FFI.Simple (delay)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as RH import Reactix.DOM.HTML as RH
import Gargantext.Hooks.Sigmax import Gargantext.Hooks.Sigmax
...@@ -43,16 +44,24 @@ graphCpt = R.hooksComponent "Graph" cpt ...@@ -43,16 +44,24 @@ graphCpt = R.hooksComponent "Graph" cpt
cpt props _ = do cpt props _ = do
ref <- R.useRef null ref <- R.useRef null
let mSigma = R.readRef props.sigmaRef let mSigma = R.readRef props.sigmaRef
_ <- pure $ log2 "[graphCpt] mSigma" mSigma sigma <- useSigma ref props.sigmaSettings
sigma <- case mSigma of
Just s -> pure s
Nothing -> do
sigma_ <- useSigma ref props.sigmaSettings
_ <- pure $ R.setRef props.sigmaRef $ Just sigma_
pure sigma_
useCanvasRenderer ref sigma useCanvasRenderer ref sigma
useData sigma props.graph useData sigma props.graph
useForceAtlas2 sigma props.forceAtlas2Settings useForceAtlas2 sigma props.forceAtlas2Settings
R.useLayoutEffect $
delay unit $ \_ -> do
log2 "[graphCpt] mSigma" mSigma
pure $ case mSigma of
Just s -> do
log2 "[graphCpt] mSigma is Just" s
pure unit
Nothing -> do
log2 "[graphCpt] setting sigmaRef" $ Just sigma
log2 "[graphCpt] readSigma" $ readSigma sigma
R.setRef props.sigmaRef $ Just sigma
pure $ RH.div { ref, style: {height: "95%"} } [] pure $ RH.div { ref, style: {height: "95%"} } []
type SigmaSettings = type SigmaSettings =
......
...@@ -84,8 +84,10 @@ pauseForceAtlasButton sigmaRef state = R.createElement el props [] ...@@ -84,8 +84,10 @@ pauseForceAtlasButton sigmaRef state = R.createElement el props []
Just sigma -> do Just sigma -> do
log2 "[pauseForceAtlasButton] sigma" sigma log2 "[pauseForceAtlasButton] sigma" sigma
log2 "[pauseForceAtlasButton] toggled" toggled log2 "[pauseForceAtlasButton] toggled" toggled
let rSigma = Sigmax.readSigma sigma
log2 "[pauseForceAtlasButton] rSigma" rSigma
if toggled then if toggled then
case Sigmax.readSigma sigma of case rSigma of
Nothing -> pure unit Nothing -> pure unit
Just s -> stopForceAtlas2 s Just s -> stopForceAtlas2 s
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment