3

I'm using an rmarkdown .Rmd file to create a revealjs_presentation.

However, when I create a chart using ggplotly, the tooltip no longer lines up with the points when hovering. Here is an example:

---
title: ""
output: 
  revealjs::revealjs_presentation:
    center: true
---


```{r setup, include=FALSE}
library(tidyverse)
library(plotly)
```

Plotly
------------------------------

```{r, echo=F, message=F}
(ggplot(mtcars, aes(wt, mpg)) + geom_point()) %>%
  ggplotly()
```

It doesn't do this with output: html_document. At different zoom levels in the browser, the tooltip gets closer or further away from the point when the hover information appears.

Has anyone run into this?

Tunn
  • 1,506
  • 16
  • 25

2 Answers2

4

I was facing the same issue, here's what I found :

  1. It's quite well documented here, here and here.
  2. Workaraound : put the plot inside of a widgetframe::frameWidget(), see here.
  3. Solution : add the following reveal_options (see here) :
reveal_options:
  minScale: 1.0
  maxScale: 1.0

Now everything seems to be working as expected.

Trusky
  • 483
  • 2
  • 13
1

If this is helpful for anyone, this seems to be entirely related to zoom.

At 140% zoom in my browser all of the htmlwidgets that I'm using (highcharter, plotly) line up correctly between the tooltip and the point I'm hovering over.

Maybe depends on screen size and browser too.

Tunn
  • 1,506
  • 16
  • 25