score:0

for those also sent here by google, i had to shim the file to export the correct variable:

requirejs.config({
    baseurl: 'scripts',
    paths: {
        ...
        'chartjs': 'vendor/chart'
    },
    shim: { 
        'chartjs': {
            exports: 'chart'
        }
    },
});

score:1

if you are using v2.0 of chart.js make sure you get a latest version (it worked for me with 2.0.0-beta2, but not with alpha). also, since chart.js depends on moment.js you'll need to include that as well.


with older versions of chart.js v2.0 (say alpha), you'll have to load chart.js as a legacy script and use the global variable (or noconflict()).


the dependency on moment.js is not very obvious (related issue - https://github.com/nnnick/chart.js/issues/2110). here's what you get on the console, when you load chart.js as a normal script file.

enter image description here

when chart.js is loaded by require.js, this dependency causes a request for moment.js.


Related Query

More Query from same tag