AS in the title, I'm using "vis": "^4.21.0-EOL" in the dependencies, and "@types/vis": "^4.21.24". Everything works well, aside editing/changing certain things, like changing color of existing nodes
node.color.background = '#0BB176'
I get an error saying that background doesn't exist.
Default Color
A default background color for nodes can be set in the network options, such as:
Individual Nodes
Individual nodes then then override this with their own colors, such as:
Updating Individual Nodes
If you've already got a nodes DataSet defined and you'd like to update the color of an existing node, then you'll need to use the DataSet
updatemethod. More detail on this method can be found in the documentation here.For example to update node 1 to a new background color you could call update like:
As described in the documentation the provided properties are merged into the current properties, so there is no need to provide the full object with all properties (e.g. label is kept even though it's not provided).
Vis.js Version
Please note the vis.js package mentioned in the question is deprecated as per https://www.npmjs.com/package/vis. They suggest moving to the new package https://www.npmjs.com/package/vis-network. This functionality works the same for both packages, however the newer version has extra methods such as
updateOnlywhich is sometimes more suitable as described here.Example
Code snippet below, using the depreciated vis.js package, click the button to update an exisitng node: