Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Network : Node color overriden by group color #3713

Open
christellenetwork opened this issue Dec 7, 2017 · 4 comments
Open

Network : Node color overriden by group color #3713

christellenetwork opened this issue Dec 7, 2017 · 4 comments

Comments

@christellenetwork
Copy link

christellenetwork commented Dec 7, 2017

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

@christellenetwork christellenetwork changed the title Node color overriden by group color when groups not defined Network : Node color overriden by group color when groups not defined Dec 7, 2017
@christellenetwork christellenetwork changed the title Network : Node color overriden by group color when groups not defined Network : Node color overriden by group color Dec 7, 2017
@christellenetwork
Copy link
Author

In fact it is always overriden by group color, it should keep custom color defined in node config.

@p1erce2023
Copy link

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

Node specific styling overrides group styling.

in node doc.

BTW, 4.20.1 is right on this.

yotamberk pushed a commit that referenced this issue Mar 31, 2018
* 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
@jcc10
Copy link

jcc10 commented Aug 4, 2018

Would it be possible to only override colors that are set IE:

// not-proper-code
group: {colors: {background: 'green', border:'darkgreen'}}
node: {colors: {border:'gold'}}

having the border of that be gold but still having a green background.

@jcc10
Copy link

jcc10 commented Aug 4, 2018

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.

mojoaxel pushed a commit to visjs/vis_original that referenced this issue Jun 9, 2019
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants