在shinydashboard中的tabPanel内添加图形标题

问题描述 投票:0回答:1

如何正确地将图形文本添加到放置在选项卡面板内的图形中? 我已尝试以下操作,但文本在 tabPanel 框中未对齐。

tabBox(
  tabPanel(
    "name",
    fluidRow(
      plotlyOutput("plot", width = "100%", height = "65vh")
    ),
    fluidRow(
      HTML("This is the caption text.")
    )
  )
)

还有其他方法可以正确执行此操作吗?

r shiny shinydashboard
1个回答
0
投票

仅看到一段代码,很难判断您看到了什么或您想要更改什么。然而,从我所做的实验来看,

fluidRow
内的
tabPanel
似乎导致绘图和文本呈现在
tabPanel
之外。删除
fluidRow
的两个实例为我解决了这个问题。

ui <- shinydashboard::dashboardPage(
    shinydashboard::dashboardHeader(title = "title"),
    shinydashboard::dashboardSidebar(),
    shinydashboard::dashboardBody(
        shinydashboard::tabBox(
            title = "title",
            shiny::tabPanel(
                "name",
                plotly::plotlyOutput("plot", width = "100%", height = "65vh"),
                shiny::tags$p("This is the caption text.")
            )
        )
    )
)

server <- function(input, output, session) {
    output$plot <- plotly::renderPlotly({
        plotly::plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
    })
}

shiny::shinyApp(ui, server)

© www.soinside.com 2019 - 2024. All rights reserved.