Skip to content

Send 'plotly_click' and 'plotly_selected' events to shiny when in shinyMode #416

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

Merged
merged 14 commits into from
Mar 2, 2016
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions inst/examples/map_click/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# git checkout feature/transmit
# R CMD install ./

library(shiny)
library(plotly)

ui <- fluidPage(
plotlyOutput("plot"),
verbatimTextOutput("click")
)

server <- function(input, output, session) {

output$plot <- renderPlotly({
# specify some map projection/options
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
lakecolor = toRGB('white')
)
plot_ly(z = state.area, text = state.name, locations = state.abb,
type = 'choropleth', locationmode = 'USA-states') %>%
layout(geo = g)
})

output$click <- renderPrint({
d <- event_data("plotly_click")
if (is.null(d)) "Click on a state to view event data" else d
})

}

shinyApp(ui, server)