charts.js / Using canvas element
June 16, 2017 12:00 AM
Hi, I'm trying to see if I can get charts.js to work inside Lectora as a nice way to display data etc. Am having trouble getting it to work though and hoping someone can help. I can get the example below to work fine when building it all from scratch in an html file but not when trying to replicate the code in Lectora.
In Lectora I have an external html custom div added on my page with the following content:
The above (apart from the first 2 lines) has just been lifted from the charts.js site from the example documentation.
I have also tried running this script via an on show action on the page and by adding it directly into the custom div html. I have also tried adapting the header code to put it in a listener, i.e:
document.addEventListener("DOMContentLoaded", function(event) {// code here
}
All I get is a blank page. Any advice?
Thanks,
Stuart
Discussion (3)
Thanks Math. I already had working code. It is the rebuilding of it in Lectora that I haven't been able to get to work. Will have another play about with it...
Make smaller steps to test it. First make sure you got a Canvas that is working as canvas. Then step for step add your external libraries... making sure you have some debugging info ( console.log("Look Ma, my script works", or alert("Help") or some like that ), then you can check whats going wrong...
You can for example download this pen.
https://codepen.io/chartjs/pen/YVWZbz
Then make sure it works on your local machine after the download...
Rebuild it step by step in Lectora... and that should work...
I'm also trying to get this to work in Lectora, and I'm getting the same result--if you make any progress, please let me know!
Discussions have been disabled for this post