4

I've created a pop-up with the popify function from the shinyBS package in Shiny. I want to have a pop-up on the bottom of my filter that is as wide as my filter itself. I can't find anything in the documentation about this.

screenshot:Screenshot of the pop-up

Example code:

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

    }
)
pnuts
  • 58,317
  • 11
  • 87
  • 139
Tim_Utrecht
  • 1,459
  • 6
  • 24
  • 44
  • Should be doable using the template option: http://getbootstrap.com/javascript/#tooltips-options, but I find that it doesn't work with the options in `popify` so perhaps it's worth filing an issue on github. – Carl Dec 01 '16 at 16:47

1 Answers1

6

You could try adding some CSS to do this.

In your sidebar panel you could add:

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

If this is not big enough, you can add options=list(container="body") in your popify to make body the holder which allows for the popup to be as large as the page.

There is more info here, I adapted that answer to R.

Community
  • 1
  • 1
NicE
  • 21,165
  • 3
  • 51
  • 68