Skip to content

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

@zeehio

Description

@zeehio

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions