i am trying to make editable graph but facing some errors unused argument (options = list(shape = "rectangle")) data frame with 0 columns and 0 rows

library(igraph)
library(visNetwork)
library(shiny)

g <- make_ring(5)

df <- data.frame(id = V(g)$name, label = V(g)$name)
ui <- fluidPage(
  titlePanel("Editable Graph"),
  visNetworkOutput("graph"),
  verbatimTextOutput("output")
)


server <- function(input, output) {
  
    output$graph <- renderVisNetwork({
    visIgraph(g, idToLabel = TRUE) %>% 
      visNodes(options = list(shape = "rectangle"))
  })
  

  observeEvent(input$graph_nodes_label, {
    df$label <- input$graph_nodes_label
    g <- set.vertex.attribute(g, "name", value = input$graph_nodes_label)
    output$graph <- renderVisNetwork({
      visIgraph(g, idToLabel = TRUE) %>% 
        visNodes(options = list(shape = "rectangle"))
    })
  })
  
  output$output <- renderPrint({
    df
  })
}
shinyApp(ui, server)

first off, you seem to have a pure visNetwork problem, shiny is a distaction. the proof is that I can reproduce the error message, without shiny in a simple script.

library(igraph)
library(visNetwork)

g <- make_ring(5)

visIgraph(g, idToLabel = TRUE) %>% 
  visNodes(options = list(shape = "rectangle"))

visNodes doesnt have an options param, so not sure where you got this code from ?
I look at what shapes it recognises, I saw box and square and some others, here is square

visIgraph(g, idToLabel = TRUE) %>% 
  visNodes(shape = "square")
1 Like

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.