Skip to content

visOptions - selectedBy no longer works when the variable name contains a dot #478

@olivier7121

Description

@olivier7121

Thank you for this great package!

I recently came across this bug: When the name of the variable from the argument selectedBy within the visOptions function contains a dot (.), the selected group is no longer displayed, instead the whole network is just greyed out, no single node is highlighted.

Below is a simple reprex:

library(visNetwork)

nodes <- jsonlite::fromJSON("https://raw.githubusercontent.com/datastorm-open/datastorm-open.github.io/master/visNetwork/data/nodes_miserables.json")
edges <- jsonlite::fromJSON("https://raw.githubusercontent.com/datastorm-open/datastorm-open.github.io/master/visNetwork/data/edges_miserables.json")

nodes$group_copy <- nodes$group
nodes$group.copy <- nodes$group

# 1. With underscore 'group_copy' - Works as intended
visNetwork(nodes, edges, height = "700px", width = "100%") %>%
	visInteraction(navigationButtons = TRUE, keyboard = TRUE) %>%
	visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE, selectedBy = "group_copy") %>%
	visPhysics(stabilization = TRUE) %>%
	visLayout(randomSeed = 123)

# 2. With dot 'group.copy' - Doesn't work
visNetwork(nodes, edges, height = "700px", width = "100%") %>%
	visInteraction(navigationButtons = TRUE, keyboard = TRUE) %>%
	visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE, selectedBy = "group.copy") %>%
	visPhysics(stabilization = TRUE) %>%
	visLayout(randomSeed = 123)

# 3. With dot 'group.copy' and list parameter - Still doesn't work
visNetwork(nodes, edges, height = "700px", width = "100%") %>%
	visInteraction(navigationButtons = TRUE, keyboard = TRUE) %>%
	visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE, selectedBy = list(variable = "group.copy")) %>%
	visPhysics(stabilization = TRUE) %>%
	visLayout(randomSeed = 123)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions