Commit 06a55f13 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[sigma] do not render labels when forceatlas is on

parent 4270b0de
...@@ -111,7 +111,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -111,7 +111,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
Nothing -> do Nothing -> do
_ <- ECC.error "elRef is empty" _ <- ECC.error "elRef is empty"
pure $ Left "elRef is empty" pure $ Left "elRef is empty"
Just el -> Sigma.sigma el {settings: sigmaSettings theme} Just el -> Sigma.sigma el { settings: sigmaSettings theme }
case eSigma of case eSigma of
Left err -> here.warn2 "[graphCpt] error creating sigma" err Left err -> here.warn2 "[graphCpt] error creating sigma" err
Right sig -> do Right sig -> do
...@@ -133,6 +133,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -133,6 +133,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
Sigmax.bindSelectedNodesClick sigma selectedNodeIds multiSelectEnabled Sigmax.bindSelectedNodesClick sigma selectedNodeIds multiSelectEnabled
Sigmax.bindShiftWheel sigma mouseSelectorSize Sigmax.bindShiftWheel sigma mouseSelectorSize
_ <- Sigma.bindMouseSelectorPlugin sigma _ <- Sigma.bindMouseSelectorPlugin sigma
Sigma.setSettings sigma { renderLabels: false }
pure unit pure unit
Sigmax.setSigmaEdgesVisibility sig { edgeConfluence: edgeConfluence' Sigmax.setSigmaEdgesVisibility sig { edgeConfluence: edgeConfluence'
...@@ -281,6 +282,7 @@ type SigmaSettings = ...@@ -281,6 +282,7 @@ type SigmaSettings =
-- , nodeBorderColor :: String -- , nodeBorderColor :: String
-- , nodeHoverColor :: String -- , nodeHoverColor :: String
--, nodesPowRatio :: Number --, nodesPowRatio :: Number
, renderLabels :: Boolean
-- , rescaleIgnoreSize :: Boolean -- , rescaleIgnoreSize :: Boolean
-- , scalingMode :: String -- , scalingMode :: String
-- , sideMargin :: Number -- , sideMargin :: Number
...@@ -349,6 +351,7 @@ sigmaSettings theme = ...@@ -349,6 +351,7 @@ sigmaSettings theme =
-- , mouseZoomDuration : 150.0 -- , mouseZoomDuration : 150.0
-- , nodeBorderColor : "default" -- choices: "default" color vs. "node" color -- , nodeBorderColor : "default" -- choices: "default" color vs. "node" color
--, nodesPowRatio : 10.8 --, nodesPowRatio : 10.8
, renderLabels: false -- initially false, because of forceatlas
-- , rescaleIgnoreSize : false -- , rescaleIgnoreSize : false
-- , singleHover : true -- , singleHover : true
-- , touchEnabled : true -- , touchEnabled : true
......
...@@ -21,6 +21,7 @@ import Gargantext.Components.GraphExplorer.Types as GET ...@@ -21,6 +21,7 @@ import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Session (useSession) import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
...@@ -101,8 +102,12 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -101,8 +102,12 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- NOTE This is a hack anyways. It's force atlas that should be fixed. -- NOTE This is a hack anyways. It's force atlas that should be fixed.
R.useEffect2' sigmaRef forceAtlasState' $ do R.useEffect2' sigmaRef forceAtlasState' $ do
T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges
v <- T.read showEdges let renderLabels = SigmaxT.forceAtlasLabelState forceAtlasState'
here.log2 "[controls] modifed showEdges to forceAtlasState'" v here.log2 "[controls] renderLabels" renderLabels
Sigmax.dependOnSigma (R.readRef sigmaRef) "[graphCpt (Cleanup)] no sigma" $ \sigma -> do
Sigma.setSettings sigma { renderLabels }
-- v <- T.read showEdges
-- here.log2 "[controls] modifed showEdges to forceAtlasState'" v
-- Automatic opening of sidebar when a node is selected (but only first time). -- Automatic opening of sidebar when a node is selected (but only first time).
R.useEffect' $ do R.useEffect' $ do
......
...@@ -165,7 +165,7 @@ function _sigma(left, right, el, opts) { ...@@ -165,7 +165,7 @@ function _sigma(left, right, el, opts) {
try { try {
let graph = new Graph(); let graph = new Graph();
let s = new sigma(graph, el, opts.settigns); let s = new sigma(graph, el, opts.settigns);
console.log('[_sigma] initializing sigma with el', el, 'opts', opts, 'sigma', s); console.log('[_sigma] initializing sigma with el', el, 'opts', opts.settings, 'sigma', s);
console.log('[_sigma] labelRenderedSizeThreshold', opts.settings.labelRenderedSizeThreshold); console.log('[_sigma] labelRenderedSizeThreshold', opts.settings.labelRenderedSizeThreshold);
sigmaMouseSelector(s); sigmaMouseSelector(s);
return right(s); return right(s);
...@@ -207,6 +207,7 @@ let dummy = function() {}; ...@@ -207,6 +207,7 @@ let dummy = function() {};
let _setSettings = function(g, settings) { let _setSettings = function(g, settings) {
for(const key in settings) { for(const key in settings) {
//console.log('[setSettings] key', key, settings[key]);
g.setSetting(key, settings[key]); g.setSetting(key, settings[key]);
} }
} }
......
...@@ -178,7 +178,6 @@ toggleForceAtlasState Killed = InitialRunning ...@@ -178,7 +178,6 @@ toggleForceAtlasState Killed = InitialRunning
-- | NOTE ETempHiddenThenShow state is a hack for force atlas -- | NOTE ETempHiddenThenShow state is a hack for force atlas
-- | flickering. Ideally it should be removed from here. -- | flickering. Ideally it should be removed from here.
data ShowEdgesState = EShow | EHide | ETempHiddenThenShow data ShowEdgesState = EShow | EHide | ETempHiddenThenShow
derive instance Generic ShowEdgesState _ derive instance Generic ShowEdgesState _
instance Eq ShowEdgesState where instance Eq ShowEdgesState where
eq = genericEq eq = genericEq
...@@ -199,21 +198,6 @@ toggleShowEdgesState s = ...@@ -199,21 +198,6 @@ toggleShowEdgesState s =
else else
EHide EHide
-- | Return the temporary hidden state, if applicable.
edgeStateTempHide :: ShowEdgesState -> ShowEdgesState
edgeStateTempHide EHide = EHide
edgeStateTempHide _ = ETempHiddenThenShow
-- | Whether, after disabling the temp state, edges will be shown or hidden.
edgeStateWillBeHidden :: ShowEdgesState -> Boolean
edgeStateWillBeHidden EHide = true
edgeStateWillBeHidden _ = false
-- | Get rid of the temporary transition
edgeStateStabilize :: ShowEdgesState -> ShowEdgesState
edgeStateStabilize ETempHiddenThenShow = EShow
edgeStateStabilize s = s
-- | Return state in which showEdges should be depending on forceAtlasState -- | Return state in which showEdges should be depending on forceAtlasState
forceAtlasEdgeState :: ForceAtlasState -> ShowEdgesState -> ShowEdgesState forceAtlasEdgeState :: ForceAtlasState -> ShowEdgesState -> ShowEdgesState
forceAtlasEdgeState InitialRunning EShow = ETempHiddenThenShow forceAtlasEdgeState InitialRunning EShow = ETempHiddenThenShow
...@@ -227,6 +211,21 @@ forceAtlasEdgeState Killed ETempHiddenThenShow = EShow ...@@ -227,6 +211,21 @@ forceAtlasEdgeState Killed ETempHiddenThenShow = EShow
forceAtlasEdgeState Killed es = es forceAtlasEdgeState Killed es = es
-- Similar situation for labels: hide them when force atlas is
-- running, to prevent flickering.
-- However, for labels this is simpler because we don't have a toggle
-- button.
-- | Return state in which labels should be depending on forceAtlasState
forceAtlasLabelState :: ForceAtlasState -> Boolean
forceAtlasLabelState InitialRunning = false
forceAtlasLabelState InitialStopped = true
forceAtlasLabelState Running = false
forceAtlasLabelState Paused = true
forceAtlasLabelState Killed = true
louvainEdges :: SGraph -> Array (Record Louvain.Edge) louvainEdges :: SGraph -> Array (Record Louvain.Edge)
louvainEdges g = Seq.toUnfoldable $ Seq.map (\{source, target, weight} -> {source, target, weight}) (graphEdges g) louvainEdges g = Seq.toUnfoldable $ Seq.map (\{source, target, weight} -> {source, target, weight}) (graphEdges g)
louvainNodes :: SGraph -> Array Louvain.Node louvainNodes :: SGraph -> Array Louvain.Node
......
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