rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
893 stars 298 forks source link

Body Content not seen(rendered) for Multiple Menu items #325

Closed rajatalpha closed 5 years ago

rajatalpha commented 5 years ago

Hi Guys, I have a code where I am taking a file Input from the user and displaying that file and have 2 other tabs(Exploring Continuous variables and Categorical variables) where no content or plot can be seen even after using convertMenuItem function to regain its data-toggle and data-value attributes. Also I need a dropdown in theses tabs to select only the Continuous or categorical variables so that I can work with them in the corresponding body of the two tabs. for eg Plotting Continuous and categorical variables differently on their respective tabs. Here is my code.

library(shiny)
library(shinydashboard)
library(DT)

convertMenuItem <- function(mi,tabName) {
  mi$children[[1]]$attribs['data-toggle']="tab"
  mi$children[[1]]$attribs['data-value'] = tabName
  mi
}
UI <- dashboardPage(
      dashboardHeader(title = 'Data Exloration'),
      dashboardSidebar(
  sidebarMenu(
    convertMenuItem(menuItem("FULL Data",tabName="Data",icon=icon("table"),
                             fileInput("file","Upload CSV files",multiple=TRUE,accept=("text/comma")),
                             selectInput("vari", "Variable", 
                                         choices=colnames(values$df_data)), tabName = "Data"),
    convertMenuItem(menuItem("Continous variables",tabName="Query2",icon=icon("table"),
                             selectInput("vari1", "Variable", 
                                         choices=colnames(values$df_data[ ,!sapply(values$df_data, is.factor)]))), tabName = "Continous variables"),
    convertMenuItem(menuItem("Categorical variables",tabName="Query2",icon=icon("table"),
                             selectInput("vari2", "Variable", 
                                         choices=colnames(values$df_data[ ,sapply(values$df_data, is.factor)])), tabName = "Categorical variables"))
)
)
   dashboardBody(
     tabItems(
      tabItem(tabName="Data", tabName="Data",
            fluidRow(
              h2("A look into the Whole Dataset")
            ),  # end of 1st Fluid Row        

            fluidRow(
              DT::dataTableOutput("data.frame"))),
      tabItem(tabName = "Continous variables", h2("Widgets tab content")),
      tabItem(tabName = "Categorical variables", h2("Widgets tab content"))
  )
)
)
server <- function(input, output) {
  values <- reactiveValues(df_data = NULL)

  observeEvent(input$file, {
    values$df_data <- read.csv(input$file$datapath)
  })
  output$data.frame <-DT::renderDataTable(values$df_data)
  output$select <- renderUI({
    df <- values$df_data
    selectInput("vari1", "Select Variables:",names(values$df_data[ ,!sapply(values$df_data, is.factor)])))

  })
  output$select <- renderUI({
    df <- values$df_data
    selectInput("vari2", "Select Variables:",names(values$df_data[ ,sapply(values$df_data, is.factor)])))

  })
}
shinyApp(UI, server)
rajatalpha commented 5 years ago

@wch Please help me with this!!

wch commented 5 years ago

Hi, this issue tracker is meant for bug reports and feature requests. For general help questions like this, please use https://community.rstudio.com/ or https://stackoverflow.com/.

rajatalpha commented 5 years ago

This is bug In Shiny Dashboardas it loses the data-toggle and data-value attributes while rendering multiple Menuitems??

wch commented 5 years ago

I think the thing you're trying to do with shinydashboard is a kind of a hack since you're directly modifying the HTML that's provided from shinydashboard's functions. When I say it's a hack, I don't mean that it's a bad thing, but it is beyond what we're able to support in this issue tracker.

Also, I tried running your code but it gives a number of errors so it wasn't possible to reproduce the problem.

rajatalpha commented 5 years ago

Hey please find the code attached, I could render the sidemenu but can't see the content on the tab after selecting the variable. Also if not possible,can you please suggest another way to this.Note-Select all the content in the file and Run it in Rstudio. Thank You in advance Rajat

On Thu, Jul 25, 2019 at 8:51 PM Winston Chang notifications@github.com wrote:

I think the thing you're trying to do with shinydashboard is a kind of a hack since you're directly modifying the HTML that's provided from shinydashboard's functions. When I say it's a hack, I don't mean that it's a bad thing, but it is beyond what we're able to support in this issue tracker.

Also, I tried running your code but it gives a number of errors so it wasn't possible to reproduce the problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rstudio/shinydashboard/issues/325?email_source=notifications&email_token=AKW3NNNK7TIP5WFON7IZK23QBHAG3A5CNFSM4IGMNTGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2ZZ6UY#issuecomment-515088211, or mute the thread https://github.com/notifications/unsubscribe-auth/AKW3NNJGSVSGKPBYKE7HYVLQBHAG3ANCNFSM4IGMNTGA .

rajatalpha commented 5 years ago

Hi Winston Chang, Also find my Screenshots of the same.

On Thu, Jul 25, 2019 at 11:45 PM rajat shrivastav rajatabhi605@gmail.com wrote:

Hey please find the code attached, I could render the sidemenu but can't see the content on the tab after selecting the variable. Also if not possible,can you please suggest another way to this.Note-Select all the content in the file and Run it in Rstudio. Thank You in advance Rajat

On Thu, Jul 25, 2019 at 8:51 PM Winston Chang notifications@github.com wrote:

I think the thing you're trying to do with shinydashboard is a kind of a hack since you're directly modifying the HTML that's provided from shinydashboard's functions. When I say it's a hack, I don't mean that it's a bad thing, but it is beyond what we're able to support in this issue tracker.

Also, I tried running your code but it gives a number of errors so it wasn't possible to reproduce the problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rstudio/shinydashboard/issues/325?email_source=notifications&email_token=AKW3NNNK7TIP5WFON7IZK23QBHAG3A5CNFSM4IGMNTGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2ZZ6UY#issuecomment-515088211, or mute the thread https://github.com/notifications/unsubscribe-auth/AKW3NNJGSVSGKPBYKE7HYVLQBHAG3ANCNFSM4IGMNTGA .

wch commented 5 years ago

I did not receive the code or screenshots. The GitHub email proxy probably strips them out.

rajatalpha commented 5 years ago

R_sample.txt Here Is My Code