如何在不破坏页面的情况下将盒子添加到闪亮的应用程序中?

如何解决如何在不破坏页面的情况下将盒子添加到闪亮的应用程序中?

我有一个看起来像这样的闪亮应用程序:

enter image description here

我想在鼠标徽标下方添加一个Box 3和Box 4,但是似乎无法弄清楚如何在不弄乱页面的情况下做到这一点。结果如下:

enter image description here

我正在使用两个fluidRow函数来制作这些盒子,但是我不确定在这样做时如何保持整个页面的完整性。任何帮助表示赞赏!代码如下:

#require packages
 rqrd_Pkg = c('shiny','plotly','plyr','tidyverse','uuid','devtools','gtools','inline','shiny','shinydashboard','shinythemes','shinycssloaders','shinyjs','DT','tictoc','data.table','htmlwidgets')

  require(shiny)
  for(p in rqrd_Pkg){
    if(!require(p,character.only = TRUE)) 
      install.packages(p,Ncpus=8);
      library(p,character.only = TRUE)
}


#include style for header
head.style <- "
         /* old shiny progress indicators */
         .shiny-progress-container {
           position: fixed;
           top: 0px;
           width: 100%;
           z-index: 4000;
     }
     .shiny-progress .progress-text {
       color: #020202;
       background-colort: #FF0000;
       width: 225px;
       left: calc(50% - 125px);
     }
     .progress-text {
       /* Copy the below to vertically center the progress bar text box in the shiny dashboard header */
       /* !important is crucial here otherwise it gets overridden by the dreaded element.style */
       top: 15px !important;
       text-align: center;
     }
     "  

#initiate dashboard attributes and colors
dashboardPage(
    skin = "purple",dashboardHeader(
    title = HTML("Title"),dropdownMenu(type = "notifications",icon = tagList(icon("question-circle"),"Help"),badgeStatus = NULL,headerText = "Links",tags$li(a(icon("external-link"),"XYZ",href = "http://info.com",target = "blank")),"ABC",target = "blank")))
),dashboardSidebar(sidebarMenu(
    menuItem("Target Dashboard",tabName = "dashboard_tab",icon = icon("dashboard"))
)),#################################################################################  
#################################################################################  
#################################################################################  
#################################################################################  

