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
3b1cda59
Commit
3b1cda59
authored
Apr 05, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add yomguithereal's curve rendering function
parent
bb494302
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
main.js
tinawebJS/main.js
+5
-1
sigmaUtils.js
tinawebJS/sigmaUtils.js
+41
-1
No files found.
tinawebJS/main.js
View file @
3b1cda59
...
@@ -211,7 +211,7 @@ if(RES["OK"]) {
...
@@ -211,7 +211,7 @@ if(RES["OK"]) {
var
customSettings
=
Object
.
assign
(
var
customSettings
=
Object
.
assign
(
{
{
drawEdges
:
true
,
// fixme edgetype curve
drawEdges
:
true
,
drawNodes
:
true
,
drawNodes
:
true
,
drawLabels
:
true
,
drawLabels
:
true
,
// nodesPowRatio: 1,
// nodesPowRatio: 1,
...
@@ -219,6 +219,7 @@ if(RES["OK"]) {
...
@@ -219,6 +219,7 @@ if(RES["OK"]) {
font
:
"Ubuntu Condensed"
,
font
:
"Ubuntu Condensed"
,
// labelColor: "node",
// labelColor: "node",
fontStyle
:
"bold"
,
fontStyle
:
"bold"
,
batchEdgesDrawing
:
false
,
autoResize
:
true
,
autoResize
:
true
,
mouseEnabled
:
true
,
mouseEnabled
:
true
,
...
@@ -239,6 +240,9 @@ if(RES["OK"]) {
...
@@ -239,6 +240,9 @@ if(RES["OK"]) {
sigma
.
canvas
.
nodes
.
def
=
sigma_utils
.
twRender
.
canvas
.
nodes
.
withBorders
sigma
.
canvas
.
nodes
.
def
=
sigma_utils
.
twRender
.
canvas
.
nodes
.
withBorders
}
}
// custom edges rendering registered under 'curve'
sigma
.
canvas
.
edges
.
curve
=
sigma_utils
.
twRender
.
canvas
.
edges
.
curve
// custom labels rendering
// custom labels rendering
// - based on the normal one sigma.canvas.labels.def
// - based on the normal one sigma.canvas.labels.def
// - additionnaly supports 'forcelabel' node property
// - additionnaly supports 'forcelabel' node property
...
...
tinawebJS/sigmaUtils.js
View file @
3b1cda59
...
@@ -92,7 +92,7 @@ SigmaUtils = function () {
...
@@ -92,7 +92,7 @@ SigmaUtils = function () {
// cf. http://yomguithereal.github.io/articles/node-border-renderer/
// cf. http://yomguithereal.github.io/articles/node-border-renderer/
// same hierarchy as in sigma.canvas
// same hierarchy as in sigma.canvas
this
.
twRender
=
{
canvas
:
{
nodes
:
{},
labels
:
{}}}
this
.
twRender
=
{
canvas
:
{
nodes
:
{},
edges
:
{},
labels
:
{}}}
this
.
twRender
.
canvas
.
labels
.
def
=
function
(
node
,
context
,
settings
)
{
this
.
twRender
.
canvas
.
labels
.
def
=
function
(
node
,
context
,
settings
)
{
var
fontSize
,
var
fontSize
,
...
@@ -129,6 +129,46 @@ SigmaUtils = function () {
...
@@ -129,6 +129,46 @@ SigmaUtils = function () {
);
);
};
};
// source: github.com/jacomyal/sigma.js/commit/25e2153
// POSS: modify to incorporate mix colors
this
.
twRender
.
canvas
.
edges
.
curve
=
function
(
edge
,
source
,
target
,
context
,
settings
)
{
var
color
=
edge
.
color
,
prefix
=
settings
(
'prefix'
)
||
''
,
edgeColor
=
settings
(
'edgeColor'
),
defaultNodeColor
=
settings
(
'defaultNodeColor'
),
defaultEdgeColor
=
settings
(
'defaultEdgeColor'
);
if
(
!
color
)
switch
(
edgeColor
)
{
case
'source'
:
color
=
source
.
color
||
defaultNodeColor
;
break
;
case
'target'
:
color
=
target
.
color
||
defaultNodeColor
;
break
;
default
:
color
=
defaultEdgeColor
;
break
;
}
context
.
strokeStyle
=
color
;
context
.
lineWidth
=
edge
[
prefix
+
'size'
]
||
1
;
context
.
beginPath
();
context
.
moveTo
(
source
[
prefix
+
'x'
],
source
[
prefix
+
'y'
]
);
context
.
quadraticCurveTo
(
(
source
[
prefix
+
'x'
]
+
target
[
prefix
+
'x'
])
/
2
+
(
target
[
prefix
+
'y'
]
-
source
[
prefix
+
'y'
])
/
4
,
(
source
[
prefix
+
'y'
]
+
target
[
prefix
+
'y'
])
/
2
+
(
source
[
prefix
+
'x'
]
-
target
[
prefix
+
'x'
])
/
4
,
target
[
prefix
+
'x'
],
target
[
prefix
+
'y'
]
);
context
.
stroke
();
};
// node rendering with borders
// node rendering with borders
this
.
twRender
.
canvas
.
nodes
.
withBorders
=
function
(
node
,
context
,
settings
)
{
this
.
twRender
.
canvas
.
nodes
.
withBorders
=
function
(
node
,
context
,
settings
)
{
var
prefix
=
settings
(
'prefix'
)
||
''
;
var
prefix
=
settings
(
'prefix'
)
||
''
;
...
...
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