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

Bug: Plot with geom_line(group=) shows wrong tooltip (with fix) #774

Closed
zeehio opened this issue Oct 28, 2016 · 0 comments
Closed

Bug: Plot with geom_line(group=) shows wrong tooltip (with fix) #774

zeehio opened this issue Oct 28, 2016 · 0 comments

Comments

@zeehio
Copy link
Contributor

@zeehio zeehio commented Oct 28, 2016

The group aesthetic in geom_line is not properly set in the tooltip rendering mismatched "id: Sample2" tooltips on Sample1 data points and viceversa.

  # Tooltips with y == 10 should belong to Sample2 in this example
  mydata <- data.frame(id = paste0("Sample", rep(1:2, times = 4)),
                       x = rep(1:4, each = 2),
                       y = rep(c(1, 10), times = 4),
                       stringsAsFactors = FALSE)
  #        id x  y
  #1 Sample1 1  1
  #2 Sample2 1 10
  #3 Sample1 2  1
  #4 Sample2 2 10
  #5 Sample1 3  1
  #6 Sample2 3 10
  #7 Sample1 4  1
  #8 Sample2 4 10
  gplt <- ggplot(mydata) + geom_line(aes(x=x, y = y, group = id))
  pltly <- plotly::ggplotly(gplt)
  pltly
  y_equal_ten <- grepl("y: 10", pltly$x$data[[1]]$text)
  sample_2 <- grepl("id: Sample2", pltly$x$data[[1]]$text)
  expect_that(all(y_equal_ten == sample_2))

The tooltip in the image should show "id: Sample2"

image

Checked against current master:

plotly        4.5.5.9000 2016-10-28 Github (ropensci/plotly@32020c2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant