Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotly graphs have don't correctly track cursor #47

Closed
sebastian-c opened this issue Apr 10, 2017 · 9 comments
Closed

plotly graphs have don't correctly track cursor #47

sebastian-c opened this issue Apr 10, 2017 · 9 comments
Labels
widgets widgets support

Comments

@sebastian-c
Copy link

Consider the following minimal document:

---
output: revealjs::revealjs_presentation #works with html_document
---

```{r plotly, message = FALSE, echo = FALSE}
library(ggplot2)
library(plotly)
g <- ggplot(mpg, aes(x = cty, y = hwy, colour = as.factor(cyl))) +
  geom_point()
ggplotly(g)
```

When using reveal.js, the cursor needs to be placed above and to the left of the points for the tooltip to trigger - rather than on top of them. This doesn't occur when using the default html_document style.

@janfreyberg
Copy link

+1, experienced this as well

@GuiMarthe
Copy link

I am also experiencing this issue. Mine however is a different hovering pattern: to the right and below.

@sebastian-c
Copy link
Author

@GuiMarthe Do you experience the same results with the minimal example?

@GuiMarthe
Copy link

@sebastian-c, with your minimal example, I get the same problem, as you described, mouse having to be placed above and to the left.

@GuiMarthe
Copy link

GuiMarthe commented May 24, 2017

Huum, this is really curious. If you change the sign on the x aestetics -- as in the code below -- getting a negatively sloped sort of data, the points on the upper leftmost have the tooltip rightly detected by the mouse. Is it the same for you guys?

 ---
output: revealjs::revealjs_presentation #works with html_document
---

```{r plotly, message = FALSE, echo = FALSE}
library(ggplot2)
library(plotly)
g <- ggplot(mpg, aes(x = -cty, y = hwy, colour = as.factor(cyl))) +
  geom_point()
ggplotly(g)
``` ```

@sebastian-c
Copy link
Author

I'm not seeing a difference, but is that extra space you have before --- possibly causing it?

@ARthuRuser
Copy link

ARthuRuser commented Jun 7, 2017

I have the same issue. Mine is also in the right and below :

output: revealjs::revealjs_presentation

library(ggplot2)
library(plotly)

g <- ggplot(df, aes(x = civility, y =age, colour = civility)) +
  geom_boxplot() +
  stat_summary(fun.y=mean, geom="point", size=1.5)+
  facet_wrap( ~ Profil)
ggplotly(g)

@cderv
Copy link
Collaborator

cderv commented Sep 17, 2021

It seems like this is a conflict with sizing feature of reveal.js because this seems to solve the problem:

---
title: plotly test
output: 
  revealjs::revealjs_presentation:
    reveal_options:
      minScale: 1.0
      maxScale: 1.0
---

```{r plotly, message = FALSE, echo = FALSE}
library(ggplot2)
library(plotly)
g <- ggplot(mpg, aes(x = cty, y = hwy, colour = as.factor(cyl))) +
  geom_point()
ggplotly(g)
```

(found in plotly/plotly.R#648 (comment))

reveal.js do (a lot ?) about presentation size (https://revealjs.com/presentation-size/) including scaling. Avoiding scaling fixes the issue. So it seems an issue between reveal.js and plotly JS libs.

I got the same issue with a recent reveal.js library using Pandoc directly.

@cderv cderv added the reveal.js upstream lib label Sep 17, 2021
@cderv
Copy link
Collaborator

cderv commented Sep 17, 2021

Related issues I believe:

It seems something has been fixed in plotly last year (plotly/plotly.js#5193) and available in plotly.js since 1.58.0

The R package version of plotly we are using here does not include this version. CRAN plotly is 4.9.4.1 and plotly.js version is 1.57 there.

However, dev version of plotly now include v2+ of plotly.js (plotly/plotly.R#1982)

And with this version, everything is working ok for me now.

---
title: plotly test
output: 
  revealjs::revealjs_presentation: default
---

# Plotly

```{r plotly, message = FALSE, echo = FALSE}
library(ggplot2)
library(plotly)
g <- ggplot(mpg, aes(x = cty, y = hwy, colour = as.factor(cyl))) +
  geom_point()
ggplotly(g)
```

So I'll close this. If you the issue now, please install the dev version of plotly from https://github.com/ropensci/plotly

Using already build binary version

# Enable this universe
options(repos = c(
    ropensci = 'https://ropensci.r-universe.dev',
    CRAN = 'https://cloud.r-project.org'))

# Install some packages
install.packages('plotly')

Or from source

remotes::install_github("ropensci/plotly")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
widgets widgets support
Projects
None yet
Development

No branches or pull requests

6 participants