Skip to content

Instantly share code, notes, and snippets.

@senthilthyagarajan
Created August 10, 2018 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senthilthyagarajan/4f32fddd58ddecd763985fc5a503ad2b to your computer and use it in GitHub Desktop.
Save senthilthyagarajan/4f32fddd58ddecd763985fc5a503ad2b to your computer and use it in GitHub Desktop.
library(shiny)
library(shinydashboard)
library(shinyWidgets)
dropDownUI <- function(id, div_width = "col-xs-12 col-md-8") {
ns <- NS(id)
div(column(3, uiOutput(ns("class_level"))),
column(
width = 3,
pickerInput(
inputId = ns("selected_product"),
label = h4("Product Family"),
choices <- c("22","33","44"),
width = "100%"
)
))
}
dropDown <- function(input, output, session) {
ns <- session$ns
output$class_level <- renderUI({
selectInput(
ns("selected_class"),
label = h4("Classification Level"),
choices = list(
"apple " = "apple",
"orange " = "orange"),
selected = "orange"
)})
observeEvent(input$class_level, {
ns <- session$ns
if (input$selected_class == "apple") {
choices <- c("foo","zoo","boo")
} else if (input$selected_class == "orange") {
choices <- c("22","33","44")
} else {
choices <- c("aa","bb","cc")
}
updateSelectInput(session,
inputId = ns("selected_product"),
label = h4("Product Family"),
choices = choices)
})
}
sidebar <- dashboardSidebar(sidebarMenu(
menuItem("aaa",tabName = "aaa"),
menuItem("bbb", tabName = "bbb"),
menuItem("ccc", tabName = "ccc")
))
body <- ## Body content
dashboardBody(tabItems(
tabItem(tabName = "aaa",
fluidRow(dropDownUI(id = "dropdown")),
fluidRow(chartTableBoxUI(id = "ATC_Topline"))) # render the tabBox inside a fluidRow
))
# Put them together into a dashboardPage
ui <- dashboardPage(
dashboardHeader(title = "Loyalty Monthly Scorecard"),
sidebar,
body
)
server = {
shinyServer(function(input, output, session) {
MyData <- read.csv(file="ldb_data.csv", header=TRUE, sep=",")
callModule(chartTableBox, id = "ATC_Topline", data = MyData)
callModule(dropDown, id = "dropdown")
})
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment