Skip to content
Snippets Groups Projects
Commit 3c23b078 authored by Marc Feger's avatar Marc Feger
Browse files

Add enum for discussion elements and replace tooltip with own functions

parent 39d5b9e9
Branches
No related tags found
No related merge requests found
export const elements = {
ISSUE: "Issue",
STATEMENT: "Statement",
ARGUMENT: "Argument",
SUPPORT: "Support",
ATTACK: "Attack",
REGARDING: "REGARDING",
CONCLUDES: "CONCLUDES",
PREMISEOF: "PREMISE_OF"
};
\ No newline at end of file
import {Neo4JAdapter} from '../neo4j/neo' import {Neo4JAdapter} from '../neo4j/neo'
import {v1 as neo4j} from 'neo4j-driver' import {v1 as neo4j} from 'neo4j-driver'
import {elements} from '../discussionElements'
export class GraphCreator { export class GraphCreator {
...@@ -11,19 +12,19 @@ export class GraphCreator { ...@@ -11,19 +12,19 @@ export class GraphCreator {
if (element instanceof neo4j.types.Node) { if (element instanceof neo4j.types.Node) {
var id = element.identity.toInt(); var id = element.identity.toInt();
var newNode = null; var newNode = null;
if (element.labels.includes("Issue")){ if (element.labels.includes(elements.ISSUE)){
newNode = { newNode = {
"id": id, "id": id,
"labels": element.labels, "labels": element.labels,
"title": element.properties.title "title": element.properties.title
}; };
}else if (element.labels.includes("Statement")){ }else if (element.labels.includes(elements.STATEMENT)){
newNode = { newNode = {
"id": id, "id": id,
"labels": element.labels, "labels": element.labels,
"textversion": element.properties.textversion "textversion": element.properties.textversion
}; };
}else if (element.labels.includes("Argument")){ }else if (element.labels.includes(elements.ARGUMENT)){
newNode = { newNode = {
"id": id, "id": id,
"labels": element.labels "labels": element.labels
......
export function getIssueTooltipOf(element) {
return "<p\>id:" + element.id
+ "<p/>Labels:" + element.labels
+ "<p/>Title:" + element.title;
}
export function getStatementTooltipOf(element) {
return "<div class='card'>"
+ "<img src='https://www.w3schools.com/w3images/avatar2.png' width='80' height='80'/>"
+ "<div class='container'>"
+ "<h4><b>John Doe</b></h4>"
+ "<p>id:" + element.id
+ "<p/>Labels:" + element.labels
+ "<p/>Textversion:" + element.textversion;
}
export function getArgumentTooltipOf(element) {
return "<p\>id:" + element.id
+ "<p/>Labels:" + element.labels;
}
export function getEdgeTooltipOf(element) {
return "<p\>Source:" + element.source.id +
"<p/>Target:" + element.target.id +
"<p/>Type:" + element.type;
}
\ No newline at end of file
...@@ -3,6 +3,8 @@ import {Neo4JAdapter} from '../neo4j/neo' ...@@ -3,6 +3,8 @@ import {Neo4JAdapter} from '../neo4j/neo'
import {Graph} from '../graph/graph' import {Graph} from '../graph/graph'
import {GraphCreator} from '../graph/graphCreator' import {GraphCreator} from '../graph/graphCreator'
import {v1 as neo4j} from 'neo4j-driver' import {v1 as neo4j} from 'neo4j-driver'
import {elements} from '../discussionElements'
import {getIssueTooltipOf, getStatementTooltipOf, getArgumentTooltipOf, getEdgeTooltipOf} from './tooltip/tooltip'
export class Network { export class Network {
async showNetwork(query) { async showNetwork(query) {
...@@ -37,11 +39,11 @@ export class Network { ...@@ -37,11 +39,11 @@ export class Network {
link link
.attr('class', 'link') .attr('class', 'link')
.attr('stroke', function (l) { .attr('stroke', function (l) {
if (l.type.includes("REGARDING")) { if (l.type.includes(elements.REGARDING)) {
return "#A9A9A9"; return "#A9A9A9";
} else if (l.type.includes("CONCLUDES")) { } else if (l.type.includes(elements.CONCLUDES)) {
return "#ce34ff"; return "#ce34ff";
} else if (l.type.includes("PREMISE_OF")) { } else if (l.type.includes(elements.PREMISEOF)) {
return "#7b6fcc"; return "#7b6fcc";
} }
}) })
...@@ -49,9 +51,7 @@ export class Network { ...@@ -49,9 +51,7 @@ export class Network {
tooltip.transition() tooltip.transition()
.duration(300) .duration(300)
.style("opacity", 0.8); .style("opacity", 0.8);
tooltip.html("Source:" + d.source.id + tooltip.html(getEdgeTooltipOf(d))
"<p/>Target:" + d.target.id +
"<p/>Type:" + d.type)
.style("left", (d3.event.pageX) + "px") .style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY + 10) + "px"); .style("top", (d3.event.pageY + 10) + "px");
}) })
...@@ -78,13 +78,13 @@ export class Network { ...@@ -78,13 +78,13 @@ export class Network {
node.append('circle') node.append('circle')
.attr('r', R) .attr('r', R)
.attr("fill", function (d) { .attr("fill", function (d) {
if (d.labels.includes("Attack")) { if (d.labels.includes(elements.ATTACK)) {
return "#ff0000"; return "#ff0000";
} else if (d.labels.includes("Support")) { } else if (d.labels.includes(elements.SUPPORT)) {
return "#00ff00"; return "#00ff00";
} else if (d.labels.includes("Statement")) { } else if (d.labels.includes(elements.STATEMENT)) {
return "#ffff00"; return "#ffff00";
} else if (d.labels.includes("Issue")) { } else if (d.labels.includes(elements.ISSUE)) {
return "#0000ff" return "#0000ff"
} }
}) })
...@@ -94,20 +94,11 @@ export class Network { ...@@ -94,20 +94,11 @@ export class Network {
.style("opacity", .8); .style("opacity", .8);
let info = ""; let info = "";
if (d.labels.includes("Issue")) { if (d.labels.includes("Issue")) {
info = "id:" + d.id info = getIssueTooltipOf(d);
+ "<p/>Labels:" + d.labels } else if (d.labels.includes(elements.STATEMENT)) {
+ "<p/>Title:" + d.title; info = getStatementTooltipOf(d);
} else if (d.labels.includes("Statement")) { } else if (d.labels.includes(elements.ARGUMENT)) {
info = "<div class='card'>" info = getArgumentTooltipOf(d);
+ "<img src='https://www.w3schools.com/w3images/avatar2.png' width='80' height='80'/>"
+ "<div class='container'>"
+ "<h4><b>John Doe</b></h4>"
+ "<p>id:" + d.id
+ "<p/>Labels:" + d.labels
+ "<p/>Textversion:" + d.textversion;
} else if (d.labels.includes("Argument")) {
info = "id:" + d.id
+ "<p/>Labels:" + d.labels;
} }
tooltip.html(info) tooltip.html(info)
.style("left", (d3.event.pageX) + "px") .style("left", (d3.event.pageX) + "px")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment