如何打开一个bsmodal闪亮的R



点击按钮是创建bmodal窗口的唯一方法吗?

是否有可能,例如,点击高图条并打开bmodal窗口?

提前感谢

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

最后一个demo可以是:

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');

相关内容

  • 没有找到相关文章

最新更新