Commit 2b884d76 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/465-dev-graph-explorer-recursion-error' into dev

parents 5ab43f24 a5758914
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-tooltip": "^4.2.8", "react-tooltip": "^4.2.8",
"secp256k1": "^4.0.2", "secp256k1": "^4.0.2",
"sigma": "^2.3.1", "sigma": "^2.4.0",
"twgl.js": "^5.0.4" "twgl.js": "^5.0.4"
}, },
"devDependencies": { "devDependencies": {
......
let upstream = let upstream =
https://github.com/garganscript/package-sets/releases/download/v0.1.6/release.dhall sha256:443a37602d5b9353c4daf4349079a77d5dddf07a7b35219016b167404d1e1138 https://github.com/garganscript/package-sets/releases/download/v0.1.7/release.dhall sha256:52886309e1f0158a85427f80c1e3d47ce747c5f14fcec671a81fe5c2c711a6db
let overrides = let overrides =
{ graphql-client = { graphql-client =
...@@ -98,7 +98,7 @@ let overrides = ...@@ -98,7 +98,7 @@ let overrides =
, "typelevel-prelude" , "typelevel-prelude"
] ]
, repo = "https://github.com/justinwoo/purescript-record-extra" , repo = "https://github.com/justinwoo/purescript-record-extra"
, version = "0.15.0-starter-kit" , version = "v5.0.1"
} }
} }
......
...@@ -10,10 +10,14 @@ import Gargantext.Prelude ...@@ -10,10 +10,14 @@ import Gargantext.Prelude
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable) import Data.Nullable (Nullable)
import Data.Tuple (Tuple(..)) import Data.Sequence as Seq
import Data.Set as Set
import Data.Traversable (traverse_)
import Data.Tuple (Tuple(..), fst, snd)
import DOM.Simple (window) import DOM.Simple (window)
import DOM.Simple.Types (Element) import DOM.Simple.Types (Element)
import Effect.Class.Console as ECC import Effect.Class.Console as ECC
import Effect.Timer (setTimeout)
import Gargantext.Components.App.Store as AppStore import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.GraphExplorer.Store as GraphStore import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
...@@ -45,10 +49,10 @@ type Props sigma forceatlas2 = ...@@ -45,10 +49,10 @@ type Props sigma forceatlas2 =
drawGraph :: forall s fa2. R2.Leaf (Props s fa2) drawGraph :: forall s fa2. R2.Leaf (Props s fa2)
drawGraph = R2.leaf drawGraphCpt drawGraph = R2.leaf drawGraphCpt
drawGraphCpt :: forall s fa2. R.Memo (Props s fa2) -- drawGraphCpt :: forall s fa2. R.Memo (Props s fa2)
drawGraphCpt = R.memo' $ here.component "graph" cpt where -- drawGraphCpt = R.memo' $ here.component "drawGraph" cpt where
-- drawGraphCpt :: forall s fa2. R.Component (Props s fa2) drawGraphCpt :: forall s fa2. R.Component (Props s fa2)
-- drawGraphCpt = here.component "graph" cpt where drawGraphCpt = here.component "drawGraph" cpt where
-- | Component -- | Component
-- | -- |
cpt { elRef cpt { elRef
...@@ -75,10 +79,10 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -75,10 +79,10 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
showEdges' <- R2.useLive' showEdges showEdges' <- R2.useLive' showEdges
edgeConfluence' <- R2.useLive' edgeConfluence edgeConfluence' <- R2.useLive' edgeConfluence
edgeWeight' <- R2.useLive' edgeWeight edgeWeight' <- R2.useLive' edgeWeight
forceAtlasState' <- R2.useLive' forceAtlasState forceAtlasState' <- R2.useLive' forceAtlasState
graphStage' <- R2.useLive' graphStage graphStage' <- R2.useLive' graphStage
startForceAtlas' <- R2.useLive' startForceAtlas startForceAtlas' <- R2.useLive' startForceAtlas
hyperdataGraph' <- R2.useLive' hyperdataGraph --hyperdataGraph' <- R2.useLive' hyperdataGraph
-- | Hooks -- | Hooks
-- | -- |
...@@ -99,9 +103,10 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -99,9 +103,10 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
here.log "[drawGraph (Cleanup)] sigma killed" here.log "[drawGraph (Cleanup)] sigma killed"
-- Stage Init -- Stage Init
R.useEffect2' hyperdataGraph' graphStage' $ case graphStage' of R.useEffect1' graphStage' $ case graphStage' of
GET.Init -> do GET.Init -> do
hyperdataGraph' <- T.read hyperdataGraph
let mCamera = getter _.mCamera hyperdataGraph' let mCamera = getter _.mCamera hyperdataGraph'
let rSigma = R.readRef sigmaRef let rSigma = R.readRef sigmaRef
...@@ -193,18 +198,26 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where ...@@ -193,18 +198,26 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
let tEdgesMap = SigmaxTypes.edgesGraphMap transformedGraph let tEdgesMap = SigmaxTypes.edgesGraphMap transformedGraph
let tNodesMap = SigmaxTypes.nodesGraphMap transformedGraph let tNodesMap = SigmaxTypes.nodesGraphMap transformedGraph
Sigmax.dependOnSigma (R.readRef sigmaRef) "[drawGraph (Ready)] no sigma" $ \sigma -> do let updateSigma _ = do
Sigmax.performDiff sigma transformedGraph Sigmax.dependOnSigma (R.readRef sigmaRef) "[drawGraph (Ready)] no sigma" $ \sigma -> do
-- Sigmax.updateEdges sigma tEdgesMap Sigmax.performDiff sigma transformedGraph
-- Sigmax.updateNodes sigma tNodesMap -- Sigmax.updateEdges sigma tEdgesMap
let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges' -- Sigmax.updateNodes sigma tNodesMap
-- here.log2 "[graphCpt] edgesState" edgesState let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges'
Sigmax.setSigmaEdgesVisibility sigma { edgeConfluence: edgeConfluence' -- here.log2 "[graphCpt] edgesState" edgesState
, edgeWeight: edgeWeight' Sigmax.setSigmaEdgesVisibility sigma { edgeConfluence: edgeConfluence'
, showEdges: showEdges' } , edgeWeight: edgeWeight'
, showEdges: showEdges' }
-- TODO This is a temporary solution that seems to fix
-- blank page of graph when there are too many edges. It
-- still throws error though, just in another thread.
_ <- setTimeout 100 $ updateSigma unit
pure unit
case Tuple forceAtlasState' graphStage' of case Tuple forceAtlasState' graphStage' of
--Tuple SigmaxTypes.InitialLoading GET.Ready -> updateGraph
Tuple SigmaxTypes.InitialRunning GET.Ready -> updateGraph Tuple SigmaxTypes.InitialRunning GET.Ready -> updateGraph
Tuple SigmaxTypes.Paused GET.Ready -> updateGraph Tuple SigmaxTypes.Paused GET.Ready -> updateGraph
......
...@@ -101,7 +101,6 @@ sidebarCpt = here.component "sidebar" cpt where ...@@ -101,7 +101,6 @@ sidebarCpt = here.component "sidebar" cpt where
sideTabLegend :: R2.Leaf Props sideTabLegend :: R2.Leaf Props
sideTabLegend = R2.leaf sideTabLegendCpt sideTabLegend = R2.leaf sideTabLegendCpt
sideTabLegendCpt :: R.Component Props sideTabLegendCpt :: R.Component Props
sideTabLegendCpt = here.component "sideTabLegend" cpt where sideTabLegendCpt = here.component "sideTabLegend" cpt where
cpt { metaData: GET.MetaData { legend } } _ = do cpt { metaData: GET.MetaData { legend } } _ = do
...@@ -165,11 +164,9 @@ sideTabDataCpt = here.component "sideTabData" cpt where ...@@ -165,11 +164,9 @@ sideTabDataCpt = here.component "sideTabData" cpt where
cpt props _ = do cpt props _ = do
-- States -- States
{ selectedNodeIds { selectedNodeIds
, graph
} <- GraphStore.use } <- GraphStore.use
selectedNodeIds' <- R2.useLive' selectedNodeIds selectedNodeIds' <- R2.useLive' selectedNodeIds
graph' <- R2.useLive' graph
-- Computed -- Computed
let let
...@@ -186,39 +183,57 @@ sideTabDataCpt = here.component "sideTabData" cpt where ...@@ -186,39 +183,57 @@ sideTabDataCpt = here.component "sideTabData" cpt where
-- No result -- No result
false -> false ->
B.caveat sideTabDataNoSelection {}
{}
[
H.text "Select one or more nodes to get their informations"
]
-- Nodes have been selected -- Nodes have been selected
true -> true ->
sideTabDataWithSelection props
]
R.fragment
[ sideTabDataNoSelection :: R2.Leaf ()
selectedNodes $ sideTabDataNoSelection = R2.leaf sideTabDataNoSelectionCpt
{ nodesMap: SigmaxT.nodesGraphMap graph' sideTabDataNoSelectionCpt :: R.Component ()
} `Record.merge` props sideTabDataNoSelectionCpt = here.component "sideTabDataNoSelection" cpt where
, cpt {} _ = do
sideBarTabSeparator pure $ B.caveat
, {}
neighborhood [
{} H.text "Select one or more nodes to get their informations"
,
sideBarTabSeparator
,
docListWrapper
{ metaData: props.metaData
}
]
] ]
sideTabDataWithSelection :: R2.Leaf Props
sideTabDataWithSelection = R2.leaf sideTabDataWithSelectionCpt
sideTabDataWithSelectionCpt :: R.Component Props
sideTabDataWithSelectionCpt = here.component "sideTabDataWithSelection" cpt where
cpt props _ = do
-- States
{ graph
} <- GraphStore.use
graph' <- R2.useLive' graph
pure $
R.fragment [
selectedNodes $
{ nodesMap: SigmaxT.nodesGraphMap graph'
} `Record.merge` props
,
sideBarTabSeparator
,
neighborhood
{}
,
sideBarTabSeparator
,
docListWrapper
{ metaData: props.metaData
}
]
------------------------------------------------------------ ------------------------------------------------------------
sideTabCommunity :: R2.Leaf Props sideTabCommunity :: R2.Leaf Props
sideTabCommunity = R2.leaf sideTabCommunityCpt sideTabCommunity = R2.leaf sideTabCommunityCpt
sideTabCommunityCpt :: R.Component Props sideTabCommunityCpt :: R.Component Props
sideTabCommunityCpt = here.component "sideTabCommunity" cpt where sideTabCommunityCpt = here.component "sideTabCommunity" cpt where
cpt props _ = do cpt props _ = do
...@@ -244,33 +259,52 @@ sideTabCommunityCpt = here.component "sideTabCommunity" cpt where ...@@ -244,33 +259,52 @@ sideTabCommunityCpt = here.component "sideTabCommunity" cpt where
-- No result -- No result
false -> false ->
sideTabCommunityNoSelection {}
B.caveat
{}
[
H.text "Select one or more nodes to get their informations"
]
-- Nodes have been selection -- Nodes have been selection
true -> true ->
sideTabCommunityWithSelection props
]
R.fragment sideTabCommunityNoSelection :: R2.Leaf ()
[ sideTabCommunityNoSelection = R2.leaf sideTabCommunityNoSelectionCpt
selectedNodes $ sideTabCommunityNoSelectionCpt :: R.Component ()
{ nodesMap: SigmaxT.nodesGraphMap graph' sideTabCommunityNoSelectionCpt = here.component "sideTabCommunityNoSelection" cpt where
} `Record.merge` props cpt {} _ = do
, pure $ B.caveat
sideBarTabSeparator {}
, [
neighborhood H.text "Select one or more nodes to get their informations"
{} ]
,
sideBarTabSeparator
, sideTabCommunityWithSelection :: R2.Leaf Props
contactListWrapper sideTabCommunityWithSelection = R2.leaf sideTabCommunityWithSelectionCpt
{ metaData: props.metaData sideTabCommunityWithSelectionCpt :: R.Component Props
} sideTabCommunityWithSelectionCpt = here.component "sideTabCommunityWithSelection" cpt where
] cpt props _ = do
{ graph
} <- GraphStore.use
graph' <- R2.useLive' graph
pure $
R.fragment
[
selectedNodes $
{ nodesMap: SigmaxT.nodesGraphMap graph'
} `Record.merge` props
,
sideBarTabSeparator
,
neighborhood
{}
,
sideBarTabSeparator
,
contactListWrapper
{ metaData: props.metaData
}
] ]
------------------------------------------- -------------------------------------------
...@@ -295,7 +329,6 @@ type SelectedNodesProps = ...@@ -295,7 +329,6 @@ type SelectedNodesProps =
selectedNodes :: R2.Leaf SelectedNodesProps selectedNodes :: R2.Leaf SelectedNodesProps
selectedNodes = R2.leaf selectedNodesCpt selectedNodes = R2.leaf selectedNodesCpt
selectedNodesCpt :: R.Component SelectedNodesProps selectedNodesCpt :: R.Component SelectedNodesProps
selectedNodesCpt = here.component "selectedNodes" cpt where selectedNodesCpt = here.component "selectedNodes" cpt where
cpt props _ = do cpt props _ = do
......
...@@ -42,10 +42,12 @@ type Store = ...@@ -42,10 +42,12 @@ type Store =
-- Controls -- Controls
, multiSelectEnabled :: T.Box Boolean , multiSelectEnabled :: T.Box Boolean
, edgeConfluence :: T.Box Range.NumberRange , edgeConfluence :: T.Box Range.NumberRange
, edgeConfluenceRange :: T.Box Range.NumberRange
, edgeWeight :: T.Box Range.NumberRange , edgeWeight :: T.Box Range.NumberRange
, forceAtlasState :: T.Box SigmaxT.ForceAtlasState , forceAtlasState :: T.Box SigmaxT.ForceAtlasState
, graphStage :: T.Box GET.Stage , graphStage :: T.Box GET.Stage
, nodeSize :: T.Box Range.NumberRange , nodeSize :: T.Box Range.NumberRange
, nodeSizeRange :: T.Box Range.NumberRange
, showEdges :: T.Box SigmaxT.ShowEdgesState , showEdges :: T.Box SigmaxT.ShowEdgesState
, showLouvain :: T.Box Boolean , showLouvain :: T.Box Boolean
, labelSize :: T.Box Number , labelSize :: T.Box Number
...@@ -73,10 +75,12 @@ type State = ...@@ -73,10 +75,12 @@ type State =
-- Controls -- Controls
, multiSelectEnabled :: Boolean , multiSelectEnabled :: Boolean
, edgeConfluence :: Range.NumberRange , edgeConfluence :: Range.NumberRange
, edgeConfluenceRange :: Range.NumberRange
, edgeWeight :: Range.NumberRange , edgeWeight :: Range.NumberRange
, forceAtlasState :: SigmaxT.ForceAtlasState , forceAtlasState :: SigmaxT.ForceAtlasState
, graphStage :: GET.Stage , graphStage :: GET.Stage
, nodeSize :: Range.NumberRange , nodeSize :: Range.NumberRange
, nodeSizeRange :: Range.NumberRange
, showEdges :: SigmaxT.ShowEdgesState , showEdges :: SigmaxT.ShowEdgesState
, showLouvain :: Boolean , showLouvain :: Boolean
, labelSize :: Number , labelSize :: Number
......
...@@ -205,6 +205,7 @@ pauseForceAtlasButtonCpt = here.component "pauseForceAtlasButtonButton" cpt ...@@ -205,6 +205,7 @@ pauseForceAtlasButtonCpt = here.component "pauseForceAtlasButtonButton" cpt
vrt SigmaxTypes.Running = ButtonVariant Secondary vrt SigmaxTypes.Running = ButtonVariant Secondary
vrt _ = OutlinedButtonVariant Secondary vrt _ = OutlinedButtonVariant Secondary
--icn SigmaxTypes.InitialLoading = "pause"
icn SigmaxTypes.InitialRunning = "pause" icn SigmaxTypes.InitialRunning = "pause"
icn SigmaxTypes.InitialStopped = "play" icn SigmaxTypes.InitialStopped = "play"
icn SigmaxTypes.Running = "pause" icn SigmaxTypes.Running = "pause"
......
...@@ -51,6 +51,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -51,6 +51,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- | States -- | States
-- | -- |
{ edgeConfluence { edgeConfluence
, edgeConfluenceRange
, edgeWeight , edgeWeight
, forceAtlasState , forceAtlasState
, graph , graph
...@@ -60,6 +61,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -60,6 +61,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, mouseSelectorSize , mouseSelectorSize
, multiSelectEnabled , multiSelectEnabled
, nodeSize , nodeSize
, nodeSizeRange
, selectedNodeIds , selectedNodeIds
, showEdges , showEdges
, showLouvain , showLouvain
...@@ -68,11 +70,13 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -68,11 +70,13 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
} <- GraphStore.use } <- GraphStore.use
forceAtlasState' <- R2.useLive' forceAtlasState forceAtlasState' <- R2.useLive' forceAtlasState
graph' <- R2.useLive' graph
graphStage' <- R2.useLive' graphStage graphStage' <- R2.useLive' graphStage
selectedNodeIds' <- R2.useLive' selectedNodeIds selectedNodeIds' <- R2.useLive' selectedNodeIds
showSidebar' <- R2.useLive' showSidebar showSidebar' <- R2.useLive' showSidebar
edgeConfluenceRange' <- R2.useLive' edgeConfluenceRange
nodeSizeRange' <- R2.useLive' nodeSizeRange
session <- useSession session <- useSession
-- ref to track automatic FA pausing -- ref to track automatic FA pausing
...@@ -116,41 +120,19 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -116,41 +120,19 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- Timer to turn off the initial FA. This is because FA eats up lot of -- Timer to turn off the initial FA. This is because FA eats up lot of
-- CPU, has memory leaks etc. -- CPU, has memory leaks etc.
R.useEffect1' forceAtlasState' $ do R.useEffect1' forceAtlasState' $ do
if forceAtlasState' == SigmaxT.InitialRunning then do case forceAtlasState' of
timeoutId <- setTimeout 9000 $ do SigmaxT.InitialRunning -> do
case forceAtlasState' of timeoutId <- setTimeout 9000 $ do
SigmaxT.InitialRunning -> case forceAtlasState' of
T.write_ SigmaxT.Paused forceAtlasState SigmaxT.InitialRunning ->
_ -> pure unit T.write_ SigmaxT.Paused forceAtlasState
R.setRef mFAPauseRef Nothing _ -> pure unit
R.setRef mFAPauseRef $ Just timeoutId R.setRef mFAPauseRef Nothing
pure unit R.setRef mFAPauseRef $ Just timeoutId
else
pure unit pure unit
_ -> pure unit
-- | Computed
-- |
let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph'
let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
let edgeConfluenceRange = Range.Closed { min: edgeConfluenceMin, max: edgeConfluenceMax }
--let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
--let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
--let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
--let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
let edgeWeightRange = Range.Closed {
min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph'
}
let nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxT.graphNodes graph'
let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted
let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted
let nodeSizeRange = Range.Closed { min: nodeSizeMin, max: nodeSizeMax }
let gap = H.span { className: "graph-toolbar__gap" } [] let gap = H.span { className: "graph-toolbar__gap" } []
-- | Render -- | Render
...@@ -250,7 +232,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -250,7 +232,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
[ [
edgeConfluenceControl edgeConfluenceControl
{ forceAtlasState { forceAtlasState
, range: edgeConfluenceRange , range: edgeConfluenceRange'
, state: edgeConfluence } , state: edgeConfluence }
{- , {- ,
edgeWeightControl edgeWeightControl
...@@ -281,7 +263,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -281,7 +263,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- labels size: 1-4 -- labels size: 1-4
nodeSizeControl nodeSizeControl
{ forceAtlasState { forceAtlasState
, range: nodeSizeRange , range: nodeSizeRange'
, state: nodeSize } , state: nodeSize }
] ]
......
...@@ -4,12 +4,13 @@ module Gargantext.Components.Nodes.Graph ...@@ -4,12 +4,13 @@ module Gargantext.Components.Nodes.Graph
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple (document, querySelector) import Data.Array as A
import Data.Int as I import Data.Int as I
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe) import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple (document, querySelector)
import Gargantext.Components.App.Store as AppStore import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.API as GraphAPI import Gargantext.Components.GraphExplorer.API as GraphAPI
...@@ -56,7 +57,7 @@ nodeCpt = here.component "node" cpt where ...@@ -56,7 +57,7 @@ nodeCpt = here.component "node" cpt where
-- | Computed -- | Computed
-- | -- |
let errorHandler = logRESTError here "[explorerLayout]" let errorHandler = logRESTError here "[node]"
-- | Hooks -- | Hooks
-- | -- |
...@@ -151,6 +152,7 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -151,6 +152,7 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
forceAtlasState forceAtlasState
= if startForceAtlas = if startForceAtlas
--then SigmaxT.InitialLoading
then SigmaxT.InitialRunning then SigmaxT.InitialRunning
else SigmaxT.InitialStopped else SigmaxT.InitialStopped
...@@ -160,6 +162,29 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -160,6 +162,29 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
sigmaRef <- Sigmax.initSigma >>= R.useRef sigmaRef <- Sigmax.initSigma >>= R.useRef
fa2Ref <- R.useRef (Nothing :: Maybe ForceAtlas.FA2Layout) fa2Ref <- R.useRef (Nothing :: Maybe ForceAtlas.FA2Layout)
-- | Precompute some values
-- |
let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
let edgeConfluenceRange = Range.Closed { min: edgeConfluenceMin, max: edgeConfluenceMax }
--let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
--let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
--let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
--let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
let edgeWeightRange = Range.Closed {
min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
}
let nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxT.graphNodes graph
let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted
let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted
let nodeSizeRange = Range.Closed { min: nodeSizeMin, max: nodeSizeMax }
-- Hydrate GraphStore -- Hydrate GraphStore
(state :: Record GraphStore.State) <- pure $ (state :: Record GraphStore.State) <- pure $
-- Data -- Data
...@@ -174,6 +199,8 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -174,6 +199,8 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
{ min: 0.0 { min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph , max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
} }
, edgeConfluenceRange
, nodeSizeRange
-- (cache options) -- (cache options)
, expandSelection: getter _.expandSelection cacheParams , expandSelection: getter _.expandSelection cacheParams
, expandNeighborhood: getter _.expandNeighborhood cacheParams , expandNeighborhood: getter _.expandNeighborhood cacheParams
......
...@@ -249,7 +249,6 @@ performDiff sigma g = do ...@@ -249,7 +249,6 @@ performDiff sigma g = do
, update: Tuple updateEdges updateNodes } = sigmaDiff sigmaGraph g , update: Tuple updateEdges updateNodes } = sigmaDiff sigmaGraph g
-- | Compute a diff between current sigma graph and whatever is set via custom controls -- | Compute a diff between current sigma graph and whatever is set via custom controls
sigmaDiff :: Graphology.Graph -> ST.SGraph -> Record ST.SigmaDiff sigmaDiff :: Graphology.Graph -> ST.SGraph -> Record ST.SigmaDiff
sigmaDiff sigmaGraph gControls = { add, remove, update } sigmaDiff sigmaGraph gControls = { add, remove, update }
...@@ -275,6 +274,8 @@ sigmaDiff sigmaGraph gControls = { add, remove, update } ...@@ -275,6 +274,8 @@ sigmaDiff sigmaGraph gControls = { add, remove, update }
ST.nodesFilter (\n -> not (Set.member n.id sigmaNodeIds)) gControls ST.nodesFilter (\n -> not (Set.member n.id sigmaNodeIds)) gControls
addEdges = ST.graphEdges addGC addEdges = ST.graphEdges addGC
addNodes = ST.graphNodes addGC addNodes = ST.graphNodes addGC
-- addEdges = Seq.empty
-- addNodes = ST.graphNodes addGC
-- Remove nodes/edges from `sigmaGraph` which aren't in -- Remove nodes/edges from `sigmaGraph` which aren't in
-- `gControls` -- `gControls`
...@@ -288,6 +289,8 @@ sigmaDiff sigmaGraph gControls = { add, remove, update } ...@@ -288,6 +289,8 @@ sigmaDiff sigmaGraph gControls = { add, remove, update }
updateEdges = Seq.filter (\e -> Just e /= Map.lookup e.id sigmaEdgeIdsMap) gcEdges updateEdges = Seq.filter (\e -> Just e /= Map.lookup e.id sigmaEdgeIdsMap) gcEdges
-- Find nodes for which `ST.compareNodes` returns `false`, i.e. nodes differ -- Find nodes for which `ST.compareNodes` returns `false`, i.e. nodes differ
updateNodes = Seq.filter (\n -> (ST.compareNodes n <$> (Map.lookup n.id sigmaNodeIdsMap)) == Just false) gcNodes updateNodes = Seq.filter (\n -> (ST.compareNodes n <$> (Map.lookup n.id sigmaNodeIdsMap)) == Just false) gcNodes
-- updateEdges = Seq.empty
-- updateNodes = Seq.empty
-- DEPRECATED -- DEPRECATED
......
...@@ -25,7 +25,9 @@ newtype Graph n e = Graph { edges :: Seq.Seq {|e}, nodes :: Seq.Seq {|n} } ...@@ -25,7 +25,9 @@ newtype Graph n e = Graph { edges :: Seq.Seq {|e}, nodes :: Seq.Seq {|n} }
derive instance Generic (Graph n e) _ derive instance Generic (Graph n e) _
instance (Eq (Record n), Eq (Record e)) => Eq (Graph n e) where instance (Eq (Record n), Eq (Record e)) => Eq (Graph n e) where
eq = genericEq --eq = genericEq
eq (Graph { edges: e1, nodes: n1 }) (Graph { edges: e2, nodes: n2 }) =
(Seq.length e1 == Seq.length e2) && (Seq.length n1 == Seq.length n2)
--instance Eq Graph where --instance Eq Graph where
-- eq (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = n1 == n2 && e1 == e2 -- eq (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = n1 == n2 && e1 == e2
...@@ -162,13 +164,14 @@ eqGraph (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = (n1 == n ...@@ -162,13 +164,14 @@ eqGraph (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = (n1 == n
-- however when graph is loaded initially, forceAtlas is running for a couple of -- however when graph is loaded initially, forceAtlas is running for a couple of
-- seconds and then stops (unless the user alters this by clicking the toggle -- seconds and then stops (unless the user alters this by clicking the toggle
-- button). -- button).
data ForceAtlasState = InitialRunning | InitialStopped | Running | Paused | Killed data ForceAtlasState = {- InitialLoading | -} InitialRunning | InitialStopped | Running | Paused | Killed
derive instance Generic ForceAtlasState _ derive instance Generic ForceAtlasState _
instance Eq ForceAtlasState where instance Eq ForceAtlasState where
eq = genericEq eq = genericEq
toggleForceAtlasState :: ForceAtlasState -> ForceAtlasState toggleForceAtlasState :: ForceAtlasState -> ForceAtlasState
-- toggleForceAtlasState InitialLoading = InitialRunning
toggleForceAtlasState InitialRunning = Paused toggleForceAtlasState InitialRunning = Paused
toggleForceAtlasState InitialStopped = InitialRunning toggleForceAtlasState InitialStopped = InitialRunning
toggleForceAtlasState Running = Paused toggleForceAtlasState Running = Paused
...@@ -177,6 +180,7 @@ toggleForceAtlasState Killed = InitialRunning ...@@ -177,6 +180,7 @@ toggleForceAtlasState Killed = InitialRunning
forceAtlasComponentStatus :: ForceAtlasState -> ComponentStatus forceAtlasComponentStatus :: ForceAtlasState -> ComponentStatus
-- forceAtlasComponentStatus InitialLoading = Disabled
forceAtlasComponentStatus InitialRunning = Disabled forceAtlasComponentStatus InitialRunning = Disabled
forceAtlasComponentStatus InitialStopped = Enabled forceAtlasComponentStatus InitialStopped = Enabled
forceAtlasComponentStatus Running = Disabled forceAtlasComponentStatus Running = Disabled
...@@ -212,6 +216,7 @@ toggleShowEdgesState s = ...@@ -212,6 +216,7 @@ toggleShowEdgesState 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 InitialLoading _ = ETempHiddenThenShow
forceAtlasEdgeState InitialRunning EShow = ETempHiddenThenShow forceAtlasEdgeState InitialRunning EShow = ETempHiddenThenShow
forceAtlasEdgeState InitialRunning es = es forceAtlasEdgeState InitialRunning es = es
forceAtlasEdgeState InitialStopped es = es forceAtlasEdgeState InitialStopped es = es
......
...@@ -9471,10 +9471,10 @@ side-channel@^1.0.4: ...@@ -9471,10 +9471,10 @@ side-channel@^1.0.4:
get-intrinsic "^1.0.2" get-intrinsic "^1.0.2"
object-inspect "^1.9.0" object-inspect "^1.9.0"
sigma@^2.3.1: sigma@^2.4.0:
version "2.3.1" version "2.4.0"
resolved "https://registry.yarnpkg.com/sigma/-/sigma-2.3.1.tgz#69fd9165479fa49ed84348afcd0432215fdf935f" resolved "https://registry.yarnpkg.com/sigma/-/sigma-2.4.0.tgz#efa213c82e8561138c9237c3a87cf15c0bbaee76"
integrity sha512-YfQsVZf78CeIUv8EYLqp/yvhMwwBXGrbpy+rD1N2X9IqtJ11+VfQRjWfVqHDhjM8oPfWPsaJMtpWFQ8pIflvCA== integrity sha512-spi4C+c3cjlhCklT+RvAxJJcarMmjRpF6RPNvBIBYDduALq8iSNm7FwSpijQNGtI+ryeZ2EfvyBNLp36OFaZiw==
dependencies: dependencies:
"@yomguithereal/helpers" "^1.1.1" "@yomguithereal/helpers" "^1.1.1"
events "^3.3.0" events "^3.3.0"
......
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