d3.js selectAll

En d3.js el método mas utilizado es tal vez el d3.selectAll()

Su función es sencilla:

Seleccionar elementos de un HTML DOM. Se pueden seleccionar todos los elementos como se haría en una hoja de estilos CSS utilizando selectores.

d3.selectAll('div')
d3.selectAll('#myId')
d3.selectAll('.myClass')
d3.selectAll('div.myClass')
d3.selectAll('div, p, span.mySpan')

All the above would return an array of elements that corresponds to the selector in the arguments of the method.

The selected nodes can be saved into a variable for further processing

a = d3.selectAll('div');
a.style({stroke:"black", "stroke-width:" "2px"});

OR append the next method directly to the selection:

d3.selectAll('div').style({stroke:"black", "stroke-width:" "2px"});

Leave a Reply

Your email address will not be published. Required fields are marked *