2016-11-21 125 views
4

我創建了彈出式窗口,shinyBS軟件包中的popify功能閃亮。我想在我的過濾器底部彈出一個與我的過濾器一樣寬的彈出窗口。我在文檔中找不到任何關於此的內容。 截圖:Screenshot of the pop-up 示例代碼:從shinyBS中增加彈出式彈出窗口的寬度

library(shiny) 
library(shinyBS) 

shinyApp(
    ui = 
    fluidPage(
     sidebarLayout(
     sidebarPanel(
      tags$span(
      popify(
      sliderInput("bins", 
         "Number of bins:", 
         min = 1, 
         max = 50, 
         value = 30), 
      'a very long popup',"1. I want everything behind 1 on one line and everything that starts after<br> 2. I want to see on the second line without wrapping it to the 3rd line.")), 
      actionButton("tabBut", "View Table") 
     ), 

     mainPanel(
      plotOutput("distPlot"), 
      bsModal("modalExample", "Data Table", "tabBut", size = "large", 
        dataTableOutput("distTable")) 
     ) 
    ) 
    ), 
    server = 
    function(input, output, session) { 

     output$distPlot <- renderPlot({ 

     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     # draw the histogram with the specified number of bins 
     hist(x, breaks = bins, col = 'darkgray', border = 'white') 

     }) 

     output$distTable <- renderDataTable({ 

     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     # draw the histogram with the specified number of bins 
     tab <- hist(x, breaks = bins, plot = FALSE) 
     tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) { 
      paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3)) 
     }) 
     tab <- as.data.frame(do.call(cbind, tab)) 
     colnames(tab) <- c("Bins", "Counts", "Density") 
     return(tab[, 1:3]) 

     }, options = list(pageLength=10)) 

    } 
) 
+0

應該用模板選項是可行的:http://getbootstrap.com/javascript/#tooltips-options,但我發現它不」 t與'popify'中的選項一起工作,所以也許值得在github上提出一個問題。 – Carl

回答

4

你可以嘗試加入一些CSS來做到這一點。

在你的側邊欄面板,你可以添加:

tags$style(".popover{ 
      max-width: 100%; 
      }") 

如果這還不夠大,你可以在你popify添加options=list(container="body")使body持有其允許彈出窗口是在頁面一樣大。

有更多信息here,我適應那個答案R.

+0

謝謝!奇蹟般有效 :) –