bernii / gauge.js

100% native and cool looking JavaScript gauge
MIT License
1.42k stars 391 forks source link

error canvas! #235

Closed pws2016 closed 3 years ago

pws2016 commented 3 years ago

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 3 years ago

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

kplindegaard commented 3 years ago

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 2 years ago

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>