datastorm-open / visNetwork

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

Show label in hidden node #417

Open dmenne opened 2 years ago

dmenne commented 2 years ago

clss

In some cases, the label in hidden modes is visible as in the middle node. In most cases, it is not as in the bottom node. I have not yet found out how I could force the "label-visible" in all hidden nodes. Below my visOptions settings:


highlightNearest = list(
              algorithm = "hierarchical",
              hover = TRUE,
              labelOnly = TRUE,
              enabled = TRUE,
              degree = 3
              ),
dmenne commented 2 years ago

Trying again... I would like to leave the node text visible in the de-highlighted branch. The example comes closes to the required look (label 2 is visible) when I click on node 5.

Rplot


library(visNetwork)
library(magrittr)

n = 5
nodes = data.frame(id = 1:n, label = paste(1:n))
edges = data.frame(from = c(1,2,1,3), to = c(2, 4, 3, 5),
                  font.size = 14
)

visNetwork(nodes, edges) %>% 
  visOptions(
    highlightNearest = list(
      algorithm = "hierarchical",
      enabled = TRUE,
      degree = 2
    )) %>% 
  visNodes(
    shape = "box",
    widthConstraint = 50,
    heightConstraint = 20,
    font = list(size = 16)
  )  %>%
  visHierarchicalLayout(
    sortMethod = "directed"
  )
bthieurmel commented 2 years ago

Hi,

It's not possible at moment... Thinking about a more flexible option of labelOnly

poxiaostudent commented 1 year ago

Trying again... I would like to leave the node text visible in the de-highlighted branch. The example comes closes to the required look (label 2 is visible) when I click on node 5.

Rplot

library(visNetwork)
library(magrittr)

n = 5
nodes = data.frame(id = 1:n, label = paste(1:n))
edges = data.frame(from = c(1,2,1,3), to = c(2, 4, 3, 5),
                  font.size = 14
)

visNetwork(nodes, edges) %>% 
  visOptions(
    highlightNearest = list(
      algorithm = "hierarchical",
      enabled = TRUE,
      degree = 2
    )) %>% 
  visNodes(
    shape = "box",
    widthConstraint = 50,
    heightConstraint = 20,
    font = list(size = 16)
  )  %>%
  visHierarchicalLayout(
    sortMethod = "directed"
  )

excuse me! How can I set the label of nodes into the nodes in the VisNetwork of R