30
rated 0 times
[
37]
[
7]
/ answers: 1 / hits: 34494
/ 12 Years ago, sun, march 25, 2012, 12:00:00
I'm making a toggle in d3, and trying to avoid global variables.
I can go ahead and select the item as though it was already in the scene:
d3.select('#awesome_line_graph')
and then test to see if I caught anything using
if (d3.select('#awesome_line_graph')[0].every(function(d){return d===null})){
// draw awesome line graph
} else {
d3.select('#awesome_line_graph').remove()
}
but this testing for the zeroth element for maybe more than one null thing seems terrible and hacky. How should I do it instead? Apologies for not knowing much javascript.
More From » d3.js