Skip to content

Improvements to algorithm for attaching key attribute for shiny's event data, fixes #1610 #1611

New issue

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

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

Already on GitHub? # to your account

Merged
merged 4 commits into from
Sep 3, 2019

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Sep 3, 2019

Fixes #1610. Note also that when pt.pointNumbers is populated, the key attribute is relayed properly

Testing notes

Install remotes::install_github("ropensci/plotly"), then run the app below. As you hover over points, information about the hovered point should appear in the R console.

library(shiny)
library(plotly)

ui <- fluidPage(
  plotlyOutput("distPlotTest")
)

server <- function(input, output) {
  
  output$distPlotTest <- renderPlotly({
    highlight_key(mtcars, ~carb) %>%
      plot_ly(x = ~mtcars$carb, key = ~row.names(mtcars), type = "histogram") %>%
        layout(barmode = "overlay") %>% 
        highlight(on = "plotly_hover", off="plotly_deselect") 
  })
  
  observe({
    print(event_data("plotly_hover"))
  })
  
}

# Run the application
shinyApp(ui = ui, server = server)

…nt data, fixes #1610

* Account for pointNumbers
* Do nothing if we don't recognize the case
@cpsievert cpsievert force-pushed the shiny-event-data-key branch from 2c219fe to 8bc36b9 Compare September 3, 2019 15:47
@cpsievert cpsievert requested a review from schloerke September 3, 2019 16:48
Copy link
Contributor

@schloerke schloerke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpsievert cpsievert merged commit 17466a3 into master Sep 3, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

highlight_key isn't working with shiny - TypeError: pt.pointNumber is undefined
2 participants