[GraphExplorer] Add a Pause button to stop/start ForceAtlas2

parent 2c779c66
...@@ -54,4 +54,15 @@ exports.goToImpl = function(cam) { ...@@ -54,4 +54,15 @@ 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()
}
}
};
...@@ -271,6 +271,8 @@ foreign import goToImpl :: forall o. CameraInstance -> EffectFn1 { | o } CameraI ...@@ -271,6 +271,8 @@ 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 :: Renderer ( renderer :: Renderer
, settings :: SigmaSettings , settings :: SigmaSettings
......
...@@ -27,7 +27,7 @@ import Effect.Aff.Class (liftAff) ...@@ -27,7 +27,7 @@ import Effect.Aff.Class (liftAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Effect.Uncurried (runEffectFn1, runEffectFn2) import Effect.Uncurried (runEffectFn1, runEffectFn2)
import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, setSigmaRef, getSigmaRef, cameras, CameraProps, getCameraProps, goTo, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings) import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, setSigmaRef, getSigmaRef, cameras, CameraProps, getCameraProps, goTo, pauseForceAtlas2, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData) import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (AuthData(..), TreeId) import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.RandomText (words) import Gargantext.Components.RandomText (words)
...@@ -253,7 +253,7 @@ mySettings :: SigmaSettings ...@@ -253,7 +253,7 @@ mySettings :: SigmaSettings
mySettings = sigmaSettings { verbose : true mySettings = sigmaSettings { verbose : true
, drawLabels: true , drawLabels: true
, drawEdgeLabels: true , drawEdgeLabels: true
, drawEdges: false , drawEdges: true
, drawNodes: true , drawNodes: true
, labelSize : "proportional" , labelSize : "proportional"
--, nodesPowRatio: 0.3 --, nodesPowRatio: 0.3
...@@ -515,6 +515,11 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -515,6 +515,11 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
, onClick \_ -> modCamera0 (const {x: 0.0, y: 0.0, ratio: 1.0}) , onClick \_ -> modCamera0 (const {x: 0.0, y: 0.0, ratio: 1.0})
] [text "Center"] ] [text "Center"]
] ]
, li'
[ button [ className "btn btn-primary"
, onClick \_ -> pauseForceAtlas2
] [text "Pause"]
]
, li' , li'
[ button [className "btn btn-primary" [ button [className "btn btn-primary"
, onClick \_ -> do , onClick \_ -> do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment