Comments (3)
Could you supply the UI part of the code, so that there's a complete working example?
from shinydashboard.
I solved this issue by creating a separate output for each message type in server;
output$notificationMenu <- renderMenu({
nots <- apply(notificationData, 1, function(row) {
notificationItem(text = row[["message"]], status = row[["status"]])
})
dropdownMenu(type = "notifications", .list = nots)
})
The header is built by calling dashboardHeader as follows:
header <- dashboardHeader(
dropdownMenuOutput("messageMenu"),
dropdownMenuOutput("notificationMenu"),
dropdownMenuOutput("taskMenu")
)
The entire app code, including app and server:
## app.R ##
library(shiny)
library(shinydashboard)
library(googleVis)
header <- dashboardHeader(
dropdownMenuOutput("messageMenu"),
dropdownMenuOutput("notificationMenu"),
dropdownMenuOutput("taskMenu")
)
sidebar <- dashboardSidebar(sidebarUserPanel("Dave",
subtitle = a(
href = "#", icon("circle", class = "text-success"), "Online"
)),
sidebarMenu(
menuItem(
"Dashboard", tabName = "dashboard", icon = icon("dashboard")
),
menuItem(
"Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green"
)
))
body <- dashboardBody(tabItems(
tabItem(
tabName = "dashboard",
# infoBoxes with fill=FALSE
fluidRow(
# A static infoBox
infoBox("Demand", 10 * 2, icon = icon("line-chart")),
# Dynamic infoBoxes
infoBoxOutput("progressBox"),
infoBoxOutput("approvalBox")
),
# infoBoxes with fill=TRUE
fluidRow(
infoBox("Price", 5 * 2, icon = icon("heart"), fill = TRUE),
infoBoxOutput("progressBox2"),
infoBoxOutput("approvalBox2")
),
fluidRow(# Clicking this will increment the progress amount
box(
width = 4, actionButton("count", "Increment progress")
))
),
tabItem(tabName = "widgets",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
))
))
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
#get data from file
menu.df <- read.csv("../../data/dropDownMenus2.csv")
#partition menu data into message, notification, and task
messageData <- subset(menu.df, type == "message")
notificationData <- subset(menu.df, type == "notification")
taskData <- subset(menu.df, type == "task")
output$messageMenu <- renderMenu({
msgs <- apply(messageData, 1, function(row) {
messageItem(from = row[["from"]], message = row[["message"]])
})
dropdownMenu(type = "messages", .list = msgs)
})
output$notificationMenu <- renderMenu({
nots <- apply(notificationData, 1, function(row) {
notificationItem(text = row[["message"]], status = row[["status"]])
})
dropdownMenu(type = "notifications", .list = nots)
})
output$taskMenu <- renderMenu({
taks <- apply(taskData, 1, function(row) {
taskItem(text = row[["message"]], color = row[["color"]], value = row[["value"]])
})
dropdownMenu(type = "tasks", .list = taks)
})
datasetInput <- reactive({
switch(
input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars
)
})
output$view <- renderGvis({
gvisScatterChart(dropDownMenus, options = list(width = 400, height = 450))
})
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$plot2 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$progressBox <- renderInfoBox({
infoBox(
"Progress", paste0(25 + input$count, "%"), icon = icon("list"),
color = "purple"
)
})
output$approvalBox <- renderInfoBox({
infoBox(
"Confidence", "80%", icon = icon("eye-open", lib = "glyphicon"),
color = "yellow"
)
})
# Same as above, but with fill=TRUE
output$progressBox2 <- renderInfoBox({
infoBox(
"Managed Spend (mil)", paste0("USD ", 25 + input$count), icon = icon("dollar"),
color = "purple", fill = TRUE
)
})
output$approvalBox2 <- renderInfoBox({
infoBox(
"Model Performance", "80%", icon = icon("thumbs-up", lib = "glyphicon"),
color = "green", fill = TRUE
)
})
}
shinyApp(ui, server)
from shinydashboard.
Great, glad you got it figured out!
from shinydashboard.
Related Issues (20)
- Maximizing tabBox with a sidebar will add a horizontal Scrollbar to the box HOT 3
- Dashboard sidebar starts uncollapsed HOT 2
- SidebarMenu menuItem href elements contain the aria-selected tag HOT 1
- can not see my second tabitem after clicking action button HOT 1
- Error with publication of a Shiny App with R
- [Update request] The default icon for menuSubItem() "angle-double-right" is now "angles-right" in Font Awesome 6.0.0 HOT 5
- dynamic footer HOT 6
- FYI copyright on the shinydashboard website HOT 1
- dashboardPage shouldn't create <title> HTML tags if title = NULL HOT 1
- dashboardBody not showing when conditionalPanel is used HOT 1
- Toggling boxes to collapse has unexpected results with nested boxes HOT 1
- ShinyDash fails to render since R4.3 added to computer. HOT 3
- `shinydashboard::updateTabItems` not matching `shiny::updateTabsetPanel` HOT 2
- Why use unsecure AdminLTE? HOT 4
- Remove/hide footer from dashboard HOT 3
- Collapsible box not responding in my navbarPage Rshiny
- shinydashboard - "Get started" Tab [1 Link + 1 Typo] HOT 1
- shinydashboard - "Appearance" Tab [1 Punctuation]
- shinydashboard - "Behavior" Tab [1 Typo]
- I am using the R Package shinydashboard, now the dashboardSidebar is NOT showing in black background HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinydashboard.