Data table not fitting correctly in Shiny dashboard - r

I am having some trouble fitting a data table with a scroll feature in my shiny dashboard. Your help would be great.
dashboardBody(
tabItems(
tabItem(tabName = "Calendar",
fluidRow(
box(width = 2, height = 300,
title = "Earnings Calendar",
div(style = 'overflow-y: scroll',tableOutput("calendar"))
)
)
),
tabItem(tabName = "Earnigns"),
tabItem(tabName = "Pre Earnings"),
tabItem(tabName = "Scanner"),
tabItem(tabName = "Contact")
)
)
)

Related

R Shinydashboard fileInput issue

I refer to codes from shiny widget gallery to create a fileInput widget on my shinydashboard.
ui.R
fluidPage(
# Copy the line below to make a file upload manager
fileInput("file", label = h3("File input")),
hr(),
fluidRow(column(4, verbatimTextOutput("value")))
)
server.R
function(input, output) {
# You can access the value of the widget with input$file, e.g.
output$value <- renderPrint({
str(input$file)
})
}
I expect my app to show "file upload progress", "upload complete" status and "summary" of the file just like image below.
Below are my codes for shinydashboard:
** for your convenience, refer to "tab Item" = "file".
library(shinydashboard)
library(shiny)
# define user interface
ui <- dashboardPage(
dashboardHeader(title = "B. Times Square"),
dashboardSidebar(
sidebarMenu(
menuItem(text = "Overview", tabName = "overview", icon = icon("balance-scale-right")),
menuItem(text = "Future", tabName = "future", icon = icon("map-signs")),
menuItem(text = "History", tabName = "history", icon = icon("history")),
menuItem(text = "File Upload", tabName = "data", icon = icon("file-upload"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "overview",
fluidRow(
infoBox(title = "Revenue", 1000, icon = icon("hand-holding-usd")),
infoBox(title = "Transaction", 50, icon = icon("bed")),
infoBox(title = "Occupancy %", 40, icon = icon("percentage"))
)
),
tabItem(tabName = "future",
fluidRow(
box(
title = "Revenue [Book]", width = 4,
plotOutput(outputId = "p1-revenue-book")
),
box(
title = "Revenue [Check-In]", width = 4,
plotOutput(outputId = "p2-revenue-checkin")
),
box(
title = "RevPAR", width = 4,
plotOutput(outputId = "p3-revpar")
)
),
fluidRow(
box(
title = "Revenue [Channel]", width = 4,
plotOutput(outputId = "p4-revenue-channel")
),
box(
title = "Occupancy [unit]", width = 4,
plotOutput(outputId = "p5-occupancy")
),
box(
title = "Book vs Cancel [Unit]", width = 4,
plotOutput(outputId = "p6-book-vs-cancel")
)
)
),
tabItem(tabName = "history",
fluidRow(
box(
title = "Revenue [Check-In]", width = 4,
plotOutput(outputId = "p2-revenue-checkin")
),
box(
title = "Revenue [Book]", width = 4,
plotOutput(outputId = "p1-revenue-book")
),
box(
title = "RevPAR", width = 4,
plotOutput(outputId = "p3-revpar")
)
),
fluidRow(
box(
title = "Revenue [Channel]", width = 4,
plotOutput(outputId = "p4-revenue-channel")
),
box(
title = "Occupancy [unit]", width = 4,
plotOutput(outputId = "p5-occupancy")
),
box(
title = "Book vs Cancel [Unit]", width = 4,
plotOutput(outputId = "p6-book-vs-cancel")
)
)
),
tabItem(tabName = ***"data"***,
column(width = 4,
fluidRow(
wellPanel(
fileInput(inputId = "***csv-upload***", label = "File Upload:",
accept = c("csv", ".csv"))
)
)
)
)
)
)
)
# define server
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
I click on "Run App", tried to upload csv file but I don't see any progress bar or file upload complete status after I select a file. The widget basically doesn't work at all.

TabItem Output is not working for R Shinydashboard

I am trying to build a simple app using Shinydashboard. One of the tabitems ("Raw Data") does not display anything and neither the page changes when clicked on it. I have cross-checked the syntax and the code is running fine. Don't understand what's wrong.
Ui.R-
header = dashboardHeader(title="COVID-19 Tracker")
sidebar = dashboardSidebar(collapsed = TRUE,
sidebarMenu(menuItem("Dashboard", tabName = "Dashboard",icon = icon("globe")),
menuItem("Raw Data", tabName = "Raw Data", icon = icon("database")),
menuItem("Graphs",tabName = "Graphs", icon = icon("chart-bar"))
))
body = dashboardBody(
tabItems(
tabItem(tabName = "Dashboard",
fluidRow(valueBox(10*3, "Cases", width = 4),
valueBoxOutput("Recovered", width = 4),
valueBoxOutput("Deaths", width = 4)
)
),
tabItem(tabName = "Raw Data", h2("Raw Data has been loaded!")
),
tabItem(tabName = "Graphs",fluidRow(
column(
width=4,
selectizeInput(
"country", label=h5("Country"), choices=NULL, width="100%")
),
column(
width=4,
selectizeInput(
"state", label=h5("State"), choices=NULL, width="100%")
),
column(
width=4,
checkboxGroupInput(
"metrics", label=h5("Selected Metrics"),
choices=c("Confirmed", "Deaths", "Recovered"),
selected=c("Confirmed", "Deaths", "Recovered"),
width="100%")
)
),
fluidRow(
plotlyOutput("dailyMetrics")
),
fluidRow(
plotlyOutput("cumulatedMetrics"))
)
)
)
ui = dashboardPage(header, sidebar, body)
I appreciate all the help!
That's because of the white space in tabName = "Raw Data". Remove it and this works.

Issue with shinydashboard - dashboardSidebar and dashboardBody

I am new to Shiny and Shinydashboard. Please consider the following code snippet (small part of huge code):
dbsidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Rank List", icon = icon("th"), tabName = "Widgets1", badgeColor = "green"),
menuItem("Build Your", icon = icon("th"), tabName = "Widgets2", badgeColor = "green"),
menuItem("Groups", icon = icon("th"), tabName = "Widgets3", badgeColor = "green")
)
)
dbBody <- dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
fluidRow(
#Pie Charts
splitLayout(
#cellWidths = c("50%", "50%"),
style = "border: 1px solid silver;",
cellWidths = 450,
cellArgs = list(style = "padding: 6px"),
plotlyOutput("Piechart1", width = "400px", height = "200px"),
plotlyOutput("Piechart2", width = "400px", height = "200px"),
plotlyOutput("Piechart3", width = "400px", height = "200px")
)
)
),
tabItem(tabName = "Widgets1",
#Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("TCScore","TCScore:",min = 0, max = 100, value = c(0,100))
),
# Show a plot of the generated distribution
mainPanel(
tabPanel("Heading", plotlyOutput("tbTable"))
)
),
downloadButton('downloadData', 'Download')
),
tabItem(tabName = "Widgets2", "XX"
# #Data Table
# sidebarLayout(
# sidebarPanel(
# sliderInput("TCCScore","TCCScore:",min = 0, max = 100, value = c(0,100)),
# ),
#
# # Show a plot of the generated distribution
# mainPanel(
# tabPanel("Heading", dataTableOutput("tbTable1"))
# )
#
# ),
# downloadButton('downloadData', 'Download')
),
tabItem(tabName = "Widgets3", "third"
)
)
)
On the dashboardSidebar, I have added 4 tabs - dashboard, Widget1, Widget2, Widget3. Initially for each of these tabs, I used simple text to render the UI dashboardBody and I got the display correctly. I started filling in each of these sections - "dashboard", "Widget1" and the display worked correctly for me. Unfortunately, for "Widget2 - when I removed the "XX" and uncommented the code shown above, the UI got completely distorted. It looks like the main UI elements in the dashboardBody did not get rendered? Can anyone tell me what I am doing wrong? Please help. I am sorry I have not posted the entire working code, but it is far too long, hence I had to put up only a small code snippet.
Thanks in advance! Cheer!

