-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadd_click.Rd
76 lines (65 loc) · 1.71 KB
/
add_click.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d3_map.R
\name{add_click}
\alias{add_click}
\title{Retrieve click in Shiny}
\usage{
add_click(map, inputId, layerId = NULL, action = "click")
}
\arguments{
\item{map}{A \code{r2d3map} \code{htmlwidget} object.}
\item{inputId}{The \code{input} slot that will be used to access the value.}
\item{layerId}{Name of a variable present in data to filter results returned,
if \code{NULL} (default) all columns are returned.}
\item{action}{What triggers input value server-side, \code{click} or \code{dblclick}.}
}
\description{
Retrieve click in Shiny
}
\examples{
\dontrun{
library( r2d3maps )
library( r2d3 )
library( rnaturalearth )
library( shiny )
france <- ne_states(country = "france", returnclass = "sf")
france <- france[france$type_en \%in\% "Metropolitan department", ]
if (interactive()) {
ui <- fluidPage(
fluidRow(
column(
offset = 2, width = 8,
tags$h2("r2d3maps Shiny example"),
fluidRow(
column(
width = 6,
d3Output(outputId = "map")
),
column(
width = 6,
verbatimTextOutput(outputId = "res_click")
)
)
)
)
)
server <- function(input, output, session) {
output$map <- renderD3({
d3_map(shape = france) \%>\%
add_tooltip() \%>\%
add_click(
inputId = "myclick",
layerId = "name", # return only name,
# NULL to get all data
action = "dblclick" # on double click,
# use "click" for simple click
)
})
output$res_click <- renderPrint({
str(input$myclick, max.level = 2)
})
}
shinyApp(ui, server)
}
}
}