# Plot: Tooltips available?

**URL:** <https://talk.observablehq.com/t/plot-tooltips-available/6583>\
**Category:** Help\
**Created:** [May 20, 2022, 2:19pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583 "2022-05-20T14:19:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![papakpmartin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/papakpmartin/32/5780_2.png) [@papakpmartin](https://talk.observablehq.com/u/papakpmartin)\
**Post date:** [May 20, 2022, 2:19pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583/1 "2022-05-20T14:19:31Z")

</div>

It’s been a while since I tried… I poked around at docs and didn’t see it…

Is there any way to generate “tooltips” when using Plot? What i mean is being able to hover over a point and see a “popup” with additional information.

---

<div class="post-metadata">

**Author:** ![papakpmartin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/papakpmartin/32/5780_2.png) [@papakpmartin](https://talk.observablehq.com/u/papakpmartin)\
**Post date:** [May 20, 2022, 2:27pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583/2 "2022-05-20T14:27:46Z")

</div>

FWIW, I’m trying to do something simple like this:

```auto
    Plot.line(output, {
      x: "timestamp", y: "psi",
      curve: "catmull-rom",
      stroke: "blue",
      marker: "circle",
      title: d => `${d.psi} psi`
    }),

```

---

<div class="post-metadata">

**Author:** ![awiederkehr](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/awiederkehr/32/6536_2.png) [@awiederkehr](https://talk.observablehq.com/u/awiederkehr)\
**Post date:** [May 20, 2022, 2:44pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583/3 "2022-05-20T14:44:08Z")

</div>

Hi!  
\*\* Edited this solution based on the reply below from @mbostock \*\*

- Tooltips should work just like you have, but they’ll appear as the browser-native tooltip (as opposed to a stylized version). Mike lists a few pluses and minuses about browser-native tooltips that you should note if you use them in your notebooks.
- Alternatively, @mkfreeman has [created a nice little import](https://observablehq.com/@mkfreeman/plot-tooltip) that you import into your notebook and go from there with the same syntax.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![papakpmartin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/papakpmartin/32/5780_2.png) [@papakpmartin](https://talk.observablehq.com/u/papakpmartin)\
**Post date:** [May 20, 2022, 2:47pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583/4 "2022-05-20T14:47:36Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [May 20, 2022, 2:49pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583/5 "2022-05-20T14:49:33Z")

</div>

The example you gave should work almost exactly as you’ve written it. However, there are a few things to be aware of with the browser-native tooltips used by the title channel:

- The tooltip only appears exactly over the rendered mark. There’s no “bubble cursor” (or Voronoi) effect to have the tooltip show up near the mark. As such you may want to add some transparent marks with a thick stroke to add a buffer area to show the tooltip.
- The tooltip only appears after a delay. If you move the mouse too quickly, the tooltip will not appear. This is to prevent tooltips from being jumpy and distracting. (This behavior is solely at the discretion of the browser vendors and cannot be changed.)
- The tooltips won’t appear on mobile devices. (This behavior is solely at the discretion of the browser vendors and cannot be changed.)

On the plus side, browser native tooltips have some nice attributes that cannot be achieved with custom tooltips: they can appear over any other content in the browser (they are not limited to the sandboxed iframe in which your notebook code runs); they can appear outside the browser window entirely; and they disappear automatically whenever you click or move the mouse.

Here’s a screenshot and example:

 ![Screen Shot 2022-05-20 at 7.46.48 AM](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/d/dea935c8790ec4336e961ea5bb25e404ce4023bc.png)

```nohighlight
Plot.plot({
  marks: [
    Plot.lineY(aapl, {x: "Date", y: "Close"}),
    Plot.lineY(aapl, {x: "Date", y: "Close", stroke: "transparent", strokeWidth: 20, title: d => `${d.Close}\n${d.Date.toLocaleDateString("en", {timeZone: "UTC"})}`}),
  ]
})

```

> **[Plot tooltips example](https://observablehq.com/d/ff4eb328a54ed5a9)**

---

<div class="post-metadata">

**Author:** ![papakpmartin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/papakpmartin/32/5780_2.png) [@papakpmartin](https://talk.observablehq.com/u/papakpmartin)\
**Post date:** [May 20, 2022, 3:00pm UTC](https://talk.observablehq.com/t/plot-tooltips-available/6583/6 "2022-05-20T15:00:38Z")

</div>

Interesting! I’m sure I was moving to quickly, then. I did just bring in @mkfreeman’s tooltips, which act more like I wa expecting and more like what I was getting in Vega-Lite.

I appreciate the buffer idea, too… thanks!
