d3/d3-queue

Uncaught TypeError: d3.queue is not a function

eablokker opened this issue · 2 comments

I'm loading in d3 and d3-queue

<script type="text/javascript" src="bower_components/d3/d3.js"></script>
<script type="text/javascript" src="bower_components/d3-queue/d3-queue.js"></script>

And trying to call d3.queue();

var q = d3.queue();

And I get this error:

Uncaught TypeError: d3.queue is not a function

Any ideas?

Per the documentation:

In a vanilla environment, a d3_queue global function is exported.

So, in the environment you’ve described, you must say:

var q = d3_queue.queue();

If you use the D3 4.0 alpha, then you can get d3-queue bundled with the other D3 modules, and it’s d3.queue. The documentation has to serve multiple environments.

I’m considering changing all the D3 modules to export to a global d3 object in a vanilla environment, so that if you load multiple D3 modules they all decorate the same object. That would eliminate the confusion, though a slight downside is that you’d no longer be able to inspect the version of each library (since there can only be one d3.version).

Oh great, it works! I didn't understand what that part of the documentation meant without the example.