我正在尝试使用自动滚动条来渲染文本输出,当文本变得太宽或太长时会激活该滚动条。目前,我x-axis在 UI 的 Textoutput 中实现了 with container=pre 上的滚动条作为参数。
我想要的是文本输出中的输出将自身限制为 4 或 5 行,然后有一个滚动条以查看剩余的行。
我查看了所有可以找到的关于该主题的帖子(这就是我实现 container=pre 的原因),但我找不到解决 y 轴滚动条的方法。我知道这与标签设置中的溢出 y: "auto" 有关,但我无法解决,也许我放错了。谢谢你。这是一个例子:
# Shiny example
library(shinydashboard)
library(shiny)
library(stringi)
library(shinyWidgets)
# Data
# Some random letters
names<- stringi::stri_rand_strings(100,20)
# Some random numbers
numbers<- runif(100,0,100000)
# a df
df<- as.data.frame(cbind(names, numbers))
shinyApp(
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
absolutePanel(id="panel", fixed = FALSE,
draggable = F, top = 80, left = "auto", right = 60, bottom = "auto",
width = 290, height = 370,
box( title = "Box example",
status = "warning", width = 230, solidHeader = T,
pickerInput(
inputId = "select_nb_names",
choices = names,
multiple = TRUE,
selected = NULL,
width = 190,inline = FALSE),
# the textoutput that only has an x-axis scrollbar
textOutput("TextThatIWantToHaveAScroll",container = pre ))))),
server <- function(input, output, session) {
output$TextThatIWantToHaveAScroll<- renderText(
paste0( input$select_nb_names," : ",df$numbers[df$names%in%input$select_nb_names],"\n"))
}
# Run the application
)