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

Fix wrong tooltip when ggplotly with geom_line(group=) #773

Merged
merged 3 commits into from Nov 1, 2016

Conversation

Projects
None yet
2 participants
@zeehio
Copy link
Contributor

zeehio commented Oct 28, 2016

This test case shows a plot with two lines where the tooltip does not contain the right text on all the points

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)

@zeehio zeehio changed the title Plot with geom_line(group=) shows wrong tooltip Test case showing bug: Plot with geom_line(group=) shows wrong tooltip Oct 28, 2016

@zeehio

This comment has been minimized.

Copy link
Contributor Author

zeehio commented Oct 28, 2016

Closes #774

image

@zeehio zeehio changed the title Test case showing bug: Plot with geom_line(group=) shows wrong tooltip Fix wrong tooltip when ggplotly with geom_line(group=) Oct 28, 2016

zeehio added some commits Oct 28, 2016

test case for buggy geom_line(group=...) tooltip
This test case shows a plot with two lines where the tooltip does not contain the right text on all the points.
The `group` aesthetic in `geom_line` is not properly set in the tooltip rendering mismatched "id: Sample2" tooltips on Sample1 data points and viceversa.

@zeehio zeehio force-pushed the zeehio:fix_tooltip_on_geom_line_group branch from 4b949f8 to 4d3ac60 Oct 31, 2016

@cpsievert

This comment has been minimized.

Copy link
Contributor

cpsievert commented Nov 1, 2016

Great work, thanks!

@cpsievert cpsievert merged commit 2e3f20d into ropensci:master Nov 1, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@zeehio zeehio deleted the zeehio:fix_tooltip_on_geom_line_group branch Nov 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment