当我在 Shiny 应用程序中添加新的 fluidRow 时,R 闪亮的仪表图会消失吗?

戴维特

我制作了一个闪亮的应用程序,当我添加一个新的fluidRow. 这是一个小例子

library(shinydashboard)
header <- dashboardHeader(title = 'Name')
sidebar <- dashboardSidebar()
body <- dashboardBody(
fluidRow(
    box(widht = 12, title = 'Group', textOutput('group_name'))
),
fluidRow(
    box(width = 4, title = 'Frim', textOutput('firm_name')),
    box(width = 4, title = 'INN', textOutput('firm_inn')),
    box(width = 4, title = 'Branch', textOutput('firm_branch'))
),
fluidRow(
    box(status = 'primary', height = '250px', width = 4, title = 'name1', plotlyOutput('firm_limits_utiliz'), solidHeader = TRUE),
    box(status = 'primary', height = '250px', width = 4, title = 'name2', plotlyOutput('firm_limits_remains'), solidHeader = TRUE),
    box(status = 'warning', height = '250px', width = 4, title = 'name3',  tableOutput('group_limits') , solidHeader = TRUE,
        style = "overflow-x: scroll;")
) )
ui <- dashboardPage(body = body, header = header, sidebar = sidebar, skin = 'blue')
server <- function(input, output) {

output$group_name <- renderText({'Shell'})

output$firm_name <- renderText({'Shell ltd'})

output$firm_inn <- renderText({'770565479'})

output$firm_branch <- renderText({'Oil and Gas'})

output$firm_limits_utiliz <- renderPlotly({
    fig <- plot_ly(
        domain = list(x = c(0, 1), y = c(0, 1)),
        value = 270,
        # title = list(text = "Speed"),
        type = "indicator",
        mode = "gauge+number",
        height = 197, width = 393) 
    fig <- fig %>%
        layout(margin = list(l=20,r=30))
    
    fig
})


output$group_limit_utiliz <- renderPlotly({
    fig <- plot_ly(
        domain = list(x = c(0, 1), y = c(0, 1)),
        value = 270,
        # title = list(text = "Speed"),
        type = "indicator",
        mode = "gauge+number",
        height = 197, width = 393) 
    fig <- fig %>%
        layout(margin = list(l=20,r=30))
    
    fig
})
}

# Run the application 
shinyApp(ui = ui, server = server)

如果我运行此代码,一切顺利。无花果图形显示在仪表板上。但!

当我添加一个新fluidRow的无花果图消失。例如,让我为您提供body一部分代码:

 body <- dashboardBody(
fluidRow(
    box(widht = 12, title = 'Group', textOutput('group_name'))
),
fluidRow(
    box(width = 4, title = 'Firm', textOutput('firm_name')),
    box(width = 4, title = 'INN', textOutput('firm_inn')),
    box(width = 4, title = 'Branch', textOutput('firm_branch'))
),
fluidRow(
    box(status = 'primary', height = '250px', width = 4, title = 'name1', plotlyOutput('firm_limits_utiliz'), solidHeader = TRUE),
    box(status = 'primary', height = '250px', width = 4, title = 'name2', plotlyOutput('firm_limits_remains'), solidHeader = TRUE),
    box(status = 'warning', height = '250px', width = 4, title = 'name3',  tableOutput('group_limits') , solidHeader = TRUE,
        style = "overflow-x: scroll;")
),
# Here i a new fluidRow
fluidRow(
        box(status = 'primary', height = '250px', width = 4, title = 'name6', plotlyOutput('group_limit_utiliz'), solidHeader = TRUE),
        box(status = 'primary', height = '250px', width = 4, title = 'name4', plotlyOutput('gtoup_limit_remains'), solidHeader = TRUE),
        box(status = 'warning', height = '250px', width = 4, title = 'name5',  tableOutput('group_limits') , solidHeader = TRUE,
            style = "overflow-x: scroll;")
        
    )
 )

如您所见,有一个新的fluidRow. 在这种情况下,fig带有firm_limits_utilizid 的图消失了。怎么了?

薇薇

如果您使用另一个变量名称创建输出副本,它会起作用:

#new fluidRow

  fluidRow(
    box(status = 'primary', height = '250px', width = 4, title = 'name6', plotlyOutput('group_limit_utiliz2'), solidHeader = TRUE),
    box(status = 'primary', height = '250px', width = 4, title = 'name4', plotlyOutput('gtoup_limit_remains2'), solidHeader = TRUE),
    box(status = 'warning', height = '250px', width = 4, title = 'name5',  tableOutput('group_limits2') , solidHeader = TRUE,
        style = "overflow-x: scroll;")

  )

输出:

  output$group_limit_utiliz2 <- renderPlotly({
    fig2 <- plot_ly(
      domain = list(x = c(0, 1), y = c(0, 1)),
      value = 270,
      # title = list(text = "Speed"),
      type = "indicator",
      mode = "gauge+number",
      height = 197, width = 393) 
    fig2 <- fig2 %>%
      layout(margin = list(l=20,r=30))
    
    fig2
  })

请注意,我为所有变量名称添加了2,但其他所有内容都相同。

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

当我尝试在CRUD Spring启动应用程序中添加新客户端时,捕获到NullPointerException

如何在我的R Shiny应用程序中添加链接以在新窗口中打开pdf文件?

闪亮的R:FluidRow中不需要的空白

当我在应用程序中添加Java模块时,Android Studio会出错

当我执行大循环时,应用程序会花费过多的RAM

当我尝试引入动态selectInput字段时,Shiny R中的gvisBubbleChart图停止显示

我可以在R Tools for Visual Studio中运行Shiny应用程序吗

为什么当我碰到鼠标滚轮时WPF应用程序会崩溃?

当我在ggplot中选择特定坐标时,闪亮的应用程序崩溃

我可以使用Shiny R扩展完整的Web应用程序吗?

当我使用上传的数据在我的r Shiny应用程序中绘制ggplot2条形图时,为什么只得到一条实线?

当我在transitionTo()中添加queryParam时,余烬应用程序会完全重新加载

嵌套的FluidRow布局在Shiny中

在R Shiny中的fluidRow()中对齐标签和radioButton

当我在Android Studio中的异步线程中调用Toast.makeText时,会导致应用程序崩溃吗?

我可以通过编程方式控制绘图缩放功能而不必在R Shiny应用程序中重新绘图吗?

当我添加VisualState时,我的TextBox消失了

当我尝试使用控制台应用程序添加新的虚拟目录时,访问被拒绝错误

当我执行ProgressDialog.show()方法时,AsyncTask会杀死我的应用程序

当我有更多内容时,发布我所有图像的速度会减慢我的应用程序的速度吗?

当我单击链接时,为什么我的react / webpack应用程序会刷新?

Android:当我在应用程序中打开相机模型时,需要一个APK(在发布模式下)。应用会崩溃吗?

使用 Fluidrow 在 Shiny 中为辅助情节提供标题

我正在尝试向 Shiny R 应用程序中的图表添加图例

当我尝试通过我的应用程序发送短信时,消息屏幕会自动取消

我可以运行 Github Enterprise 存储库上的 R Shiny 应用程序吗?

当我点击运行应用程序时,android 服务消失了,当应用程序崩溃时也是如此

当我在 Flutter 应用程序中刷新标签栏视图时,其他标签栏视图也会刷新

为什么当我点击项目时我的应用程序会强制关闭?