christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
652 stars 268 forks source link

"An error has occurred!" displayed after publish rshiny #297

Closed gwonchan closed 2 years ago

gwonchan commented 2 years ago

Hi, This is Jason and I am a user of your networkD3 to plot my network! I really appreciate your amazing job!

I want to publish the network plot on rshinyapps.io for my project and I have an issue after publishing them. When I run app, it is working fine like yours. but publishing is not working with the error msg below.

https://6jv0lq-jason-yoon.shinyapps.io/project.

Also server.r is here.

library(shiny)

UI

ui <- shinyUI(fluidPage(

titlePanel("Shiny networkD3 "),

sidebarLayout( sidebarPanel( sliderInput("opacity", "Opacity (not for Sankey)", 0.6, min = 0.1, max = 1, step = .1) ), mainPanel( tabsetPanel( tabPanel("Simple Network", simpleNetworkOutput("simple")), tabPanel("Force Network", forceNetworkOutput("force")) ) ) ) ))

ui.r is here.

library(shiny)

UI

ui <- shinyUI(fluidPage(

titlePanel("Shiny networkD3 "),

sidebarLayout( sidebarPanel( sliderInput("opacity", "Opacity (not for Sankey)", 0.6, min = 0.1, max = 1, step = .1) ), mainPanel( tabsetPanel( tabPanel("Simple Network", simpleNetworkOutput("simple")), tabPanel("Force Network", forceNetworkOutput("force")) ) ) ) ))

gwonchan commented 2 years ago

my bad, just added library(networkD3) in server.r and working!

cjyetman commented 2 years ago

I would guess this has nothing to do with {networkD3} and has to do with your {shiny} code and/or the shiny server. I would not expect {networkD3} to completely error our the page like that. What happens when you run it locally? Does this work locally...

library(shiny)
library(networkD3)

data(MisLinks)
data(MisNodes)

server <- shinyServer(function(input, output) {

  output$simple <- renderSimpleNetwork({
    src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
    target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
    networkData <- data.frame(src, target)
    simpleNetwork(networkData, opacity = input$opacity)
  })

  output$force <- renderForceNetwork({
    forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
                 Target = "target", Value = "value", NodeID = "name",
                 Group = "group", opacity = input$opacity)
  })
})

ui <- shinyUI(fluidPage(

  titlePanel("Shiny networkD3 "),

  sidebarLayout(
    sidebarPanel(
      numericInput("opacity", "Opacity", 0.6, min = 0.1, max = 1, step = .1)
    ),
    mainPanel(
      tabsetPanel(
        tabPanel("Simple Network", simpleNetworkOutput("simple")),
        tabPanel("Force Network", forceNetworkOutput("force"))
      )
    )
  )
))

shinyApp(ui, server)
gwonchan commented 2 years ago

Hey, thank you for your response!

I have checked logs on rshinyapps.io and it says

2022-11-22T15:29:47.698659+00:00 shinyapps[7541695]: Warning: Error in simpleNetworkOutput: could not find function "simpleNetworkOutput"

I just added library(networkD3) in server.r and no issues!

I am sorry to bother you and have a great thanksgiving!

Jason

Gwonchan Jason Yoon, Ph.D

Engineer

Frisco, TX 75035

Tel: 617-417-4270

www.linkedin.com/in/jason-yoon-41754880

2022년 11월 22일 (화) 오전 9:42, CJ Yetman @.***>님이 작성:

I would guess this has nothing to do with {networkD3} and has to do with your {shiny} code and/or the shiny server. I would not expect {networkD3} to completely error our the page like that. What happens when you run it locally? Does this work locally...

library(shiny) library(networkD3)

data(MisLinks) data(MisNodes) server <- shinyServer(function(input, output) {

output$simple <- renderSimpleNetwork({ src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D") target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I") networkData <- data.frame(src, target) simpleNetwork(networkData, opacity = input$opacity) })

output$force <- renderForceNetwork({ forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = input$opacity) }) })

ui <- shinyUI(fluidPage(

titlePanel("Shiny networkD3 "),

sidebarLayout( sidebarPanel( numericInput("opacity", "Opacity", 0.6, min = 0.1, max = 1, step = .1) ), mainPanel( tabsetPanel( tabPanel("Simple Network", simpleNetworkOutput("simple")), tabPanel("Force Network", forceNetworkOutput("force")) ) ) ) ))

shinyApp(ui, server)

— Reply to this email directly, view it on GitHub https://github.com/christophergandrud/networkD3/issues/297#issuecomment-1323874666, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMADAD544STTD5756GAUAXLWJTSV3ANCNFSM6AAAAAASH6EMDA . You are receiving this because you modified the open/close state.Message ID: @.***>