From 14ce47f52b0c790743d56d93ab18e0806c64ff05 Mon Sep 17 00:00:00 2001 From: Speros Kokenes Date: Fri, 27 Feb 2015 16:21:52 -0500 Subject: [PATCH] Fixed multiple lasso bug A d3.select("path") is called to select the path drawn in order to get the path definition and create a closed path from it. This does not work if multiple lassos are drawn on the page, since the d3.select("path") will only select the first path. Instead of using d3.select() to find this value, it is actually already stored previously in a variable called "path". So the closed path can be created by just using path + "Z"; Instead of d3.select(path). This version allows you to use multiple lasso's on one page. --- lasso/lasso.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasso/lasso.js b/lasso/lasso.js index b9245a9..c21b088 100644 --- a/lasso/lasso.js +++ b/lasso/lasso.js @@ -106,7 +106,7 @@ d3.lasso = function() { isPathClosed = distance<=closePathDistance; // create complete path - var complete_path_d = d3.select("path")[0][0].attributes.d.value + "Z"; + var complete_path_d = path + "Z"; complete_path.attr("d",complete_path_d); // get path length @@ -296,4 +296,4 @@ d3.lasso = function() { return lasso; -}; \ No newline at end of file +};