Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select :last-child in d3.js?

Tags:

select

d3.js

I need to manipulate the text elements of the first and last tick of an axis to bring them more towards the center.

I am trying to select them, one at the time, with something like svg.select('.tick:last-child text') but it doesn't work. I'd then apply .transform('translate(4,0)')...

Am I doing something wrong? How can I achieve this?

like image 815
mettjus Avatar asked Aug 20 '14 12:08

mettjus


Video Answer


1 Answers

Here's the cleanest method I've found:

g.selectAll(".tick:first-of-type text").remove();
g.selectAll(".tick:last-of-type text").remove();
like image 154
emilyinamillion Avatar answered Oct 13 '22 02:10

emilyinamillion