I have been trying for some time with little success to be able to load highcharts as a require module. I was wondering if anyone had managed to get this working, or if they had any pointers to get me on the right track?
Thank you
With require.js 2.1.0+ a plugin is not necessary. You can include Highcharts with a shim:
require.config({
paths: {
require: "libs/require",
jquery: "libs/jquery",
highcharts: "libs/highcharts"
},
shim: {
highcharts: {
exports: "Highcharts",
deps: ["jquery"]
}
} // end Shim Configuration
});
I just got it to work as follows:
Add this at the top:
define(['jquery'], function (jQuery) {
Add this at the very end:
return window.Highcharts; });
This assumes you have jquery already defined, eg
require.config({
paths: {
'jquery': 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min'
}
});
You can follow this general approach for most third party libraries. For example, I did this for jquery.tmpl.js and knockout.js.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With