Browse Source

more bugfixes, setOptions now propagates shapes, smooth and font options when set globally.

flowchartTest
Alex de Mulder 9 years ago
parent
commit
eec31b0d86
8 changed files with 7227 additions and 7124 deletions
  1. +7166
    -7112
      dist/vis.js
  2. +2
    -1
      examples/network/01_basic_usage.html
  3. +4
    -3
      lib/network/modules/ConfigurationSystem.js
  4. +23
    -1
      lib/network/modules/EdgesHandler.js
  5. +15
    -0
      lib/network/modules/NodesHandler.js
  6. +6
    -4
      lib/network/modules/PhysicsEngine.js
  7. +6
    -1
      lib/network/modules/components/Edge.js
  8. +5
    -2
      lib/network/modules/components/Node.js

+ 7166
- 7112
dist/vis.js
File diff suppressed because it is too large
View File


+ 2
- 1
examples/network/01_basic_usage.html View File

@ -46,7 +46,8 @@
}; };
var options = { var options = {
configure: true, configure: true,
physics:{solver:'BarnesHut'}
physics:{solver:'BarnesHut'},
// nodes:{physics:false}
} }
var network = new vis.Network(container, data, options); var network = new vis.Network(container, data, options);
// network.setOptions({nodes:{color:'red'}}) // network.setOptions({nodes:{color:'red'}})

+ 4
- 3
lib/network/modules/ConfigurationSystem.js View File

@ -467,8 +467,8 @@ class ConfigurationSystem {
if (value * 0.1 < min) { if (value * 0.1 < min) {
range.min = value / 10; range.min = value / 10;
} }
if (value * 10 > max && max !== 1) {
range.max = value * 10;
if (value * 2 > max && max !== 1) {
range.max = value * 2;
} }
range.value = value; range.value = value;
} }
@ -505,7 +505,7 @@ class ConfigurationSystem {
} }
let me = this; let me = this;
checkbox.onchange = function() {me._update(this.value, path)};
checkbox.onchange = function() {me._update(this.checked, path)};
let label = this._makeLabel(path[path.length-1], path); let label = this._makeLabel(path[path.length-1], path);
this._makeEntree(path, label, checkbox); this._makeEntree(path, label, checkbox);
@ -653,6 +653,7 @@ class ConfigurationSystem {
pointer[path[i]] = value; pointer[path[i]] = value;
} }
} }
console.log(JSON.stringify(options))
this.network.setOptions(options); this.network.setOptions(options);
} }
} }

+ 23
- 1
lib/network/modules/EdgesHandler.js View File

@ -167,7 +167,29 @@ class EdgesHandler {
util.mergeOptions(this.options.color, options.color, 'inherit'); util.mergeOptions(this.options.color, options.color, 'inherit');
} }
// font cases are handled by the Label class
// update smooth settings
let dataChanged = false;
if (options.smooth !== undefined) {
for (let nodeId in this.body.edges) {
if (this.body.edges.hasOwnProperty(nodeId)) {
dataChanged = this.body.edges[nodeId].updateEdgeType() || dataChanged;
}
}
}
// update fonts
if (options.font) {
for (let nodeId in this.body.edges) {
if (this.body.edges.hasOwnProperty(nodeId)) {
this.body.edges[nodeId].updateLabelModule();
}
}
}
// update the state of the variables if needed
if (options.hidden !== undefined || options.physics !== undefined || dataChanged === true) {
this.body.emitter.emit('_dataChanged');
}
} }
} }

+ 15
- 0
lib/network/modules/NodesHandler.js View File

@ -110,6 +110,7 @@ class NodesHandler {
if (parsedColor.hover.background !== undefined) {this.options.color.hover.background = parsedColor.hover.background;} if (parsedColor.hover.background !== undefined) {this.options.color.hover.background = parsedColor.hover.background;}
} }
// update the shape
if (options.shape !== undefined) { if (options.shape !== undefined) {
for (let nodeId in this.body.nodes) { for (let nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) { if (this.body.nodes.hasOwnProperty(nodeId)) {
@ -117,6 +118,20 @@ class NodesHandler {
} }
} }
} }
// update fonts
if (options.font) {
for (let nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
this.body.nodes[nodeId].updateLabelModule();
}
}
}
// update the state of the variables if needed
if (options.hidden !== undefined || options.physics !== undefined) {
this.body.emitter.emit('_dataChanged');
}
} }
} }

+ 6
- 4
lib/network/modules/PhysicsEngine.js View File

@ -288,10 +288,12 @@ class PhysicsEngine {
for (let i = 0; i < nodeIds.length; i++) { for (let i = 0; i < nodeIds.length; i++) {
let nodeId = nodeIds[i]; let nodeId = nodeIds[i];
if (nodes[nodeId] !== undefined) { if (nodes[nodeId] !== undefined) {
velocities[nodeId].x = this.previousStates[nodeId].vx;
velocities[nodeId].y = this.previousStates[nodeId].vy;
nodes[nodeId].x = this.previousStates[nodeId].x;
nodes[nodeId].y = this.previousStates[nodeId].y;
if (nodes[nodeId].options.physics === true) {
velocities[nodeId].x = this.previousStates[nodeId].vx;
velocities[nodeId].y = this.previousStates[nodeId].vy;
nodes[nodeId].x = this.previousStates[nodeId].x;
nodes[nodeId].y = this.previousStates[nodeId].y;
}
} }
else { else {
delete this.previousStates[nodeId]; delete this.previousStates[nodeId];

+ 6
- 1
lib/network/modules/components/Edge.js View File

@ -134,12 +134,17 @@ class Edge {
// A node is connected when it has a from and to node that both exist in the network.body.nodes. // A node is connected when it has a from and to node that both exist in the network.body.nodes.
this.connect(); this.connect();
this.labelModule.setOptions(this.options);
// update label Module
this.updateLabelModule();
let dataChanged = this.updateEdgeType(); let dataChanged = this.updateEdgeType();
return dataChanged; return dataChanged;
} }
updateLabelModule() {
this.labelModule.setOptions(this.options);
}
updateEdgeType() { updateEdgeType() {
let dataChanged = false; let dataChanged = false;
let changeInType = true; let changeInType = true;

+ 5
- 2
lib/network/modules/components/Node.js View File

@ -177,14 +177,17 @@ class Node {
} }
this.updateShape(); this.updateShape();
this.labelModule.setOptions(this.options, options);
this.updateLabelModule();
// reset the size of the node, this can be changed // reset the size of the node, this can be changed
this._reset(); this._reset();
} }
updateLabelModule() {
this.labelModule.setOptions(this.options);
}
updateShape() { updateShape() {
// choose draw method depending on the shape // choose draw method depending on the shape
switch (this.options.shape) { switch (this.options.shape) {

Loading…
Cancel
Save