How have labels inside the scaled nodes in visNetwork?

I've found another way, adding spaces on bot sides of the label.
That will keep all fonts the same size.

n <- 5L
nodes <- data.frame(id = 1:3, label=paste0(strrep(" ",n), 2014:2016,
strrep(" ",n)) ,value=1:3,shape='circle')
edges <- data.frame(from = c(1,2), to = c(1,3))
visNetwork(nodes, edges, width = "100%")

enter image description here

If the length of the labels is not the same you may want to try other criteria.


I found a tricky way to solve this bug. setting up font.size instead of value property works fine. You need to scale it for best visualization. For instance I scale it 10 times bigger:

require(visNetwork, quietly = TRUE)
nodes <- data.frame(id = 1:3, label=2014:2016 ,font.size =(1:3)*10,shape='circle')
edges <- data.frame(from = c(1,2), to = c(1,3))
visNetwork(nodes, edges, width = "100%")

enter image description here

Tags:

Graph

R