Skip to content

Commit 900f7c8

Browse files
committed
Merge branch 'feature/transmit' of https://github.com/ropensci/plotly into feature/transmit
2 parents e5746ae + ba4b936 commit 900f7c8

File tree

1 file changed

+33
-0
lines changed
  • inst/examples/map_click

1 file changed

+33
-0
lines changed

inst/examples/map_click/app.R

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# git checkout feature/transmit
2+
# R CMD install ./
3+
4+
library(shiny)
5+
library(plotly)
6+
7+
ui <- fluidPage(
8+
plotlyOutput("plot"),
9+
verbatimTextOutput("click")
10+
)
11+
12+
server <- function(input, output, session) {
13+
14+
output$plot <- renderPlotly({
15+
# specify some map projection/options
16+
g <- list(
17+
scope = 'usa',
18+
projection = list(type = 'albers usa'),
19+
lakecolor = toRGB('white')
20+
)
21+
plot_ly(z = state.area, text = state.name, locations = state.abb,
22+
type = 'choropleth', locationmode = 'USA-states') %>%
23+
layout(geo = g)
24+
})
25+
26+
output$click <- renderPrint({
27+
d <- event_data("plotly_click")
28+
if (is.null(d)) "Click on a state to view event data" else d
29+
})
30+
31+
}
32+
33+
shinyApp(ui, server)

0 commit comments

Comments
 (0)