如何打开bsmodal闪亮R.

时间:2016-09-27 08:31:07

标签: javascript r shiny shinybs

单击按钮是创建bsmodal窗口的唯一方法吗?

例如,是否有可能点击高亮度条并打开一个bsmodal窗口?

提前谢谢

2 个答案:

答案 0 :(得分:1)

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


})

答案 1 :(得分:0)

您可以通过编程方式执行此操作 -

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