I have a clarification question regarding the .on('mouseover') method in d3. The code I have is:
svg.selectAll('text')
.data(dataset)
.enter()
.append('text')
.attr('x',function(d){
return xScale(d[0]);
})
.attr('y',function(d){
return yScale(d[1]);
})
.text(function(d) {
return d[0] + ',' + d[1];
})
.style('visibility','hidden');
.on('mouseover',...)
What kind of function shall I put instead of the ...
in the code to make the style of a single text tag become visible
when hovering with the mouse?
I have checked different solutions but none of them work. (One is: d3 - trigger mouseover event)
Moreover, I was wondering if what I thought about d3 workflow is corrected (I started to learn d3 only yesterday so be patient..):
.selectAll
iterates through what it is given to it inside the .data
argument.
At each iteration a text object(?) is created at the given position and with a given label. What does the .style
refer to? The single object .selectAll
iterates through? So are there multiple .style
for each object iterated? And how to modify that object? Would d3.select(this).style('visibility','visible')
be enough? (Looking at the link above it does not seem so...)