Browse Source

- Fixed dataView support for storePositions

flowchartTest
Alex de Mulder 9 years ago
parent
commit
5b1aecffd7
3 changed files with 29821 additions and 29817 deletions
  1. +29808
    -29806
      dist/vis.js
  2. +7
    -7
      lib/network/modules/ManipulationSystem.js
  3. +6
    -4
      lib/network/modules/NodesHandler.js

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


+ 7
- 7
lib/network/modules/ManipulationSystem.js View File

@ -273,7 +273,7 @@ class ManipulationSystem {
if (this.options.editNode.length === 2) { if (this.options.editNode.length === 2) {
this.options.editNode(data, (finalizedData) => { this.options.editNode(data, (finalizedData) => {
if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'editNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) { if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'editNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {
this.body.data.nodes.update(finalizedData);
this.body.data.nodes.getDataSet().update(finalizedData);
} }
this.showManipulatorToolbar(); this.showManipulatorToolbar();
}); });
@ -448,8 +448,8 @@ class ManipulationSystem {
if (deleteFunction.length === 2) { if (deleteFunction.length === 2) {
deleteFunction(data, (finalizedData) => { deleteFunction(data, (finalizedData) => {
if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'delete') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) { if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'delete') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {
this.body.data.edges.remove(finalizedData.edges);
this.body.data.nodes.remove(finalizedData.nodes);
this.body.data.edges.getDataSet().remove(finalizedData.edges);
this.body.data.nodes.getDataSet().remove(finalizedData.nodes);
this.body.emitter.emit('startSimulation'); this.body.emitter.emit('startSimulation');
this.showManipulatorToolbar(); this.showManipulatorToolbar();
} }
@ -460,8 +460,8 @@ class ManipulationSystem {
} }
} }
else { else {
this.body.data.edges.remove(selectedEdges);
this.body.data.nodes.remove(selectedNodes);
this.body.data.edges.getDataSet().remove(selectedEdges);
this.body.data.nodes.getDataSet().remove(selectedNodes);
this.body.emitter.emit('startSimulation'); this.body.emitter.emit('startSimulation');
this.showManipulatorToolbar(); this.showManipulatorToolbar();
} }
@ -1053,7 +1053,7 @@ class ManipulationSystem {
if (this.options.addNode.length === 2) { if (this.options.addNode.length === 2) {
this.options.addNode(defaultData, (finalizedData) => { this.options.addNode(defaultData, (finalizedData) => {
if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'addNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'addNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback
this.body.data.nodes.add(finalizedData);
this.body.data.nodes.getDataSet().add(finalizedData);
this.showManipulatorToolbar(); this.showManipulatorToolbar();
} }
}); });
@ -1064,7 +1064,7 @@ class ManipulationSystem {
} }
} }
else { else {
this.body.data.nodes.add(defaultData);
this.body.data.nodes.getDataSet().add(defaultData);
this.showManipulatorToolbar(); this.showManipulatorToolbar();
} }
} }

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

@ -342,15 +342,17 @@ class NodesHandler {
storePositions() { storePositions() {
// todo: add support for clusters and hierarchical. // todo: add support for clusters and hierarchical.
let dataArray = []; let dataArray = [];
for (let nodeId in this.body.data.nodes._data) {
if (this.body.data.nodes._data.hasOwnProperty(nodeId)) {
var dataset = this.body.data.nodes.getDataSet();
for (let nodeId in dataset._data) {
if (dataset._data.hasOwnProperty(nodeId)) {
let node = this.body.nodes[nodeId]; let node = this.body.nodes[nodeId];
if (this.body.data.nodes._data[nodeId].x != Math.round(node.x) || this.body.data.nodes._data[nodeId].y != Math.round(node.y)) {
if (dataset._data[nodeId].x != Math.round(node.x) || dataset._data[nodeId].y != Math.round(node.y)) {
dataArray.push({id:nodeId,x:Math.round(node.x),y:Math.round(node.y)}); dataArray.push({id:nodeId,x:Math.round(node.x),y:Math.round(node.y)});
} }
} }
} }
this.body.data.nodes.update(dataArray);
dataset.update(dataArray);
} }
/** /**

Loading…
Cancel
Save