1
votes

I've been trying for hours on end to get this working however it does not work. I simply wish to render the charts in this dashboard for the different tabs. I have tried enclosing it with box(), using renderHighchart2 and highchartOutput2. The chart renders outside shiny just fine, what is wrong?

Edit: The charts I am referring to are the highcharts, not the valueboxes! Furthermore, the app does show the correct titles for each graph and fluidRow however fails to plot the highcharts

This is the code:

       library(shiny)
        library(shinydashboard)
        library(highcharter)
        library(tidyverse)
        
        
        ui <- dashboardPage(
          skin = "purple",
          dashboardHeader(title = h4(HTML("Generic company name<br/>Something to analyze")),
                          titleWidth = 275),
          dashboardSidebar(
            sidebarMenu(
              menuItem("Dashboard",icon = icon("dashboard"),
                       menuSubItem('Samenvatting', tabName = "samenvatting", icon = icon('atlas')),
                       menuSubItem('Statusverloop', tabName = "statusverloop", icon = icon('battery-three-quarters')),
                       menuSubItem('Tijdsverloop', tabName = "tijdsverloop", icon = icon("hourglass-end")),
                       menuSubItem('Affiliates', tabName = "affiliates", icon = icon("handshake")),
                       menuSubItem('Klanten informatie', tabName = "klanteninformatie", icon = icon("address-card"))
              ),
              menuItem("Kijkglas",tabname = "kijkglas",icon = icon("search"))
            )
          ),
          dashboardBody(
            tabItems(
              tabItem(tabName = 'samenvatting',
                      #contents
                      fluidRow(
                        valueBoxOutput("YTDnieuweA"),
                        valueBoxOutput("YTDomvangA")
                      ),
                      fluidRow(
                        valueBoxOutput("YTDnieuweP") ,
                        valueBoxOutput("YTDomvangP")
                      ),
                      fluidRow(
                        column( width = 6,h4("Wekelijkse statistieken", align = 'center'), highchartOutput('a') ),
                        column( width = 6,h4("Wekelijkse totale statistieken", align = 'center'), highchartOutput('b'))
                      )
              ),
              tabItem(tabName = "statusverloop"
                      #Empty TODO:
                      
              ),
              tabItem(tabName = "tijdsverloop"
                      #EMPTY: TODO
                      
              ),
              tabItem(tabName = "affiliates",
                      fluidRow(
                        column( width = 6,h4("Affiliates over aanmeldingen", align = 'center'), highchartOutput('a') ),
                        column( width = 6,h4("Affiliates over passen", align = 'center'), highchartOutput('b'))
                      )
              ),
              tabItem(tabName = "klanteninformatie",
                      fluidRow(
                        column( width = 4,h4("Wekelijkse statistieken", align = 'center'), highchartOutput('a') ),
                        column( width = 4,h4("Wekelijkse totale statistieken", align = 'center'), highchartOutput('b')),
                        column( width = 4,h4("Wekelijkse totale statistieken", align = 'center'), highchartOutput('a'))
                      )
              )
            )
          )
        )
    
server <- function(input, output) {
  output$a <- renderHighchart2({
    
    hc <- highcharts_demo() %>%
      hc_rm_series("Berlin") %>% 
      hc_chart(type = 'line')
    
    
      theme <- sandsignika = hc_theme_sandsignika()

      hc <- hc %>% hc_add_theme(theme)
      
    }
    
    hc
  })
  output$b <- renderHighchart2({
    
    hc <- highcharts_demo() %>%
      hc_rm_series("Berlin") %>% 
      hc_chart(type = 'line')
    

    
      theme <- hc_theme_economist()
      
      hc <- hc %>% hc_add_theme(theme)
      
    }
    
    hc
  })
}
shinyApp(ui,server)
1

1 Answers

0
votes

In shiny, you can't refer to any output more than once in the UI.

Try storing the chart in an object (could use either a reactiveValues or reactive() to store it), then assigning that object into separate outputs.