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

Tooltip along the length of a segment #1832

Open
julianstanley opened this issue Aug 3, 2020 · 2 comments
Open

Tooltip along the length of a segment #1832

julianstanley opened this issue Aug 3, 2020 · 2 comments

Comments

@julianstanley
Copy link
Contributor

@julianstanley julianstanley commented Aug 3, 2020

I posted about this here in RStudio community in mid-June but didn't get any responses.

Edit Aug17: Stopped using x-unified hovermode, added new video to show the problem more clearly. Also posted another RStudio community post.

Maybe this feature exists, but I'm missing it? I would like to have a tooltip that extends across the entire length of a segment from add_segments().

Example:

library(plotly)
my_data <- data.frame(
  x = c(1, 6), xend = c(5, 10),
  y = c(1, 2), yend = c(1, 2),
  text = c("First", "Second")
)

plot_ly(my_data, x = ~x, xend = ~xend, y = ~y, yend = ~yend, 
        text = ~text, hoverinfo = "text") %>%
  add_segments()

This will put a tooltip at the beginning and the end of the segment, but users will tend to put their cursor near the middle of the segment and expect a tooltip to appear. Even more importantly, users won't get a tooltip if they are zoomed into the middle of a segment.

demonstration of the problem


I've been getting around this problem by using add_lines() instead, but this is terribly inefficient when I'm trying to plot thousands of these segments at once, and it doesn't solve the zooming problem. E.g.

my_data <- data.frame(
  x = c(seq(1, 5, length.out = 10), NA,
         seq(6, 10, length.out = 10)),
  y = c(rep(1, 10), NA, 
         rep(2, 10)),
  text = c(rep("First", 10), NA,
           rep("Second", 10))
)

plot_ly(my_data, x = ~x,y = ~y,
        text = ~text, hoverinfo = "text") %>%
  add_lines() %>%
  layout(hovermode = "x unified")

demonstration of problem work-around

@tdhock
Copy link
Contributor

@tdhock tdhock commented Aug 18, 2020

sometimes it helps if you tag specific people that you may think can help with the issue @cpsievert ??

@cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Aug 18, 2020

As far as I'm aware, plotly/plotly.js doesn't really provide a better option than your add_lines() workaround. If the inefficiently is happening at render time, then you may be able to get a speed up from toWebGL()

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

No branches or pull requests

3 participants