Browse Source

- Fixed #1358: Fixed example for clustering on zoom. Also removed private keyword from public methods. Let physics listen to data updates instead of being called from network.

fixDataView
Alex de Mulder 8 years ago
parent
commit
410f83aa38
8 changed files with 17 additions and 35 deletions
  1. +1
    -0
      HISTORY.md
  2. +5
    -17
      dist/vis.js
  3. +5
    -1
      examples/network/other/clusteringByZoom.html
  4. +0
    -1
      lib/network/Network.js
  5. +0
    -1
      lib/network/modules/Clustering.js
  6. +0
    -10
      lib/network/modules/ManipulationSystem.js
  7. +6
    -1
      lib/network/modules/PhysicsEngine.js
  8. +0
    -4
      lib/network/modules/SelectionHandler.js

+ 1
- 0
HISTORY.md View File

@ -19,6 +19,7 @@ http://visjs.org
- Fixed #1362: Layout of hierarchicaly systems no longer overlaps NODES. - Fixed #1362: Layout of hierarchicaly systems no longer overlaps NODES.
- Fixed #1414: Fixed color references for nodes and edges. - Fixed #1414: Fixed color references for nodes and edges.
- Fixed #1408: Unclustering without release function respects fixed positions now. - Fixed #1408: Unclustering without release function respects fixed positions now.
- Fixed #1358: Fixed example for clustering on zoom.
### Timeline ### Timeline

+ 5
- 17
dist/vis.js View File

@ -27312,7 +27312,6 @@ return /******/ (function(modules) { // webpackBootstrap
this.body.emitter.on("_dataChanged", function () { this.body.emitter.on("_dataChanged", function () {
// update shortcut lists // update shortcut lists
_this3._updateVisibleIndices(); _this3._updateVisibleIndices();
_this3.physics.updatePhysicsData();
_this3.body.emitter.emit("_requestRedraw"); _this3.body.emitter.emit("_requestRedraw");
// call the dataUpdated event because the only difference between the two is the updating of the indices // call the dataUpdated event because the only difference between the two is the updating of the indices
_this3.body.emitter.emit("_dataUpdated"); _this3.body.emitter.emit("_dataUpdated");
@ -33394,6 +33393,11 @@ return /******/ (function(modules) { // webpackBootstrap
_this.stopSimulation(false); _this.stopSimulation(false);
_this.body.emitter.off(); _this.body.emitter.off();
}); });
// this event will trigger a rebuilding of the cache everything. Used when nodes or edges have been added or removed.
this.body.emitter.on("_dataChanged", function () {
// update shortcut lists
_this.updatePhysicsData();
});
} }
/** /**
@ -33886,7 +33890,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* Find a stable position for all nodes * Find a stable position for all nodes
* @private
*/ */
}, { }, {
key: 'stabilize', key: 'stabilize',
@ -35887,7 +35890,6 @@ return /******/ (function(modules) { // webpackBootstrap
* Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node * Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node
* @param nodeId * @param nodeId
* @returns {Array} * @returns {Array}
* @private
*/ */
}, { }, {
key: 'findNode', key: 'findNode',
@ -38711,7 +38713,6 @@ return /******/ (function(modules) { // webpackBootstrap
* *
* @param {{x: Number, y: Number}} pointer * @param {{x: Number, y: Number}} pointer
* @return {Node | undefined} node * @return {Node | undefined} node
* @private
*/ */
}, { }, {
key: "getNodeAt", key: "getNodeAt",
@ -38772,7 +38773,6 @@ return /******/ (function(modules) { // webpackBootstrap
* *
* @param pointer * @param pointer
* @returns {undefined} * @returns {undefined}
* @private
*/ */
}, { }, {
key: "getEdgeAt", key: "getEdgeAt",
@ -38844,8 +38844,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* Unselect all. The selectionObj is useful for this. * Unselect all. The selectionObj is useful for this.
*
* @private
*/ */
}, { }, {
key: "unselectAll", key: "unselectAll",
@ -40167,8 +40165,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* Create the toolbar for adding Nodes * Create the toolbar for adding Nodes
*
* @private
*/ */
}, { }, {
key: 'addNodeMode', key: 'addNodeMode',
@ -40198,8 +40194,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* call the bound function to handle the editing of the node. The node has to be selected. * call the bound function to handle the editing of the node. The node has to be selected.
*
* @private
*/ */
}, { }, {
key: 'editNode', key: 'editNode',
@ -40246,8 +40240,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* create the toolbar to connect nodes * create the toolbar to connect nodes
*
* @private
*/ */
}, { }, {
key: 'addEdgeMode', key: 'addEdgeMode',
@ -40284,8 +40276,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* create the toolbar to edit edges * create the toolbar to edit edges
*
* @private
*/ */
}, { }, {
key: 'editEdgeMode', key: 'editEdgeMode',
@ -40361,8 +40351,6 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* delete everything in the selection * delete everything in the selection
*
* @private
*/ */
}, { }, {
key: 'deleteSelected', key: 'deleteSelected',

+ 5
- 1
examples/network/other/clusteringByZoom.html View File

@ -72,7 +72,7 @@ Stabilize when clustering:
nodes: nodes, nodes: nodes,
edges: edges edges: edges
}; };
var options = {layout: {randomSeed: 8}};
var options = {layout: {randomSeed: 8}, physics:{adaptiveTimestep:false}};
var network = new vis.Network(container, data, options); var network = new vis.Network(container, data, options);
// set the first initial zoom level // set the first initial zoom level
@ -125,6 +125,8 @@ Stabilize when clustering:
} }
network.clusterOutliers(clusterOptionsByData); network.clusterOutliers(clusterOptionsByData);
if (document.getElementById('stabilizeCheckbox').checked === true) { if (document.getElementById('stabilizeCheckbox').checked === true) {
// since we use the scale as a unique identifier, we do NOT want to fit after the stabilization
network.setOptions({physics:{stabilization:{fit: false}}});
network.stabilize(); network.stabilize();
} }
} }
@ -145,6 +147,8 @@ Stabilize when clustering:
} }
clusters = newClusters; clusters = newClusters;
if (declustered === true && document.getElementById('stabilizeCheckbox').checked === true) { if (declustered === true && document.getElementById('stabilizeCheckbox').checked === true) {
// since we use the scale as a unique identifier, we do NOT want to fit after the stabilization
network.setOptions({physics:{stabilization:{fit: false}}});
network.stabilize(); network.stabilize();
} }
} }

