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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
57f6fa5c
Commit
57f6fa5c
authored
Dec 11, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] edge filtering
By edge.weight and edge.confluence.
parent
990eaab3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
30 deletions
+71
-30
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+23
-4
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+11
-7
RangeControl.purs
src/Gargantext/Components/GraphExplorer/RangeControl.purs
+30
-13
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+3
-5
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+4
-1
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
57f6fa5c
...
...
@@ -216,7 +216,14 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxTypes.Graph {nodes, edges}
cDef (GET.Cluster {clustDefault}) = clustDefault
nodesMap = SigmaxTypes.nodesMap nodes
edges = foldMap edgeFn r.edges
edgeFn (GET.Edge e) = Seq.singleton {id : e.id_, color, size: 1.0, source : e.source, target : e.target}
edgeFn (GET.Edge e) = Seq.singleton { id : e.id_
, color
, confluence : e.confluence
, hidden : false
, size: 1.0
, source : e.source
, target : e.target
, weight : e.weight }
where
color = case Map.lookup e.source nodesMap of
Nothing -> "#000000"
...
...
@@ -370,14 +377,26 @@ transformGraph controls graph = SigmaxTypes.Graph {nodes: newNodes, edges: newEd
$ Seq.filter (\e -> Set.member e.source (fst controls.selectedNodeIds)) edges
hasSelection = not $ Set.isEmpty (fst controls.selectedNodeIds)
newNodes = nodeSize
s
<$> nodeMarked <$> nodes
newEdges = edgeMarked <$> edges
newNodes = nodeSize
Filter
<$> nodeMarked <$> nodes
newEdges = edge
ConfluenceFilter <$> edgeWeightFilter <$> edge
Marked <$> edges
nodeSize
s
node@{ size } =
nodeSize
Filter
node@{ size } =
if Range.within (fst controls.nodeSize) size then
node
else
node { hidden = true }
edgeConfluenceFilter edge@{ confluence } =
if Range.within (fst controls.edgeConfluence) confluence then
edge
else
edge { hidden = true }
edgeWeightFilter edge@{ weight } =
if Range.within (fst controls.edgeWeight) weight then
edge
else
edge { hidden = true }
edgeMarked edge@{ id } = do
let isSelected = Set.member id selectedEdgeIds
let sourceNode = Map.lookup edge.source graphNodesMap
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
57f6fa5c
...
...
@@ -23,7 +23,7 @@ import Reactix.DOM.HTML as RH
import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton)
import Gargantext.Components.GraphExplorer.RangeControl (edge
Size
Control, nodeSizeControl)
import Gargantext.Components.GraphExplorer.RangeControl (edge
ConfluenceControl, edgeWeight
Control, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Search (nodeSearchControl)
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton)
import Gargantext.Components.GraphExplorer.ToggleButton (multiSelectEnabledButton, edgesToggleButton, pauseForceAtlasButton)
...
...
@@ -35,6 +35,8 @@ import Gargantext.Utils.Reactix as R2
type Controls =
( cursorSize :: R.State Number
, edgeConfluence :: R.State Range.NumberRange
, edgeWeight :: R.State Range.NumberRange
, graph :: SigmaxTypes.SGraph
, graphStage :: R.State Graph.Stage
, multiSelectEnabled :: R.State Boolean
...
...
@@ -50,15 +52,13 @@ controlsToSigmaSettings :: Record Controls -> Record Graph.SigmaSettings
controlsToSigmaSettings { cursorSize: (cursorSize /\ _)} = Graph.sigmaSettings
type LocalControls =
( edgeSize :: R.State Range.NumberRange
, labelSize :: R.State Number
( labelSize :: R.State Number
, pauseForceAtlas :: R.State Boolean
, showEdges :: R.State Boolean
)
initialLocalControls :: R.Hooks (Record LocalControls)
initialLocalControls = do
edgeSize <- R.useState' $ Range.Closed { min: 0.5, max: 1.0 }
labelSize <- R.useState' 14.0
--nodeSize <- R.useState' $ Range.Closed { min: 0.0, max: 10.0 }
pauseForceAtlas <- R.useState' true
...
...
@@ -66,8 +66,7 @@ initialLocalControls = do
showEdges <- R.useState' true
pure $ {
edgeSize
, labelSize
labelSize
--, nodeSize
, pauseForceAtlas
, showEdges
...
...
@@ -124,7 +123,8 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
RH.li {} [ centerButton props.sigmaRef ]
, RH.li {} [ pauseForceAtlasButton props.sigmaRef localControls.pauseForceAtlas ] -- spatialization (pause ForceAtlas2)
, RH.li {} [ edgesToggleButton props.sigmaRef localControls.showEdges ]
, RH.li {} [ edgeSizeControl props.sigmaRef localControls.edgeSize ] -- edge size : 0-3
, RH.li {} [ edgeConfluenceControl props.sigmaRef props.edgeConfluence ]
, RH.li {} [ edgeWeightControl props.sigmaRef props.edgeWeight ]
-- change level
-- file upload
-- run demo
...
...
@@ -147,6 +147,8 @@ useGraphControls graph = do
let nodes = SigmaxTypes.graphNodes graph
cursorSize <- R.useState' 10.0
edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
edgeWeight <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
graphStage <- R.useState' Graph.Init
multiSelectEnabled <- R.useState' false
nodeSize <- R.useState' $ Range.Closed { min: 0.0, max: 100.0 }
...
...
@@ -158,6 +160,8 @@ useGraphControls graph = do
sigmaRef <- R.useRef sigma
pure { cursorSize
, edgeConfluence
, edgeWeight
, graph
, graphStage
, multiSelectEnabled
...
...
src/Gargantext/Components/GraphExplorer/RangeControl.purs
View file @
57f6fa5c
module Gargantext.Components.GraphExplorer.RangeControl
( Props
, rangeControl
, edgeSizeControl
, edgeConfluenceControl
, edgeWeightControl
, nodeSizeControl
) where
...
...
@@ -33,25 +34,41 @@ rangeControlCpt = R.hooksComponent "RangeButton" cpt
, RS.rangeSlider sliderProps
]
edge
Siz
eControl :: R.Ref Sigmax.Sigma -> R.State Range.NumberRange -> R.Element
edge
Siz
eControl sigmaRef (state /\ setState) =
edge
Confluenc
eControl :: R.Ref Sigmax.Sigma -> R.State Range.NumberRange -> R.Element
edge
Confluenc
eControl sigmaRef (state /\ setState) =
rangeControl {
caption: "Edge
Size
"
caption: "Edge
Confluence Weight
"
, sliderProps: {
bounds: Range.Closed { min: 0.0, max:
3
.0 }
bounds: Range.Closed { min: 0.0, max:
1
.0 }
, initialValue: state
, epsilon: 0.1
, epsilon: 0.
0
1
, step: 1.0
, width: 10.0
, height: 5.0
, onChange: \range@(Range.Closed {min, max}) -> do
let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[edgeSizeControl] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
minEdgeSize: min
, maxEdgeSize: max
, onChange: setState <<< const
}
setState $ const range
}
edgeWeightControl :: R.Ref Sigmax.Sigma -> R.State Range.NumberRange -> R.Element
edgeWeightControl sigmaRef (state /\ setState) =
rangeControl {
caption: "Edge Weight"
, sliderProps: {
bounds: Range.Closed { min: 0.0, max: 3.0 }
, initialValue: state
, epsilon: 0.01
, step: 1.0
, width: 10.0
, height: 5.0
, onChange: setState <<< const
-- , onChange: \range@(Range.Closed {min, max}) -> do
-- let sigma = R.readRef sigmaRef
-- Sigmax.dependOnSigma sigma "[edgeWeightControl] sigma: Nothing" $ \s -> do
-- Sigma.setSettings s {
-- minEdgeSize: min
-- , maxEdgeSize: max
-- }
-- setState $ const range
}
}
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
57f6fa5c
...
...
@@ -191,8 +191,9 @@ updateEdges sigma edgesMap = do
let mTEdge = Map.lookup e.id edgesMap
case mTEdge of
Nothing -> error $ "Edge id " <> e.id <> " not found in edgesMap"
(Just
tEdge@{color: tColor
}) -> do
(Just
{color: tColor, hidden: tHidden
}) -> do
_ <- pure $ (e .= "color") tColor
_ <- pure $ (e .= "hidden") tHidden
pure unit
Sigma.refresh sigma
...
...
@@ -203,7 +204,7 @@ updateNodes sigma nodesMap = do
let mTNode = Map.lookup n.id nodesMap
case mTNode of
Nothing -> error $ "Node id " <> n.id <> " not found in nodesMap"
(Just
tNode@
{color: tColor, hidden: tHidden}) -> do
(Just {color: tColor, hidden: tHidden}) -> do
_ <- pure $ (n .= "color") tColor
_ <- pure $ (n .= "hidden") tHidden
pure unit
...
...
@@ -224,9 +225,7 @@ multiSelectUpdate new selected = foldl fld selected new
bindSelectedNodesClick :: Sigma.Sigma -> R.State SelectedNodeIds -> R.Ref Boolean -> Effect Unit
bindSelectedNodesClick sigma (_ /\ setSelectedNodeIds) multiSelectEnabledRef =
Sigma.bindClickNodes sigma $ \nodes -> do
log2 "[bindSelectedNodesClick] nodes" nodes
let multiSelectEnabled = R.readRef multiSelectEnabledRef
log2 "[bindSelectedNodesClick] multiSelectEnabled" multiSelectEnabled
let nodeIds = Set.fromFoldable $ map _.id nodes
if multiSelectEnabled then
setSelectedNodeIds $ multiSelectUpdate nodeIds
...
...
@@ -237,7 +236,6 @@ bindSelectedEdgesClick :: R.Ref Sigma -> R.State SelectedEdgeIds -> Effect Unit
bindSelectedEdgesClick sigmaRef (_ /\ setSelectedEdgeIds) =
dependOnSigma (R.readRef sigmaRef) "[graphCpt] no sigma" $ \sigma -> do
Sigma.bindClickEdge sigma $ \edge -> do
log2 "[bindClickEdge] edge" edge
setSelectedEdgeIds \eids ->
if Set.member edge.id eids then
Set.delete edge.id eids
...
...
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
57f6fa5c
...
...
@@ -30,9 +30,12 @@ type Node =
type Edge =
( id :: String
, color :: String
, confluence :: Number
, hidden :: Boolean
, size :: Number
, source :: String
, target :: String )
, target :: String
, weight :: Number )
type SelectedNodeIds = Set.Set String
type SelectedEdgeIds = Set.Set 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