Lasso use in d3 implemented using react

103 views
Skip to first unread message

Faheem Nizar

unread,
Feb 12, 2023, 1:28:48 AM2/12/23
to d3-js
I am implementing d3 in a react application and want to use d3 lasso for a particular use case. However, as d3-lasso isn't a default feature of d3, I cannot directly call d3.lasso().

After installing d3-lasso from npm, While using d3, I encountered issues with its usability. While calling a reference of d3, it gives the following error:
Importing:
`
import * as d3 from 'd3'
import {lasso} from 'd3-lasso';
`

Usage:
`
const lasso_d3 = lasso()
    .closePathSelect(true)
    .closePathDistance(100)
    .items(data_scat)
    .targetArea(svg)
    .on("start",lasso_start)
    .on("draw",lasso_draw)
    .on("end",lasso_end);

    svg.call(lasso_d3)
`

Error:
`
Uncaught (in promise) ReferenceError: d3 is not defined
    at lasso (d3-lasso.js:776:1)
    at Selection.__WEBPACK_DEFAULT_EXPORT__ [as call] (call.js:4:1)
`

I have been trying different methods of calling the lasso, but none of them gives any fruitful results, and I believe it is due to d3 not being a default module available that causes this issue with the lasso.

I request anyone who has experienced the same issue and has resolved it to hopefully give some insights, if possible.

Thank You.
Reply all
Reply to author
Forward
0 new messages