Hi. I am trying to set up a simple chart.js chart on my website for testing. This requires a javascript script to run on a page. I have not been able to set up the script on the website successfully. I have however got a chart displayed on the webpage but in a way that I do not understand why it works this way and how to make it work properly.
- I have installed a code plugin - https://github.com/dartiss/code-embed
- I have added the JS to a code block in that plugin. That in itself did not work. Chart does not display.
- I then added the JS to the Theme co customisation code area. That in itself did not work. Chart does not display.
- Together the above two steps work - JS added to Theme customisation and the code block simultaneously. Chart displays.
- If I delete parts of the script in either place the chart does not display.
I am using the example script from chart.js so the script itself is fine. The above scenario is almost certainly going to throw up issues in the future, such as trying to make the chart dynamically respond to data inputted by a user. Not to mention the fact that the script has to run on every page in my website because it is in the Theme customisation area (at least I think it is the case that it runs on all pages).
The webpage I am trying to create the chart on: https://wonkylogic.co/area51/chart-js/