Invoke method in external JS file from Vue component

Viewed 31

I am trying to use some clustering methods in an external Javascript file I found online. The HTML example using the same JS file works (example file available in the sandbox) but I am trying to get it to work within a Vue component so that I can use it for some Vue coding

Here is some code that unfortunately breaks when I try it:

https://codesandbox.io/s/hierarchical-clustering-8t6ckt?file=/src/components/RunClustering.vue

Interestingly, when I enter the variable from the external JS file, the online editor (as well as my VSC) "sees" the variable and shows me what it can do. So there is something going on. But when I the run the code, it breaks

TypeError
Cannot read properties of undefined (reading 'agglomerate')
1 Answers

That happens because you don't export the figue from the Clustering.js file, Also, there are some declaration errors in the Clustering.js file itself.

If fixed it all you can check this.

Related