From 5b5a41b3684e6993e0bfd00e6abc505cfb95956f Mon Sep 17 00:00:00 2001
From: Merle Stahl <merle.stahl@studium.uni-hamburg.de>
Date: Fri, 26 Nov 2021 20:04:01 +0100
Subject: [PATCH] falsche Position der Knoten gefixt

---
 Output/cn.js          | 28 ++++++++++++++--------------
 Output/json_text.json |  4 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/Output/cn.js b/Output/cn.js
index d4ddeb2..539084c 100644
--- a/Output/cn.js
+++ b/Output/cn.js
@@ -22,7 +22,7 @@ color = d3.scaleOrdinal()
     .range([' #01d7c0', ' #8b90fe ', '  #a15eb2 ']),
 yscale = d3.scaleOrdinal()
     .domain(["citing", "input", "cited"])
-    .range([50, height/2+20, height-10]),
+    .range([50, height/2, height-50]),
 toRemove;
 
 /**
@@ -45,14 +45,13 @@ var rect = svg.append("rect")
 /**
 * creates a new simulation
 * arranges the nodes according to their group on the y-axis
-* arranges the nodes according to their year on the x-axis
 */
 var simulation = d3.forceSimulation()
-    .force("link", d3.forceLink().id(function(d) {return d.doi;}).distance(150).strength(1))
-    .force("collide", d3.forceCollide(30))
-    //.force("charge", d3.forceManyBody().strength(-50))
+    .force("link", d3.forceLink().id(function(d) {return d.doi;}).distance(100).strength(1))
+    .force("collide", d3.forceCollide(60))
+    .force("charge", d3.forceManyBody().strength(-50))
     .force("center", d3.forceCenter(width/2, height/2+50))
-    .force("xscale", d3.forceX().strength(1).x(function(d) {return xscale(parseInt(d.year))}))
+    //.force("xscale", d3.forceX().strength(1).x(function(d) {return xscale(parseFloat(d.year))}))
     .force("yscale", d3.forceY().strength(1).y(function(d) {return yscale(d.group)}));
     
 /**
@@ -65,7 +64,8 @@ var g = svg.append("g")
 * creates XAxis element
 */
 var xAxis = d3.axisBottom()
-    .tickFormat(function(d) {return d;});
+    .tickFormat(function(d) {return d;})
+    .ticks(10);;
 
 /**
 * draw xAxis
@@ -117,12 +117,12 @@ function update(links, nodes) {
 function updateXAxis(nodes) {
     years = [];
     for (i = 0; i < nodes.length; i++) {
-        years.push(parseInt(nodes[i]["year"]));
+        years.push(parseFloat(nodes[i]["year"]));
     }
 
     xscale = d3.scaleLinear()
-        .domain([d3.min(years), d3.max(years)])
-        .range([0, width])
+        .domain([d3.min(years)-10, d3.max(years)+10])
+        .range([50, width-50])
 
     xAxis.scale(xscale);
     gX.call(xAxis);
@@ -155,6 +155,7 @@ function updateNodes(nodes) {
         .enter()
         .append("g")
         .attr("class", "node")
+        .attr('dx', function(d) {return xscale(parseFloat(d.year))})
         .attr("initial_x", function(d) {return d.dx;})
         .attr("initial_y", function(d) {return d.dy;})
         /*.call(d3.drag()
@@ -275,11 +276,11 @@ function textfunc(node){
 * updates the positions of the links and nodes
 */
 function tickHandler() {
-    link.attr("x1", function (d) {return d.source.x;})
+    link.attr("x1", function (d) {return xscale(parseInt(d.source.year));})
         .attr("y1", function (d) {return d.source.y;})
-        .attr("x2", function (d) {return d.target.x;})
+        .attr("x2", function (d) {return xscale(parseInt(d.target.year));})
         .attr("y2", function (d) {return d.target.y;});
-    node.attr("transform", function (d) {return "translate(" + d.x + ", " + d.y + ")";});
+    node.attr("transform", function (d) {return "translate(" + xscale(parseInt(d.year)) + ", " + d.y + ")";});
 }
 
 /**
@@ -317,7 +318,6 @@ function resetGraph() {
 */
 function zoomHandler() {
     d3.select('g').attr("transform", d3.event.transform);
-    //gX.call(xAxis.scale(d3.event.transform.rescaleX(xscale)));
     var new_xScale = d3.event.transform.rescaleX(xscale)
     gX.call(xAxis.scale(new_xScale));
 }
diff --git a/Output/json_text.json b/Output/json_text.json
index 12491ef..1a080a0 100644
--- a/Output/json_text.json
+++ b/Output/json_text.json
@@ -3,7 +3,7 @@
         {
             "name": "Comparing Molecular Patterns Using the Example of SMARTS: Applications and Filter Collection Analysis",
             "author":"Emanuel S. R. Ehmki,Robert Schmidt, Farina Ohm, Matthias Rarey",
-            "year":"1997",
+            "year":"2001",
             "doi": "https://doi.org/10.1021/acs.jcim.9b00249",
             "group": "input",
             "citations": 0
@@ -27,7 +27,7 @@
         {
             "name": "Evolution of Novartis\u2019 Small Molecule Screening Deck Design ",
             "author": "Ansgar Schuffenhauer, Nadine Schneider, Samuel Hintermann, Douglas Auld, Jutta Blank, Simona Cotesta, Caroline Engeloch, Nikolas Fechner, Christoph Gaul, Jerome Giovannoni, Johanna Jansen, John Joslin, Philipp Krastel, Eugen Lounkine, John Manchester, Lauren G. Monovich, Anna Paola Pelliccioli, Manuel Schwarze, Michael D. Shultz, Nikolaus Stiefl, Daniel K. Baeschlin. ",
-            "year":"2001",
+            "year":"1990",
             "doi": "https://doi.org/10.1021/acs.jmedchem.0c01332",
             "group": "input",
             "citations": 250
-- 
GitLab