This is a script for a data table that is created in R shiny.I am trying to fit the plot within the box completely by adjusting the width of the plot. Below is the script of the plot along with the box in which I am trying to fit. Please help me to adjust the width of the plot produced using datatable. Also, I don't want to increase the width of the box. A link to apossible solution would be of great help. Thanks.
Script for datatable:
r3_blood = subset(patient, handling == "Blood test" & employee == "r3")
datatable(r3_blood, options = list(
searching = FALSE,
pageLength = 5,
lengthMenu = c(5, 10, 15, 20)
))
Script to fit table in box:
box( title = "Case Summary", status = "primary", height =
"575",solidHeader = T,
dataTableOutput("sankey_table"))
As such, the width of the column can be controlled using the columns. width option. This example shows the first column being set to width: 200px (note that this is not pixel perfect in a table, the browser will make some adjustments!), a width that is reflected in the fixed column.
As such, if you apply the width attribute to the HTML table tag or inline width style ( style="width:100%" ), it will be used as the width for the table (overruling any CSS styles).
Set to 'fixed' for columns with equal widths. Set to 'auto' for column widths that are based on the width of the column content and the table width. The default is 'fixed'. Array of the columns object that's used to define the data types.
1) Along with already proposed possible duplicate
ticket where you can use div(DT::dataTableOutput("table"), style = "font-size: 75%; width: 75%")
2) Also you can add scrollX = T
into your options
library(DT)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
box(title = "Case Summary", width = 4,status = "primary", height = "575",solidHeader = T, dataTableOutput("Table"))
)
)
server <- function(input, output, session) {
output$Table <- renderDataTable(
datatable(mtcars, options = list(searching = FALSE,pageLength = 5,lengthMenu = c(5, 10, 15, 20), scrollX = T))
)
}
shinyApp(ui, server)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With