+ 0
- 1
lib/network/Network.js View File

@ -270,7 +270,6 @@ Network.prototype.bindEventListeners = function () {
this.body.emitter.on("_dataChanged", () => { this.body.emitter.on("_dataChanged", () => {
// update shortcut lists // update shortcut lists
this._updateVisibleIndices(); this._updateVisibleIndices();
this.physics.updatePhysicsData();
this.body.emitter.emit("_requestRedraw"); this.body.emitter.emit("_requestRedraw");
// call the dataUpdated event because the only difference between the two is the updating of the indices // call the dataUpdated event because the only difference between the two is the updating of the indices
this.body.emitter.emit("_dataUpdated"); this.body.emitter.emit("_dataUpdated");

+ 0
- 1
lib/network/modules/Clustering.js View File

@ -686,7 +686,6 @@ class ClusterEngine {
* Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node * Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node
* @param nodeId * @param nodeId
* @returns {Array} * @returns {Array}
* @private
*/ */
findNode(nodeId) { findNode(nodeId) {
let stack = []; let stack = [];

+ 0
- 10
lib/network/modules/ManipulationSystem.js View File

@ -221,8 +221,6 @@ class ManipulationSystem {
/** /**
* Create the toolbar for adding Nodes * Create the toolbar for adding Nodes
*
* @private
*/ */
addNodeMode() { addNodeMode() {
// when using the gui, enable edit mode if it wasnt already. // when using the gui, enable edit mode if it wasnt already.
@ -250,8 +248,6 @@ class ManipulationSystem {
/** /**
* call the bound function to handle the editing of the node. The node has to be selected. * call the bound function to handle the editing of the node. The node has to be selected.
*
* @private
*/ */
editNode() { editNode() {
// when using the gui, enable edit mode if it wasnt already. // when using the gui, enable edit mode if it wasnt already.
@ -298,8 +294,6 @@ class ManipulationSystem {
/** /**
* create the toolbar to connect nodes * create the toolbar to connect nodes
*
* @private
*/ */
addEdgeMode() { addEdgeMode() {
// when using the gui, enable edit mode if it wasnt already. // when using the gui, enable edit mode if it wasnt already.
@ -334,8 +328,6 @@ class ManipulationSystem {
/** /**
* create the toolbar to edit edges * create the toolbar to edit edges
*
* @private
*/ */
editEdgeMode() { editEdgeMode() {
// when using the gui, enable edit mode if it wasnt already. // when using the gui, enable edit mode if it wasnt already.
@ -406,8 +398,6 @@ class ManipulationSystem {
/** /**
* delete everything in the selection * delete everything in the selection
*
* @private
*/ */
deleteSelected() { deleteSelected() {
// when using the gui, enable edit mode if it wasnt already. // when using the gui, enable edit mode if it wasnt already.

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

@ -112,6 +112,12 @@ class PhysicsEngine {
this.stopSimulation(false); this.stopSimulation(false);
this.body.emitter.off(); this.body.emitter.off();
}); });
// this event will trigger a rebuilding of the cache everything. Used when nodes or edges have been added or removed.
this.body.emitter.on("_dataChanged", () => {
// update shortcut lists
this.updatePhysicsData();
});
} }
@ -587,7 +593,6 @@ class PhysicsEngine {
/** /**
* Find a stable position for all nodes * Find a stable position for all nodes
* @private
*/ */
stabilize(iterations = this.options.stabilization.iterations) { stabilize(iterations = this.options.stabilization.iterations) {
if (typeof iterations !== 'number') { if (typeof iterations !== 'number') {

+ 0
- 4
lib/network/modules/SelectionHandler.js View File

@ -159,7 +159,6 @@ class SelectionHandler {
* *
* @param {{x: Number, y: Number}} pointer * @param {{x: Number, y: Number}} pointer
* @return {Node | undefined} node * @return {Node | undefined} node
* @private
*/ */
getNodeAt(pointer, returnNode = true) { getNodeAt(pointer, returnNode = true) {
// we first check if this is an navigation controls element // we first check if this is an navigation controls element
@ -217,7 +216,6 @@ class SelectionHandler {
* *
* @param pointer * @param pointer
* @returns {undefined} * @returns {undefined}
* @private
*/ */
getEdgeAt(pointer, returnEdge = true) { getEdgeAt(pointer, returnEdge = true) {
let positionObject = this._pointerToPositionObject(pointer); let positionObject = this._pointerToPositionObject(pointer);
@ -286,8 +284,6 @@ class SelectionHandler {
/** /**
* Unselect all. The selectionObj is useful for this. * Unselect all. The selectionObj is useful for this.
*
* @private
*/ */
unselectAll() { unselectAll() {
for(let nodeId in this.selectionObj.nodes) { for(let nodeId in this.selectionObj.nodes) {

Loading…
Cancel
Save