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
81c46e79
Commit
81c46e79
authored
Apr 23, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SELECTOR WIP]
parent
98537466
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
60 deletions
+56
-60
Sigmajs.js
src/Gargantext/Components/GraphExplorer/Sigmajs.js
+56
-60
No files found.
src/Gargantext/Components/GraphExplorer/Sigmajs.js
View file @
81c46e79
...
...
@@ -69,76 +69,72 @@ exports.pauseForceAtlas2 = function() {
exports
.
cursor_size
=
10
;
// TODO
//
exports.shift_key = false;
exports
.
shift_key
=
true
;
exports
.
shift_key
=
false
;
//
exports.shift_key = true;
exports
.
trackMouse
=
function
()
{
exports
.
trackMouse
=
function
(
e
)
{
var
partialGraph
=
window
.
sigmaGargInstance
;
console
.
log
(
'FUN t.minimap:trackMouse'
)
console
.
log
(
'FUN t.minimap:trackMouse'
);
if
(
!
exports
.
shift_key
)
{
// $.doTimeout(300,function (){
var
ctx
=
partialGraph
.
_core
.
domElements
.
mouse
.
getContext
(
'2d'
)
;
// new sigma.js 2D mouse context
var
ctx
=
partialGraph
.
renderers
[
0
].
contexts
.
mouse
;
ctx
.
globalCompositeOperation
=
"source-over"
;
ctx
.
clearRect
(
0
,
0
,
partialGraph
.
_core
.
domElements
.
nodes
.
width
,
partialGraph
.
_core
.
domElements
.
nodes
.
height
);
x
=
partialGraph
.
_core
.
mousecaptor
.
mouseX
;
y
=
partialGraph
.
_core
.
mousecaptor
.
mouseY
;
// clear zone each time to prevent repeated frame artifacts
ctx
.
clearRect
(
50
,
50
,
partialGraph
.
renderers
[
0
].
container
.
offsetWidth
,
partialGraph
.
renderers
[
0
].
container
.
offsetHeight
);
// classic mousemove event or other similar non-sigma events
var
coord
=
window
.
sigma
.
utils
.
mouseCoords
(
e
)
var
x
=
(
coord
.
x
+
coord
.
clientX
)
/
2
// ; // sigma.utils.getX(e);
var
y
=
(
coord
.
y
+
coord
.
clientY
)
/
2
// ; // sigma.utils.getY(e);
console
.
log
(
coord
);
// optional: make more labels appear on circle hover (/!\ costly /!\ esp. on large graphs)
// if (partialGraph.conf.moreLabelsUnderArea) {
// // convert screen => mouse => cam
// var mouseCoords = (50,50); // sigma.utils.mouseCoords(e)
// var camCoords = partialGraph.cam.cameraPosition(mouseCoords.x, mouseCoords.y)
//
// var exactNodeset = circleGetAreaNodes(camCoords.x,camCoords.y)
// // console.log("nodes under circle:", exactNodeset)
//
// // we'll use labelThreshold / 3 as the "boosted" cam:size threshold
// var pfx = partialGraph.cam.readPrefix
// var toRedraw = []
// for (var k in exactNodeset) {
// var n = partialGraph.graph.nodes(exactNodeset[k])
// if(!n.hidden && n[pfx+'size'] > (partialGraph.customSettings.labelThreshold / 3)) {
// toRedraw.push(n)
// }
// }
// redrawNodesInHoverLayer(toRedraw, "hovers")
// }
// draw the circle itself
ctx
.
strokeStyle
=
'#000'
;
ctx
.
lineWidth
=
1
;
ctx
.
fillStyle
=
"#71C3FF"
;
ctx
.
globalAlpha
=
0.5
;
ctx
.
beginPath
();
if
(
partialGraph
.
_core
.
mousecaptor
.
ratio
>
showLabelsIfZoom
){
for
(
var
i
in
partialGraph
.
_core
.
graph
.
nodesIndex
){
n
=
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
];
if
(
n
.
hidden
==
false
){
distance
=
Math
.
sqrt
(
Math
.
pow
((
x
-
parseInt
(
n
.
displayX
)),
2
)
+
Math
.
pow
((
y
-
parseInt
(
n
.
displayY
)),
2
)
);
if
(
parseInt
(
distance
)
<=
exports
.
cursor_size
)
{
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
true
;
}
else
{
if
(
typeof
(
n
.
neighbour
)
!==
"undefined"
)
{
if
(
!
n
.
neighbour
)
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
false
;
}
else
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
false
;
}
}
}
if
(
partialGraph
.
forceatlas2
&&
partialGraph
.
forceatlas2
.
count
<=
1
)
{
partialGraph
.
draw
(
2
,
2
,
2
);
}
}
else
{
for
(
var
i
in
partialGraph
.
_core
.
graph
.
nodesIndex
){
n
=
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
];
if
(
!
n
.
hidden
){
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
false
;
if
(
typeof
(
n
.
neighbour
)
!==
"undefined"
)
{
if
(
!
n
.
neighbour
)
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
false
;
else
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
true
;
}
else
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
forceLabel
=
false
;
}
}
if
(
partialGraph
.
forceatlas2
&&
partialGraph
.
forceatlas2
.
count
<=
1
)
{
partialGraph
.
draw
(
2
,
2
,
2
);
}
}
ctx
.
arc
(
x
,
y
,
exports
.
cursor_size
,
0
,
Math
.
PI
*
2
,
true
);
//ctx.arc(partialGraph._core.width/2, partialGraph._core.height/2, 4, 0, 2 * Math.PI, true);/*todel*/
ctx
.
arc
(
x
,
y
,
30.0
,
0
,
Math
.
PI
*
2
,
true
);
//ctx.arc(x, y, partialGraph.gui.circleSize, 0, Math.PI * 2, true);
ctx
.
closePath
();
ctx
.
fill
();
ctx
.
stroke
();
// });
ctx
.
globalAlpha
=
1
}
};
exports
.
sigmaOnMouseMove
=
function
(
e
)
{
return
function
()
{
console
.
log
(
'sigmaOnMouseMove'
);
if
(
typeof
(
window
.
sigmaGargInstance
)
!==
"undefined"
)
{
if
(
exports
.
cursor_size
>
0
)
exports
.
trackMouse
();
if
(
exports
.
cursor_size
>
0
)
exports
.
trackMouse
(
e
);
}
};
};
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