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