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

[sigma] do not render labels when forceatlas is on

parent 4270b0de
Pipeline #3288 canceled with stage
......@@ -111,7 +111,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
Nothing -> do
_ <- ECC.error "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
Left err -> here.warn2 "[graphCpt] error creating sigma" err
Right sig -> do
......@@ -133,6 +133,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
Sigmax.bindSelectedNodesClick sigma selectedNodeIds multiSelectEnabled
Sigmax.bindShiftWheel sigma mouseSelectorSize
_ <- Sigma.bindMouseSelectorPlugin sigma
Sigma.setSettings sigma { renderLabels: false }
pure unit
Sigmax.setSigmaEdgesVisibility sig { edgeConfluence: edgeConfluence'
......@@ -281,6 +282,7 @@ type SigmaSettings =
-- , nodeBorderColor :: String
-- , nodeHoverColor :: String
--, nodesPowRatio :: Number
, renderLabels :: Boolean
-- , rescaleIgnoreSize :: Boolean
-- , scalingMode :: String
-- , sideMargin :: Number
......@@ -349,6 +351,7 @@ sigmaSettings theme =
-- , mouseZoomDuration : 150.0
-- , nodeBorderColor : "default" -- choices: "default" color vs. "node" color
--, nodesPowRatio : 10.8
, renderLabels: false -- initially false, because of forceatlas
-- , rescaleIgnoreSize : false
-- , singleHover : true
-- , touchEnabled : true
......
......@@ -21,6 +21,7 @@ import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Types as GT
import Gargantext.Utils.Range as Range
......@@ -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.
R.useEffect2' sigmaRef forceAtlasState' $ do
T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges
v <- T.read showEdges
here.log2 "[controls] modifed showEdges to forceAtlasState'" v
let renderLabels = SigmaxT.forceAtlasLabelState forceAtlasState'
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).
R.useEffect' $ do
......
......@@ -165,7 +165,7 @@ function _sigma(left, right, el, opts) {
try {
let graph = new Graph();
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);
sigmaMouseSelector(s);
return right(s);
......@@ -207,6 +207,7 @@ let dummy = function() {};
let _setSettings = function(g, settings) {
for(const key in settings) {
//console.log('[setSettings] key', key, settings[key]);
g.setSetting(key, settings[key]);
}
}
......
......@@ -178,7 +178,6 @@ toggleForceAtlasState Killed = InitialRunning
-- | 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 _
instance Eq ShowEdgesState where
eq = genericEq
......@@ -199,21 +198,6 @@ toggleShowEdgesState s =
else
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
forceAtlasEdgeState :: ForceAtlasState -> ShowEdgesState -> ShowEdgesState
forceAtlasEdgeState InitialRunning EShow = ETempHiddenThenShow
......@@ -227,6 +211,21 @@ forceAtlasEdgeState Killed ETempHiddenThenShow = EShow
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 g = Seq.toUnfoldable $ Seq.map (\{source, target, weight} -> {source, target, weight}) (graphEdges g)
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