skokenes / d3-lasso

A lasso plugin for d3
BSD 3-Clause "New" or "Revised" License
88 stars 35 forks source link

In order to use lasso, one has to import whole "d3" module, do we have any better way? #5

Open rahul-winner opened 6 years ago

rahul-winner commented 6 years ago

I'm using this package in one of my Angular application. Presently, I need to import "d3" package and set it to window variable to make lasso work. A snippet of code is as follows

import * as d3 from "d3"; ... ... @Component() export class mycomp { constructor() { window["d3"] = d3; }

ngOnInit() { initLasso(); }

initLasso() { const targetAreaToSelectNodes = lasso() .closePathSelect(true) .closePathDistance(100) .items(nodes) .targetArea(svg); targetAreaToSelectNodes.on("start", () => { }); targetAreaToSelectNodes.on("draw", () => { }); targetAreaToSelectNodes.on("end", this.onNodesSelectionEnd.bind(this, targetAreaToSelectNodes, d3)); svg.call(targetAreaToSelectNodes); }

}

Does anyone here think this can be done a little differently?