diff --git a/dist/vis.js b/dist/vis.js index ca2cb679..2b0ce38c 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 4.8.2-SNAPSHOT - * @date 2015-09-11 + * @date 2015-09-13 * * @license * Copyright (C) 2011-2015 Almende B.V, http://almende.com @@ -29491,7 +29491,7 @@ return /******/ (function(modules) { // webpackBootstrap key: 'distanceToBorder', value: function distanceToBorder(ctx, angle) { this.resize(ctx); - return this._distanceToBorder(angle); + return this._distanceToBorder(ctx, angle); } }]); @@ -30054,8 +30054,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'distanceToBorder', value: function distanceToBorder(ctx, angle) { - this.resize(ctx); - return this._distanceToBorder(angle); + return this._distanceToBorder(ctx, angle); } }]); @@ -30341,8 +30340,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'distanceToBorder', value: function distanceToBorder(ctx, angle) { - this.resize(ctx); - return this._distanceToBorder(angle); + return this._distanceToBorder(ctx, angle); } }]); @@ -39242,28 +39240,31 @@ return /******/ (function(modules) { // webpackBootstrap // if less than half of the nodes have a predefined position we continue if (positionDefined < 0.5 * this.body.nodeIndices.length) { - var MAX_LEVELS = 200; - var levels = 0; + var MAX_LEVELS = 10; + var level = 0; var clusterThreshold = 100; // if there are a lot of nodes, we cluster before we run the algorithm. if (this.body.nodeIndices.length > clusterThreshold) { var startLength = this.body.nodeIndices.length; while (this.body.nodeIndices.length > clusterThreshold) { - levels += 1; + //console.time("clustering") + level += 1; var before = this.body.nodeIndices.length; // if there are many nodes we do a hubsize cluster - if (levels % 3 === 0) { + if (level % 3 === 0) { this.body.modules.clustering.clusterBridges(); } else { this.body.modules.clustering.clusterOutliers(); } var after = this.body.nodeIndices.length; - if (before == after && levels % 3 !== 0 || levels > MAX_LEVELS) { + if (before == after && level % 3 !== 0 || level > MAX_LEVELS) { this._declusterAll(); this.body.emitter.emit("_layoutFailed"); - console.info("This network could not be positioned by this version of the improved layout algorithm."); + console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance."); return; } + //console.timeEnd("clustering") + //console.log(level,after) } // increase the size of the edges this.body.modules.kamadaKawai.setOptions({ springLength: Math.max(150, 2 * startLength) }); diff --git a/lib/network/modules/LayoutEngine.js b/lib/network/modules/LayoutEngine.js index a3ce9f42..b38bc393 100644 --- a/lib/network/modules/LayoutEngine.js +++ b/lib/network/modules/LayoutEngine.js @@ -189,29 +189,32 @@ class LayoutEngine { // if less than half of the nodes have a predefined position we continue if (positionDefined < 0.5 * this.body.nodeIndices.length) { - let MAX_LEVELS = 200; - let levels = 0; + let MAX_LEVELS = 10; + let level = 0; let clusterThreshold = 100; // if there are a lot of nodes, we cluster before we run the algorithm. if (this.body.nodeIndices.length > clusterThreshold) { let startLength = this.body.nodeIndices.length; while (this.body.nodeIndices.length > clusterThreshold) { - levels += 1; + //console.time("clustering") + level += 1; let before = this.body.nodeIndices.length; // if there are many nodes we do a hubsize cluster - if (levels % 3 === 0) { + if (level % 3 === 0) { this.body.modules.clustering.clusterBridges(); } else { this.body.modules.clustering.clusterOutliers(); } let after = this.body.nodeIndices.length; - if ((before == after && levels % 3 !== 0) || levels > MAX_LEVELS) { + if ((before == after && level % 3 !== 0) || level > MAX_LEVELS) { this._declusterAll(); this.body.emitter.emit("_layoutFailed"); - console.info("This network could not be positioned by this version of the improved layout algorithm."); + console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance."); return; } + //console.timeEnd("clustering") + //console.log(level,after) } // increase the size of the edges this.body.modules.kamadaKawai.setOptions({springLength: Math.max(150, 2 * startLength)}) diff --git a/lib/network/modules/components/nodes/shapes/CircularImage.js b/lib/network/modules/components/nodes/shapes/CircularImage.js index 7b4121c0..494b9ac8 100644 --- a/lib/network/modules/components/nodes/shapes/CircularImage.js +++ b/lib/network/modules/components/nodes/shapes/CircularImage.js @@ -68,7 +68,7 @@ class CircularImage extends CircleImageBase { distanceToBorder(ctx, angle) { this.resize(ctx); - return this._distanceToBorder(angle); + return this._distanceToBorder(ctx,angle); } } diff --git a/lib/network/modules/components/nodes/shapes/Icon.js b/lib/network/modules/components/nodes/shapes/Icon.js index 183b0772..c01df052 100644 --- a/lib/network/modules/components/nodes/shapes/Icon.js +++ b/lib/network/modules/components/nodes/shapes/Icon.js @@ -75,8 +75,7 @@ class Icon extends NodeBase { } distanceToBorder(ctx, angle) { - this.resize(ctx); - return this._distanceToBorder(angle); + return this._distanceToBorder(ctx,angle); } } diff --git a/lib/network/modules/components/nodes/shapes/Text.js b/lib/network/modules/components/nodes/shapes/Text.js index 4f0fb81a..ac22dc5c 100644 --- a/lib/network/modules/components/nodes/shapes/Text.js +++ b/lib/network/modules/components/nodes/shapes/Text.js @@ -45,8 +45,7 @@ class Text extends NodeBase { } distanceToBorder(ctx, angle) { - this.resize(ctx); - return this._distanceToBorder(angle); + return this._distanceToBorder(ctx,angle); } } diff --git a/test/networkTest.html b/test/networkTest.html index e608bd61..4b335579 100644 --- a/test/networkTest.html +++ b/test/networkTest.html @@ -1,661 +1,122 @@ - + + - - - - - - -Reset causes crash + + Network | Static smooth curves - World Cup Network -
+    
+    
 
-When you press the button, the nodes dataset will receive an update which shall reset the font and color properties, instead, vis crashes :(
 
-(The browser console shows the details)
+    
+    
+
 
-
+ - +

Performance - World Cup Network

-
+
+ This example shows the performance of vis with a larger network. The edges in + particular (~9200) are very computationally intensive + to draw. Drag and hold the graph to see the performance difference if the + edges are hidden. +

+ We use the following physics configuration:
+ {barnesHut: {gravitationalConstant: -80000, springConstant: 0.001, + springLength: 200}} +

+
+
- \ No newline at end of file +