Git Product home page Git Product logo

Comments (1)

TimothyEbert avatar TimothyEbert commented on September 16, 2024

The following is a minimally reproducible example where I have removed all of the code that converts the raw data into node and edges. I have also left out code that adjusts the physics.

library(visNetwork)

Build nodes

nodes <- data.frame(
id=c("C", "G", "NP", "D", "E1", "E2"),
label=c("C", "G", "NP", "D", "E1", "E2"),
size = c(45.095856, 37.859089, 116.437705,
1.546333, 1.373999, 23.07729),
color.background = c("cyan", "blue", "brown4",
"lightgreen", "lightgreen", "lightgreen")
)

Build edges

edges <- data.frame(
to = c('C', 'C', 'C', 'D', 'D', 'E1', 'E1',
'E2', 'E2', 'G', 'G', 'NP'),
from = c('D', 'G', 'NP', 'C', 'E1',
'C', 'E2', 'C', 'E1', 'C', 'NP', 'C'),
width = c(5.135724, 5.629823, 13.597379, 12.25, 12.4,
15.97265, 6.712251, 10, 13.333333, 19.62963, 6.666667, 20),
arrows = "to",
font_multi = "html",
color = c('lightgreen', 'blue', 'brown4', 'cyan', 'lightgreen', 'cyan',
'lightgreen', 'cyan', 'lightgreen', 'cyan', 'brown4', 'cyan')
)
visNetwork(nodes, edges)

Code where color works

Build nodes

nodes <- data.frame(
id=c("C", "G", "NP", "D", "E1", "E2"),
label=c("C", "G", "NP", "D", "E1", "E2"),
size = c(45.095856, 37.859089, 116.437705,
1.546333, 1.373999, 23.07729),
color.background = c("cyan", "blue", "brown",
"lightgreen", "lightgreen", "lightgreen")
)

Build edges

edges <- data.frame(
to = c('C', 'C', 'C', 'D', 'D', 'E1', 'E1',
'E2', 'E2', 'G', 'G', 'NP'),
from = c('D', 'G', 'NP', 'C', 'E1',
'C', 'E2', 'C', 'E1', 'C', 'NP', 'C'),
width = c(5.135724, 5.629823, 13.597379, 12.25, 12.4,
15.97265, 6.712251, 10, 13.333333, 19.62963, 6.666667, 20),
arrows = "to",
font_multi = "html",
color = c('lightgreen', 'blue', 'brown', 'cyan', 'lightgreen', 'cyan',
'lightgreen', 'cyan', 'lightgreen', 'cyan', 'brown', 'cyan')
)
visNetwork(nodes, edges)

from visnetwork.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.