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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
gargantext
purescript-gargantext
Commits
d6d813f4
Commit
d6d813f4
authored
Sep 25, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] forceAtlasButton2 which uses props
parent
ec6db7d5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
30 deletions
+63
-30
Graph.purs
src/Gargantext/Components/Graph.purs
+15
-4
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+11
-6
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+12
-8
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+10
-0
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+6
-3
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+9
-9
No files found.
src/Gargantext/Components/Graph.purs
View file @
d6d813f4
...
@@ -29,6 +29,7 @@ type Graph = Sigmax.Graph Node Edge
...
@@ -29,6 +29,7 @@ type Graph = Sigmax.Graph Node Edge
type Props sigma forceatlas2 =
type Props sigma forceatlas2 =
( graph :: Graph
( graph :: Graph
, forceAtlas2Paused :: Boolean
, forceAtlas2Settings :: forceatlas2
, forceAtlas2Settings :: forceatlas2
, sigmaSettings :: sigma
, sigmaSettings :: sigma
, sigmaRef :: R.Ref (Maybe Sigma)
, sigmaRef :: R.Ref (Maybe Sigma)
...
@@ -40,11 +41,20 @@ graph props = R.createElement graphCpt props []
...
@@ -40,11 +41,20 @@ graph props = R.createElement graphCpt props []
graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = R.hooksComponent "Graph" cpt
graphCpt = R.hooksComponent "Graph" cpt
where
where
cpt props _ = do
cpt {graph, forceAtlas2Paused, forceAtlas2Settings, sigmaSettings, sigmaRef} _ = do
let memoProps = {
graph
, forceAtlas2Paused
, forceAtlas2Settings
, sigmaSettings
, sigmaRef
}
ref <- R.useRef null
ref <- R.useRef null
startSigma ref
props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.
graph
startSigma ref
sigmaRef sigmaSettings forceAtlas2Paused forceAtlas2Settings
graph
pure $ RH.div { ref, style: {height: "95%"} } []
--pure $ RH.div { ref, style: {height: "95%"} } []
R.useMemo1 memoProps $ const $ RH.div { ref, style: {height: "95%"} } []
type SigmaSettings =
type SigmaSettings =
( animationsTime :: Number
( animationsTime :: Number
...
@@ -204,7 +214,7 @@ type ForceAtlas2Settings =
...
@@ -204,7 +214,7 @@ type ForceAtlas2Settings =
, startingIterations :: Number
, startingIterations :: Number
, strongGravityMode :: Boolean
, strongGravityMode :: Boolean
-- , timeout :: Number
-- , timeout :: Number
--
, worker :: Boolean
, worker :: Boolean
)
)
forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings :: {|ForceAtlas2Settings}
...
@@ -222,4 +232,5 @@ forceAtlas2Settings =
...
@@ -222,4 +232,5 @@ forceAtlas2Settings =
, slowDown : 0.7
, slowDown : 0.7
, startingIterations : 2.0
, startingIterations : 2.0
, strongGravityMode : false
, strongGravityMode : false
, worker: true
}
}
src/Gargantext/Components/GraphExplorer.purs
View file @
d6d813f4
...
@@ -89,7 +89,10 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
...
@@ -89,7 +89,10 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
]
]
, row [ Controls.controls controls ]
, row [ Controls.controls controls ]
, row [ tree {mCurrentRoute, treeId} controls
, row [ tree {mCurrentRoute, treeId} controls
, mGraph controls.sigmaRef {graphId, graph}
, mGraph controls.sigmaRef {
forceAtlas2Paused: fst controls.forceAtlas2Paused
, graphId
, graph}
, Sidebar.sidebar {showSidePanel: fst controls.showSidePanel} ]
, Sidebar.sidebar {showSidePanel: fst controls.showSidePanel} ]
, row [ ]
, row [ ]
]
]
...
@@ -111,12 +114,13 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
...
@@ -111,12 +114,13 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
Tree.elTreeview {mCurrentRoute, root: treeId}
Tree.elTreeview {mCurrentRoute, root: treeId}
]
]
mGraph :: R.Ref (Maybe Sigmax.Sigma) -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph :: R.Ref (Maybe Sigmax.Sigma) -> {
forceAtlas2Paused :: Boolean,
graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph _ {graph: Nothing} = RH.div {} []
mGraph _ {graph: Nothing} = RH.div {} []
mGraph sigmaRef {
graphId, graph: Just graph} = graphView sigmaRef {
graphId, graph}
mGraph sigmaRef {
forceAtlas2Paused, graphId, graph: Just graph} = graphView sigmaRef {forceAtlas2Paused,
graphId, graph}
type GraphProps = (
type GraphProps = (
graphId :: GraphId
forceAtlas2Paused :: Boolean
, graphId :: GraphId
, graph :: Graph.Graph
, graph :: Graph.Graph
)
)
...
@@ -126,12 +130,13 @@ graphView sigmaRef props = R.createElement el props []
...
@@ -126,12 +130,13 @@ graphView sigmaRef props = R.createElement el props []
where
where
--memoCmp props1 props2 = props1.graphId == props2.graphId
--memoCmp props1 props2 = props1.graphId == props2.graphId
el = R.hooksComponent "GraphView" cpt
el = R.hooksComponent "GraphView" cpt
cpt {graphId, graph} _children = do
cpt {
forceAtlas2Paused,
graphId, graph} _children = do
pure $
pure $
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
forceAtlas2Paused
, forceAtlas2Settings: Graph.forceAtlas2Settings
, graph
, graph
, sigmaSettings: Graph.sigmaSettings
, sigmaSettings: Graph.sigmaSettings
, sigmaRef: sigmaRef
, sigmaRef: sigmaRef
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
d6d813f4
...
@@ -27,7 +27,7 @@ import Gargantext.Components.Graph as Graph
...
@@ -27,7 +27,7 @@ import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton)
import Gargantext.Components.GraphExplorer.Button (centerButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeSizeControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.RangeControl (edgeSizeControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton)
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton)
import Gargantext.Components.GraphExplorer.ToggleButton (edgesToggleButton, pauseForceAtlasButton)
import Gargantext.Components.GraphExplorer.ToggleButton (edgesToggleButton, pauseForceAtlasButton
, pauseForceAtlasButton2
)
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Utils.Range as Range
import Gargantext.Utils.Range as Range
...
@@ -36,6 +36,7 @@ import Gargantext.Utils.Reactix as R2
...
@@ -36,6 +36,7 @@ import Gargantext.Utils.Reactix as R2
type Controls =
type Controls =
( cursorSize :: R.State Number
( cursorSize :: R.State Number
, forceAtlas2Paused :: R.State Boolean
, multiNodeSelect :: R.Ref Boolean
, multiNodeSelect :: R.Ref Boolean
, showControls :: R.State Boolean
, showControls :: R.State Boolean
, showSidePanel :: R.State Boolean
, showSidePanel :: R.State Boolean
...
@@ -103,6 +104,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -103,6 +104,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
[ -- change type button (?)
[ -- change type button (?)
RH.li {} [ centerButton props.sigmaRef ]
RH.li {} [ centerButton props.sigmaRef ]
, RH.li {} [ pauseForceAtlasButton props.sigmaRef localControls.pauseForceAtlas ] -- spatialization (pause ForceAtlas2)
, RH.li {} [ pauseForceAtlasButton props.sigmaRef localControls.pauseForceAtlas ] -- spatialization (pause ForceAtlas2)
, RH.li {} [ pauseForceAtlasButton2 props.forceAtlas2Paused ]
, RH.li {} [ edgesToggleButton props.sigmaRef localControls.showEdges ]
, RH.li {} [ edgesToggleButton props.sigmaRef localControls.showEdges ]
, RH.li {} [ edgeSizeControl props.sigmaRef localControls.edgeSize ] -- edge size : 0-3
, RH.li {} [ edgeSizeControl props.sigmaRef localControls.edgeSize ] -- edge size : 0-3
-- change level
-- change level
...
@@ -123,6 +125,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -123,6 +125,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
useGraphControls :: R.Hooks (Record Controls)
useGraphControls :: R.Hooks (Record Controls)
useGraphControls = do
useGraphControls = do
cursorSize <- R.useState' 10.0
cursorSize <- R.useState' 10.0
forceAtlas2Paused <- R.useState' false
multiNodeSelect <- R.useRef false
multiNodeSelect <- R.useRef false
showControls <- R.useState' false
showControls <- R.useState' false
showSidePanel <- R.useState' false
showSidePanel <- R.useState' false
...
@@ -130,13 +133,14 @@ useGraphControls = do
...
@@ -130,13 +133,14 @@ useGraphControls = do
sigmaRef <- R2.nothingRef
sigmaRef <- R2.nothingRef
pure {
pure {
cursorSize
cursorSize
, multiNodeSelect
, forceAtlas2Paused
, showControls
, multiNodeSelect
, showSidePanel
, showControls
, showTree
, showSidePanel
, sigmaRef
, showTree
}
, sigmaRef
}
getShowControls :: Record Controls -> Boolean
getShowControls :: Record Controls -> Boolean
getShowControls { showControls: ( should /\ _ ) } = should
getShowControls { showControls: ( should /\ _ ) } = should
...
...
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
d6d813f4
...
@@ -4,6 +4,7 @@ module Gargantext.Components.GraphExplorer.ToggleButton
...
@@ -4,6 +4,7 @@ module Gargantext.Components.GraphExplorer.ToggleButton
, edgesToggleButton
, edgesToggleButton
, sidebarToggleButton
, sidebarToggleButton
, pauseForceAtlasButton
, pauseForceAtlasButton
, pauseForceAtlasButton2
, treeToggleButton
, treeToggleButton
) where
) where
...
@@ -95,6 +96,15 @@ pauseForceAtlasButton sigmaRef state =
...
@@ -95,6 +96,15 @@ pauseForceAtlasButton sigmaRef state =
setToggled not
setToggled not
}
}
pauseForceAtlasButton2 :: R.State Boolean -> R.Element
pauseForceAtlasButton2 state =
toggleButton {
state: state
, onMessage: "Pause Force Atlas2"
, offMessage: "Start Force Atlas2"
, onClick: \_ -> snd state not
}
treeToggleButton :: R.State Boolean -> R.Element
treeToggleButton :: R.State Boolean -> R.Element
treeToggleButton state =
treeToggleButton state =
toggleButton {
toggleButton {
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
d6d813f4
...
@@ -51,8 +51,8 @@ cleanupFirst :: Sigma -> Effect Unit -> Effect Unit
...
@@ -51,8 +51,8 @@ cleanupFirst :: Sigma -> Effect Unit -> Effect Unit
cleanupFirst sigma =
cleanupFirst sigma =
R.setRef sigma.cleanup <<< (flip Seq.cons) (R.readRef sigma.cleanup)
R.setRef sigma.cleanup <<< (flip Seq.cons) (R.readRef sigma.cleanup)
startSigma :: forall settings faSettings n e. R.Ref (Nullable Element) -> R.Ref (Maybe Sigma) -> settings -> faSettings -> Graph n e -> R.Hooks Unit
startSigma :: forall settings faSettings n e. R.Ref (Nullable Element) -> R.Ref (Maybe Sigma) -> settings ->
Boolean ->
faSettings -> Graph n e -> R.Hooks Unit
startSigma ref sigmaRef settings forceAtlas2Settings graph = do
startSigma ref sigmaRef settings forceAtlas2
Paused forceAtlas2
Settings graph = do
{sigma, isNew} <- useSigma ref settings sigmaRef
{sigma, isNew} <- useSigma ref settings sigmaRef
useCanvasRenderer ref sigma
useCanvasRenderer ref sigma
...
@@ -71,7 +71,10 @@ startSigma ref sigmaRef settings forceAtlas2Settings graph = do
...
@@ -71,7 +71,10 @@ startSigma ref sigmaRef settings forceAtlas2Settings graph = do
_ <- case rSigma of
_ <- case rSigma of
Nothing -> log2 "[handleRefresh] can't refresh" sigma
Nothing -> log2 "[handleRefresh] can't refresh" sigma
Just s -> do
Just s -> do
Sigma.refreshForceAtlas s
if forceAtlas2Paused then do
Sigma.refreshForceAtlas s
else
Sigma.restartForceAtlas2 s
pure $ pure unit
pure $ pure unit
-- | Manages a sigma with the given settings
-- | Manages a sigma with the given settings
...
...
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
d6d813f4
...
@@ -61,16 +61,16 @@ foreign import _refresh :: EffectFn1 Sigma Unit
...
@@ -61,16 +61,16 @@ foreign import _refresh :: EffectFn1 Sigma Unit
refreshForceAtlas :: Sigma -> Effect Unit
refreshForceAtlas :: Sigma -> Effect Unit
refreshForceAtlas sigma = do
refreshForceAtlas sigma = do
isRunning <- isForceAtlas2Running sigma
--isRunning <- isForceAtlas2Running sigma
if isRunning then
--if isRunning then
pure unit
--pure unit
else do
--else do
_ <- setTimeout 100 $ do
_ <- setTimeout 100 $ do
restartForceAtlas2 sigma
restartForceAtlas2 sigma
_ <- setTimeout 100 $
_ <- setTimeout 100 $
stopForceAtlas2 sigma
stopForceAtlas2 sigma
pure unit
pure unit
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