Bind Data To Axis Ticks D3.js
I would bind data to my axis ticks (generated by ordinal scale) to use it later on mouseover event. I don't want to display it, just bind it: //data what I would like to bind on
Solution 1:
The ticks are already bound to the tick values.
Something like this trick to set some extra data:
d3.selectAll(".tick")[0].forEach(function(tick){
//set the data all ticks
d3.select(tick)[0][0].myData = {foo:"bar"}
});
get data from ticks
d3.selectAll(".tick")[0].forEach(function(tick){
//set the data
console.log(d3.select(tick)[0][0].myData)
});
Post a Comment for "Bind Data To Axis Ticks D3.js"