bernii / gauge.js

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

RequireJS - Gauge is not defined #255

Open davidhill001 opened 2 years ago

davidhill001 commented 2 years ago

I love the look of gauge.js and would love to try it out on one of my projects but I'm really struggling to get it to run when including the JS file via. RequireJS 2.3.6. It just says 'Gauge is not defined':

image

I can see that RequireJS has downloaded and included the JS file but for some reason the Gauge variable just isn't set:

image

image

My require.js configuration:

define('global/window', [], function(){
  return window;
});

define('global/document', ['global/window'], function(window){
  return window.document;
});

requirejs.config({
    appDir: "../",
    baseUrl: "/js",
    paths: {
            'Gauge_js': ['https://bernii.github.io/gauge.js/dist/gauge']
    },
    shim: {
    },    
    map: {
    },    
    attributes: {
       crossorigin: "anonymous"
    }, 
    onNodeCreated: function(node, config, name, url){
      if(config.attributes){
        Object.keys(config.attributes).forEach(function(attribute) {
          node.setAttribute(attribute, config.attributes[attribute]);
        });
      }
    }
});

require(['Gauge_js'], function($) {
    return {};
});

I have tried the minified version and the full versions from both CDNJS and bernii.github.io.

Please does anyone have any ideas?