单击按钮是创建 bsmodal 窗口的唯一方法吗?
例如,是否可以单击一个高图栏并打开一个 bsmodal 窗口?
先感谢您
在 highchars(然后是 highcharter)中,您需要使用 javascript 事件。您可以知道用户何时单击图表中的某些系列。特别是,您可以使用@Skalbhile 使用 jquery 和模态名称给出的答案来使用类似的东西:
highchart() %>%
hc_chart(type = "column") %>%
hc_add_series(data = c(1, 2, 3)) %>%
hc_add_series(data = c(2, 1, 3), name = "other data") %>%
hc_plotOptions(
series = list(
point = list(
events = list(
click = JS("function(){
/* alert(this.series.name + ' ' + this.category); */
/* here you activate trigger the modal */
$('#modalExample').modal('show');
}")
)
)
)
)
所以最后一个演示可以是:
library(shiny)
library(shinyBS)
library(highcharter)
shinyApp(
ui =
fluidPage(
highchartOutput("chart"),
bsModal("modalExample", "Data Table", "tabBut", size = "large",
"Modal Content")
),
server =
function(input, output, session) {
output$chart <- renderHighchart({
highchart() %>%
hc_chart(type = "column") %>%
hc_add_series(data = c(1, 2, 3)) %>%
hc_add_series(data = c(2, 1, 3), name = "other data") %>%
hc_plotOptions(
series = list(
point = list(
events = list(
click = JS("function(){
/* alert(this.series.name + ' ' + this.category); */
/* here you activate trigger the modal */
$('#modalExample').modal('show');
}")
)
)
)
)
})
})
您可以以编程方式执行此操作 -
$("#modal_id").modal('show');