Skip to content
Snippets Groups Projects
Commit e6e44a75 authored by Katja's avatar Katja
Browse files

comments

parent 355a66d6
No related branches found
No related tags found
2 merge requests!10Output,!9Main
......@@ -56,6 +56,12 @@ d3.json("json_text.json").then(function(graph) {
update(graph.links, graph.nodes);
})
/**
* display links and nodes (with circle and text)
* initialises link, node objects
* @param {object} nodes - nodes
* @param {object} links - links
*/
function update(links, nodes) {
link = g.append("g")
.selectAll(".link")
......@@ -118,10 +124,20 @@ simulation.force("link")
.links(links);
}
/**
* returns true if link is directly connected to node and false if it is not
* @param {object} node - node
* @param {object} link - link
*/
function isLinkForNode(node, link){
return link.source.index == node.index || link.target.index == node.index;
}
/**
* sets color of link (line and arrowhead) to black if it is directly connected to node
* and to grey otherwise
* @param {object} node - node
*/
function marklink(node){
d3.selectAll(".link")
.style("stroke", function(o) {
......@@ -130,6 +146,10 @@ function marklink(node){
return isLinkForNode(node, o) ? marker('#000000') : marker('#999');})
}
/**
* creates arrowhead and returns its url
* @param {string} color - color of arrowhead
*/
function marker(color) {
svg.append('defs').append('marker')//arrowhead
.attr('id',color.replace("#", ""))
......@@ -149,7 +169,7 @@ function marker(color) {
/**
* returns last name of first author
* @param {string} authors - The comma-separated string of authors
* @param {string} authors - the comma-separated string of authors
*/
function firstauthor(authors){
if (/,/.test(authors)==false){
......@@ -161,6 +181,10 @@ function firstauthor(authors){
return firstauthor[1]
}
/**
* outputs node info to textbox
* @param {object} d - data of current node
*/
function textfunc(d){
document.getElementById('textbox').innerHTML = "Title:" + '</br>' + d.name +
'</br>' +'</br>'+"Author:"+ '</br>' +d.author+'</br>'+'</br>'+"Year:"+'</br>'+d.year+'</br>'+'</br>'
......
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