【问题标题】:To allign text to the rightmost region of shinydashboard :R将文本与闪亮仪表板的最右侧区域对齐:R
【发布时间】:2018-03-15 14:53:40
【问题描述】:

DATA

我想在仪表板最右边的区域添加文本,文本应该覆盖所有右边的空格列。

    dashboardPage(skin="yellow",
  dashboardHeader(title = "Wheat Price dashboard  ),
   dashboardSidebar(
      sidebarMenu( 
  menuItem("Punjab-khanna", tabName = "dashboard", icon = icon("area-chart"))
       )
       ),
   dashboardBody(
         tabItems(
       tabItem(tabName = "dashboard",
          fluidPage(
            titlePanel("Wheat DARA"),
             mainPanel(fluidRow(
              box( side="right",
                           tabPanel("Price chart", dygraphOutput("plot1")

              )
            ),box(side = "right",height="250px",includeMarkdown("read.md")))

          ) )
          )
  ))

)

SERVER.R

   d1<-read_excel("data/Wheat data forecasted.xlsx",sheet = 1,col_names =   
       TRUE)
   #stock
   d2 <-subset(d1, select = c(1,2,3,4,5))
  #last
  d1 <-subset(d1, select = c(1,5,6,7))
  d1$`Date GMT` <- as.POSIXct(d1$`Date GMT`, format = "%Y-%m-%d", tz="GMT")
  ts1 <- irts(time=d1$`Date GMT`,value=as.matrix(d1[,2:4]))
  #stock
  d2$`Date GMT` <- as.POSIXct(d2$`Date GMT`, format = "%Y-%m-%d", tz="GMT")
   ts2 <- irts(time=d2$`Date GMT`,value=as.matrix(d2[,2:5]))

   shinyServer(function(input, output) {
   output$plot1 <- renderDygraph({   
  dygraph(ts1) %>% 
  dyRangeSelector() %>% 
  dyLegend(show = "always", hideOnMouseOut = FALSE) %>%
  dyHighlight(highlightCircleSize = 5) %>%
  dyOptions(axisLineColor = "navy", gridLineColor = "grey")
 })


  } ) 

我无法将它安排到右侧。

注意:我写了不同的文本(来自图像),但将文本排列到仪表板最右侧区域的任务是相同的

【问题讨论】:

  • 如果你能分享一个可重现的代码,回答你会很容易!
  • @amrrs 完成,先生,现在您能帮帮我吗?
  • 其实上面的不是可复现的代码。请参考这里。 stackoverflow.com/questions/5963269/…
  • @amrrs 希望你能帮上忙?

标签: r rstudio shiny shinydashboard


【解决方案1】:

我自己添加了一个最小的可重现代码。请检查。您只需使用 fluidrowcolumnwidth 值一起玩。

if(interactive()) {



## app.R ##
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      column(

      column(
        fluidRow(
          box(plotOutput("plot1"))
        ),
        fluidRow(
          box(plotOutput("plot2"))
        ),
        width = 10
      ),

      column(
        h3(
          textOutput('text1')
        ),
        width = 2
      ),
      width = 12
      )

    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)

  output$plot1 <- renderPlot({

    hist(histdata)
  })


  output$plot2 <- renderPlot({

    hist(histdata)
  })

  output$text1 <- renderText({
    "Uniform: These functions provide information about the uniform distribution on the interval from min to max. dunif gives the density, punif gives the distribution function qunif gives the quantile function and runif generates random deviates."
  })



}

shinyApp(ui, server)

}

源代码修改:

请像下面这样修改您的仪表板输入。它也有 plot2,因为你最初的问题有一个。

dashboardBody(
  # Boxes need to be put in a row (or column)
  fluidRow(
    column(

      column(
        fluidRow(
          tabPanel("Price chart", dygraphOutput("plot1")
        ),
        fluidRow(
          plotOutput("plot2")
        ),
        width = 10
      ),

      column(
        h3(
          includeMarkdown("read.md")
        ),
        width = 2
      ),
      width = 12
    )

  )
)

【讨论】:

  • 先生,它看起来很乱,仍然没有得到想要的位置。
  • 你修改了我提到的代码?你能详细说明一下混乱的部分吗?
  • 是的,我做到了,但图形和之间的空间很大。先生,我也尝试了不同的方法,但正确的空间没有被覆盖,空间仍然存在。我正在更新当前代码。
  • 你现在能帮帮我吗?
猜你喜欢
  • 2017-12-23
  • 2018-02-18
  • 1970-01-01
  • 2014-06-30
  • 1970-01-01
  • 1970-01-01
  • 2016-06-05
  • 2016-11-11
  • 2021-06-28
相关资源
最近更新 更多