Browse Source

fixed sankey drag handler

Piotr Labudda 7 years ago
parent
commit
c2b218adec
1 changed files with 20 additions and 35 deletions
  1. 20 35
      theme/assets/js/graph/sankey-init-widget.js

+ 20 - 35
theme/assets/js/graph/sankey-init-widget.js

@@ -197,7 +197,7 @@ var change = function(d) {
 			return i
 		}).on("dragstart", function() {
 			this.parentNode.appendChild(this)
-		}).on("drag", b));
+		}).on("drag", samkeyOnDragMove));
 	c.append("rect") //node
 		.attr("height", function(i) {
 			return i.dy
@@ -272,44 +272,29 @@ var change = function(d) {
 			})
 		});
 
-	function b(i) { //dragmove
-		// if (document.getElementById("ymove").checked) {
-		// 	if (document.getElementById("xmove").checked) {
-		// 		d3.select(this).attr("transform", "translate(" + (i.x = Math.max(0, Math.min(width - i.dx, d3.event.x))) + "," + (i.y = Math.max(0, Math.min(height - i.dy, d3.event.y))) + ")")
-		// 	} else {
-		dragged = true;
+		function samkeyOnDragMove(i) {
+			// if (document.getElementById("ymove").checked) {
+			// 	if (document.getElementById("xmove").checked) {
+			// 		d3.select(this).attr("transform", "translate(" + (i.x = Math.max(0, Math.min(width - i.dx, d3.event.x))) + "," + (i.y = Math.max(0, Math.min(height - i.dy, d3.event.y))) + ")")
+			// 	} else {
+			dragged = true
 			d3.select(this).attr("transform", "translate(" + i.x + "," + (i.y = Math.max(0, Math.min(height - i.dy, d3.event.y))) + ")")
-		// 	}
-		// } else {
-		// 	if (document.getElementById("xmove").checked) {
-		// 		d3.select(this).attr("transform", "translate(" + (i.x = Math.max(0, Math.min(width - i.dx, d3.event.x))) + "," + i.y + ")")
-		// 	}
-		// }
-		// sankey.relayout();
-		// f.attr("d", path(1));
-		// h.attr("d", path(0));
-		// e.attr("d", path(2))
-	};
+			// 	}
+			// } else {
+			// 	if (document.getElementById("xmove").checked) {
+			// 		d3.select(this).attr("transform", "translate(" + (i.x = Math.max(0, Math.min(width - i.dx, d3.event.x))) + "," + i.y + ")")
+			// 	}
+			// }
+			sankey.relayout();
+			f.attr("d", path(1)); // TODO: global var f
+			h.attr("d", path(0)); // TODO: global var h
+			e.attr("d", path(2)); // TODO: global var e
+		}
+
 };
 // draw();
 
-//<!-- SAVE FUNCTION-->
-
-d3.select("#pngdownloadwrapper")
-.on("click",function(){
-	seturl();
-	setTimeout(function(){d3.select("#pngdownload").node().click();},500);
-})
-
-function seturl(){
-	exportInlineSVG(d3.select("#chart").select("svg").node(), function(data) {
-		d3.select("#pngdownload").node().href=data;
-	});
-}
-
-// ----
-
-	renderGraph = (htmlNode, data, opts) => {
+	var renderGraph = (htmlNode, data, opts) => {
 		var opts = opts || {}
 		if (!htmlNode) throw "Missing html node";
 		if (!data) throw "Missing data";