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
6c2f3c69
Unverified
Commit
6c2f3c69
authored
Apr 16, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GraphExplorer,MouseSelector,WIP] Unfinished attempt at re-using part of Gargantext V3
parent
a2522ff6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
3 deletions
+80
-3
Sigmajs.js
src/Gargantext/Components/GraphExplorer/Sigmajs.js
+75
-0
Sigmajs.purs
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
+1
-0
Graph.purs
src/Gargantext/Pages/Corpus/Graph.purs
+4
-3
No files found.
src/Gargantext/Components/GraphExplorer/Sigmajs.js
View file @
6c2f3c69
...
@@ -66,3 +66,78 @@ exports.pauseForceAtlas2 = function() {
...
@@ -66,3 +66,78 @@ exports.pauseForceAtlas2 = function() {
}
}
};
};
exports
.
cursor_size
=
10
;
// TODO
exports
.
shift_key
=
false
;
exports
.
trackMouse
=
function
()
{
var
partialGraph
=
window
.
sigmaGargInstance
;
console
.
log
(
'FUN t.minimap:trackMouse'
)
if
(
!
exports
.
shift_key
)
{
// $.doTimeout(300,function (){
var
ctx
=
partialGraph
.
_core
.
domElements
.
mouse
.
getContext
(
'2d'
);
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
;
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
.
closePath
();
ctx
.
fill
();
ctx
.
stroke
();
// });
}
};
exports
.
sigmaOnMouseMove
=
function
(
e
)
{
return
function
()
{
console
.
log
(
'sigmaOnMouseMove'
);
if
(
typeof
(
window
.
sigmaGargInstance
)
!==
"undefined"
)
{
if
(
exports
.
cursor_size
>
0
)
exports
.
trackMouse
();
}
};
};
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
View file @
6c2f3c69
...
@@ -260,6 +260,7 @@ type SigmaInstance = { | SigmaInstance' }
...
@@ -260,6 +260,7 @@ type SigmaInstance = { | SigmaInstance' }
type CameraInstance = { | CameraInstance' }
type CameraInstance = { | CameraInstance' }
foreign import setSigmaRef :: EffectFn1 (Nullable ReactRef) Unit
foreign import setSigmaRef :: EffectFn1 (Nullable ReactRef) Unit
foreign import getSigmaRef :: Effect SigmaInstance
foreign import getSigmaRef :: Effect SigmaInstance
foreign import sigmaOnMouseMove :: forall o. o -> Effect Unit
cameras :: SigmaInstance -> Array CameraInstance
cameras :: SigmaInstance -> Array CameraInstance
cameras = unsafeGet "cameras"
cameras = unsafeGet "cameras"
...
...
src/Gargantext/Pages/Corpus/Graph.purs
View file @
6c2f3c69
...
@@ -27,7 +27,7 @@ import Effect.Aff.Class (liftAff)
...
@@ -27,7 +27,7 @@ import Effect.Aff.Class (liftAff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Effect.Console (log)
import Effect.Uncurried (runEffectFn1, runEffectFn2)
import Effect.Uncurried (runEffectFn1, runEffectFn2)
import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, setSigmaRef, getSigmaRef, cameras, CameraProps, getCameraProps, goTo, pauseForceAtlas2, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, setSigmaRef, getSigmaRef, cameras, CameraProps, getCameraProps, goTo, pauseForceAtlas2, sStyle, sigma
OnMouseMove, sigma
, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.RandomText (words)
...
@@ -42,7 +42,7 @@ import Math (cos, sin)
...
@@ -42,7 +42,7 @@ import Math (cos, sin)
import Partial.Unsafe (unsafePartial)
import Partial.Unsafe (unsafePartial)
import React (ReactElement)
import React (ReactElement)
import React.DOM (a, br', h2, button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul')
import React.DOM (a, br', h2, button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul')
import React.DOM.Props (_id, _type, checked, className, defaultValue, href, max, min, name, onChange, onClick, placeholder, style, title, value)
import React.DOM.Props (_id, _type, checked, className, defaultValue, href, max, min, name, onChange, onClick, placeholder, style, title, value
, onMouseMove
)
import Thermite (PerformAction, Render, Spec, _render, cmapProps, createClass, defaultPerformAction, defaultRender, modifyState, modifyState_, noState, simpleSpec, withState)
import Thermite (PerformAction, Render, Spec, _render, cmapProps, createClass, defaultPerformAction, defaultRender, modifyState, modifyState_, noState, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Web.HTML (window)
import Web.HTML (window)
...
@@ -534,7 +534,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -534,7 +534,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
]
]
, div [className "row"]
, div [className "row"]
[div [if (st.showSidePanel && st.showTree) then className "col-md-10" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"]
[div [if (st.showSidePanel && st.showTree) then className "col-md-10" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"]
[ div [style {height: "90%"}] $
[ div [style {height: "90%"}
,onMouseMove sigmaOnMouseMove] $
[
[
]
]
<>
<>
...
...
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