I am trying to use RequireJS to load the plotly and d3 libraries in my js code. I have tried this:
require.config({
paths: {
d3: '/static/scripts/plotly/dependencies/d3.v3.min',
plotly: '/static/scripts/plotly/plotly.min'
}
});
require(['d3'], function(d3) {
d3();
});
require(['plotly'], function(plotly) {
plotly();
});
But this doesn't work. When my js function is called I get:
Uncaught ReferenceError: plotly is not defined
Uncaught ReferenceError: Plotly is not defined
Uncaught ReferenceError: d3 is not defined
Uncaught TypeError: d3 is not a function
What is the proper way to use RequireJS in this situation?
Updating post with current version of code, still not working.
In the calling script I have this now:
require.config({
paths: {
heatmap: '/static/scripts/heatmap',
d3: '/static/scripts/plotly/dependencies/d3.v3.min',
plotly: '/static/scripts/plotly/plotly.min',
}
});
require(['d3', 'plotly', 'heatmap'], function(d3, plotly, heatmap) {
generate_heatmap();
});
And it fails with:
Uncaught ReferenceError: Plotly is not defined(anonymous function) @ plotly.min.js:17
The function Plotly (upper case P) is defined in plotly.min.js. Do I have to add some reference to that function somewhere?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…