Skip to content
Snippets Groups Projects
Commit 6f060a66 authored by Stahl, Merle's avatar Stahl, Merle
Browse files

drag nodes

parent 5b5a41b3
No related branches found
No related tags found
2 merge requests!10Output,!9Main
...@@ -158,10 +158,11 @@ function updateNodes(nodes) { ...@@ -158,10 +158,11 @@ function updateNodes(nodes) {
.attr('dx', function(d) {return xscale(parseFloat(d.year))}) .attr('dx', function(d) {return xscale(parseFloat(d.year))})
.attr("initial_x", function(d) {return d.dx;}) .attr("initial_x", function(d) {return d.dx;})
.attr("initial_y", function(d) {return d.dy;}) .attr("initial_y", function(d) {return d.dy;})
/*.call(d3.drag() .call(d3.drag()
.on("start", dragstarted) .on("start", dragstarted)
.on("drag", dragged) .on("drag", dragged)
)*/; .on("end", dragended)
);
node.append("circle") node.append("circle")
.attr("class", "circle") .attr("class", "circle")
...@@ -303,6 +304,16 @@ function dragged(node) { ...@@ -303,6 +304,16 @@ function dragged(node) {
node.fy = d3.event.y; node.fy = d3.event.y;
} }
/**
* ends the dragging and resets the position of the node
* @param {object} node - data of current node
*/
function dragended(node) {
if (!d3.event.active) simulation.alphaTarget(.03);
node.fx = null;
node.fy = null;
}
/** /**
* resets the positions of the nodes * resets the positions of the nodes
*/ */
......
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