datastorm-open / visNetwork

R package, using vis.js library for network visualization
Other
543 stars 126 forks source link

visNetwork (or vis.js?) mixes tooltips between nodes and edges #392

Open olivier7121 opened 4 years ago

olivier7121 commented 4 years ago

Hi all,

First many thanks to the creators of the vis.js library and visNetwork R package, they are great tools!

Before posting my issue here I performed of course a quick search but didn't find any hint.

I recently ran into a strange issue: when hovering some edges, the associated tooltip doesn't show but rather the tooltip associated to another (random?) node.

It happened with more than one network but the typical networks I am working with usually involve approx. 100 nodes and 250 edges.

Do you have any idea whether this issue comes from vis.js or visNetwork?

Do you need more information on the issue?

Best regards,

Olivier

olivier7121 commented 3 years ago

visNetwork.zip I attach to this message a zip file containing network data where this issue occurred, as well as the reproducible example provided below:



RequiredLibraries2Install <- RequiredLibraries[!(RequiredLibraries %in% installed.packages()[, "Package"])]

if(length(RequiredLibraries2Install))   install.packages(RequiredLibraries2Install, dependencies = TRUE)

lapply(RequiredLibraries, library, character.only = TRUE)

Nodes <- fread(file = file.path(".", "Issue with edges tooltips", "Nodes.csv"), header = TRUE, na.strings = NULL)
Links <- fread(file = file.path(".", "Issue with edges tooltips", "Links.csv"), header = TRUE, na.strings = NULL)

ui <- fluidPage(
    titlePanel(windowTitle = "Application Title", title = "Application Title"),

    mainPanel(
        tabsetPanel(type = "tabs",
            tabPanel("Network",
                visNetworkOutput(outputId = "Network", width = "100%", height = "75vh")
            ),
            tabPanel(actionLink(inputId = "Download.Network.Data", label = "Download current network data", icon = icon(name = "download", class = NULL, lib = "font-awesome"))
            )
        ),
        width = 10
    )
)

server <- function(input, output, session)
{
    GenerateNetwork <- function()
    {
        visNetwork(Nodes, Links, width = "100%", height = "100%", main = "NetworkTitle") %>%
            visInteraction(navigationButtons = TRUE, keyboard = TRUE) %>%
            visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE, selectedBy = "Undertaking.DetailedType") %>%
            visPhysics(stabilization = TRUE) %>%
            #visLegend(addNodes = Legend.Nodes, addEdges = Legend.Links, useGroups = FALSE, width = 0.25, position = "right", main = "Network Legend", ncol = 1) %>%
            visLayout(randomSeed = 123)
    }

    output$Network <- renderVisNetwork(GenerateNetwork())
}

runApp(list(ui = ui, server = server), launch.browser = TRUE)```