1

Is it possible to use expression for subscript or superscript at the node label in vis network? Or is it possible to change the label after the plot?

 nodes <- data.frame(id = 1:10,

                # add labels on nodes
                label = paste("N[", 1:10,"]", sep = ""),

                # add groups on nodes 
                group = c("GrA", "GrB"),

                # size adding value
                value = 1:10,          

                # control shape of nodes
                shape = c("square", "triangle", "box", "circle", "dot", "star",
                          "ellipse", "database", "text", "diamond"),

                # tooltip (html or character), when the mouse is above
                title = paste0("<p><b>", 1:10,"</b><br>Node !</p>"),

                # color
                color = c("darkred", "grey", "orange", "darkblue", "purple"),

                # shadow
                shadow = c(FALSE, TRUE, FALSE, TRUE, TRUE))             

# head(nodes)
# id  label group value    shape                     title    color shadow
#  1 Node 1   GrA     1   square <p><b>1</b><br>Node !</p>  darkred  FALSE
#  2 Node 2   GrB     2 triangle <p><b>2</b><br>Node !</p>     grey   TRUE

edges <- data.frame(from = c(1,2,5,7,8,10), to = c(9,3,1,6,4,7))

visNetwork(nodes, edges, height = "500px", width = "100%")
mjberlin15
  • 147
  • 1
  • 10
  • I don't see any passage of text to plotmath or html processing in the code. Experimenting with ` ...` failed. Experimenting with R expressions failed. Looks like you would need to hack the code so that you could apply the lessons of this SO Q&A: https://stackoverflow.com/questions/45537398/render-sub-superscript-in-table-shiny – IRTFM Oct 11 '18 at 23:28
  • And see ... and this material: http://datastorm-open.github.io/visNetwork/shiny.html – IRTFM Oct 11 '18 at 23:33
  • Yes, that's right. I will update the answer when I solve it. Thanks – mjberlin15 Oct 12 '18 at 16:57

0 Answers0