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
26de4b9d
Commit
26de4b9d
authored
Sep 06, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] forceAtlast start/stop works now
parent
3268a4c7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
47 deletions
+44
-47
Graph.purs
src/Gargantext/Components/Graph.purs
+1
-15
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+2
-1
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+25
-15
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+8
-13
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+4
-3
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+4
-0
No files found.
src/Gargantext/Components/Graph.purs
View file @
26de4b9d
...
...
@@ -8,7 +8,6 @@ import Prelude
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, null)
import DOM.Simple.Console (log2)
import FFI.Simple (delay)
import Reactix as R
import Reactix.DOM.HTML as RH
import Gargantext.Hooks.Sigmax
...
...
@@ -43,25 +42,12 @@ graphCpt = R.hooksComponent "Graph" cpt
where
cpt props _ = do
ref <- R.useRef null
let mSigma = R.readRef props.sigmaRef
sigma <- useSigma ref props.sigmaSettings
sigma <- useSigma ref props.sigmaSettings props.sigmaRef
useCanvasRenderer ref sigma
useData sigma props.graph
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%"} } []
type SigmaSettings =
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
26de4b9d
...
...
@@ -121,7 +121,8 @@ graphView controls props = R.createElement el props []
where
el = R.hooksComponent "GraphView" cpt
cpt {graphId, graph} _children = do
pure $ RH.div { className: colSize controls }
pure $
RH.div { className: colSize controls }
[
Graph.graph {
forceAtlas2Settings: Graph.forceAtlas2Settings
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
26de4b9d
...
...
@@ -37,7 +37,6 @@ type Controls =
, labelSize :: R.State Number
, nodeSize :: R.State Range.NumberRange
, multiNodeSelect :: R.Ref Boolean
, pauseForceAtlas :: R.State Boolean
, showControls :: R.State Boolean
, showEdges :: R.State Boolean
, showSidePanel :: R.State Boolean
...
...
@@ -61,21 +60,34 @@ controlsToSigmaSettings { cursorSize: (cursorSize /\ _)
, maxNodeSize = nodeSizeMax
}
type LocalControls =
( pauseForceAtlas :: R.State Boolean
)
initialLocalControls :: R.Hooks (Record LocalControls)
initialLocalControls = do
pauseForceAtlas <- R.useState' true
pure $ {
pauseForceAtlas
}
controls :: Record Controls -> R.Element
controls props = R.createElement controlsCpt props []
controlsCpt :: R.Component Controls
controlsCpt = R.hooksComponent "GraphControls" cpt
where
cpt props _ =
case getShowControls props of
false -> pure $ RH.div {} []
true -> do
pure $ RH.div { className: "col-md-12", style: { paddingBottom: "10px" } }
cpt props _ = do
localControls <- initialLocalControls
pure $ case getShowControls props of
false -> RH.div {} []
true -> RH.div { className: "col-md-12", style: { paddingBottom: "10px" } }
[ R2.menu { id: "toolbar" }
[ RH.ul {}
[ -- change type button (?)
RH.li {} [ pauseForceAtlasButton props.sigmaRef
prop
s.pauseForceAtlas ] -- spatialization (pause ForceAtlas2)
RH.li {} [ pauseForceAtlasButton props.sigmaRef
localControl
s.pauseForceAtlas ] -- spatialization (pause ForceAtlas2)
, RH.li {} [ edgesToggleButton props.showEdges ]
, RH.li {} [ edgeSizeControl props.edgeSize ] -- edge size : 0-3
-- change level
...
...
@@ -100,7 +112,6 @@ useGraphControls = do
labelSize <- R.useState' 3.0
nodeSize <- R.useState' $ Range.Closed { min: 5.0, max: 10.0 }
multiNodeSelect <- R.useRef false
pauseForceAtlas <- R.useState' true
showControls <- R.useState' false
showEdges <- R.useState' true
showSidePanel <- R.useState' false
...
...
@@ -113,7 +124,6 @@ useGraphControls = do
, labelSize
, multiNodeSelect
, nodeSize
, pauseForceAtlas
, showControls
, showEdges
, showSidePanel
...
...
@@ -121,15 +131,15 @@ useGraphControls = do
, sigmaRef
}
getShowTree :: Record Controls -> Boolean
getShowTree { showTree: ( should /\ _ ) } = should
getShowControls :: Record Controls -> Boolean
getShowControls { showControls: ( should /\ _ ) } = should
getShowSidePanel :: Record Controls -> Boolean
getShowSidePanel { showSidePanel: ( should /\ _ ) } = should
getShowTree :: Record Controls -> Boolean
getShowTree { showTree: ( should /\ _ ) } = should
getShowEdges :: Record Controls -> Boolean
getShowEdges { showEdges: ( should /\ _ ) } = should
...
...
@@ -145,15 +155,15 @@ getNodeSize { nodeSize: ( size /\ _ ) } = size
getMultiNodeSelect :: Record Controls -> Boolean
getMultiNodeSelect { multiNodeSelect } = R.readRef multiNodeSelect
setShowTree :: Record Controls -> Boolean -> Effect Unit
setShowTree { showTree: ( _ /\ set ) } v = set $ const v
setShowControls :: Record Controls -> Boolean -> Effect Unit
setShowControls { showControls: ( _ /\ set ) } v = set $ const v
setShowSidePanel :: Record Controls -> Boolean -> Effect Unit
setShowSidePanel { showSidePanel: ( _ /\ set ) } v = set $ const v
setShowTree :: Record Controls -> Boolean -> Effect Unit
setShowTree { showTree: ( _ /\ set ) } v = set $ const v
setShowEdges :: Record Controls -> Boolean -> Effect Unit
setShowEdges { showEdges: ( _ /\ set ) } v = set $ const v
...
...
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
26de4b9d
...
...
@@ -17,7 +17,7 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma (startForceAtlas2, stopForceAtlas2)
import Gargantext.Hooks.Sigmax.Sigma (
re
startForceAtlas2, stopForceAtlas2)
import Gargantext.Utils.Reactix as R2
type Props = (
...
...
@@ -78,22 +78,17 @@ pauseForceAtlasButton sigmaRef state = R.createElement el props []
{ className: "btn btn-primary"
, on: {click: \_ -> do
let mSigma = R.readRef sigmaRef
log2 "[pauseForceAtlasButton] mSigma" mSigma
case mSigma of
Nothing -> pure unit
Just sigma -> do
log2 "[pauseForceAtlasButton] sigma" sigma
log2 "[pauseForceAtlasButton] toggled" toggled
let rSigma = Sigmax.readSigma sigma
log2 "[pauseForceAtlasButton] rSigma" rSigma
if toggled then
case rSigma of
Nothing -> pure unit
Just s -> stopForceAtlas2 s
Just s -> if toggled then
stopForceAtlas2 s
else
--startForceAtlas2 $ graph.sigma
pure unit
--setToggled not
restartForceAtlas2 s
setToggled not
}
}
[ H.text (text onMessage offMessage toggled) ]
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
26de4b9d
...
...
@@ -51,8 +51,8 @@ cleanupFirst sigma =
R.setRef sigma.cleanup <<< (flip Seq.cons) (R.readRef sigma.cleanup)
-- | Manages a sigma with the given settings
useSigma :: forall settings. R.Ref (Nullable Element) -> settings -> R.Hooks Sigma
useSigma container settings = do
useSigma :: forall settings. R.Ref (Nullable Element) -> settings -> R.
Ref (Maybe Sigma) -> R.
Hooks Sigma
useSigma container settings
sigmaRef
= do
sigma <- newSigma <$> R2.nothingRef <*> R.useRef Seq.empty
R.useEffect2 container sigma.sigma $
delay unit $ handleSigma sigma (readSigma sigma)
...
...
@@ -63,7 +63,8 @@ useSigma container settings = do
handleSigma sigma Nothing _ = do
ret <- createSigma settings
traverse_ (writeSigma sigma <<< Just) ret
pure (cleanupSigma sigma "useSigma")
R.setRef sigmaRef $ Just sigma
pure $ cleanupSigma sigma "useSigma"
-- | Manages a renderer for the sigma
useCanvasRenderer :: R.Ref (Nullable Element) -> Sigma -> R.Hooks Unit
...
...
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
26de4b9d
...
...
@@ -3,6 +3,7 @@ module Gargantext.Hooks.Sigmax.Sigma where
import Prelude
import Type.Row (class Union)
import Data.Either (Either(..))
import Data.Nullable (null)
import Data.Unit (Unit)
import Effect (Effect)
import FFI.Simple.Objects (named)
...
...
@@ -98,6 +99,9 @@ foreign import _bind :: forall e. EffectFn3 Sigma String (EffectFn1 e Unit) Unit
startForceAtlas2 :: forall settings. Sigma -> settings -> Effect Unit
startForceAtlas2 = runEffectFn2 _startForceAtlas2
restartForceAtlas2 :: Sigma -> Effect Unit
restartForceAtlas2 sigma = runEffectFn2 _startForceAtlas2 sigma null
stopForceAtlas2 :: Sigma -> Effect Unit
stopForceAtlas2 = runEffectFn1 _stopForceAtlas2
...
...
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