Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在有光泽的演示文稿中减少renderDataTable中的字体大小_R_Shiny - Fatal编程技术网

在有光泽的演示文稿中减少renderDataTable中的字体大小

在有光泽的演示文稿中减少renderDataTable中的字体大小,r,shiny,R,Shiny,我使用一个闪亮的演示文稿来显示两个表。 这是我的密码: tabsetPanel( tabPanel('iris', renderDataTable(iris,options = list(lengthMenu = c(5, 10), pageLength = 5, scrollX = TRUE), escape = FALSE)), tabPanel('mtcars', renderDataTable(mtcars, options =

我使用一个闪亮的演示文稿来显示两个表。 这是我的密码:

tabsetPanel(
  tabPanel('iris',
           renderDataTable(iris,options = 
list(lengthMenu = c(5, 10), pageLength = 5, scrollX = TRUE), escape = 
FALSE)), 
  tabPanel('mtcars',
           renderDataTable(mtcars, options = list(lengthMenu 
= c(5, 10), pageLength = 5, scrollX = TRUE), escape = FALSE))
)
我想缩小桌子的尺寸。我尝试通过以下方式添加div:

div(renderDataTable(mtcars, options = list(lengthMenu 
= c(5, 10), pageLength = 5, scrollX = TRUE), escape = FALSE), style = "font-
size:50% ")
但这是行不通的

我也试过这样做:

mainPanel( 
  tabsetPanel(id='BLMS', 
              tabPanel("iris", fluidRow(div(dataTableOutput(outputId="iris"),  
style = "font-size:50%"))), 
              tabPanel("mtcars", 
fluidRow(div(dataTableOutput(outputId="mtcars"),  style = "font-size:50%")))
              )
  )  

output$iris<- renderDataTable({iris}, options = list(lengthMenu = c(5, 10), 
pageLength = 5, scrollX = TRUE))

output$mtcars<- renderDataTable({mtcars},options = list(lengthMenu = c(5, 
10), pageLength = 5, scrollX = TRUE))
主面板(
选项卡集面板(id='BLMS',
选项卡面板(“iris”,fluidRow(div)(dataTableOutput(outputId=“iris”),
style=“font-size:50%”),
选项卡面板(“mtcars”,
fluidRow(div(dataTableOutput(outputId=“mtcars”),style=“font size:50%”)
)
)  

输出$iris如果要减小表的大小,请将其放入宽度为
的列中。如果您还想减小字体大小,shinyjs::inlineCSS很方便:

library(DT)
library(shinyjs)
shinyApp(shinyUI(
  fluidPage(column(width=6, dataTableOutput("iris")),
        useShinyjs(),
        inlineCSS(list("table" = "font-size: 8px")))
  ),

  shinyServer(function(input, output) {
    output$iris = renderDataTable({
        datatable(iris,options =
                    list(lengthMenu = c(5, 10), pageLength = 5, scrollX = TRUE), escape =
                    FALSE)
    })
  })
)


编辑:如前所述,向包含表的div添加
style
命令效果更好:
fluidPage(style=“font size:75%;width:75%”,dataTableOutput(“iris”))
如果要减小表的大小,请将其放在宽度
width
<12的列中。如果您还想减小字体大小,shinyjs::inlineCSS很方便:

library(DT)
library(shinyjs)
shinyApp(shinyUI(
  fluidPage(column(width=6, dataTableOutput("iris")),
        useShinyjs(),
        inlineCSS(list("table" = "font-size: 8px")))
  ),

  shinyServer(function(input, output) {
    output$iris = renderDataTable({
        datatable(iris,options =
                    list(lengthMenu = c(5, 10), pageLength = 5, scrollX = TRUE), escape =
                    FALSE)
    })
  })
)


编辑:正如所指出的,在包含表的div中添加
style
命令效果更好:
fluidPage(style=“font size:75%;width:75%”,dataTableOutput(“iris”))
font size
只会减小字体大小。您试过了吗?是的,它没有正确显示任何内容。
font size
只会减小字体大小。你试过了吗?是的,它没有正确显示任何内容。