Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visNetwork and timevis package can not be useed together in Shiny #90

Closed
waitalone opened this issue Aug 30, 2016 · 7 comments
Closed

Comments

@waitalone
Copy link

I am trying to include the timevis package and the visnetwork package into my Shiny app. but i find it did not work when i put them together.and there are no errors in R. could you help me see what is the reason? appreciate for your any help.

here is the code below,

library(timevis)
library(shiny)
library(visNetwork)

nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))

dataBasic <- data.frame(
id = 1:4,
content = c("Item one", "Item two" ,"Ranged item", "Item four"),
start = c("2016-01-10", "2016-01-11", "2016-01-20", "2016-02-14"),
end = c(NA, NA, "2016-02-04", NA)
)

ui<-fluidPage(
timevisOutput('timeline'),
visNetworkOutput('snagraph')
)

server<-function(input,output)({

output$snagraph<-renderVisNetwork(visNetwork(nodes,edges))
output$timeline<-renderTimevis(timevis(dataBasic))

}
)

shinyApp(ui,server)

@daattali
Copy link

@bthieurmel the problem was that I was only including the vis-timeline.js file and you were only including the vis-network.js file.

I fixed this on my end, so now timevis includes the entire vis.min.js file (which is twice as large, but c'est la vie), and now it works on my end. So if you define a timevis before defining a visNetwork widget, then it works because my JS file gets called first and it defines vis with both timeline and network. But if a visNetwork widget is defined before a timevis widget, then it still doesn't work because it uses your version of vis that only has the network module.

I'd appreciate if you fixed it on your end as well

@bthieurmel
Copy link
Contributor

Done.

@DivadNojnarg
Copy link

DivadNojnarg commented Jul 17, 2017

I re-open this problem:

"Hello Dean,

I saw that there are some issues between timevis and visNetwork since they both use vis.js. However, I thought that it was fixed last year in 2016. I still have problems when I run a code like that :

library(shiny)
library(timevis)
library(visNetwork)
library(shinydashboard)
library(shinyjqui)
library(lubridate)

myevents <- data.frame(
  id      = 1,
  content = "Item one",
  start   = now(),  
  end     = now()+7200, # 2hours later
  editable = TRUE,
  type = "range",
  title = "Item one"
)

ui <- fluidPage(
  dashboardPage(
    dashboardHeader(title = "blabla"),
    dashboardSidebar(disable = TRUE),
    dashboardBody(
      box(
        visNetworkOutput("network")
      ),
      jqui_sortabled(
        div(
          box(
            timevisOutput("timeline")
          )
        )
      )
    )
  )
)

server <- function(input, output, session) {
  
   output$network <- renderVisNetwork({
     # minimal example
     nodes <- data.frame(id = 1:3)
     edges <- data.frame(from = c(1,2), to = c(1,3)) 
     visNetwork(nodes, edges)
   })
  
  output$timeline <- renderTimevis({
    timevis(myevents)
  })
  
}

shinyApp(ui = ui, server = server)

In this code, the timeline does not start at the current time (now()) nor ends 2 hours later. However, if you comment the visNetwork elements in UI and server code, the timeline renders well.

How can I fix that?

Cheers
"

@daattali
Copy link

I'm currently traveling and don't have much time to debug stuff like this, so I can't promise I'll take a look. But can you please post a minimal example, with as least code as possible? Having so many packages in the mix increases the points of possible problems, we can more efficiently investigate the issue when the code only involves the two packages

@DivadNojnarg
Copy link

Here is what is essential. I commented the network part to show that it works as expected. But if you uncomment :)

library(shiny)
library(timevis)
library(visNetwork)

myevents <- data.frame(
  id      = 1,
  content = "Item one",
  start   = Sys.time(),  
  end     = Sys.time()+7200 # 2hours later
)

ui <- fluidPage(
  #visNetworkOutput("network"),
  timevisOutput("timeline")
)

server <- function(input, output, session) {
  
  # output$network <- renderVisNetwork({
  #   # minimal example
  #   nodes <- data.frame(id = 1:3)
  #   edges <- data.frame(from = c(1,2), to = c(1,3)) 
  #   visNetwork(nodes, edges)
  # })
  # 
  output$timeline <- renderTimevis({
    timevis(myevents)
  })
  
}

shinyApp(ui = ui, server = server)

@bthieurmel
Copy link
Contributor

Hi, it's seems ok for me.

other attached packages:
[1] visNetwork_2.0.0 timevis_0.4      shiny_1.0.3  

@bthieurmel
Copy link
Contributor

But, we can observe that :

  • latest visNetwork use vis.js 4.20
  • latest timevis use vis.js 4.16.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants