1๐
โ
You need to
-
Move / copy the block you have in your
$(document).ready
above into your AJAX callback. -
Replace the (currently hardcoded) array with your AJAX result (reformatting if necessary into a flat array)
-
Attach an onclick event handler for your refresh button that
-
Calls a
.destroy()
on the corresponding chart instance -
Replaces the canvas element with your loading icon
-
Does the AJAX call (that has the callback from Step 1 above)
-
-
In Your AJAX callback handler, you replace the loading icon with the canvas before doing the remaining steps (from Step 1 above) to (re)initialize the chart
Source:stackexchange.com