Ticks only at the start and end of an axis

d3.js, javascript, visualization

Solution

The minimum and maximum value (the domain extent) are part of the domain path, so one option is to set axis.ticks to zero to hide the ticks and only show the domain path. For example:

- http://bl.ocks.org/2996766

However, the domain path doesn't include text labels for the values. So, for that, you could instead set axis.tickValues to the minimum and maximum value for explicit ticks:

- http://bl.ocks.org/2996785

Problem

I'm new to using D3. I'd like to only put ticks on an axis at the start and the end. How do I do this? Thanks

Original source