bernii / gauge.js

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

[vue.js] Difference between gauge.min.js and gauge.js @ NPM v1.3.5 #151

Closed justinkames closed 6 years ago

justinkames commented 6 years ago

I've tried to get the package working with vue.js and couldn't get it working using version v1.3.5 from NPM.

Initialising the library as specified on http://bernii.github.io/gauge.js/ the with the following import statement =

const {Gauge} = require('gaugeJS')

Results in =

vue.esm.js?65d7:434 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'getContext' of undefined"

While initialising the library with the following import statement works fine =

const {Gauge} = require('gaugeJS/dist/gauge.min')

Please make sure the minified version and the actual version are the same!

kplindegaard commented 6 years ago

Don't know what's going on here, but if you take the gauge.js you get with npm install gaugeJS and minify it with jscompress.com, which is what has been used since I first contributed to this project, you will find that the resulting minified version is identical with what's in the npm 1.3.5 package. So as far as I can tell, it is consistent.

That being said, I'm a complete noob when it comes to packaging and npm. If you spot what the problem is (perhaps in package.json?), a PR is highly appreciated.

kplindegaard commented 6 years ago

Silly question, but are you sure that the page is fully rendered and that the you actually supply the canvas element in the init call? Just asking because it's the kind of error you would see if the canvas isn't available as you init the Gauge. See @dmonaldo's comment in #132. Don't ask me why you experience any difference between gauge.js and gauge.min.js.....

justinkames commented 6 years ago

@kplindegaard

Thanks for the quick reply. I think you are right. I've tested the example above again, and now it is not failing anymore. It probably had something to do with my development environment setup ( Webpack / hot reloading ).

Thanks for taking the time to investigate. The issue can be closed.

amroessam commented 5 years ago

You can use my package that's made for vue. It's a wrapper for gauge.js