如何打开 bsmodal shiny R

How to open a bsmodal shiny R

单击按钮是创建 bsmodal 的唯一方法 window?

是否可以,例如,点击高图栏并打开 bsmodal window?

提前致谢

您可以通过编程方式完成 -

$("#modal_id").modal('show');

在 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');
                         }")
              )
            )
          )
        )
    })


})