#Configure dashboard body. 
dashboardBody(
    tags$head(
        tags$link(rel = "shortcut icon",href = "favicon.ico"),tags$link(rel = "apple-touch-icon",sizes = "180x180",tags$link(rel = "icon",type = "image/png",sizes = "32x32",href = "favicon-32x32.png"),sizes = "16x16",href = "favicon-16x16.png"),tags$style(head.style)
    ),#h1(paste0("<b>","Gene summary:","</b>")),titlePanel(div(HTML("<b>Gene summary</b>"),align = "left")),tabItems(
        tabItem(tabName = "dashboard_tab",tags$style(HTML("
                  #first {
                      border: 4px double red;
                  }
                  #second {
                      border: 2px dashed blue;
                  }
                ")),fluidRow(
                  valueBoxOutput("valueGeneName"),valueBoxOutput("valueGeneRank"),valueBoxOutput("gtexSpec"),valueBoxOutput("valueHuman"),valueBoxOutput("valueMouse"),valueBoxOutput("valueNHP"),valueBoxOutput("exprCompartment")
                ),h2(paste0("Header 1"),align="left"),#insert human logo
                mainPanel(
                  img(src='man_log.png',height="10%",width="10%",),#create boxes
                fluidRow( 
                    box(
                        title = "Box 1",status = "primary",solidHeader = TRUE,collapsible = TRUE,plotOutput("roc",height = "300px")
                    ),box(
                        title = "Box 2",plotOutput("sensDNAProt",height = "300px")
                    )),mainPanel(
                  img(src='mouse.png',align="left")
                ),h2(paste0("Header 2"),#ADDING THIS CAUSES PROBLEMS!!!
                fluidRow(
                  box(
                    title = "Box 3",height = "300px")
                  ),box(
                    title = "Box 4",height = "300px")
                  )
                )
        )
    )      
)

) `

解决方法

您应该由此获得所需的输出。

### include style for header
head.style <- "
         /* old shiny progress indicators */
         .shiny-progress-container {
           position: fixed;
           top: 0px;
           width: 100%;
           z-index: 4000;
     }
     .shiny-progress .progress-text {
       color: #020202;
       background-colort: #FF0000;
       width: 225px;
       left: calc(50% - 125px);
     }
     .progress-text {
       /* Copy the below to vertically center the progress bar text box in the shiny dashboard header */
       /* !important is crucial here otherwise it gets overridden by the dreaded element.style */
       top: 15px !important;
       text-align: center;
     }
     "

#initiate dashboard attributes and colors
ui <- dashboardPage(
  skin = "purple",dashboardHeader(
    title = HTML("Title"),dropdownMenu(type = "notifications",icon = tagList(icon("question-circle"),"Help"),badgeStatus = NULL,headerText = "Links",tags$li(a(icon("external-link"),"XYZ",href = "http://info.com",target = "blank")),"ABC",target = "blank")))
  ),dashboardSidebar(sidebarMenu(
    menuItem("Target Dashboard",tabName = "dashboard_tab",icon = icon("dashboard"))
  )),#################################################################################
  #################################################################################
  #################################################################################
  #################################################################################

  #Configure dashboard body.
  dashboardBody(
    tags$head(
      tags$link(rel = "shortcut icon",href = "favicon.ico"),tags$link(rel = "apple-touch-icon",sizes = "180x180",tags$link(rel = "icon",type = "image/png",sizes = "32x32",href = "favicon-32x32.png"),sizes = "16x16",href = "favicon-16x16.png"),tags$style(head.style)
    ),#h1(paste0("<b>","Gene summary:","</b>")),titlePanel(div(HTML("<b>Gene summary</b>"),align = "left")),tabItems(
      tabItem(tabName = "dashboard_tab",tags$style(HTML("
                  #first {
                      border: 4px double red;
                  }
                  #second {
                      border: 2px dashed blue;
                  }
                ")),fluidRow(width=12,tabBox(id = "tabset1",height = "2250px",width=12,title = " ",tabPanel(
                    br(),br(),fluidRow(h2(paste0("Header 0"),align="left")),fluidRow(
                      shinydashboard::valueBoxOutput("myvaluebox1",width=4),shinydashboard::valueBoxOutput("myvaluebox2",shinydashboard::valueBoxOutput("myvaluebox3",width=4)
                    ),fluidRow(
                      shinydashboard::valueBoxOutput("myvaluebox4",shinydashboard::valueBoxOutput("myvaluebox5",shinydashboard::valueBoxOutput("myvaluebox6",fluidRow(
                      shinydashboard::infoBoxOutput("myvaluebox7",shinydashboard::valueBoxOutput("myvaluebox8",fluidRow(h2(paste0("Header 1"),#br(),fluidRow(img(src='man_log.png',height="5%",width="5%",fluidRow(
                      column(6,box( height="300px",width=NULL,collapsible = TRUE,title = "Box 1",status = "primary",solidHeader = TRUE,plotOutput("plot1",height = "210px",width="350px")
                             ),style='width: 500px; height: 400px' ),column(6,box(height="300px",width="450px",title = "Box 2",plotOutput("plot2",height = "230px",width="380px")
                             ),style='width: 500px; height: 400px') 
                    ),# br(),img(src='mouse.png',height="10%",width="10%",align="left"),h2(paste0("Header 2"),title = "Box 3",plotOutput("plot3",height = "220px",title = "Box 4",plotOutput("plot4",style='width: 500px; height: 400px')
                    )
                  )  ## end of tabPanel

                  )  ## end of tabBox
                ) 

              )  ## end of tabItem
            
      )
    )
  )


server <- function(input,output,session){
  output$plot1 <- renderPlot(qplot(rnorm(500),fill=I("red"),binwidth=0.2,title="plotgraph1"))
  output$plot2 <- renderPlot(qplot(rnorm(500),fill=I("green"),title="plotgraph2"))
  output$plot3 <- renderPlot(qplot(rnorm(500),fill=I("blue"),title="plotgraph3"))
  output$plot4 <- renderPlot(qplot(rnorm(500),fill=I("orange"),title="plotgraph4"))

  output$myvaluebox1 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2000',subtitle = "blah blah blah1",icon = icon("car"),color = "green"
    )
  })
  output$myvaluebox2 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2001',subtitle = "blah blah blah2",color = "green"
    )
  })
  output$myvaluebox3 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2002',subtitle = "blah blah blah3",color = "green"
    )
  })
  output$myvaluebox4 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2009',subtitle = "blah blah blah4",color = "red"
    )
  })
  output$myvaluebox5 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2010',subtitle = "XYZ1",color = "red"
    )
  })
  output$myvaluebox6 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2011',subtitle = "XYZ2",color = "green"
    )
  })
  output$myvaluebox7 <- shinydashboard::renderInfoBox({
    shinydashboard::infoBox('2020',subtitle = "This is infobox",color = "blue"
    )
  })
  output$myvaluebox8 <- shinydashboard::renderValueBox({
    shinydashboard::valueBox('2021',subtitle = "This is valuebox",color = "blue"
    )
  })
}

shinyApp(ui = ui,server = server)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-