如何使一个闪亮的应用程序侧边栏适合页面?

时间:2018-04-03 09:58:31

标签: r user-interface shiny rstudio

shinyUI(

  navbarPage(inverse = TRUE, title = "Campaign Launch Demo",
             ##############Week Day insights#############################################
             tabPanel(
               # "Week Days Insights",tags$head(
               # tags$style(HTML('
               #                 #sidebar {
               #                 background-color: #4D394B;
               #                 color: #b8b0b7;
               #                 height: 90vh;
               #                 overflow-y: auto;
               #                 }
               #                 
               #                 body, label, input, button, select { 
               #                 font-family: "Arial";
               #                 }hr {border-top: 2px solid #FFFFFF;}'))
               # ),



           "Week Days Insights",tags$head(
             tags$style(HTML("hr {border-top: 1px solid #000000;}"))
           ),

           sidebarLayout(
             sidebarPanel(fluid = TRUE,width=3, 
                          # id = "sidebar", style = "position:fixed;width:inherit;",
                          # "Inputs", 
                          # tags$head(tags$style(HTML("color: violetred")),
                          # CONTROLS conditional panels
                          h3("Insights", style = "align:center;text-align:center"),

                          selectInput("Segmentation", "Please Select Segmentaion",
                                      choices=c("Daily","Hourly"),1),
                          # # option 1
                          conditionalPanel(condition = "input.Segmentation == 'Daily'",
                                           selectInput("segTypeDaily", "Select Type of Daily Segmentation",
                                                       choices=c("Per Day Revenue","Per Day Transactions"))),

                          #       # option 2
                          conditionalPanel(condition = "input.Segmentation == 'Hourly'",
                                           selectInput("segTypeHourly", "Select Type of Hourly Segmentation",
                                                       choices=c("Hourly Revenue","Hourly Transaction"))),

                          hr(),
                          h3("Marketing", style = "align:center;text-align:center"),

                          selectInput("WeekdayMarketingChoice", "Please Select Marketing Type",
                                      choices=c("Email Marketing" = "emailMarketing","SMS Marketing" = "smsMarketing"),2),


                          br(),

                          #### Condition for SMS Marketing
                          conditionalPanel(condition = "input.WeekdayMarketingChoice == 'smsMarketing'",

                                           uiOutput("dayFilterControlForSMS"),
                                           helpText("Note: SMS will be sent to all customers on selected Days"),

                                           actionButton("manualSmsCampaign", "Launch SMS Campaign", style = "align:center;text-align:center"),
                                           hr(),

                                           actionButton("maxSmsCampaign", "Campaign for Max Revenue Day"),
                                           helpText("Note: Campaigns will lauch for day with Max Revenue"),

                                           br(),
                                           actionButton("minSmsCampaign", "Campaign for Min Revenue Day"),
                                           helpText("Note: Campaigns will lauch for day with Max Revenue")

                          ),
                          # 
                          # 
                          #### Condition for Email Marketing
                          conditionalPanel(condition = "input.WeekdayMarketingChoice == 'emailMarketing'",

                                           uiOutput("dayFilterControlForEmail"),
                                           helpText("Note: Emails will be sent to all customers on selected Days"),

                                           # textAreaInput("camMessage", "Enter campaign text or offers to send: ", "Special Discount Offers!", "250px", "100px"),
                                           actionButton("manualEmailCampaign", "Launch Email Campaign", style = "align:center;background:#9966CC"),
                                           hr(),
                                           #helpText("Note: Max and Min Campaigns"),

                                           actionButton("maxEmailCampaign", "Campaign for Max Revenue Day"),
                                           helpText("Note: Campaigns will lauch for day with Max Revenue"),


                                           br(),
                                           actionButton("minEmailCampaign", "Campaign for Min Revenue Day"),
                                           helpText("Note: Campaigns will lauch for day with Min Revenue"),
                                           br()
                          )










             ),

             mainPanel(fluid = TRUE,width=9,
                       plotlyOutput('sidePlot') %>% withSpinner(color="#0dc5c1"),

                       #
                       #verbatimTextOutput("daytext") %>% withSpinner(color="#0dc5c1"),

                       br(),
                       br(),
                       br(),
                       br(),
                       hr(),
                       plotlyOutput('sidePlot2') %>% withSpinner(color="#0dc5c1")

                       # br(),
                       # br(),
                       # br(),
                       # br()
                       # 
                       #verbatimTextOutput("selectedDaysText")
                       #DT::dataTableOutput("daysDT", width = 800)

                       # plotOutput("prodgressPlot")

             )

           )
         ),
         #######################################################################




         ###############Customer Insights Tab######################################
         tabPanel("Individual Customer Insights",
                  sidebarLayout
                  ( sidebarPanel(fluid = TRUE,width=3,
                                 verbatimTextOutput("customerSidePaneltext"),
                                 actionButton("customercampaign", "Launch Personalised Campaigns")),
                    mainPanel(fluid = TRUE,width=9,
                              #DT::dataTableOutput("topcust", width = 800) %>% withSpinner(color="#0dc5c1"),
                              br(),
                              plotlyOutput('revenuePerCustomer') %>% withSpinner(color="#0dc5c1"),

                              hr(),
                              br(),
                              #plotlyOutput('transactionsPerCustomer') %>% withSpinner(color="#0dc5c1"),
                              br(),
                              br(),
                              DT::dataTableOutput("breakdownTable", width = 800) %>% withSpinner(color =
                                                                                                   "#0dc5c1"),

                              br(),
                              plotlyOutput('rfmGraphPlot') %>% withSpinner(color = "#0dc5c1"),

                              br()
                              # DT::dataTableOutput("customertext", width = 800)
                    )
                  )),
         #########################################################################

         #### Country Segmentation ####
         tabPanel("Country Centric Insights", 
                  sidebarLayout(fluid = TRUE,
                                sidebarPanel( width=3,
                                              # CONTROLS conditional panels
                                              selectInput("CountrySegmentation", "Please Select Segmentaion",
                                                          choices=c("Revenue by Country","Average Order Value over Time", "Numer of Daily Transactions"),1),
                                              uiOutput("selCountry"),


                                              br(),
                                              hr(),

                                              headerPanel("Marketing!"),
                                              uiOutput("countryControls"),
                                              helpText("Note: Emails will be sent to all customers in selected Countries"),
                                              br(),
                                              uiOutput("productControls"),
                                              # choices=c('All','Netherlands','EIRE','Germany','France','Australia'),1),
                                              helpText("Note: Discounts will be applied only on selected products"),

                                              textAreaInput("camCountryMessage", "Enter campaign text or offers to send: ", "Special Discount Offers!", "250px", "100px"),
                                              actionButton("manualCountryCampaign", "Launch Campaign"),
                                              hr()



                                ),

                                mainPanel( width=9,

                                           plotlyOutput("countryTransPlotly") %>% withSpinner(color="#0dc5c1"),
                                           br(), 
                                           plotlyOutput("countryPlotly") %>% withSpinner(color="#0dc5c1"),
                                           plotlyOutput("transactionPlotly") %>% withSpinner(color="#0dc5c1"),



                                           br(),
                                           br(),
                                           #textOutput("countryMarketingText"),
                                           verbatimTextOutput("countryText"),
                                           verbatimTextOutput("emailText"),
                                           #verbatimTextOutput("sentMail")

                                           DT::dataTableOutput("sentMail", width = 1000) %>% withSpinner(color="#0dc5c1")
                                           # verbatimTextOutput("countryText")
                                           # 

                                ))


         )



  )

)

options(shiny.error = browser)
options(warn=-1)

enter image description here当应用程序执行时,我需要闪亮应用中的侧边栏以适应浏览器/小程序的大小。 目前,只有在添加输入时,侧边栏才会展开。

1 个答案:

答案 0 :(得分:0)

您可以通过指定.well css属性的高度并将高度设置为屏幕的像素数来实现此目的,或者可以设置min-height: 720px,它应适用于大多数现代屏幕。我已将其包含在您的tags内的navbarPage通话中

tags$style(HTML("hr {border-top: 1px solid #000000;}
                .well {height: 1200px;}"))