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
9c39f34c
Commit
9c39f34c
authored
Jan 02, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Sigma] refactoring of sigma FFI, documentation added
parent
db513bb3
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
235 additions
and
270 deletions
+235
-270
package.json
package.json
+1
-0
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+3
-3
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+18
-16
Sigma.js
src/Gargantext/Hooks/Sigmax/Sigma.js
+0
-77
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+205
-168
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+8
-6
No files found.
package.json
View file @
9c39f34c
...
...
@@ -7,6 +7,7 @@
"build"
:
"pulp --psc-package browserify -t dist/bundle.js"
,
"sass"
:
"sass dist/styles/"
,
"dev"
:
"webpack-dev-server --env dev --mode development"
,
"docs"
:
"pulp docs -- --format html"
,
"repl"
:
"pulp --psc-package repl"
,
"clean"
:
"rm -Rf output"
,
"test"
:
"pulp test"
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
9c39f34c
...
...
@@ -162,7 +162,7 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
, placeholder: "Search"
, type: "value"
, value: searchQuery
, on: {input:
\e -> setSearchQuery (R2.unsafeEventValue e)
}}
, on: {input:
setSearchQuery <<< R2.unsafeEventValue
}}
, H.div {} (
if A.null props.tableBody && searchQuery /= "" then [
H.button { className: "btn btn-primary"
...
...
@@ -175,14 +175,14 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
[ R2.select { id: "picklistmenu"
, className: "form-control custom-select"
, value: (maybe "" show termListFilter)
, on: {change:
(\e -> setTermListFilter $ readTermList $ R2.unsafeEventValue e)
}}
, on: {change:
setTermListFilter <<< readTermList <<< R2.unsafeEventValue
}}
(map optps1 termLists)]]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: "list-group-item"}
[ R2.select {id: "picktermtype"
, className: "form-control custom-select"
, value: (maybe "" show termSizeFilter)
, on: {change:
(\e -> setTermSizeFilter $ readTermSize $ R2.unsafeEventValue e)
}}
, on: {change:
setTermSizeFilter <<< readTermSize <<< R2.unsafeEventValue
}}
(map optps1 termSizes)]]
, H.div {className: "col-md-4", style: {marginTop : "6px", marginBottom : "1px"}}
[ H.li {className: " list-group-item"}
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
9c39f34c
...
...
@@ -74,11 +74,12 @@ cleanupSigma sigma context = traverse_ kill (readSigma sigma)
refreshData :: forall n e. Sigma.Sigma -> Sigma.Graph n e -> Effect Unit
refreshData sigma graph
= log clearingMsg
*> Sigma.clear sigma
*> Sigma.clear sigma
Graph
*> log readingMsg
*> Sigma.graphRead sigma graph
*> Sigma.graphRead sigma
Graph
graph
>>= either (log2 errorMsg) refresh
where
sigmaGraph = Sigma.graph sigma
refresh _ = log refreshingMsg *> Sigma.refresh sigma
clearingMsg = "[refreshData] Clearing existing graph data"
readingMsg = "[refreshData] Reading graph data"
...
...
@@ -116,7 +117,7 @@ handleForceAtlas2Pause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
dependOnSigma sigma "[handleForceAtlas2Pause] sigma: Nothing" $ \s -> do
--log2 "[handleForceAtlas2Pause] mSigma: Just " s
--log2 "[handleForceAtlas2Pause] toggled: " toggled
isFARunning <-
Sigma.isForceAtlas2Running s
let isFARunning =
Sigma.isForceAtlas2Running s
--log2 "[handleForceAtlas2Pause] isFARunning: " isFARunning
case Tuple toggled isFARunning of
Tuple ST.InitialRunning false -> do
...
...
@@ -145,7 +146,7 @@ setEdges sigma val = do
updateEdges :: Sigma.Sigma -> ST.EdgesMap -> Effect Unit
updateEdges sigma edgesMap = do
Sigma.forEachEdge
sigma
\e -> do
Sigma.forEachEdge
(Sigma.graph sigma)
\e -> do
let mTEdge = Map.lookup e.id edgesMap
case mTEdge of
Nothing -> error $ "Edge id " <> e.id <> " not found in edgesMap"
...
...
@@ -158,7 +159,7 @@ updateEdges sigma edgesMap = do
updateNodes :: Sigma.Sigma -> ST.NodesMap -> Effect Unit
updateNodes sigma nodesMap = do
Sigma.forEachNode
sigma
\n -> do
Sigma.forEachNode
(Sigma.graph sigma)
\n -> do
let mTNode = Map.lookup n.id nodesMap
case mTNode of
Nothing -> error $ "Node id " <> n.id <> " not found in nodesMap"
...
...
@@ -166,7 +167,7 @@ updateNodes sigma nodesMap = do
, color: tColor
, equilateral: tEquilateral
, hidden: tHidden
, type: tType}) -> do
, type: tType
}) -> do
_ <- pure $ (n .= "borderColor") tBorderColor
_ <- pure $ (n .= "color") tColor
_ <- pure $ (n .= "equilateral") tEquilateral
...
...
@@ -213,24 +214,25 @@ selectorWithSize sigma size = do
performDiff :: Sigma.Sigma -> ST.SGraph -> Effect Unit
performDiff sigma g = do
sigmaEdgeIds <- Sigma.sigmaEdgeIds sigma
sigmaNodeIds <- Sigma.sigmaNodeIds sigma
let {add: Tuple addEdges addNodes, remove: Tuple removeEdges removeNodes} = ST.sigmaDiff sigmaEdgeIds sigmaNodeIds g
traverse_ (Sigma.addNode sigma) addNodes
traverse_ (Sigma.addEdge sigma) addEdges
traverse_ (Sigma.removeEdge sigma) removeEdges
traverse_ (Sigma.removeNode sigma) removeNodes
if (Seq.null addEdges) && (Seq.null addNodes) && (Set.isEmpty removeEdges) && (Set.isEmpty removeNodes) then
pure unit
else do
traverse_ (Sigma.addNode sigmaGraph) addNodes
traverse_ (Sigma.addEdge sigmaGraph) addEdges
traverse_ (Sigma.removeEdge sigmaGraph) removeEdges
traverse_ (Sigma.removeNode sigmaGraph) removeNodes
Sigma.refresh sigma
Sigma.killForceAtlas2 sigma
where
sigmaGraph = Sigma.graph sigma
sigmaEdgeIds = Sigma.sigmaEdgeIds sigmaGraph
sigmaNodeIds = Sigma.sigmaNodeIds sigmaGraph
{add: Tuple addEdges addNodes, remove: Tuple removeEdges removeNodes} = ST.sigmaDiff sigmaEdgeIds sigmaNodeIds g
-- DEPRECATED
markSelectedEdges :: Sigma.Sigma -> ST.SelectedEdgeIds -> ST.EdgesMap -> Effect Unit
markSelectedEdges sigma selectedEdgeIds graphEdges = do
Sigma.forEachEdge
sigma
\e -> do
Sigma.forEachEdge
(Sigma.graph sigma)
\e -> do
case Map.lookup e.id graphEdges of
Nothing -> error $ "Edge id " <> e.id <> " not found in graphEdges map"
Just {color} -> do
...
...
@@ -245,7 +247,7 @@ markSelectedEdges sigma selectedEdgeIds graphEdges = do
markSelectedNodes :: Sigma.Sigma -> ST.SelectedNodeIds -> ST.NodesMap -> Effect Unit
markSelectedNodes sigma selectedNodeIds graphNodes = do
Sigma.forEachNode
sigma
\n -> do
Sigma.forEachNode
(Sigma.graph sigma)
\n -> do
case Map.lookup n.id graphNodes of
Nothing -> error $ "Node id " <> n.id <> " not found in graphNodes map"
Just {color} -> do
...
...
src/Gargantext/Hooks/Sigmax/Sigma.js
View file @
9c39f34c
...
...
@@ -148,14 +148,6 @@ function _sigma(left, right, opts) {
}
}
function
graphRead
(
left
,
right
,
sigma
,
data
)
{
try
{
return
right
(
sigma
.
graph
.
read
(
data
));
}
catch
(
e
)
{
return
left
(
e
);
}
}
function
refresh
(
sigma
)
{
sigma
.
refresh
();
}
function
addRenderer
(
left
,
right
,
sigma
,
renderer
)
{
try
{
return
right
(
sigma
.
addRenderer
(
renderer
));
...
...
@@ -171,78 +163,9 @@ function bindMouseSelectorPlugin(left, right, sig) {
return
left
(
e
);
}
}
function
killRenderer
(
left
,
right
,
sigma
,
renderer
)
{
try
{
sigma
.
killRenderer
(
renderer
);
return
right
(
sigma
)
}
catch
(
e
)
{
return
left
(
e
);
}
}
function
getRendererContainer
(
sigma
)
{
return
sigma
.
renderers
[
0
].
container
;
}
function
setRendererContainer
(
sigma
,
el
)
{
sigma
.
renderers
[
0
].
container
=
el
;
}
function
killSigma
(
left
,
right
,
sigma
)
{
try
{
sigma
.
kill
()
return
right
(
null
)
}
catch
(
e
)
{
return
left
(
e
);
}
}
function
clear
(
sigma
)
{
sigma
.
graph
.
clear
();
}
function
bind
(
sigma
,
event
,
handler
)
{
sigma
.
bind
(
event
,
handler
);
}
function
unbind
(
sigma
,
event
)
{
sigma
.
unbind
(
event
);
}
function
forEachNode
(
sigma
,
handler
)
{
sigma
.
graph
.
nodes
().
forEach
(
handler
);
}
function
forEachEdge
(
sigma
,
handler
)
{
sigma
.
graph
.
edges
().
forEach
(
handler
);
}
function
setSettings
(
sigma
,
settings
)
{
sigma
.
settings
(
settings
);
}
function
startForceAtlas2
(
sigma
,
settings
)
{
sigma
.
startForceAtlas2
(
settings
);
}
function
stopForceAtlas2
(
sigma
)
{
sigma
.
stopForceAtlas2
();
}
function
killForceAtlas2
(
sigma
)
{
sigma
.
killForceAtlas2
();
}
function
isForceAtlas2Running
(
sigma
)
{
return
sigma
.
isForceAtlas2Running
();
}
function
edgeIds
(
sigma
)
{
return
sigma
.
graph
.
edges
().
map
(
function
(
e
)
{
return
e
.
id
;
});
}
function
nodeIds
(
sigma
)
{
return
sigma
.
graph
.
nodes
().
map
(
function
(
n
)
{
return
n
.
id
;
});
}
function
addEdge
(
sigma
,
e
)
{
return
sigma
.
graph
.
addEdge
(
e
);
}
function
removeEdge
(
sigma
,
e
)
{
return
sigma
.
graph
.
dropEdge
(
e
);
}
function
addNode
(
sigma
,
n
)
{
return
sigma
.
graph
.
addNode
(
n
);
}
function
removeNode
(
sigma
,
n
)
{
return
sigma
.
graph
.
dropNode
(
n
);
}
function
getCameras
(
sigma
)
{
// For some reason, sigma.cameras is an object with integer keys
return
Object
.
values
(
sigma
.
cameras
);
};
function
goTo
(
cam
,
props
)
{
return
cam
.
goTo
(
props
);
};
exports
.
_sigma
=
_sigma
;
exports
.
_graphRead
=
graphRead
;
exports
.
_refresh
=
refresh
;
exports
.
_addRenderer
=
addRenderer
;
exports
.
_bindMouseSelectorPlugin
=
bindMouseSelectorPlugin
;
exports
.
_killRenderer
=
killRenderer
;
exports
.
_getRendererContainer
=
getRendererContainer
;
exports
.
_setRendererContainer
=
setRendererContainer
;
exports
.
_killSigma
=
killSigma
exports
.
_clear
=
clear
;
exports
.
_bind
=
bind
;
exports
.
_unbind
=
unbind
;
exports
.
_forEachNode
=
forEachNode
;
exports
.
_forEachEdge
=
forEachEdge
;
exports
.
_setSettings
=
setSettings
;
exports
.
_startForceAtlas2
=
startForceAtlas2
;
exports
.
_stopForceAtlas2
=
stopForceAtlas2
;
exports
.
_killForceAtlas2
=
killForceAtlas2
;
exports
.
_isForceAtlas2Running
=
isForceAtlas2Running
;
exports
.
_getCameras
=
getCameras
;
exports
.
_goTo
=
goTo
;
exports
.
_edgeIds
=
edgeIds
;
exports
.
_nodeIds
=
nodeIds
;
exports
.
_addEdge
=
addEdge
;
exports
.
_removeEdge
=
removeEdge
;
exports
.
_addNode
=
addNode
;
exports
.
_removeNode
=
removeNode
;
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
9c39f34c
This diff is collapsed.
Click to expand it.
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
9c39f34c
...
...
@@ -26,6 +26,8 @@ newtype Graph n e = Graph { edges :: Seq.Seq {|e}, nodes :: Seq.Seq {|n} }
type Renderer = { "type" :: String, container :: Element }
type NodeId = String
type EdgeId = String
type Node =
( borderColor :: String
...
...
@@ -33,7 +35,7 @@ type Node =
, equilateral :: { numPoints :: Int }
, gargType :: GT.Mode
, hidden :: Boolean
, id ::
String
, id ::
NodeId
, label :: String
, size :: Number
, type :: String -- available types: circle, cross, def, diamond, equilateral, pacman, square, star
...
...
@@ -44,17 +46,17 @@ type Node =
type Edge =
( color :: String
, confluence :: Number
, id ::
String
, id ::
EdgeId
, hidden :: Boolean
, size :: Number
, source ::
String
, source ::
NodeId
, sourceNode :: Record Node
, target ::
String
, target ::
NodeId
, targetNode :: Record Node
, weight :: Number )
type SelectedNodeIds = Set.Set
String
type SelectedEdgeIds = Set.Set
String
type SelectedNodeIds = Set.Set
NodeId
type SelectedEdgeIds = Set.Set
EdgeId
type EdgesMap = Map.Map String (Record Edge)
type NodesMap = Map.Map String (Record Node)
...
...
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