d3js: Can I port observablehq code to openwisp/django-netjsongraph environment

I need to port this code “https://observablehq.com/d/ed463733efd48775” to the openwisp/django-netjsongraph environment. Has anyone in the group done this before. Because when I port this I am getting some errors. I am presuming it is an issue of porting d3v5(observable) code to d3v3.

You could start by changing the import to d3@3 and fixing the compatibility issues.

Hi Jed,
What I did was in my openwisp django netjsongraph enivronment I pointed the base.html file to point to d3v5 version which is compatible to observable hq version. Still I am facing errors porting the code of “https://observablehq.com/d/ed463733efd48775" to openwisp enviornment even though both are pointing to the same version. Openwisp autogenerates netjsongraph.js file based on the topology I have created. Now in this js which is auto generated I need to port the above code. Since I am a novice to d3.js world I am suspecting even placement of the functions in the auto generated js code might be an issue.I am sharing the autogenerated code where I have ported the observablehq code. If someone can guide me as to where I am doing mistakes that would be really helpful. Link to my autogenerated code where I have incorporate the observablehq code: https://github.com/una2511/js