Commit 6963af35 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] force atlas flickering fix

parent b2e22224
Pipeline #1590 failed with stage
......@@ -54,14 +54,9 @@ graph = R.createElement graphCpt
graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = here.component "graph" cpt where
cpt props@{ elRef
, mCamera
, multiSelectEnabledRef
, selectedNodeIds
, showEdges
, sigmaRef
, stage
, startForceAtlas
, transformedGraph } _ = do
, stage } _ = do
showEdges' <- T.useLive T.unequal showEdges
stage' <- T.useLive T.unequal stage
......@@ -83,8 +78,16 @@ graphCpt = here.component "graph" cpt where
Nothing -> RH.div {} []
Just el -> R.createPortal [] el
stageHooks props@{ elRef, mCamera, multiSelectEnabledRef, selectedNodeIds, forceAtlas2Settings: fa2, graph: graph'
, sigmaRef, stage, stage': Init, startForceAtlas } = do
stageHooks { elRef
, mCamera
, multiSelectEnabledRef
, selectedNodeIds
, forceAtlas2Settings: fa2
, graph: graph'
, sigmaRef
, stage
, stage': Init
, startForceAtlas } = do
R.useEffectOnce' $ do
let rSigma = R.readRef sigmaRef
......@@ -126,7 +129,7 @@ graphCpt = here.component "graph" cpt where
Sigma.updateCamera sig { ratio, x, y }
pure unit
Just sig -> do
Just _sig -> do
pure unit
T.write Ready stage
......@@ -145,7 +148,9 @@ graphCpt = here.component "graph" cpt where
Sigmax.performDiff sigma transformedGraph
Sigmax.updateEdges sigma tEdgesMap
Sigmax.updateNodes sigma tNodesMap
Sigmax.setEdges sigma (not $ SigmaxTypes.edgeStateHidden showEdges')
let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges'
here.log2 "[graphCpt] edgesState" edgesState
Sigmax.setEdges sigma edgesState
stageHooks _ = pure unit
......@@ -305,8 +310,10 @@ type ForceAtlas2Settings =
( adjustSizes :: Boolean
, barnesHutOptimize :: Boolean
-- , barnesHutTheta :: Number
, batchEdgesDrawing :: Boolean
, edgeWeightInfluence :: Number
-- , fixedY :: Boolean
, hideEdgesOnMove :: Boolean
, gravity :: Number
, includeHiddenEdges :: Boolean
, includeHiddenNodes :: Boolean
......@@ -326,16 +333,18 @@ forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings =
{ adjustSizes : true
, barnesHutOptimize : true
, batchEdgesDrawing : true
, edgeWeightInfluence : 1.0
-- fixedY : false
, gravity : 0.01
, includeHiddenEdges: false
, includeHiddenNodes: true
, hideEdgesOnMove : true
, includeHiddenEdges : false
, includeHiddenNodes : true
, iterationsPerRender : 50.0 -- 10.0
, linLogMode : false -- false
, outboundAttractionDistribution: false
, outboundAttractionDistribution : false
, scalingRatio : 1000.0
, skipHidden: false
, skipHidden : false
, slowDown : 1.0
, startingIterations : 10.0
, strongGravityMode : false
......
......@@ -78,9 +78,8 @@ explorerWriteGraph :: R2.Component GraphWriteProps
explorerWriteGraph = R.createElement explorerWriteGraphCpt
explorerWriteGraphCpt :: R.Component GraphWriteProps
explorerWriteGraphCpt = here.component "explorerWriteGraph" cpt where
cpt props@{ boxes: { sidePanelGraph, sidePanelState }
cpt props@{ boxes: { sidePanelGraph }
, graph
, hyperdataGraph
, mMetaData' } _ = do
R.useEffectOnce' $ do
T.write_ (Just { mGraph: Just graph
......@@ -99,13 +98,13 @@ explorer = R.createElement explorerCpt
explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt
where
cpt props@{ boxes: boxes@{ graphVersion, handed, reloadForest, showTree, sidePanelGraph, sidePanelState }
cpt { boxes: { graphVersion, handed, reloadForest, showTree, sidePanelGraph, sidePanelState }
, graph
, graphId
, hyperdataGraph
, session
} _ = do
{ mMetaData, sideTab } <- GEST.focusedSidePanel sidePanelGraph
{ mMetaData } <- GEST.focusedSidePanel sidePanelGraph
graphVersion' <- T.useLive T.unequal graphVersion
handed' <- T.useLive T.unequal handed
mMetaData' <- T.useLive T.unequal mMetaData
......@@ -318,7 +317,10 @@ transformGraph graph { edgeConfluence'
hasSelection = not $ Set.isEmpty selectedNodeIds'
newEdges' = Seq.filter edgeFilter $ Seq.map (
edgeHideWeight <<< edgeHideConfluence <<< edgeShowFilter <<< edgeMarked
-- NOTE We don't use edgeShowFilter anymore because of
-- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/304
-- edgeHideWeight <<< edgeHideConfluence <<< edgeShowFilter <<< edgeMarked
edgeHideWeight <<< edgeHideConfluence <<< edgeMarked
) edges
newNodes = Seq.filter nodeFilter $ Seq.map (nodeMarked <<< nodeHideSize) nodes
newEdges = Seq.filter (edgeInGraph $ Set.fromFoldable $ Seq.map _.id newNodes) newEdges'
......
......@@ -85,7 +85,6 @@ controlsCpt = here.component "controls" cpt
, showControls
, showEdges
, showLouvain
, showTree
, sidePanelState
, sideTab
, sigmaRef } _ = do
......@@ -112,8 +111,9 @@ controlsCpt = here.component "controls" cpt
-- Handle automatic edge hiding when FA is running (to prevent flickering).
-- TODO Commented temporarily: this breaks forceatlas rendering after reset
-- R.useEffect2' sigmaRef forceAtlasState' $ do
-- T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges
-- NOTE This is a hack anyways. It's force atlas that should be fixed.
R.useEffect2' sigmaRef forceAtlasState' $ do
T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges
-- Automatic opening of sidebar when a node is selected (but only first time).
R.useEffect' $ do
......
......@@ -6,7 +6,6 @@ import DOM.Simple.Types (Element)
import Data.Array as A
import Data.Either (Either(..))
import Data.Maybe (Maybe)
import Data.Nullable (null)
import Data.Sequence as Seq
import Data.Set as Set
import Data.Traversable (traverse_)
......@@ -48,7 +47,7 @@ sigma = runEffectFn3 _sigma Left Right
-- | Kill a sigmajs instance.
kill :: Sigma -> Effect Unit
kill sigma = pure $ sigma ... "kill" $ []
kill s = pure $ s ... "kill" $ []
-- | Call the `refresh()` method on a sigmajs instance.
refresh :: Sigma -> Effect Unit
......
......@@ -2,10 +2,8 @@ module Gargantext.Hooks.Sigmax.Sigmajs where
import Prelude
import Data.Nullable (Nullable)
import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1)
import React (SyntheticEventHandler)
import React.Ref as RR
import Record.Unsafe (unsafeGet)
import Unsafe.Coerce (unsafeCoerce)
......
......@@ -173,6 +173,8 @@ toggleForceAtlasState Killed = InitialRunning
-- | Custom state for show edges. Normally it is EShow or EHide (show/hide
-- | edges). However, edges are temporarily turned off when forceAtlas is
-- | running.
-- | NOTE ETempHiddenThenShow state is a hack for force atlas
-- | flickering. Ideally it should be removed from here.
data ShowEdgesState = EShow | EHide | ETempHiddenThenShow
derive instance Generic ShowEdgesState _
......
This diff is collapsed.
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