-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Network : Node color overriden by group color #3713
Comments
In fact it is always overriden by group color, it should keep custom color defined in node config. |
same problem here in https://jsfiddle.net/dfkep0pk/, basically the code in example http://visjs.org/examples/network/nodeStyles/groups.html, but only change two node color. does not override, though
in node doc. BTW, 4.20.1 is right on this. |
Would it be possible to only override colors that are set IE:
having the border of that be gold but still having a green background. |
Could a possible fix be something like this StackOverflow post? This would merge the group object with the node object overwriting settings from the group with the ones in the node (If they exist.) This could potentially allow for multiple groups that cascade using a array. (With later items over-writing earlier ones.) Edit: This could also allow for other kinds of data to be added to groups. |
* Checks if color is not defined at node level before overriding it with the Group color * Checking if newOptions is not undefined before checking for color property
Hi,
When defining color for a node which has a "group" option, color gets overriden by said group if group is not defined in options.
Example using network example found on http://visjs.org/examples/network/edgeStyles/colors.html :
I just add a group to node 1 which causes the node to appear blue instead of red.
`// create an array with nodes
var nodes = new vis.DataSet([
{id: 1, label: 'node\none', group:'test', shape: 'box', color:'red'},
{id: 2, label: 'node\ntwo', shape: 'circle', color:'#FFFF00'},
{id: 3, label: 'node\nthree', shape: 'diamond', color:'#FB7E81'},
{id: 4, label: 'node\nfour', shape: 'dot', size: 10, color:'#7BE141'},
{id: 5, label: 'node\nfive', shape: 'ellipse', color:'#6E6EFD'},
{id: 6, label: 'node\nsix', shape: 'star', color:'#C2FABC'},
{id: 7, label: 'node\nseven', shape: 'triangle', color:'#FFA807'},
{id: 8, label: 'node\neight', shape: 'triangleDown', color:'#6E6EFD'}
]);
// create an array with edges
var edges = new vis.DataSet([
{from: 1, to: 8, color:{color:'red'}},
{from: 1, to: 3, color:'rgb(20,24,200)'},
{from: 1, to: 2, color:{color:'rgba(30,30,30,0.2)', highlight:'blue'}},
{from: 2, to: 4, color:{inherit:'to'}},
{from: 2, to: 5, color:{inherit:'from'}},
{from: 5, to: 6, color:{inherit:'both'}},
{from: 6, to: 7, color:{color:'#ff0000', opacity:0.3}},
{from: 6, to: 8, color:{opacity:0.3}},
]);
// create a network
var container = document.getElementById('mynetwork');
var data = {
nodes: nodes,
edges: edges
};
var options = {
nodes: {
shape: 'circle'
}
};
var network = new vis.Network(container, data, options);`
Thank you
The text was updated successfully, but these errors were encountered: