Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
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
david Chavalarias
clinicaltrials
Commits
c93c008f
Commit
c93c008f
authored
Mar 28, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP port: custom node rendering lives in sigmaUtils
parent
d3d78b6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
+62
-4
settings_explorerjs.js
settings_explorerjs.js
+6
-0
main.js
tinawebJS/main.js
+8
-4
sigmaUtils.js
tinawebJS/sigmaUtils.js
+48
-0
No files found.
settings_explorerjs.js
View file @
c93c008f
...
...
@@ -113,6 +113,12 @@ var sigmaJsDrawingProperties = {
borderSize
:
2.5
,
//Something other than 0 (works only for hovered nodes)
defaultNodeBorderColor
:
"black"
,
nodeBorderColor
:
"default"
,
// vs. node
// for custom TW node renderer with borders
// (if twNodeRendBorder, triggers overriding sigma.canvas.nodes.def)
twNodeRendBorder
:
true
,
twNodeRendBorderSize
:
1
,
twNodeRendBorderColor
:
"#222"
};
var
sigmaJsGraphProperties
=
{
minEdgeSize
:
2
,
...
...
tinawebJS/main.js
View file @
c93c008f
...
...
@@ -151,10 +151,6 @@ if(RES["OK"]) {
console
.
log
(
getUrlParam
.
file
)
console
.
log
(
"
\n
============================
\n
"
)
}
if
(
file
==
"api.json"
)
{
...
...
@@ -230,6 +226,14 @@ if(RES["OK"]) {
console
.
log
(
"customSettings"
,
customSettings
)
// custom rendering
if
(
customSettings
[
'twNodeRendBorder'
])
{
// overriding the def is simplest
// (could also do it by type)
sigma
.
canvas
.
nodes
.
def
=
sigma_utils
.
twRender
.
canvas
.
nodes
.
withBorders
}
// ==================================================================
// sigma js library invocation (https://github.com/jacomyal/sigma.js)
// ==================================================================
...
...
tinawebJS/sigmaUtils.js
View file @
c93c008f
...
...
@@ -83,6 +83,54 @@ SigmaUtils = function () {
return
graph
;
}
// output = sigma graph
// ================= alternative rendering =====================
// alternative subrenderers for canvas rendering of sigma instances
// cf. http://yomguithereal.github.io/articles/node-border-renderer/
// same hierarchy as in sigma.canvas
this
.
twRender
=
{
canvas
:
{
nodes
:
{}}}
// node rendering with borders
this
.
twRender
.
canvas
.
nodes
.
withBorders
=
function
(
node
,
context
,
settings
)
{
var
prefix
=
settings
(
'prefix'
)
||
''
;
if
(
settings
(
'twNodeRendBorderSize'
)
>
0
)
{
context
.
beginPath
();
context
.
fillStyle
=
settings
(
'twNodeRendBorderColor'
)
||
"#000"
context
.
arc
(
node
[
prefix
+
'x'
],
node
[
prefix
+
'y'
],
node
[
prefix
+
'size'
]
+
settings
(
'twNodeRendBorderSize'
),
0
,
Math
.
PI
*
2
,
true
);
context
.
closePath
();
context
.
fill
();
}
context
.
fillStyle
=
node
.
color
||
settings
(
'defaultNodeColor'
);
context
.
beginPath
();
context
.
arc
(
node
[
prefix
+
'x'
],
node
[
prefix
+
'y'
],
node
[
prefix
+
'size'
],
0
,
Math
.
PI
*
2
,
true
);
context
.
closePath
();
context
.
fill
();
};
// ================ /alternative rendering =====================
}
...
...
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