D3 automatically disables global namespace pollution when it detects AMD like require.js. Dimple.js expects d3 to be in the global namespace. This guy says he can load dimple using a shim, and I can find similar claims for nvd3, and yet another incomplete example here.
However, I can find no complete working examples. Here's a non-working example of a require.config
:
require.config({
shim: {
d3: { exports: "d3" },
dimple: {
exports: "dimple",
deps: ["d3"]
}
},
paths: {
d3: "http://d3js.org/d3.v3.min",
dimple: "http://dimplejs.org/dist/dimple.v1.1.5.min"
}
});
And an example of something that doesn't work:
require(["dimple"], function(dimple) {
var svg = dimple.newSvg("#awesome_bars", 800, 600);
}
// -> dimple is undefined
Dimple is (I think!) a proper CommonJS library, and I'm able to load d3 (without a shim) just fine. And if you're wondering, yes, I have an appropriate div, and that wouldn't be relevant to the undefined result.
So, how can I get access to dimple in the context of require.js?