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

legend upper right

parent 991519ba
No related branches found
No related tags found
2 merge requests!10Output,!9Main
...@@ -7,7 +7,10 @@ var zoom = d3.zoom().on("zoom", zoomHandler); ...@@ -7,7 +7,10 @@ var zoom = d3.zoom().on("zoom", zoomHandler);
* creates svg object and associated attributes * creates svg object and associated attributes
* applies the zoom behavior to svg * applies the zoom behavior to svg
*/ */
var svg = d3.select("svg")
var svg2=d3.select("svg.legendsvg")
var svg = d3.select("svg.graph")
.call(zoom), .call(zoom),
width = svg.attr("width"), width = svg.attr("width"),
height = svg.attr("height"); height = svg.attr("height");
...@@ -23,6 +26,9 @@ color = d3.scaleOrdinal() ...@@ -23,6 +26,9 @@ color = d3.scaleOrdinal()
yscale = d3.scaleOrdinal() yscale = d3.scaleOrdinal()
.domain(["citing", "input", "cited"]) .domain(["citing", "input", "cited"])
.range([0, 200, 400]), .range([0, 200, 400]),
linetype=d3.scaleOrdinal()
.domain(["line","dotted"])
.range([("8,0"),("8,8")]),
toRemove; toRemove;
/** /**
...@@ -99,39 +105,45 @@ var rect2 = svg.append("rect") ...@@ -99,39 +105,45 @@ var rect2 = svg.append("rect")
.attr("width", 210) .attr("width", 210)
.style("fill", 'white'); .style("fill", 'white');
legendposition=[70,110,150] legendposition=[65,95,125]
arrowlegendposition=[0,25]
arrowgroupnames=["citation","self-citation"]
groupnames=["citing","input","cited"] groupnames=["citing","input","cited"]
var legend = svg.selectAll(".legend") var legend = svg2.selectAll(".legend")
.data(legendposition) .data(legendposition)
.enter() .enter()
.append("g") .append("g")
.attr("class","legend") .attr("class","legend")
.attr("transform", function(d) { return "translate(0," + d + ")"; }); .attr("transform", function(d,i) {return "translate(0," + d + ")"; });
legend.append("text") legend.append("text")
.attr("x", 100) .attr("x", 80)
.attr("y", 0) .attr("y", 0)
.attr("dy", ".35em") .attr("dy", ".35em")
.style("text-anchor", "start") .style("text-anchor", "start")
.text(function(d){return groupnames[legendposition.indexOf(d)]}); .text(function(d,i){return groupnames[i]});
legend.append("circle") legend.append("circle")
.attr("r", r) .attr("r", r)
.attr("cx",50-r) .attr("cx",30-r)
.style("fill", color); .style("fill", color);
var legendarrow = svg.append("g") var legendarrow = svg2.selectAll(".legendarr")
.attr("class","legend") .data(arrowlegendposition)
.attr("transform","translate(20,20)"); .enter()
.append("g")
.attr("class","legendarr")
.attr("transform", function(d) { return "translate(0," + d + ")"; });
legendarrow.append("line") legendarrow.append("line")
.attr("x1", 10) .attr("x1", 10)
.attr("x2", 50) .attr("x2", 50)
.attr("y1", 10) .attr("y1", 10)
.attr("y2", 10) .attr("y2", 10)
.style("stroke-dasharray","8,8") .style("stroke-dasharray",linetype)
.style("stroke", '#999') .style("stroke", '#999')
.style("stroke-width", "1px") .style("stroke-width", "1px")
.style('pointer-events', 'none') .style('pointer-events', 'none')
...@@ -141,7 +153,7 @@ legendarrow.append("text") ...@@ -141,7 +153,7 @@ legendarrow.append("text")
.attr("y", 10) .attr("y", 10)
.attr("dy", ".35em") .attr("dy", ".35em")
.style("text-anchor", "start") .style("text-anchor", "start")
.text("self-citation"); .text(function(d,i){return arrowgroupnames[i]});
/** /**
...@@ -299,7 +311,8 @@ function firstauthor(authors){ ...@@ -299,7 +311,8 @@ function firstauthor(authors){
function textfunc(node){ function textfunc(node){
document.getElementById('textbox').innerHTML = "Title:" + '</br>' + node.name + document.getElementById('textbox').innerHTML = "Title:" + '</br>' + node.name +
'</br>' +'</br>'+"Author:"+ '</br>' +node.author+'</br>'+'</br>'+"Year:"+'</br>' '</br>' +'</br>'+"Author:"+ '</br>' +node.author+'</br>'+'</br>'+"Year:"+'</br>'
+node.year+'</br>'+'</br>'+"doi:"+'</br>'+node.doi; +node.year+'</br>'+'</br>'+"doi:"+'</br>'+'<a href="'+node.doi+ '">'+node.doi
+'</a>'+'</br>'+'</br>'+"Citations:"+'</br>'+node.citations;
} }
/** /**
......
...@@ -4,35 +4,60 @@ ...@@ -4,35 +4,60 @@
<meta charset="utf-8"> <meta charset="utf-8">
<style type="text/css"> <style type="text/css">
/* div.legendbox {
width:270px;
height:170px;
padding: 10px;
/*border: 1px solid #999;*/
position: absolute;
top: 10px;
left: 968px;
display: inline-block;
margin: 0;
}
button { button {
width: 150px; width: 100px;
font-size: 15px; height:20px;
padding: 7px; display: flex;
border-radius: 3px; justify-content: center;
border: 3px solid #999; position: absolute;
left: 430px;
top: 575px;
}
button.resetGraph {
color: black; color: black;
cursor: pointer; }
position : absolute;
top: 500px;
right: 550px;
} */
button.resetZoom {
margin-left: 110px;
}
/* textbox */ button.center {
div { margin-left: 220px;
}
button.save{
margin-left: 330px;
}
div.textbox{
width:270px; width:270px;
min-height:200px; min-height:200px;
max-height:370px; max-height:370px;
padding: 10px; padding: 10px;
border: 1px solid #999; border: 1px solid #999;
position: absolute; position: absolute;
top: 100px; top: 200px;
left: 980px; left: 968px;
display: inline-block; display: inline-block;
overflow-y: scroll; overflow-y: scroll;
margin: 0; margin: 0;
} }
/ textbox */
</style> </style>
</head> </head>
...@@ -41,18 +66,19 @@ ...@@ -41,18 +66,19 @@
<p id="id"></p> <!--for commenting with document.getElementById("id").innerHTML = "text"; --> <p id="id"></p> <!--for commenting with document.getElementById("id").innerHTML = "text"; -->
<!-- graph --> <!-- graph -->
<svg width="960" height="500" ></svg> <svg class="graph" width="960" height="560" ></svg>
<div class="legendbox"> <svg class="legendsvg"></svg> </div>
<!-- textbox --> <!-- textbox -->
<div id = "textbox" style="border:1px solid" >Click node</div> <div class="textbox" id = "textbox" >Click node</div>
<!-- reset-buttons --> <!-- reset-buttons -->
<button onclick="javascript:location.reload();">Reload</button> <!-- <button onclick="javascript:location.reload();">Reload</button>-->
<button onclick="resetGraph()">Reset graph</button> <button class="resetGraph" onclick="resetGraph()">Reset graph</button>
<button onclick="resetZoom()">Reset zoom</button> <button class="resetZoom" onclick="resetZoom()">Reset zoom</button>
<button onclick="center()">Center</button> <button class="center" onclick="center()">Center</button>
<button onclick="savesvg()">Save</button> <button class="save" onclick="savesvg()">Save</button>
<!-- link D3 (version 5) --> <!-- link D3 (version 5) -->
<script src="https://d3js.org/d3.v5.min.js"></script> <script src="https://d3js.org/d3.v5.min.js"></script>
......
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