Re: [shinyapps-users] GGVIS will not generate graph in shinydashboard

28 views
Skip to first unread message

Tareef Kawaf

unread,
Jun 20, 2016, 5:32:05 PM6/20/16
to Reid Kananen, shiny-...@googlegroups.com
Hi Reid,
This seems like more of a shiny question and not a shinyapps.io issue.  Moving to the shiny-discuss list.  I am guessing that if you could provide the data file, this would be a reproducible example for someone to be able to help.

Best,
Tareef

On Mon, Jun 20, 2016 at 4:53 PM, Reid Kananen <reidk...@gmail.com> wrote:
Hi all,

I have a small sample of GGVIS code that works outside of rshiny, however when I try to run in my app I can not get the graph to generate in the dashboard.  I've tried a several different approaches, but can't seem to get anything to work.

Is there a bug in my code - or am I missing something else?

Thanks! Reid



library(ggvis)
library(DT)
library(shinydashboard)
library(shiny)
library(dplyr)



#########################################################
#Loading R data
########################################################
load("packagedetail.Rdata")

#########################################################
#begin ui
#########################################################
ui <- dashboardPage(dashboardHeader(dropdownMenuOutput("bigSizeAlert"),title="Package Cycle Time",titleWidth=400),
                    dashboardSidebar(
                      br(),
                      dateRangeInput('dateRange',
                                     label = 'Date range input: yyyy-mm-dd',
                                     start = Sys.Date() - 2, end = Sys.Date() + 2
                      ),
                      selectizeInput("parentcompany", "ParentCo", choices=unique(as.character(mydfsummary$parentcompany)),multiple=FALSE,selected = "" ),
                      selectizeInput("brand", "Brand", choices=unique(as.character(mydfsummary$brand)),multiple=TRUE,selected = "" ),
                      selectizeInput("State","State", choices=unique(as.character(mydfsummary$State)),multiple=TRUE,selected = "" ),
                      selectizeInput("ShippingZone", "Shipping Zone", choices=unique(as.character(mydfsummary$ShippingZone)),multiple=TRUE,selected = "" ),
                      width=400),
                    # guess I spoke too soon when I said couldn't be the hr()!! 
                    # hr(),
                    dashboardBody(
                      tags$head(
                        tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
                      ),
                      fluidRow(
                        box(
                          tags$img(src="NGS_logo.png",height="57px")
                          ,width=3, height="100%",background = "black",solidHeader = TRUE)
                      ),
                      fluidRow( tabBox(
                        tabPanel("Package Detail"
                                 , ggvisOutput("ggvis_deliverydata")
                        ),
                        title="",id="mainBox",width=12, height = 500
                      )
                      )
                    )
)

#)


#################################################################################
#  Enter Svr Fuction
#################################################################################
server <- shinyServer(function(input, output) {
  options(shiny.error=recover) 
  
  # 
  # ##  i think i want this to be a reactive function  
  deliverydata <- reactive({
    deliverydatadf <- mydfsummary %>%
      filter(parentcompany == "test"
             ,brand == "test"
             ,State == "test"
             ,ShippingZone == "test" 
      )
    return(deliverydatadf)
  })
  
  
  #################################################################################
  #  Basic Stacked Bar Chart Delivered versus non-delivered
  #################################################################################
  
  ggvis_deliverydata <- renderPlot({
    deliverydatadf() %>%
      ggvis( y = ~PackageCounter 
             , x = ~InductionScanDateKey2
             , fill = ~PackageStatus
      ) %>%
      group_by(PackageStatus) %>%
      layer_bars() %>%
      set_options(width = 300, height = 300) %>%
      bind_shiny("ggvis_deliverydata")
  })
  
  ###########################################################################
  ## this is the end of the ouput function                   ################
  ###########################################################################
})

shinyApp(ui=ui,server=server)

--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/b81f6c60-4003-44ab-a318-e0d93ac6819a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reid Kananen

unread,
Jun 22, 2016, 5:27:19 PM6/22/16
to Shiny - Web Framework for R, reidk...@gmail.com
This was a bug in my code...please ignore
Reply all
Reply to author
Forward
0 new messages