According to type of chart, different values are retrieved:
bar and column: retrieve category (x-axis).
pie and donut: retrieve label.
time-series: retrieve x-axis value, you have to display markers
with size > 0 and set tooltip's options intersect = TRUE
and shared = FALSE
.
scatter: retrieve XY coordinates.
set_input_click(
ax,
inputId,
multiple = FALSE,
effect_type = c("darken", "lighten", "none"),
effect_value = 0.35,
session = shiny::getDefaultReactiveDomain()
)
An apexcharts
htmlwidget
object.
The id that will be used server-side for retrieving click.
Allow multiple selection: TRUE
or FALSE
(default).
Type of effect for selected element, default is to use lightly darken color.
A larger value intensifies the select effect, accept value between 0 and 1.
The Shiny session.
An apexcharts
htmlwidget
object.
If x-axis is of type datetime, value retrieved is of class POSIXct
.
library(apexcharter)
# Not in Shiny but you can still click on bars
data.frame(
month = month.abb,
value = sample(1:100, 12)
) %>%
apex(aes(month, value)) %>%
set_input_click("month_click", multiple = TRUE)
# Interactive examples:
if (interactive()) {
run_demo_input("click")
}