ReferenceError: d3 is not defined
fr0z3nfyr opened this issue · 3 comments
Using d3.v3.min.js
Get error when include your js file. (See Firebug snapshot for details)
ReferenceError: d3 is not defined
d3.contextMenu = function (menu, openCallback) {
It is quite a strange error because d3
does exist, though contextMenu
is undefined for d3. I fixed it by simply changing d3.contextMenu = function (menu, openCallback) {...}
to var contextMenu = function (menu, openCallback) {..}
and then accordingly calling .on('contextmenu', contextMenu(menu));
on my node.enter()
.
Hi fr0z3nfyr,
Thanks for the report. Are you including the d3-context-menu.js after d3.js? I tried out the example in the examples folder and I didn't get an error. Ex:
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<script src="../js/d3-context-menu.js"></script>
If you are, which exact version of d3 are you using?
Thanks for this awesome plugin and a super fast response.
Interestingly enough, I'm unable to reproduce the error too... FYI - I always had D3.js included before d3-context-menu.js. You can close the issue for now, I will reopen with steps to reproduce if I encounter this again. I'm using http://d3js.org/d3.v3.min.js
By the way, can you include examples to add/edit/delete nodes to already initialized D3 in real-time using this context menu? I mean, the exact functions that can do these actions to include in "action". For example, I'm trying to extend http://bl.ocks.org/mbostock/4339083 to add/edit/delete nodes after the tree is populated. For reference I'm using http://bl.ocks.org/mbostock/1095795 to achieve this but I'm unable to do it. :(
Sounds good, I'll close this issue then.
I put together a quick example of how to delete a node using the tree code you gave:
http://plnkr.co/edit/bDBe0xGX1mCLzqYGOqOS?p=info
Adding and editing should be pretty similar. Hope this helps.