Hello Govarthini Rajan,
Have you added the script file into your project directory inside theme and added a script call inside index.html, Because it seems the method not defined. You can add the method in two ways,
Adding the script tag inside index.html file like, <script src="https://d3js.org/d3.v5.min.js"></script>
Add the folder ‘scripts’ inside the theme folder of your project directory, add d3.v5.min.js into ‘scripts’ folderthen add the following inside index.html file <script rel="preload" src="scripts/d3.v5.min.js"></script>
You can add the version based on your feasibility, I gave the sample for version 5
Hope this helps, Thanks!
Are you able to see more detailed information in the Java Script Console of your browser?