Using JavaScript in WordPress page to call for server data using AJAX

There’s a lot of good resources out there to help you build a plugin, but the one I recommend most is the WordPress Plugin Developer Handbook, especially the section on Ajax. You will still need to figure out the functionality needed for the Plotly data, but that should get you in the right direction.