Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
04dafd01
Commit
04dafd01
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Implemented link colors for different types
parent
746afdef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
editor/js/editor.js
+2
-1
2 additions, 1 deletion
editor/js/editor.js
editor/js/graph.js
+26
-2
26 additions, 2 deletions
editor/js/graph.js
editor/js/state.js
+8
-0
8 additions, 0 deletions
editor/js/state.js
editor/js/tools/tool.js
+16
-0
16 additions, 0 deletions
editor/js/tools/tool.js
with
52 additions
and
3 deletions
editor/js/editor.js
+
2
−
1
View file @
04dafd01
...
@@ -50,7 +50,8 @@ function load() {
...
@@ -50,7 +50,8 @@ function load() {
.
width
(
width
)
.
width
(
width
)
.
graphData
(
graph
.
data
)
.
graphData
(
graph
.
data
)
.
nodeLabel
(
Graph
.
NODE_LABEL
)
.
nodeLabel
(
Graph
.
NODE_LABEL
)
.
nodeAutoColorBy
(
Graph
.
NODE_GROUP
)
.
linkColor
((
link
)
=>
state
.
linkColor
(
link
))
.
nodeColor
((
node
)
=>
state
.
nodeColor
(
node
))
.
onNodeClick
((
node
)
=>
state
.
onNodeClick
(
node
))
.
onNodeClick
((
node
)
=>
state
.
onNodeClick
(
node
))
.
autoPauseRedraw
(
false
)
// keep redrawing after engine has stopped
.
autoPauseRedraw
(
false
)
// keep redrawing after engine has stopped
.
linkWidth
((
link
)
=>
state
.
linkWidth
(
link
))
.
linkWidth
((
link
)
=>
state
.
linkWidth
(
link
))
...
...
This diff is collapsed.
Click to expand it.
editor/js/graph.js
+
26
−
2
View file @
04dafd01
import
ManagedData
from
"
./manageddata
"
;
import
ManagedData
from
"
./manageddata
"
;
import
{
PLUGIN_PATH
}
from
"
../../config
"
;
import
{
PLUGIN_PATH
,
COLOR_PALETTE
}
from
"
../../config
"
;
export
const
NODE_LABEL
=
"
name
"
;
export
const
NODE_LABEL
=
"
name
"
;
export
const
NODE_ID
=
"
id
"
;
export
const
NODE_ID
=
"
id
"
;
...
@@ -23,7 +23,7 @@ export const NODE_PARAMS = [NODE_ID, NODE_LABEL, NODE_IMAGE, NODE_DESCRIPTION];
...
@@ -23,7 +23,7 @@ export const NODE_PARAMS = [NODE_ID, NODE_LABEL, NODE_IMAGE, NODE_DESCRIPTION];
export
const
LINK_SIM_PARAMS
=
[
"
index
"
];
export
const
LINK_SIM_PARAMS
=
[
"
index
"
];
export
const
NODE_SIM_PARAMS
=
[
"
index
"
,
"
x
"
,
"
y
"
,
"
vx
"
,
"
vy
"
,
"
fx
"
,
"
fy
"
];
// Based on https://github.com/d3/d3-force#simulation_nodes
export
const
NODE_SIM_PARAMS
=
[
"
index
"
,
"
x
"
,
"
y
"
,
"
vx
"
,
"
vy
"
,
"
fx
"
,
"
fy
"
];
// Based on https://github.com/d3/d3-force#simulation_nodes
export
const
JSON_CONFIG
=
PLUGIN_PATH
+
"
datasets/aud1.json
"
;
export
const
JSON_CONFIG
=
PLUGIN_PATH
+
"
datasets/aud1
v2
.json
"
;
export
const
STOP_PHYSICS_DELAY
=
5000
;
// ms
export
const
STOP_PHYSICS_DELAY
=
5000
;
// ms
...
@@ -31,6 +31,7 @@ export class Graph extends ManagedData {
...
@@ -31,6 +31,7 @@ export class Graph extends ManagedData {
constructor
(
data
)
{
constructor
(
data
)
{
super
(
Graph
.
addIdentifiers
(
data
));
super
(
Graph
.
addIdentifiers
(
data
));
this
.
calculateLinkTypes
();
this
.
onChangeCallbacks
=
[];
this
.
onChangeCallbacks
=
[];
}
}
...
@@ -50,6 +51,29 @@ export class Graph extends ManagedData {
...
@@ -50,6 +51,29 @@ export class Graph extends ManagedData {
return
this
.
getCleanData
(
data
,
true
);
return
this
.
getCleanData
(
data
,
true
);
}
}
/**
* Based on the function from the 3d-graph code from @JoschaRode
*/
calculateLinkTypes
()
{
const
linkClasses
=
[];
this
.
data
[
GRAPH_LINKS
].
forEach
((
link
)
=>
linkClasses
.
push
(
link
[
LINK_TYPE
])
);
this
.
linkTypes
=
[...
new
Set
(
linkClasses
)];
}
getLinkColor
(
link
)
{
return
this
.
getLinkTypeColor
(
link
[
LINK_TYPE
])
}
getLinkTypeColor
(
linkClass
)
{
var
classIndex
=
this
.
linkTypes
.
indexOf
(
linkClass
);
return
COLOR_PALETTE
[
classIndex
%
COLOR_PALETTE
.
length
];
}
deleteNode
(
nodeId
)
{
deleteNode
(
nodeId
)
{
// Delete node from nodes
// Delete node from nodes
this
.
data
[
GRAPH_NODES
]
=
this
.
data
[
GRAPH_NODES
].
filter
(
this
.
data
[
GRAPH_NODES
]
=
this
.
data
[
GRAPH_NODES
].
filter
(
...
...
This diff is collapsed.
Click to expand it.
editor/js/state.js
+
8
−
0
View file @
04dafd01
...
@@ -90,6 +90,14 @@ export class State extends Tool {
...
@@ -90,6 +90,14 @@ export class State extends Tool {
this
.
tool
.
onLinkClick
(
link
);
this
.
tool
.
onLinkClick
(
link
);
}
}
linkColor
(
link
)
{
return
graph
.
getLinkColor
(
link
);
}
nodeColor
(
node
)
{
return
'
lightblue
'
;
}
onKeyDown
(
key
)
{
onKeyDown
(
key
)
{
var
id
=
this
.
getKeyId
(
key
);
var
id
=
this
.
getKeyId
(
key
);
var
previous
=
this
.
keyStates
[
id
];
var
previous
=
this
.
keyStates
[
id
];
...
...
This diff is collapsed.
Click to expand it.
editor/js/tools/tool.js
+
16
−
0
View file @
04dafd01
...
@@ -92,6 +92,22 @@ export default class Tool {
...
@@ -92,6 +92,22 @@ export default class Tool {
}
}
}
}
linkColor
(
link
)
{
if
(
this
.
warnings
)
{
console
.
warn
(
'
Method "linkColor" not implemented.
'
);
}
}
nodeColor
(
node
)
{
if
(
this
.
warnings
)
{
console
.
warn
(
'
Method "nodeColor" not implemented.
'
);
}
}
onBackgroundClick
(
event
,
positions
)
{
onBackgroundClick
(
event
,
positions
)
{
if
(
this
.
warnings
)
{
if
(
this
.
warnings
)
{
console
.
warn
(
'
Method "onBackgroundClick" not implemented.
'
);
console
.
warn
(
'
Method "onBackgroundClick" not implemented.
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment