I’ve tried
d3.select(".cell:first")
d3.selectAll(".cell").filter(":first")
d3.selectAll(".cell").select(":first")
but neither work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
d3.select(".cell")already selects the first matched element:Source: https://github.com/mbostock/d3/wiki/Selections#wiki-d3_select
“How would I get the last item?“
D3 appears to return the results of
d3.selectAll()in a collection, positioned in an array. For instance, requesting all paragraphs on the d3 homepage results in:So if we wanted to get the last paragraph from that collection, we could do the following:
Or more concisely:
“What about :last-child?”
The
:last-childselector isn’t the same as getting the last element on a page. This selector will give you the elements that are the last child of their parent container. Consider the following markup:In this example, running
d3.select("p:last-child")won’t return any of your paragraphs. Evend3.selectAll("p:last-child")won’t. Neither of those containers have a last child that is a paragraph (they are<div>elements:<div>English</div>and<div>Portuguese</div>).