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
faf6c03f
Commit
faf6c03f
authored
Sep 27, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[sigma] node selector works now
parent
0548858f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+3
-2
Sigma.js
src/Gargantext/Hooks/Sigmax/Sigma.js
+16
-9
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+2
-2
No files found.
src/Gargantext/Hooks/Sigmax.purs
View file @
faf6c03f
...
...
@@ -196,8 +196,9 @@ multiSelectUpdate new selected = foldl fld selected new
bindSelectedNodesClick :: Sigma.Sigma -> T.Box ST.NodeIds -> T.Box Boolean -> Effect Unit
bindSelectedNodesClick sigma selectedNodeIds multiSelectEnabled =
Sigma.bindClickNodes sigma $ \nodes -> do
let nodeIds = Set.fromFoldable $ map _.id nodes
Sigma.bindClickNodes sigma $ \nodeIds' -> do
console.log2 "[bindSelectedNodesClick] nodeIds'" nodeIds'
let nodeIds = Set.fromFoldable nodeIds'
multiSelectEnabled' <- T.read multiSelectEnabled
if multiSelectEnabled' then
T.modify_ (multiSelectUpdate nodeIds) selectedNodeIds
...
...
src/Gargantext/Hooks/Sigmax/Sigma.js
View file @
faf6c03f
...
...
@@ -140,7 +140,9 @@ let sigmaMouseSelector = function(sigma, options) {
}
const
onClick
=
(
e
)
=>
{
if
(
!
_isValidClick
)
{
// TODO For some reason this event is sent again, with
// _clickPositionX/Y empty
if
(
!
_isValidClick
||
!
_clickPositionX
||
!
_clickPositionY
)
{
return
;
}
const
size
=
sigma
.
settings
[
'mouseSelectorSize'
]
||
3
;
...
...
@@ -148,12 +150,12 @@ let sigmaMouseSelector = function(sigma, options) {
//const y = e.data.clientY + document.body.scrollTop - _offset.top - size/2;
//const prefix = _renderer.options.prefix;
//console.log('[sigmaMouseSelector] clicked', e, x, y, size);
let
nodes
=
[];
for
(
let
node
in
sigma
.
nodeDataCache
)
{
let
data
=
sigma
.
nodeDataCache
[
node
];
let
node
Id
s
=
[];
for
(
let
node
Id
in
sigma
.
nodeDataCache
)
{
let
data
=
sigma
.
nodeDataCache
[
node
Id
];
let
position
=
sigma
.
framedGraphToViewport
(
data
);
if
(
distance
(
e
.
x
,
e
.
y
,
position
.
x
,
position
.
y
)
<=
size
)
{
node
s
.
push
(
node
);
node
Ids
.
push
(
nodeId
);
}
}
/*
...
...
@@ -163,10 +165,12 @@ let sigmaMouseSelector = function(sigma, options) {
}
});
*/
console
.
log
(
'clicked node ids'
,
nodes
);
//console.log('[sigmaMouseSelector] nodes', nodes);
sigma
.
emit
(
'clickNode'
,
{
node
:
nodes
// nodes.forEach((n) => {
// sigma.emit('clickNode', { node: n });
// })
sigma
.
emit
(
'clickNodes'
,
{
nodeIds
:
nodeIds
//captor: e.data
})
_clickPositionX
=
null
;
...
...
@@ -194,6 +198,10 @@ let sigmaMouseSelector = function(sigma, options) {
}
mouseSelector
();
// sigma.on('clickNode', (e) => {
// console.log('clickNode', e);
// })
}
//sigmaMouseSelector(sigma);
...
...
@@ -266,7 +274,6 @@ let _setSettings = function(g, settings) {
}
let
_refresh
=
function
(
g
)
{
console
.
log
(
'[refresh], g'
,
g
);
return
g
.
refresh
();
}
...
...
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
faf6c03f
...
...
@@ -129,9 +129,9 @@ unbindClickNode :: Sigma -> Effect Unit
unbindClickNode s = unbind_ s "clickNode"
-- | Bind a `clickNodes` event.
bindClickNodes :: Sigma -> (Array
(Record Types.Node)
-> Effect Unit) -> Effect Unit
bindClickNodes :: Sigma -> (Array
Types.NodeId
-> Effect Unit) -> Effect Unit
bindClickNodes s f = on_ s "clickNodes" $ \e -> do
let ns = e .. "
data" .. "node" :: Array (Record Types.Node)
let ns = e .. "
nodeIds" :: Array Types.NodeId
f ns
-- | Unbind a `clickNodes` event.
unbindClickNodes :: Sigma -> Effect Unit
...
...
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