# Tooltip not showing in d3 latest version

**URL:** <https://talk.observablehq.com/t/tooltip-not-showing-in-d3-latest-version/5567>\
**Category:** Help\
**Created:** [September 13, 2021, 8:12am UTC](https://talk.observablehq.com/t/tooltip-not-showing-in-d3-latest-version/5567 "2021-09-13T08:12:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cadasa](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cadasa/32/5516_2.png) [@cadasa](https://talk.observablehq.com/u/cadasa)\
**Post date:** [September 13, 2021, 8:12am UTC](https://talk.observablehq.com/t/tooltip-not-showing-in-d3-latest-version/5567/1 "2021-09-13T08:12:41Z")

</div>

Hi,

I created a map here: [link](https://observablehq.com/d/692ed807b56dde0e) and the custom `tooltip` works fine in d3@5 but not showing up in later version.

Can anyone help?

Thanks

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [September 13, 2021, 1:42pm UTC](https://talk.observablehq.com/t/tooltip-not-showing-in-d3-latest-version/5567/2 "2021-09-13T13:42:56Z")

</div>

See [D3 6.0 migration guide / D3 / Observable](https://observablehq.com/@d3/d3v6-migration-guide#events)

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [September 13, 2021, 2:23pm UTC](https://talk.observablehq.com/t/tooltip-not-showing-in-d3-latest-version/5567/3 "2021-09-13T14:23:12Z")

</div>

The mouseenter function should be e,d not just d as that would put the event in d

```auto
    .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:

```auto
   .on('mousemove', function () {
          tooltip
            .style('top', d3.event.pageY - 10 + 'px')
           .style('left', d3.event.pageX + 10 + 'px');
    });

```

![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/1/17e71a3cf49f53dbe230071ed903ecb262d7e6e1.png)

That can be fixed with:

```auto
   .on('mousemove', function (e) {
          tooltip
            .style('top', e.clientY - 10 + 'px')
           .style('left', e.clientX + 10 + 'px');
    });

```

---

<div class="post-metadata">

**Author:** ![cadasa](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cadasa/32/5516_2.png) [@cadasa](https://talk.observablehq.com/u/cadasa)\
**Post date:** [September 13, 2021, 2:35pm UTC](https://talk.observablehq.com/t/tooltip-not-showing-in-d3-latest-version/5567/4 "2021-09-13T14:35:42Z")

</div>

Many thanks for your detailed instruction!