shinydashboard tabItems not working

I have a simple shiny dashboard that has four tabs in the side menu, and for some reason, when I build the shiny app, clicking on the side menu does not show me a new page, and the content of tab2 just appends itself to tab1.
While searching stackoverflow showed me this question: Shinydashboars tabItems not working properly, the answer doesn't apply to me since I'm not using rmd, and i don't plan to host it to a AWS server.
Here is the code for reference:
ui <- dashboardPage(
dashboardHeader(title = "Study Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Overall Objectives", tabName = "objectives"),
menuItem("Wellpad Operator", tabName = "wellpad_operator"),
menuItem("Wastewater Expert", tabName = "wastewater_expert"),
menuItem("Freshwater Expert", tabName = "freshwater_expert"),
menuItem("Environmental Impact", tabName = "environ_impact")
)
),
dashboardBody(
#Tab 1 Objective View
tabItems(
tabItem(tabName = "objectives",
h2("Overall Objectives"),
fluidRow(
box(
title = "Overall Objective Comparison", width = 6, solidHeader = TRUE,
plotOutput("objective_plot")
),
box(
title = "Cost Category Breakdown", width = 6, solidHeader = TRUE,
plotOutput("costbreakdown_plot")
),
box(
title = "Decision Variables", width = 12, solidHeader = TRUE,
tableOutput("decision_table"))
))
),
#Tab 2 Wellpad Decision
tabItem(tabName = "wellpad_operator",
h2("Wellpad Operator")
),
#Tab 3 Wastewater Expert
tabItem(tabName = "wastewater_expert",
h2("Wastewater Expert")
),
#Tab 4 Freshwater Expert
tabItem(tabName = "freshwater_expert",
h2("Freshwater Expert")
),
#Tab 5 Environmental Damages
tabItem(tabName = "environ_impact",
h2("Environmental Impact"))
)
)
server <- function(input, output) {
#server side code that generates the plots
}
shinyApp(ui = ui, server = server)
Thanks for all your help!
You need to put all your tabItem inside tabItems. Try this:
dashboardBody(
#Tab 1 Objective View
tabItems(
tabItem(tabName = "objectives",
h2("Overall Objectives"),
fluidRow(
box(
title = "Overall Objective Comparison", width = 6, solidHeader = TRUE,
plotOutput("objective_plot")
),
box(
title = "Cost Category Breakdown", width = 6, solidHeader = TRUE,
plotOutput("costbreakdown_plot")
),
box(
title = "Decision Variables", width = 12, solidHeader = TRUE,
tableOutput("decision_table"))
)),
#Tab 2 Wellpad Decision
tabItem(tabName = "wellpad_operator",
h2("Wellpad Operator")
),
#Tab 3 Wastewater Expert
tabItem(tabName = "wastewater_expert",
h2("Wastewater Expert")
),
#Tab 4 Freshwater Expert
tabItem(tabName = "freshwater_expert",
h2("Freshwater Expert")
),
#Tab 5 Environmental Damages
tabItem(tabName = "environ_impact",
h2("Environmental Impact"))
)
)

