I am developing a site on WordPress that uses the JavaScript-based plotting library, Plotly, to plot data retrieved from a data server. I need the user to be able to enter text into a text field that will update the graph as the user types. I want the site to work similar to this w3schools example.
What I have so far:
- I can run JavaScript in my page using this plugin, Scripts and Styles.
I can run the Ploty graph on the page using the Scripts and Styles plugin using this code:
<head> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> </head> <body> <div id="tester" style="width:600px;height:250px;"></div> <script> TESTER = document.getElementById('tester'); Plotly.plot( TESTER, [{ x: [1, 2, 3, 4, 5], y: [1, 2, 4, 8, 16] }], { margin: { t: 0 } } ); </script> </body>
What I'm missing:
- I don't know how to make JavaScript send an AJAX to a custom PHP plugin to retrieve data to post back to the Plotly graph.
Moral of the story, I need to be able to update a Plotly graph on a WordPress site.
Thanks in advance!