Open shw079 opened 4 years ago
If you are using the development version from Github, I have had to make changes to the way events are handled. Before every event was sent back to the R server which caused the visualisation to lag on large graphs. You now have to specify the events you want to capture with sg_events
.
Does this work for you?
library(shiny)
library(sigmajs)
ui <- fluidPage(
sigmajsOutput("sg", height = "100vh")
)
server <- function(input, output, session) {
nodes <- sg_make_nodes(100)
edges <- sg_make_edges(nodes)
output$sg <- renderSigmajs({
sigmajs() %>%
sg_nodes(nodes, id, size, color) %>%
sg_edges(edges, id, source, target) %>%
sg_layout() %>%
sg_events("clickNode")
})
observeEvent(input$sg_click_node, {
sigmajsProxy("sg") %>%
sg_zoom_p(input$sg_click_node$id)
})
}
shinyApp(ui, server)
Thanks a lot for your reply! Yes the above codes work but it doesn't seem to zoom on the correct node, although the node id is specified to be the node clicked.
Hi, I am trying to use the function
sg_zoom_p
so that upon clicking on a node, I would zoom onto that node. However, I can't get that working and I cannot find an example in the documentation. I did something like this, whereoutput$sg <- renderSigmajs({...})
:When I click on a node, nothing has changed. Do you know what I am doing wrong here, or could you provide an example of how to do that? Thanks!