整个应用程序中闪亮的覆盖滚动条中的div

时间:2019-06-16 19:15:33

标签: r shiny

我正在尝试使用一个程序包,该程序包允许用户以闪亮(esquiss)的形式对其数据进行图形处理。工作正常。但是,包装中发光模块的用户界面需要固定高度的容器。因此,我将对模块的调用放置在由按钮调用的tag $ div(在模式内)中。

问题是,对此模块的此调用似乎摆脱了该应用程序主页的所有滚动条(因此,我无法滚动到主页底部(这是一页应用程序))。 如何限制模块的html以防止其覆盖应用程序的其余部分?所调用模块的代码为here

我的可复制示例如下:

ui.R

server {
  listen  80;
  root /var/www/html;
  server_name _;
  index index.php index.html index.htm;

  # All non-API routes should be handled by the frontend.
  # Use a regular expression to identify all requests
  # that do NOT begin with "/api".
  location ~ "^(?!/api).*$" {
    root /var/www/frontend/public;
    try_files $uri $uri/ /index.html =404;
  }

  # API routes should be handled by the backend (Laravel).
  # (Since regex-based location blocks are matched first,
  # this will be a fallback to the above location block).
  location / {
    root /var/www/backend/public;
    try_files $uri $uri/ /index.php?$query_string;

    location ~ \.php$ {
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param SCRIPT_NAME $fastcgi_script_name;
      fastcgi_index index.php;
      include fastcgi_params;
    }

  }

}

server.R

library(shiny)
library(esquisse)
library(shinyBS)

ui <- fluidPage(
  dashboardPage(
    dashboardHeader(title = ''),
    dashboardSidebar(
      sidebarMenu(
        menuItem("Dashboard")
      )),

  dashboardBody(   
      actionButton(inputId = "esquissGraphs",label = "esquissGraphs"),
      DT::dataTableOutput("mytable"),
      bsModal("modalExample", "Data Table", "esquissGraphs", size = "large",

  tags$h1("Use esquisse as a Shiny module"),
  radioButtons(
    inputId = "data",
    label = "Data to use:",
    choices = c("Mydftbbinnit", "mtcars"),
    inline = TRUE
  ),
  tags$div(
    style = "height: 700px;", # needs to be in fixed height container
    esquisserUI(
      id = "esquisse",
      header = FALSE, # dont display gadget title
      choose_data = FALSE # dont display button to change data
    )
  )
    )
)
)
)

1 个答案:

答案 0 :(得分:6)

您需要添加

tags$style("html, body {overflow: visible !important;")

在用户界面中强制滚动条显示。

来源:https://github.com/dreamRs/esquisse/blob/master/R/esquisserUI.R

完整示例给出:

library(shiny)
library(shinydashboard)
library(esquisse)
library(shinyBS)
library(shiny)
library(esquisse)
library(shinyBS)

ui <- fluidPage(
  dashboardPage(
    dashboardHeader(title = ""),
    dashboardSidebar(
      sidebarMenu(
        menuItem("Dashboard")
      )
    ),

    dashboardBody(
      tags$style("html, body {overflow: visible !important;"),
      actionButton(inputId = "esquissGraphs", label = "esquissGraphs"),
      DT::dataTableOutput("mytable"),
      bsModal("modalExample", "Data Table", "esquissGraphs",
        size = "large",

        tags$h1("Use esquisse as a Shiny module"),
        radioButtons(
          inputId = "data",
          label = "Data to use:",
          choices = c("Mydftbbinnit", "mtcars"),
          inline = TRUE
        ),
        tags$div(
          style = "height: 700px;", # needs to be in fixed height container
          esquisserUI(
            id = "esquisse",
            header = FALSE, # dont display gadget title
            choose_data = FALSE # dont display button to change data
          )
        )
      )
    )
  )
)

RV <- reactiveValues(data = data.frame())
RV2 <- reactiveValues(data = data.frame())

server <- function(input, output, session) {
  n <- c("1", "434", "101")
  t <- c("Bugs", "Mugs", "Thugs")
  RV$data <- data.frame(n, t, stringsAsFactors = FALSE)

  o <- c("1", "434", "101")
  p <- c("Bugs", "Mugs", "Thugs")
  RV2$data <- data.frame(o, p, stringsAsFactors = FALSE)

  output$mytable <- DT::renderDataTable({
    mtcars
  })


  data_r <- reactiveValues(data = data.frame())
  observeEvent(input$data, {
    if (input$data == "Mydftbbinnit") {
      data_r$data <- RV$data
      data_r$name <- "Mydftbbinnit"
    } else {
      data_r$data <- RV2$data
      data_r$name <- "The rest"
    }
  })
  callModule(module = esquisserServer, id = "esquisse", data = data_r)
}
shinyApp(ui, server)