从ShinyBS增加弹出弹出窗口的宽度 [英] Increase width of popify pop-up from shinyBS

查看:257
本文介绍了从ShinyBS增加弹出弹出窗口的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过Shiny中的shinyBS包中的popify函数创建了一个弹出窗口.我想在过滤器的底部弹出一个与过滤器本身一样宽的弹出窗口.我在文档中找不到关于此的任何内容.

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.

屏幕截图:

示例代码:

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

    }
)

推荐答案

您可以尝试添加一些CSS来实现此目的.

You could try adding some CSS to do this.

在侧边栏面板中,您可以添加:

In your sidebar panel you could add:

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

如果这还不够大,则可以在popify中添加options=list(container="body")以使body成为保持器,以允许弹出窗口与页面一样大.

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.

此处有更多信息,我将该答案改编为R.

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

这篇关于从ShinyBS增加弹出弹出窗口的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