Shiny Graphic disappears when i switch from a tabPanel to another

I get this problem when i plot many dygraphs in shinydashbord tabPanel. I have an app with many tabPanel with a shiny graph on each of them. When the app is lunch every graph are correctly plot when i switch for a first time from a tabPanel to another. But when i come back to a graph on a tabPanel previously load : graph disappears. Before (tab1 and tab2):


After :

(coming back from tab3)

Hi, welcome!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one for a shiny app

Hi Thanks.
this is the link on shinyapps.io of my app : https://sno-observil.shinyapps.io/Matriochkas_ok/

The differents part of my shiny app are :

  • R file for csv and rds data import from dropbox : here

  • R file for graphs generation with dygraph : here

  • R file for UI and server : here

(Under my code for reprex)
Shiny Graphic disappears when i switch from a tabPanel to another
I get this problem when i plot many dygraphs in shinydashbord tabPanel. I have an app with many tabPanel with a shiny graph on each of them. When the app is lunch every graph are correctly plot when i switch for a first time from a tabPanel to another. But when i come back to a graph on a tabPanel previously load : graph disappears. Before (tab1 and tab2):

After :

You can download the data here
borja_id_temp_2019
borja_id_temp_2018



library(shiny)
library(shinydashboard)
library(dygraphs)

borja_id_temp_2019 <-readRDS(file="Noue_Dumont_Amont_Debit_2019_ord.rds")
borja_id_temp_2018 <-readRDS(file="Noue_Dumont_Amont_Debit_2018_ord.rds")

dygrph_noue_amont_2019<- dygraph(borja_id_temp_2019, main = "Debit Amont 2019", group = "Debit Amont Noue")%>% dyAxis("y", label = "Debit(m3/s)") %>% dyAxis("y2", label = "Qualite")%>%  dySeries("Debit", axis = 'y')%>%dySeries("Code_Quali", axis = 'y2')%>% dyRangeSelector()
dygrph_noue_amont_2018<-dygraph(borja_id_temp_2018, main = "Debit Amont 2018", group = "Debit Amont Noue")%>% dyAxis("y", label = "Debit(m3/s)") %>% dyAxis("y2", label = "Qualite")%>%  dySeries("Debit", axis = 'y')%>%dySeries("Code_Quali", axis = 'y2')%>% dyRangeSelector()

ui <- dashboardPage(
  
 
  dashboardHeader(title = 'Reporting Dashboard'),
 
  dashboardSidebar(
    width = 350,
    sidebarMenu(
      menuItem("Site 1: Noue Dumont", tabName = "dumont", icon = icon("dashboard"))
      
    )),
  
  
  dashboardBody
  
  (
    tabItems(
      tabItem(
        
        tabName = "dumont",
        h2("Noue centralisée Standard de Nantes/Site Dumont"),
        
        box( width=NULL,
             title = "Debit Amont", status = "info", solidHeader = TRUE,
             collapsible = TRUE,collapsed = TRUE,
             
             tabBox(width=NULL,
                    
                    tabPanel("Noue_Debit_Amont2019",  
                                                      
                             dygraphOutput("dydebiamont2019",width = "100%")
                    ),
                    tabPanel("Noue_Debit_Amont2018",                         
                             dygraphOutput("dydebiamont2018",width = "100%")
                    )
             )
        )
      )
      
    )
  ))
  
  
  #fin du dashboardHeader
  
  
  server <- function(input, output)
  {
     
    output$dydebiamont2019 <- renderDygraph({
      dygrph_noue_amont_2019
    })
    output$dydebiamont2018 <- renderDygraph({
      dygrph_noue_amont_2018
    })
  }
  
  shinyApp(ui, server)

Found it at last!

I noticed that the x-axis was automatically syncing between the plots, and since they had different years, that's why they appeared blank when you visit the other one (completely different range). I first thought it was a Shiny issue, but diving into the Dygraph documentation I found the culprit: the group variable in your main dygraph function. If you set this, graphs are linked, and the x-asis will automatically sync. Just removing the group fixed it!

dygrph_noue_amont_2018<-dygraph(borja_id_temp_2018, 
  main = "Debit Amont 2018", group = "Debit Amont Noue") %>% 
  dyAxis("y", label = "Debit(m3/s)") %>% dyAxis("y2", label = "Qualite") %>%  
  dySeries("Debit", axis = 'y')%>%dySeries("Code_Quali", axis = 'y2') %>% 
  dyRangeSelector()

#Remove group

dygrph_noue_amont_2018<-dygraph(borja_id_temp_2018, 
  main = "Debit Amont 2018") %>% 
  dyAxis("y", label = "Debit(m3/s)") %>% dyAxis("y2", label = "Qualite") %>%  
  dySeries("Debit", axis = 'y')%>%dySeries("Code_Quali", axis = 'y2') %>% 
  dyRangeSelector()

Do this for both and it's fixed.

PJ

It's work !
Thank you !!!!

Is there a way to use the group function, such that comparing two graphs with different time stamps can be grouped?

I have one graph that represents data from this year and another graph that represents data from previous year. Everything works, but I would like to use the zoom function that comes with the 'group' parameter. The first graph disappears when I add the 'group' parameter.

Thanks already for the information!

Regards,
LM

Hi,

Would you open a new topic and explain this again in some more detail (preferably using a Reprex) given the question is different from the one posted here and we like to keep it to one question per topic. Feel free to refer to this one if needed.

Thanks!
PJ

Okay, I will open a new topic in more detail, with reprex!

Kind regards,
LM

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.