Hi,
I created a map here: link and the custom tooltip
works fine in d3@5 but not showing up in later version.
Can anyone help?
Thanks
Hi,
I created a map here: link and the custom tooltip
works fine in d3@5 but not showing up in later version.
Can anyone help?
Thanks
The mouseenter function should be e,d not just d as that would put the event in d
.on('mouseenter', function(e,d) { // event, data element, 'this' is a svg path for the country
d3.select(this)
.transition()
.delay(100)
.style("fill", colors.day);
tooltip.html(
`<div><strong>DST in ${d.properties.Country}</strong></br>
<u>Observed from</u>: ${d.properties.Introduced}</br>
<u>Location</u>: ${d.properties.Observed}</br>
<u>Next change</u>: ${d.properties.Next_change}</div>`)
return tooltip.style('visibility', 'visible');
})
This other bug is here:
.on('mousemove', function () {
tooltip
.style('top', d3.event.pageY - 10 + 'px')
.style('left', d3.event.pageX + 10 + 'px');
});
That can be fixed with:
.on('mousemove', function (e) {
tooltip
.style('top', e.clientY - 10 + 'px')
.style('left', e.clientX + 10 + 'px');
});
Many thanks for your detailed instruction!