Skip to content
Snippets Groups Projects
Commit 7a294788 authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Fixed node color issues

parent f355f6b2
No related branches found
No related tags found
No related merge requests found
Pipeline #54692 passed
...@@ -87,16 +87,17 @@ export class Graph extends ManagedData { ...@@ -87,16 +87,17 @@ export class Graph extends ManagedData {
} }
getNodeColor(node) { getNodeColor(node) {
return node.type.color; if (node === undefined || node.type === undefined) {
return "black";
}
return "#" + node.type.color;
} }
calculateNodeTypes() { calculateNodeTypes() {
// TODO: Collect all types from database // TODO: Collect all types from database
const nodeClasses = []; const nodeClasses = [];
this.data.nodes.forEach((node) => this.data.nodes.forEach((node) => nodeClasses.push(node[NODE_TYPE]));
nodeClasses.push(node[NODE_TYPE])
);
this.nodeTypes = [...new Set(nodeClasses)]; this.nodeTypes = [...new Set(nodeClasses)];
} }
......
...@@ -266,11 +266,11 @@ export class State extends Tool { ...@@ -266,11 +266,11 @@ export class State extends Tool {
// Color at source node referencing the target node and vice versa // Color at source node referencing the target node and vice versa
gradient.addColorStop( gradient.addColorStop(
"0", "0",
"#" + graph.getNodeColor(link[Graph.LINK_TARGET_OBJ]) graph.getNodeColor(link[Graph.LINK_TARGET_OBJ])
); );
gradient.addColorStop( gradient.addColorStop(
"1", "1",
"#" + graph.getNodeColor(link[Graph.LINK_SOURCE_OBJ]) graph.getNodeColor(link[Graph.LINK_SOURCE_OBJ])
); );
ctx.beginPath(); ctx.beginPath();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment