You can select them with d3 and then bind a function to them with .on('click', function)
For your code, it looks something like this:
d3.select('#xaxis') .selectAll('.tick.major') .on('click',clickMe) function clickMe(){alert("I've been clicked!")}
Note that this will select the entire tick, and not just the text, since .tick.major is a group class that contains both the label label (text) and the tick itself (SVG line).
You can also use d as an argument to a function that you call on your ticks. If you do this, d will contain the check mark. For example, the following message will send a warning containing each checkmark value:
d3.select('#xaxis') .selectAll('.tick.major') .on('click',clickMe) function clickMe(d){alert(d)}
Note that you can call .major instead of .tick.major if only the main ticks have class major .
ckersch
source share