benfred/venn.js

TypeError: Cannot read property 'select' of undefined

Closed this issue · 6 comments

angular-package-1.4.9.min.js:107 
TypeError: Cannot read property 'select' of undefined
    at SVGTextElement.<anonymous> (other-plugins.min.js:91)
    at pt.each (d3-4.10.0.min.js:2)
    at t (other-plugins.min.js:91)
    at pt.call (d3-4.10.0.min.js:2)
    at drawVenn (overlap.js:227)

drawVenn is my function and line 227 is :
d3.select("#venn").datum(sets).call(chart);
and my further research find that the problem lies in .call(chart) part.
the chart can show roughly but the my code following about style and events don't work. What is the problem, thank you so much!

What is the 'sets' data you are passing in?

the same as the example

var sets = [ {sets: ['A'], size: 12}, 
             {sets: ['B'], size: 12},
             {sets: ['A','B'], size: 2}];

Anyway, I wrap the sentence with try/catch, and everything looks fine. But I still don't know where did the Error come from =。=

Whats the code you are using? The example works with that data, so there must be something in how you are calling this

It's because "d3Selection" was not being added properly. I'm building this out on an Angular app with weird injections and had to add the d3 packages indivually, in some cases.

Commenting here just in case somebody else has the same issue. I was getting Cannot read property 'select' of undefined errors from d3Selection in plain ol' HTML, and figured out the problem was that I was importing venn.js before d3.js.

d3.js has to come first so venn.js can access its functions. Or something like that, I think.