score:1

Accepted answer

I never used d3.lasso before but looking at this bl.ock using d3 v4, looks like your code is missing a few minor things:

  1. Area to be passed to d3 lasso is now done using targetArea

     var lasso = d3.lasso()
      .targetArea(svg)
    
  2. Items passed to d3 lasso must be a d3 selection and not a string

    var circles = svg.selectAll("circle")...
    
    var lasso = d3.lasso()
     .items(circles) 
    

And of course, using the actual minified lasso code in a script tag, here's a snippet:

https://bl.ocks.org/shashank2104/f878d660bd9013faa6d48236b5fe9502/67d50a5c7a21c0adfa5ed66ce3dc725f0a45c8c2

Also, I've added some CSS to the selected circles just to differentiate when compared with others:

.selected {
   fill: steelblue;
}

Hope this helps.


Related Query