Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
9e296c86
Commit
9e296c86
authored
Dec 12, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] implemented node hover for selected nodes
Also, preliminary work done for selectorSize control.
parent
2a9ccf59
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
57 deletions
+82
-57
Graph.purs
src/Gargantext/Components/Graph.purs
+5
-0
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+8
-4
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+3
-0
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+42
-46
Sigma.js
src/Gargantext/Hooks/Sigmax/Sigma.js
+15
-1
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+9
-6
No files found.
src/Gargantext/Components/Graph.purs
View file @
9e296c86
...
@@ -32,6 +32,7 @@ type Props sigma forceatlas2 =
...
@@ -32,6 +32,7 @@ type Props sigma forceatlas2 =
, graph :: SigmaxTypes.SGraph
, graph :: SigmaxTypes.SGraph
, multiSelectEnabledRef :: R.Ref Boolean
, multiSelectEnabledRef :: R.Ref Boolean
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, selectorSize :: R.State Int
, showEdges :: R.State SigmaxTypes.ShowEdgesState
, showEdges :: R.State SigmaxTypes.ShowEdgesState
, sigmaRef :: R.Ref Sigmax.Sigma
, sigmaRef :: R.Ref Sigmax.Sigma
, sigmaSettings :: sigma
, sigmaSettings :: sigma
...
@@ -102,6 +103,10 @@ graphCpt = R.hooksComponent "Graph" cpt
...
@@ -102,6 +103,10 @@ graphCpt = R.hooksComponent "Graph" cpt
Sigmax.updateNodes sigma tNodesMap
Sigmax.updateNodes sigma tNodesMap
Sigmax.setEdges sigma (not $ SigmaxTypes.edgeStateHidden showEdges)
Sigmax.setEdges sigma (not $ SigmaxTypes.edgeStateHidden showEdges)
-- R.useEffect1' (fst props.selectorSize) $ do
-- Sigmax.dependOnSigma (R.readRef sigmaRef) "[graphCpt (Ready)] no sigma" $ \sigma -> do
-- Sigmax.selectorWithSize sigma $ fst props.selectorSize
stageHooks _ = pure unit
stageHooks _ = pure unit
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
9e296c86
...
@@ -189,6 +189,7 @@ graphViewCpt = R.hooksComponent "GraphView" cpt
...
@@ -189,6 +189,7 @@ graphViewCpt = R.hooksComponent "GraphView" cpt
, graph
, graph
, multiSelectEnabledRef
, multiSelectEnabledRef
, selectedNodeIds: controls.selectedNodeIds
, selectedNodeIds: controls.selectedNodeIds
, selectorSize: controls.selectorSize
, showEdges: controls.showEdges
, showEdges: controls.showEdges
, sigmaRef: controls.sigmaRef
, sigmaRef: controls.sigmaRef
, sigmaSettings: Graph.sigmaSettings
, sigmaSettings: Graph.sigmaSettings
...
@@ -202,16 +203,19 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxTypes.Graph {nodes, edges}
...
@@ -202,16 +203,19 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxTypes.Graph {nodes, edges}
nodes = foldMapWithIndex nodeFn r.nodes
nodes = foldMapWithIndex nodeFn r.nodes
nodeFn i (GET.Node n) =
nodeFn i (GET.Node n) =
Seq.singleton
Seq.singleton
{
id : n.id_
{
borderColor: color
,
size : log (toNumber n.size + 1.0)
,
color : color
, hidden : false
, hidden : false
, id : n.id_
, label : n.label
, label : n.label
, size : log (toNumber n.size + 1.0)
, type : "def" -- default type
, x : n.x -- cos (toNumber i)
, x : n.x -- cos (toNumber i)
, y : n.y -- sin (toNumber i)
, y : n.y -- sin (toNumber i)
, color : GET.intColor (cDef n.attributes)
}
}
where
where
cDef (GET.Cluster {clustDefault}) = clustDefault
cDef (GET.Cluster {clustDefault}) = clustDefault
color = GET.intColor (cDef n.attributes)
nodesMap = SigmaxTypes.nodesMap nodes
nodesMap = SigmaxTypes.nodesMap nodes
edges = foldMap edgeFn r.edges
edges = foldMap edgeFn r.edges
edgeFn (GET.Edge e) = Seq.singleton { id : e.id_
edgeFn (GET.Edge e) = Seq.singleton { id : e.id_
...
@@ -410,6 +414,6 @@ transformGraph controls graph = SigmaxTypes.Graph {nodes: newNodes, edges: newEd
...
@@ -410,6 +414,6 @@ transformGraph controls graph = SigmaxTypes.Graph {nodes: newNodes, edges: newEd
_ -> edge
_ -> edge
nodeMarked node@{ id } =
nodeMarked node@{ id } =
if Set.member id (fst controls.selectedNodeIds) then
if Set.member id (fst controls.selectedNodeIds) then
node {
color = "#ff0000
" }
node {
borderColor = "#000", type = "hovered
" }
else
else
node
node
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
9e296c86
...
@@ -43,6 +43,7 @@ type Controls =
...
@@ -43,6 +43,7 @@ type Controls =
, multiSelectEnabled :: R.State Boolean
, multiSelectEnabled :: R.State Boolean
, nodeSize :: R.State Range.NumberRange
, nodeSize :: R.State Range.NumberRange
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, selectorSize :: R.State Int
, showControls :: R.State Boolean
, showControls :: R.State Boolean
, showEdges :: R.State SigmaxTypes.ShowEdgesState
, showEdges :: R.State SigmaxTypes.ShowEdgesState
, showSidePanel :: R.State GET.SidePanelState
, showSidePanel :: R.State GET.SidePanelState
...
@@ -167,6 +168,7 @@ useGraphControls graph = do
...
@@ -167,6 +168,7 @@ useGraphControls graph = do
nodeSize <- R.useState' $ Range.Closed { min: 0.0, max: 100.0 }
nodeSize <- R.useState' $ Range.Closed { min: 0.0, max: 100.0 }
showTree <- R.useState' false
showTree <- R.useState' false
selectedNodeIds <- R.useState' $ Set.empty
selectedNodeIds <- R.useState' $ Set.empty
selectorSize <- R.useState' 5
showControls <- R.useState' false
showControls <- R.useState' false
showEdges <- R.useState' SigmaxTypes.EShow
showEdges <- R.useState' SigmaxTypes.EShow
showSidePanel <- R.useState' GET.InitialClosed
showSidePanel <- R.useState' GET.InitialClosed
...
@@ -182,6 +184,7 @@ useGraphControls graph = do
...
@@ -182,6 +184,7 @@ useGraphControls graph = do
, multiSelectEnabled
, multiSelectEnabled
, nodeSize
, nodeSize
, selectedNodeIds
, selectedNodeIds
, selectorSize
, showControls
, showControls
, showEdges
, showEdges
, showSidePanel
, showSidePanel
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
9e296c86
...
@@ -132,12 +132,6 @@ handleForceAtlas2Pause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
...
@@ -132,12 +132,6 @@ handleForceAtlas2Pause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
-- restore edges state
-- restore edges state
Sigma.stopForceAtlas2 s
Sigma.stopForceAtlas2 s
_ -> pure unit
_ -> pure unit
-- handle case when user pressed pause/start fa button before timeout fired
--case R.readRef mFAPauseRef of
-- Nothing -> pure unit
-- Just timeoutId -> do
-- R.setRef mFAPauseRef Nothing
-- clearTimeout timeoutId
setEdges :: Sigma.Sigma -> Boolean -> Effect Unit
setEdges :: Sigma.Sigma -> Boolean -> Effect Unit
setEdges sigma val = do
setEdges sigma val = do
...
@@ -148,45 +142,6 @@ setEdges sigma val = do
...
@@ -148,45 +142,6 @@ setEdges sigma val = do
}
}
Sigma.setSettings sigma settings
Sigma.setSettings sigma settings
-- -- prevent showing edges (via show edges button) when FA is running (flickering)
-- isFARunning <- Sigma.isForceAtlas2Running sigma
-- case Tuple val isFARunning of
-- Tuple false _ ->
-- Sigma.setSettings sigma settings
-- Tuple true false ->
-- Sigma.setSettings sigma settings
-- _ -> pure unit
markSelectedEdges :: Sigma.Sigma -> ST.SelectedEdgeIds -> ST.EdgesMap -> Effect Unit
markSelectedEdges sigma selectedEdgeIds graphEdges = do
Sigma.forEachEdge sigma \e -> do
case Map.lookup e.id graphEdges of
Nothing -> error $ "Edge id " <> e.id <> " not found in graphEdges map"
Just {color} -> do
let newColor =
if Set.member e.id selectedEdgeIds then
"#ff0000"
else
color
_ <- pure $ (e .= "color") newColor
pure unit
Sigma.refresh sigma
markSelectedNodes :: Sigma.Sigma -> ST.SelectedNodeIds -> ST.NodesMap -> Effect Unit
markSelectedNodes sigma selectedNodeIds graphNodes = do
Sigma.forEachNode sigma \n -> do
case Map.lookup n.id graphNodes of
Nothing -> error $ "Node id " <> n.id <> " not found in graphNodes map"
Just {color} -> do
let newColor =
if Set.member n.id selectedNodeIds then
"#ff0000"
else
color
_ <- pure $ (n .= "color") newColor
pure unit
Sigma.refresh sigma
updateEdges :: Sigma.Sigma -> ST.EdgesMap -> Effect Unit
updateEdges :: Sigma.Sigma -> ST.EdgesMap -> Effect Unit
updateEdges sigma edgesMap = do
updateEdges sigma edgesMap = do
...
@@ -207,9 +162,14 @@ updateNodes sigma nodesMap = do
...
@@ -207,9 +162,14 @@ updateNodes sigma nodesMap = do
let mTNode = Map.lookup n.id nodesMap
let mTNode = Map.lookup n.id nodesMap
case mTNode of
case mTNode of
Nothing -> error $ "Node id " <> n.id <> " not found in nodesMap"
Nothing -> error $ "Node id " <> n.id <> " not found in nodesMap"
(Just {color: tColor, hidden: tHidden}) -> do
(Just { borderColor: tBorderColor
, color: tColor
, hidden: tHidden
, type: tType}) -> do
_ <- pure $ (n .= "borderColor") tBorderColor
_ <- pure $ (n .= "color") tColor
_ <- pure $ (n .= "color") tColor
_ <- pure $ (n .= "hidden") tHidden
_ <- pure $ (n .= "hidden") tHidden
_ <- pure $ (n .= "type") tType
pure unit
pure unit
--Sigma.refresh sigma
--Sigma.refresh sigma
...
@@ -244,3 +204,39 @@ bindSelectedEdgesClick sigmaRef (_ /\ setSelectedEdgeIds) =
...
@@ -244,3 +204,39 @@ bindSelectedEdgesClick sigmaRef (_ /\ setSelectedEdgeIds) =
Set.delete edge.id eids
Set.delete edge.id eids
else
else
Set.insert edge.id eids
Set.insert edge.id eids
selectorWithSize :: Sigma.Sigma -> Int -> Effect Unit
selectorWithSize sigma size = do
pure unit
-- DEPRECATED
markSelectedEdges :: Sigma.Sigma -> ST.SelectedEdgeIds -> ST.EdgesMap -> Effect Unit
markSelectedEdges sigma selectedEdgeIds graphEdges = do
Sigma.forEachEdge sigma \e -> do
case Map.lookup e.id graphEdges of
Nothing -> error $ "Edge id " <> e.id <> " not found in graphEdges map"
Just {color} -> do
let newColor =
if Set.member e.id selectedEdgeIds then
"#ff0000"
else
color
_ <- pure $ (e .= "color") newColor
pure unit
Sigma.refresh sigma
markSelectedNodes :: Sigma.Sigma -> ST.SelectedNodeIds -> ST.NodesMap -> Effect Unit
markSelectedNodes sigma selectedNodeIds graphNodes = do
Sigma.forEachNode sigma \n -> do
case Map.lookup n.id graphNodes of
Nothing -> error $ "Node id " <> n.id <> " not found in graphNodes map"
Just {color} -> do
let newColor =
if Set.member n.id selectedNodeIds then
"#ff0000"
else
color
_ <- pure $ (n .= "color") newColor
pure unit
Sigma.refresh sigma
src/Gargantext/Hooks/Sigmax/Sigma.js
View file @
9e296c86
...
@@ -6,7 +6,21 @@ if (typeof window !== 'undefined') {
...
@@ -6,7 +6,21 @@ if (typeof window !== 'undefined') {
window
.
sigma
=
sigma
;
window
.
sigma
=
sigma
;
}
}
require
(
'sigma/plugins/garg.js'
).
init
(
sigma
,
window
);
const
CustomShapes
=
require
(
'sigma/plugins/garg.js'
).
init
(
sigma
,
window
).
customShapes
;
require
(
'sigma/src/utils/sigma.utils.js'
).
init
(
sigma
);
sigma
.
canvas
.
nodes
.
hovered
=
(
node
,
context
,
settings
)
=>
{
// hack
// We need to temporarily set node.type to 'def'. This is for 2 reasons
// 1. Make it render as a normal node
// 2. Avoid infinite recursion (hovers.def calls node renderer and we would end up here back
// again with node.type = 'hovered')
node
.
type
=
'def'
;
sigma
.
canvas
.
hovers
.
def
(
node
,
context
,
settings
);
node
.
type
=
'hovered'
;
};
CustomShapes
.
init
();
function
_sigma
(
left
,
right
,
opts
)
{
function
_sigma
(
left
,
right
,
opts
)
{
try
{
try
{
...
...
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
9e296c86
...
@@ -22,18 +22,21 @@ type Renderer = { "type" :: String, container :: Element }
...
@@ -22,18 +22,21 @@ type Renderer = { "type" :: String, container :: Element }
type Node =
type Node =
(
id
:: String
(
borderColor
:: String
,
label
:: String
,
color
:: String
, hidden :: Boolean
, hidden :: Boolean
, id :: String
, label :: String
, size :: Number
, type :: String -- available types: circle, cross, def, diamond, equilateral, pacman, square, star
, x :: Number
, x :: Number
, y :: Number
, y :: Number
, size :: Number
)
, color :: String )
type Edge =
type Edge =
( id :: String
( color :: String
, color :: String
, confluence :: Number
, confluence :: Number
, id :: String
, hidden :: Boolean
, hidden :: Boolean
, size :: Number
, size :: Number
, source :: String
, source :: String
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment