Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there to check if a js variable is a d3 selection?

I some variables coming into my function.

If the first of these is a d3 selection I want to use it, otherwise I want to use a default selection.

How do I check if a variable is a d3 selection or not?

like image 634
George Mauer Avatar asked Jan 04 '13 22:01

George Mauer


1 Answers

To check if variable sel is a d3.selection:

var isselection = sel instanceof d3.selection;
like image 136
nautat Avatar answered Nov 14 '22 22:11

nautat