Commit 1ed34b98 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[GraphExplorer] fix forceAtlas settings

parent f1cff044
...@@ -52,7 +52,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -52,7 +52,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
cpt { elRef cpt { elRef
, fa2Ref , fa2Ref
, sigmaRef , sigmaRef
, forceAtlas2Settings: fa2 , forceAtlas2Settings: fa2Settings
, transformedGraph , transformedGraph
} _ = do } _ = do
...@@ -136,7 +136,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -136,7 +136,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
if startForceAtlas' then if startForceAtlas' then
case R.readRef fa2Ref of case R.readRef fa2Ref of
Nothing -> do Nothing -> do
fa2 <- ForceAtlas2.init (Sigma.graph sig) fa2 <- ForceAtlas2.init (Sigma.graph sig) fa2Settings
ForceAtlas2.start fa2 ForceAtlas2.start fa2
R.setRef fa2Ref (Just fa2) R.setRef fa2Ref (Just fa2)
Just fa2 -> do Just fa2 -> do
...@@ -389,7 +389,7 @@ type ForceAtlas2Settings = ...@@ -389,7 +389,7 @@ type ForceAtlas2Settings =
-- , worker :: Boolean -- , worker :: Boolean
) )
forceAtlas2Settings :: {|ForceAtlas2Settings} forceAtlas2Settings :: Record ForceAtlas2Settings
forceAtlas2Settings = forceAtlas2Settings =
{ adjustSizes : true { adjustSizes : true
, barnesHutOptimize : true , barnesHutOptimize : true
...@@ -405,7 +405,7 @@ forceAtlas2Settings = ...@@ -405,7 +405,7 @@ forceAtlas2Settings =
, outboundAttractionDistribution : false , outboundAttractionDistribution : false
, scalingRatio : 1000.0 , scalingRatio : 1000.0
, skipHidden : false , skipHidden : false
, slowDown : 1.0 , slowDown : 0.2
, startingIterations : 10.0 , startingIterations : 10.0
, strongGravityMode : false , strongGravityMode : false
} }
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
// https://graphology.github.io/standard-library/layout-forceatlas2.html // https://graphology.github.io/standard-library/layout-forceatlas2.html
// import forceAtlas2 from 'graphology-layout-forceatlas2';
import FA2Layout from 'graphology-layout-forceatlas2/worker'; import FA2Layout from 'graphology-layout-forceatlas2/worker';
export function _init(graph) { export function _init(graph, settings) {
// let inferred = forceAtlas2.inferSettings(graph);
return new FA2Layout(graph, { return new FA2Layout(graph, {
settings: {gravity: 1}, settings,
getEdgeWeight: 'weight' getEdgeWeight: 'weight'
}) })
} }
......
...@@ -21,14 +21,14 @@ foreign import data FA2Layout :: Type ...@@ -21,14 +21,14 @@ foreign import data FA2Layout :: Type
-- TODO inferSettings -- TODO inferSettings
-- TODO init with settings -- TODO init with settings
foreign import _init :: EffectFn1 Graphology.Graph FA2Layout foreign import _init :: forall settings. EffectFn2 Graphology.Graph settings FA2Layout
foreign import _start :: EffectFn1 FA2Layout Unit foreign import _start :: EffectFn1 FA2Layout Unit
foreign import _stop :: EffectFn1 FA2Layout Unit foreign import _stop :: EffectFn1 FA2Layout Unit
foreign import _kill :: EffectFn1 FA2Layout Unit foreign import _kill :: EffectFn1 FA2Layout Unit
foreign import _isRunning :: EffectFn1 FA2Layout Boolean foreign import _isRunning :: EffectFn1 FA2Layout Boolean
init :: Graphology.Graph -> Effect FA2Layout init :: forall settings. Graphology.Graph -> settings -> Effect FA2Layout
init = runEffectFn1 _init init = runEffectFn2 _init
start :: FA2Layout -> Effect Unit start :: FA2Layout -> Effect Unit
start = runEffectFn1 _start start = runEffectFn1 _start
......
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