Browse Source

altered behaviour of groups, properties are now extended instead of copied. #477

v3_develop
Alex de Mulder 10 years ago
parent
commit
3a27e55c3a
4 changed files with 27 additions and 21 deletions
  1. +3
    -9
      dist/vis.js
  2. +21
    -3
      examples/network/01_basic_usage.html
  3. +0
    -3
      lib/network/Groups.js
  4. +3
    -6
      lib/network/Node.js

+ 3
- 9
dist/vis.js View File

@ -26104,9 +26104,6 @@ return /******/ (function(modules) { // webpackBootstrap
*/ */
Groups.prototype.add = function (groupname, style) { Groups.prototype.add = function (groupname, style) {
this.groups[groupname] = style; this.groups[groupname] = style;
if (style.color) {
style.color = util.parseColor(style.color);
}
return style; return style;
}; };
@ -26343,12 +26340,9 @@ return /******/ (function(modules) { // webpackBootstrap
// copy group properties // copy group properties
if (typeof this.options.group === 'number' || (typeof this.options.group === 'string' && this.options.group != '')) { if (typeof this.options.group === 'number' || (typeof this.options.group === 'string' && this.options.group != '')) {
var groupObj = this.grouplist.get(this.options.group); var groupObj = this.grouplist.get(this.options.group);
for (var prop in groupObj) {
if (groupObj.hasOwnProperty(prop)) {
this.options[prop] = groupObj[prop];
}
}
console.log(this.options)
util.deepExtend(this.options, groupObj);
// the color object needs to be completely defined. Since groups can partially overwrite the colors, we parse it again, just in case.
this.options.color = util.parseColor(this.options.color);
} }
else if (properties.color === undefined) { else if (properties.color === undefined) {
this.options.color = constants.nodes.color; this.options.color = constants.nodes.color;

+ 21
- 3
examples/network/01_basic_usage.html View File

@ -22,8 +22,8 @@
<script type="text/javascript"> <script type="text/javascript">
// create an array with nodes // create an array with nodes
var nodes = [ var nodes = [
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2'},
{id: 1, label: 'Node 1', group: 'mygroup1'},
{id: 2, label: 'Node 2', group: 'mygroup1'},
{id: 3, label: 'Node 3'}, {id: 3, label: 'Node 3'},
{id: 4, label: 'Node 4'}, {id: 4, label: 'Node 4'},
{id: 5, label: 'Node 5'} {id: 5, label: 'Node 5'}
@ -43,9 +43,27 @@
nodes: nodes, nodes: nodes,
edges: edges edges: edges
}; };
var options = {};
var options = {
width: '400px',
height: '400px',
hover: true,
groups: {
mygroup1: {
color: {
hover: {
background: 'red',
border: 'red'
},
highlight: 'green'
},
shape: 'box'
}
}
};
var network = new vis.Network(container, data, options); var network = new vis.Network(container, data, options);
</script> </script>
</body> </body>
</html> </html>

+ 0
- 3
lib/network/Groups.js View File

@ -74,9 +74,6 @@ Groups.prototype.get = function (groupname) {
*/ */
Groups.prototype.add = function (groupname, style) { Groups.prototype.add = function (groupname, style) {
this.groups[groupname] = style; this.groups[groupname] = style;
if (style.color) {
style.color = util.parseColor(style.color);
}
return style; return style;
}; };

+ 3
- 6
lib/network/Node.js View File

@ -166,12 +166,9 @@ Node.prototype.setProperties = function(properties, constants) {
// copy group properties // copy group properties
if (typeof this.options.group === 'number' || (typeof this.options.group === 'string' && this.options.group != '')) { if (typeof this.options.group === 'number' || (typeof this.options.group === 'string' && this.options.group != '')) {
var groupObj = this.grouplist.get(this.options.group); var groupObj = this.grouplist.get(this.options.group);
for (var prop in groupObj) {
if (groupObj.hasOwnProperty(prop)) {
this.options[prop] = groupObj[prop];
}
}
console.log(this.options)
util.deepExtend(this.options, groupObj);
// the color object needs to be completely defined. Since groups can partially overwrite the colors, we parse it again, just in case.
this.options.color = util.parseColor(this.options.color);
} }
else if (properties.color === undefined) { else if (properties.color === undefined) {
this.options.color = constants.nodes.color; this.options.color = constants.nodes.color;

Loading…
Cancel
Save