bernii/gauge.js

error canvas!

pws2016 opened this issue · 3 comments

hello,
i integrate your script but i get the error:
Uncaught TypeError: this.canvas.getContext is not a function at new Gauge (gauge.js:467)

mch03 commented

I have this same error. Installed the script just the way instructions are here in github page.

It means that you failed to fetch the DOM reference to the html canvas element. I.e target you supply to the Gauge constructor is undefined. Maybe you never created that?

Ref. Example in https://bernii.github.io/gauge.js

qroft commented

I suggest that within the documentation should be mentioned that "the canvas element" must be a HTML canvas element.
As on the web "canvas" is often related to some kind of space, i first thought that it could be a simple DIV or SVG.
What did not work.
So i tried it out with "canvas" and it did work.
Anyone struggeling here too, the answer is that you simply have to create something like
<canvas id="foo"></canvas>