R Shiny tabsetPanel displaying strange tab name?

I am working with shinydashboard and using tabsetPanel, however strange name/number appears on the each tabPanel in the upper-left corner (like: tab-4750-1 and the number changes).
Does anyone know how i can remove it?
Hint: The problem appears in the menuItem: Tabelle & Plots
Code:
library(shiny)
library(shinydashboard)
library(ggplot2)
library(scales)
library(reshape2)
library(plyr)
library(dplyr)
library(DT)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Tabelle & Plots", icon = icon("area-chart"), tabName = "tabelle")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard"
),
tabItem(tabName = "tabelle",
tabsetPanel(id="tabs",width = NULL, height = "800px", selected = 1,
tabPanel(value=1,title="Tabelle filtern",
fluidRow(
column(12,
box(width = NULL, div(style = 'overflow-y: scroll; overflow-x: scroll;max-height: 650px; position:relative;',
dataTableOutput("tabelle")))))),
tabPanel("Plots", value = 2,
fluidRow(
column(12,
box(width = NULL, plotOutput("plot", height=650)),
box(status = "danger",width = NULL,div(style = 'overflow-x: scroll;position:relative;',
dataTableOutput("tabelle2")))))))
)
)
)
)
server <- function(input, output) {
}
shinyApp(ui, server)
Thanks for help!
Cheers

Resources