Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
8f6cbb5e
Commit
8f6cbb5e
authored
Sep 17, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] forceAtlas refresh on controls change
parent
f8e96c7d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
6 deletions
+32
-6
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+1
-1
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+13
-3
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+18
-2
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
8f6cbb5e
...
@@ -131,7 +131,7 @@ graphView sigmaRef props = R.createElement el props []
...
@@ -131,7 +131,7 @@ graphView sigmaRef props = R.createElement el props []
RH.div { id: "graph-view", className: "col-md-12" }
RH.div { id: "graph-view", className: "col-md-12" }
[
[
Graph.graph {
Graph.graph {
forceAtlas2Settings: Graph.forceAtlas2Settings
forceAtlas2Settings: Graph.forceAtlas2Settings
, graph
, graph
, sigmaSettings: Graph.sigmaSettings
, sigmaSettings: Graph.sigmaSettings
, sigmaRef: sigmaRef
, sigmaRef: sigmaRef
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
8f6cbb5e
...
@@ -60,9 +60,19 @@ startSigma ref sigmaRef settings forceAtlas2Settings graph = do
...
@@ -60,9 +60,19 @@ startSigma ref sigmaRef settings forceAtlas2Settings graph = do
useData sigma graph
useData sigma graph
useForceAtlas2 sigma forceAtlas2Settings
useForceAtlas2 sigma forceAtlas2Settings
else
else
R.useEffect' $ do
pure unit
log2 "refreshing" $ readSigma sigma
delay unit $ \_ -> pure $ Sigma.refresh <$> readSigma sigma
R.useEffect $ do
delay unit $ handleRefresh sigma
where
handleRefresh sigma _ = do
let rSigma = readSigma sigma
_ <- case rSigma of
Nothing -> log2 "[handleRefresh] can't refresh" sigma
Just s -> do
Sigma.refreshForceAtlas s
pure $ pure unit
-- | Manages a sigma with the given settings
-- | Manages a sigma with the given settings
useSigma :: forall settings. R.Ref (Nullable Element) -> settings -> R.Ref (Maybe Sigma) -> R.Hooks {sigma :: Sigma, isNew :: Boolean}
useSigma :: forall settings. R.Ref (Nullable Element) -> settings -> R.Ref (Maybe Sigma) -> R.Hooks {sigma :: Sigma, isNew :: Boolean}
...
...
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
8f6cbb5e
module Gargantext.Hooks.Sigmax.Sigma where
module Gargantext.Hooks.Sigmax.Sigma where
import Prelude
import Prelude
import Type.Row (class Union)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Nullable (null)
import Data.Nullable (null)
import Data.Unit (Unit)
import Data.Unit (Unit)
import DOM.Simple.Console (log, log2)
import Effect (Effect)
import Effect (Effect)
import
FFI.Simple.Objects (named
)
import
Effect.Timer (setTimeout
)
import Effect.Uncurried (EffectFn1, mkEffectFn1, runEffectFn1, EffectFn2, runEffectFn2, EffectFn3, runEffectFn3, EffectFn4, runEffectFn4)
import Effect.Uncurried (EffectFn1, mkEffectFn1, runEffectFn1, EffectFn2, runEffectFn2, EffectFn3, runEffectFn3, EffectFn4, runEffectFn4)
import FFI.Simple.Objects (named)
import Type.Row (class Union)
foreign import data Sigma :: Type
foreign import data Sigma :: Type
...
@@ -54,6 +57,19 @@ refresh = runEffectFn1 _refresh
...
@@ -54,6 +57,19 @@ refresh = runEffectFn1 _refresh
foreign import _refresh :: EffectFn1 Sigma Unit
foreign import _refresh :: EffectFn1 Sigma Unit
refreshForceAtlas :: Sigma -> Effect Unit
refreshForceAtlas sigma = do
isRunning <- isForceAtlas2Running sigma
if isRunning then
pure unit
else do
_ <- setTimeout 100 $ do
restartForceAtlas2 sigma
_ <- setTimeout 100 $
stopForceAtlas2 sigma
pure unit
pure unit
addRenderer :: forall r err. Sigma -> r -> Effect (Either err Unit)
addRenderer :: forall r err. Sigma -> r -> Effect (Either err Unit)
addRenderer = runEffectFn4 _addRenderer Left Right
addRenderer = runEffectFn4 _addRenderer Left Right
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment