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
1a6af8b1
Commit
1a6af8b1
authored
May 18, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph explorer] some drafts on handling hidden edges
parent
15e4fe66
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
47 deletions
+61
-47
Graph.purs
src/Gargantext/Components/Graph.purs
+19
-15
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+3
-2
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+27
-0
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+4
-11
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+5
-5
Sigmajs.js
src/Gargantext/Hooks/Sigmax/Sigmajs.js
+0
-11
Sigmajs.purs
src/Gargantext/Hooks/Sigmax/Sigmajs.purs
+0
-2
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+3
-1
No files found.
src/Gargantext/Components/Graph.purs
View file @
1a6af8b1
...
@@ -302,22 +302,24 @@ sigmaSettings =
...
@@ -302,22 +302,24 @@ sigmaSettings =
}
}
type ForceAtlas2Settings =
type ForceAtlas2Settings =
( adjustSizes :: Boolean
( adjustSizes :: Boolean
, barnesHutOptimize :: Boolean
, barnesHutOptimize :: Boolean
-- , barnesHutTheta :: Number
-- , barnesHutTheta :: Number
, edgeWeightInfluence :: Number
, edgeWeightInfluence :: Number
-- , fixedY :: Boolean
-- , fixedY :: Boolean
, gravity :: Number
, gravity :: Number
, iterationsPerRender :: Number
, includeHiddenEdges :: Boolean
, linLogMode :: Boolean
, includeHiddenNodes :: Boolean
, iterationsPerRender :: Number
, linLogMode :: Boolean
, outboundAttractionDistribution :: Boolean
, outboundAttractionDistribution :: Boolean
, scalingRatio :: Number
, scalingRatio
:: Number
, skipHidden :: Boolean
, skipHidden
:: Boolean
, slowDown :: Number
, slowDown
:: Number
, startingIterations :: Number
, startingIterations
:: Number
, strongGravityMode :: Boolean
, strongGravityMode
:: Boolean
-- , timeout :: Number
-- , timeout
:: Number
-- , worker :: Boolean
-- , worker
:: Boolean
)
)
forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings :: {|ForceAtlas2Settings}
...
@@ -327,6 +329,8 @@ forceAtlas2Settings =
...
@@ -327,6 +329,8 @@ forceAtlas2Settings =
, edgeWeightInfluence : 1.0
, edgeWeightInfluence : 1.0
-- fixedY : false
-- fixedY : false
, gravity : 0.01
, gravity : 0.01
, includeHiddenEdges: false
, includeHiddenNodes: true
, iterationsPerRender : 50.0 -- 10.0
, iterationsPerRender : 50.0 -- 10.0
, linLogMode : false -- false
, linLogMode : false -- false
, outboundAttractionDistribution: false
, outboundAttractionDistribution: false
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
1a6af8b1
...
@@ -20,7 +20,7 @@ import Gargantext.Components.Graph as Graph
...
@@ -20,7 +20,7 @@ import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton, cameraButton)
import Gargantext.Components.GraphExplorer.Button (centerButton, cameraButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.SlideButton (labelSizeButton, mouseSelectorSizeButton)
import Gargantext.Components.GraphExplorer.SlideButton (labelSizeButton, mouseSelectorSizeButton)
import Gargantext.Components.GraphExplorer.ToggleButton (multiSelectEnabledButton, edgesToggleButton, louvainToggleButton, pauseForceAtlasButton)
import Gargantext.Components.GraphExplorer.ToggleButton (multiSelectEnabledButton, edgesToggleButton, louvainToggleButton, pauseForceAtlasButton
, resetForceAtlasButton
)
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax as Sigmax
...
@@ -108,7 +108,7 @@ controlsCpt = here.component "controls" cpt
...
@@ -108,7 +108,7 @@ controlsCpt = here.component "controls" cpt
_ -> pure unit
_ -> pure unit
-- Handle case when FA is paused from outside events, eg. the automatic timer.
-- Handle case when FA is paused from outside events, eg. the automatic timer.
R.useEffect' $ Sigmax.handleForceAtlas2Pause sigmaRef forceAtlasState mFAPauseRef
R.useEffect' $ Sigmax.handleForceAtlas2Pause sigmaRef forceAtlasState mFAPauseRef
Graph.forceAtlas2Settings
-- Handle automatic edge hiding when FA is running (to prevent flickering).
-- Handle automatic edge hiding when FA is running (to prevent flickering).
R.useEffect2' sigmaRef forceAtlasState' $ do
R.useEffect2' sigmaRef forceAtlasState' $ do
...
@@ -162,6 +162,7 @@ controlsCpt = here.component "controls" cpt
...
@@ -162,6 +162,7 @@ controlsCpt = here.component "controls" cpt
[ RH.ul { className: "navbar-nav mx-auto" }
[ RH.ul { className: "navbar-nav mx-auto" }
[ -- change type button (?)
[ -- change type button (?)
navItem [ centerButton sigmaRef ]
navItem [ centerButton sigmaRef ]
, navItem [ resetForceAtlasButton { forceAtlasState, sigmaRef } [] ]
, navItem [ pauseForceAtlasButton { state: forceAtlasState } [] ]
, navItem [ pauseForceAtlasButton { state: forceAtlasState } [] ]
, navItem [ edgesToggleButton { state: showEdges } [] ]
, navItem [ edgesToggleButton { state: showEdges } [] ]
, navItem [ louvainToggleButton { state: showLouvain } [] ]
, navItem [ louvainToggleButton { state: showLouvain } [] ]
...
...
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
1a6af8b1
...
@@ -8,6 +8,7 @@ module Gargantext.Components.GraphExplorer.ToggleButton
...
@@ -8,6 +8,7 @@ module Gargantext.Components.GraphExplorer.ToggleButton
, multiSelectEnabledButton
, multiSelectEnabledButton
, sidebarToggleButton
, sidebarToggleButton
, pauseForceAtlasButton
, pauseForceAtlasButton
, resetForceAtlasButton
, treeToggleButton
, treeToggleButton
) where
) where
...
@@ -18,6 +19,9 @@ import Reactix as R
...
@@ -18,6 +19,9 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Toestand as T
import Toestand as T
import Gargantext.Components.Graph as Graph
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as SigmaxTypes
import Gargantext.Hooks.Sigmax.Types as SigmaxTypes
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
...
@@ -156,9 +160,32 @@ pauseForceAtlasButtonCpt = here.component "forceAtlasToggleButton" cpt
...
@@ -156,9 +160,32 @@ pauseForceAtlasButtonCpt = here.component "forceAtlasToggleButton" cpt
text SigmaxTypes.InitialStopped = "Start Force Atlas"
text SigmaxTypes.InitialStopped = "Start Force Atlas"
text SigmaxTypes.Running = "Pause Force Atlas"
text SigmaxTypes.Running = "Pause Force Atlas"
text SigmaxTypes.Paused = "Start Force Atlas"
text SigmaxTypes.Paused = "Start Force Atlas"
text SigmaxTypes.Killed = "Start Force Atlas"
onClick state _ = T.modify_ SigmaxTypes.toggleForceAtlasState state
onClick state _ = T.modify_ SigmaxTypes.toggleForceAtlasState state
type ResetForceAtlasProps = (
forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, sigmaRef :: R.Ref Sigmax.Sigma
)
resetForceAtlasButton :: R2.Component ResetForceAtlasProps
resetForceAtlasButton = R.createElement resetForceAtlasButtonCpt
resetForceAtlasButtonCpt :: R.Component ResetForceAtlasProps
resetForceAtlasButtonCpt = here.component "resetForceAtlasToggleButton" cpt
where
cpt { forceAtlasState, sigmaRef } _ = do
pure $ H.button { className: "btn btn-outline-primary"
, on: { click: onClick forceAtlasState sigmaRef }
} [ R2.small {} [ H.text "Reset Force Atlas" ] ]
onClick forceAtlasState sigmaRef _ = do
-- TODO Sigma.killForceAtlas2 sigma
-- startForceAtlas2 sigma
Sigmax.dependOnSigma (R.readRef sigmaRef) "[resetForceAtlasButton] no sigma" $ \sigma -> do
Sigma.killForceAtlas2 sigma
T.write_ SigmaxTypes.Killed forceAtlasState
type TreeToggleButtonProps = (
type TreeToggleButtonProps = (
state :: T.Box Boolean
state :: T.Box Boolean
)
)
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
1a6af8b1
...
@@ -113,28 +113,21 @@ dependOnContainer container notFoundMsg f = do
...
@@ -113,28 +113,21 @@ dependOnContainer container notFoundMsg f = do
-- | Effect for handling pausing FA via state changes. We need this because
-- | Effect for handling pausing FA via state changes. We need this because
-- | pausing can be done not only via buttons but also from the initial
-- | pausing can be done not only via buttons but also from the initial
-- | setTimer.
-- | setTimer.
--handleForceAtlasPause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
handleForceAtlas2Pause :: forall settings. R.Ref Sigma -> T.Box ST.ForceAtlasState -> R.Ref (Maybe TimeoutId) -> settings -> Effect Unit
handleForceAtlas2Pause :: R.Ref Sigma -> T.Box ST.ForceAtlasState -> R.Ref (Maybe TimeoutId) -> Effect Unit
handleForceAtlas2Pause sigmaRef forceAtlasState mFAPauseRef settings = do
handleForceAtlas2Pause sigmaRef forceAtlasState mFAPauseRef = do
let sigma = R.readRef sigmaRef
let sigma = R.readRef sigmaRef
toggled <- T.read forceAtlasState
toggled <- T.read forceAtlasState
dependOnSigma sigma "[handleForceAtlas2Pause] sigma: Nothing" $ \s -> do
dependOnSigma sigma "[handleForceAtlas2Pause] sigma: Nothing" $ \s -> do
--log2 "[handleForceAtlas2Pause] mSigma: Just " s
--log2 "[handleForceAtlas2Pause] toggled: " toggled
let isFARunning = Sigma.isForceAtlas2Running s
let isFARunning = Sigma.isForceAtlas2Running s
--log2 "[handleForceAtlas2Pause] isFARunning: " isFARunning
case Tuple toggled isFARunning of
case Tuple toggled isFARunning of
Tuple ST.InitialRunning false -> do
Tuple ST.InitialRunning false -> do
-- hide edges during forceAtlas rendering, this prevents flickering
Sigma.restartForceAtlas2 s settings
Sigma.restartForceAtlas2 s
Tuple ST.Running false -> do
Tuple ST.Running false -> do
-- hide edges during forceAtlas rendering, this prevents flickering
Sigma.restartForceAtlas2 s settings
Sigma.restartForceAtlas2 s
case R.readRef mFAPauseRef of
case R.readRef mFAPauseRef of
Nothing -> pure unit
Nothing -> pure unit
Just timeoutId -> clearTimeout timeoutId
Just timeoutId -> clearTimeout timeoutId
Tuple ST.Paused true -> do
Tuple ST.Paused true -> do
-- restore edges state
Sigma.stopForceAtlas2 s
Sigma.stopForceAtlas2 s
_ -> pure unit
_ -> pure unit
...
...
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
1a6af8b1
...
@@ -222,8 +222,8 @@ startForceAtlas2 :: forall settings. Sigma -> settings -> Effect Unit
...
@@ -222,8 +222,8 @@ startForceAtlas2 :: forall settings. Sigma -> settings -> Effect Unit
startForceAtlas2 s settings = pure $ s ... "startForceAtlas2" $ [ settings ]
startForceAtlas2 s settings = pure $ s ... "startForceAtlas2" $ [ settings ]
-- | Restart forceAtlas2 on a sigmajs instance.
-- | Restart forceAtlas2 on a sigmajs instance.
restartForceAtlas2 ::
Sigma
-> Effect Unit
restartForceAtlas2 ::
forall settings. Sigma -> settings
-> Effect Unit
restartForceAtlas2 s
= startForceAtlas2 s null
restartForceAtlas2 s
settings = startForceAtlas2 s settings
-- | Stop forceAtlas2 on a sigmajs instance.
-- | Stop forceAtlas2 on a sigmajs instance.
stopForceAtlas2 :: Sigma -> Effect Unit
stopForceAtlas2 :: Sigma -> Effect Unit
...
@@ -239,14 +239,14 @@ isForceAtlas2Running s = s ... "isForceAtlas2Running" $ [] :: Boolean
...
@@ -239,14 +239,14 @@ isForceAtlas2Running s = s ... "isForceAtlas2Running" $ [] :: Boolean
-- | Refresh forceAtlas2 (with a `setTimeout` hack as it seems it doesn't work
-- | Refresh forceAtlas2 (with a `setTimeout` hack as it seems it doesn't work
-- | otherwise).
-- | otherwise).
refreshForceAtlas ::
Sigma
-> Effect Unit
refreshForceAtlas ::
forall settings. Sigma -> settings
-> Effect Unit
refreshForceAtlas s = do
refreshForceAtlas s
settings
= do
let isRunning = isForceAtlas2Running s
let isRunning = isForceAtlas2Running s
if isRunning then
if isRunning then
pure unit
pure unit
else do
else do
_ <- setTimeout 100 $ do
_ <- setTimeout 100 $ do
restartForceAtlas2 s
restartForceAtlas2 s
settings
_ <- setTimeout 100 $
_ <- setTimeout 100 $
stopForceAtlas2 s
stopForceAtlas2 s
pure unit
pure unit
...
...
src/Gargantext/Hooks/Sigmax/Sigmajs.js
View file @
1a6af8b1
...
@@ -4,14 +4,3 @@ exports.goToImpl = function(cam) {
...
@@ -4,14 +4,3 @@ exports.goToImpl = function(cam) {
return
cam
.
goTo
(
props
);
return
cam
.
goTo
(
props
);
};
};
};
};
exports
.
pauseForceAtlas2
=
function
()
{
var
s
=
window
.
sigmaGargInstance
;
if
(
s
)
{
if
(
s
.
isForceAtlas2Running
())
{
s
.
stopForceAtlas2
()
}
else
{
s
.
startForceAtlas2
()
}
}
};
src/Gargantext/Hooks/Sigmax/Sigmajs.purs
View file @
1a6af8b1
...
@@ -103,8 +103,6 @@ foreign import goToImpl :: forall o. CameraInstance -> EffectFn1 { | o } CameraI
...
@@ -103,8 +103,6 @@ foreign import goToImpl :: forall o. CameraInstance -> EffectFn1 { | o } CameraI
goTo :: forall o. Optional o CameraProps => CameraInstance -> { | o } -> Effect CameraInstance
goTo :: forall o. Optional o CameraProps => CameraInstance -> { | o } -> Effect CameraInstance
goTo cam = runEffectFn1 (goToImpl cam)
goTo cam = runEffectFn1 (goToImpl cam)
foreign import pauseForceAtlas2 :: Effect Unit
type SigmaProps =
type SigmaProps =
( renderer :: String
( renderer :: String
, settings :: SigmaSettings
, settings :: SigmaSettings
...
...
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
1a6af8b1
...
@@ -157,7 +157,7 @@ eqGraph (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = (n1 == n
...
@@ -157,7 +157,7 @@ eqGraph (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = (n1 == n
-- however when graph is loaded initially, forceAtlas is running for a couple of
-- however when graph is loaded initially, forceAtlas is running for a couple of
-- seconds and then stops (unless the user alters this by clicking the toggle
-- seconds and then stops (unless the user alters this by clicking the toggle
-- button).
-- button).
data ForceAtlasState = InitialRunning | InitialStopped | Running | Paused
data ForceAtlasState = InitialRunning | InitialStopped | Running | Paused
| Killed
derive instance genericForceAtlasState :: Generic ForceAtlasState _
derive instance genericForceAtlasState :: Generic ForceAtlasState _
instance eqForceAtlasState :: Eq ForceAtlasState where
instance eqForceAtlasState :: Eq ForceAtlasState where
...
@@ -168,6 +168,7 @@ toggleForceAtlasState InitialRunning = Paused
...
@@ -168,6 +168,7 @@ toggleForceAtlasState InitialRunning = Paused
toggleForceAtlasState InitialStopped = InitialRunning
toggleForceAtlasState InitialStopped = InitialRunning
toggleForceAtlasState Running = Paused
toggleForceAtlasState Running = Paused
toggleForceAtlasState Paused = Running
toggleForceAtlasState Paused = Running
toggleForceAtlasState Killed = Running
-- | Custom state for show edges. Normally it is EShow or EHide (show/hide
-- | Custom state for show edges. Normally it is EShow or EHide (show/hide
-- | edges). However, edges are temporarily turned off when forceAtlas is
-- | edges). However, edges are temporarily turned off when forceAtlas is
...
@@ -218,6 +219,7 @@ forceAtlasEdgeState Running EShow = ETempHiddenThenShow
...
@@ -218,6 +219,7 @@ forceAtlasEdgeState Running EShow = ETempHiddenThenShow
forceAtlasEdgeState Running es = es
forceAtlasEdgeState Running es = es
forceAtlasEdgeState Paused ETempHiddenThenShow = EShow
forceAtlasEdgeState Paused ETempHiddenThenShow = EShow
forceAtlasEdgeState Paused es = es
forceAtlasEdgeState Paused es = es
forceAtlasEdgeState Killed es = es
louvainEdges :: SGraph -> Array (Record Louvain.Edge)
louvainEdges :: SGraph -> Array (Record Louvain.Edge)
...
...
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