dygraphs shiny app problem

I am experiencing strange behaviour when launching a shiny application which has two dyGraphs. The data displayed on the legend does not appear on mouse hover over. My limited JS understanding is that there is a conflict between rhandsontable and dygrpahs with the moment JS library.

I believe this is happening only when I use quarterly data in a time object (XTS, TS) - this doesn't happen with yearly or monthly.

A reproduceable example is below:


library(shiny)
library(rhandsontable)
library(dygraphs)
library(DT)

#
ui <- fluidPage(

    # Application title
    titlePanel("Handsontable/Dygraphs issue"),


       
        mainPanel(
        # Quarterly data, issue
          dygraphOutput("dygraph_q"),
          rHandsontableOutput("table_q"),
          
          # Works
          dygraphOutput("dygraph_y"),
          rHandsontableOutput("table_y")
          
    )
    
    )



server <- function(input, output) {
    
    #####
    # Quarterly data issue!
    #####
    

    output$dygraph_q <- renderDygraph({
     
        
        dat <- data.frame(x=(seq.Date(ymd("2020-02-01"),length.out = 100, by = "quarter")),
                          
                          y= 1:100) 
        
        dat <- xts(dat$y,order.by = dat$x)
        
        
     dygraph(dat)
            
        
    })
    
    output$table_q <- renderRHandsontable( {        dat <- data.frame(x=seq.Date(ymd("2020-02-01"),length.out = 100, by = "quarter"),
                                                                     y= 1:100)
    
    
    
    rhandsontable(dat, width = 200, height = 200)
                                                 
                                                 })
    #####
    # Yearly data fine!
    #####
    
    output$dygraph_y <- renderDygraph({
        
        dat <- data.frame(x=(seq.Date(ymd("2020-02-01"),length.out = 100, by = "year")),
                          
                          y= 1:100) 
        
        dat <- xts(dat$y,order.by = dat$x)
        
        
        dygraph(dat)
        
        
    })
    
    output$table_y <- renderRHandsontable( {        dat <- data.frame(x=seq.Date(ymd("2020-02-01"),length.out = 100, by = "year"),
                                                                     y= 1:100)
    
    
    
    rhandsontable(dat, width = 200, height = 200)
    
    })
    
    
    
    
}

# Run the application 
shinyApp(ui = ui, server = server)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.