diff --git a/dist/vis.js b/dist/vis.js index a31e15f9..60217584 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -19398,7 +19398,9 @@ return /******/ (function(modules) { // webpackBootstrap var localSearchThreshold = 8; var globalSearchThreshold = 4; - if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) { + if (localSearch.indexMatch !== undefined) { + console.log('%cUnknown option detected: "' + option + '" in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n', printStyle); + } else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) { console.log('%cUnknown option detected: "' + option + '" in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was misplaced? Matching option found at: ' + Validator.printLocation(globalSearch.path, globalSearch.closestMatch, ''), printStyle); } else if (localSearch.distance <= localSearchThreshold) { console.log('%cUnknown option detected: "' + option + '". Did you mean "' + localSearch.closestMatch + '"?' + Validator.printLocation(localSearch.path, option), printStyle); @@ -19426,6 +19428,8 @@ return /******/ (function(modules) { // webpackBootstrap var min = 1000000000; var closestMatch = ''; var closestMatchPath = []; + var lowerCaseOption = option.toLowerCase(); + var indexMatch = undefined; for (var op in options) { var type = Validator.getType(options[op]); var distance = undefined; @@ -19435,8 +19439,12 @@ return /******/ (function(modules) { // webpackBootstrap closestMatch = result.closestMatch; closestMatchPath = result.path; min = result.distance; + indexMatch = result.indexMatch; } } else { + if (op.toLowerCase().indexOf(lowerCaseOption) !== -1) { + indexMatch = op; + } distance = Validator.levenshteinDistance(option, op); if (min > distance) { closestMatch = op; @@ -19445,7 +19453,7 @@ return /******/ (function(modules) { // webpackBootstrap } } } - return { closestMatch: closestMatch, path: closestMatchPath, distance: min }; + return { closestMatch: closestMatch, path: closestMatchPath, distance: min, indexMatch: indexMatch }; } }, { key: 'printLocation', @@ -20951,7 +20959,7 @@ return /******/ (function(modules) { // webpackBootstrap min: 14, max: 30, maxVisible: 30, - drawThreshold: 6 + drawThreshold: 5 }, customScalingFunction: function customScalingFunction(min, max, total, value) { if (max === min) { @@ -21409,7 +21417,7 @@ return /******/ (function(modules) { // webpackBootstrap min: 14, max: 30, maxVisible: 30, - drawThreshold: 6 + drawThreshold: 5 }, customScalingFunction: function customScalingFunction(min, max, total, value) { if (max === min) { diff --git a/docs/network/edges.html b/docs/network/edges.html index 18fcf9f3..2180da56 100644 --- a/docs/network/edges.html +++ b/docs/network/edges.html @@ -138,7 +138,7 @@ var options = { min: 14, max: 30, maxVisible: 30, - drawThreshold: 6 + drawThreshold: 5 }, customScalingFunction: function (min,max,total,value) { if (max === min) { @@ -480,7 +480,7 @@ var options: { scaling.label.drawThreshold Number - 6 + 5 When zooming out, the font will be drawn smaller. This defines a lower limit for when the font is drawn. When using font scaling, you can use this together with the maxVisible to first show labels of important edges when zoomed out and only show the rest when zooming in. diff --git a/docs/network/nodes.html b/docs/network/nodes.html index 4ae5ecba..bc153b8b 100644 --- a/docs/network/nodes.html +++ b/docs/network/nodes.html @@ -143,7 +143,7 @@ var options = { min: 14, max: 30, maxVisible: 30, - drawThreshold: 6 + drawThreshold: 5 }, customScalingFunction: function (min,max,total,value) { if (max === min) { @@ -507,7 +507,7 @@ network.setOptions(options); scaling.label.drawThreshold Number - 6 + 5 When zooming out, the font will be drawn smaller. This defines a lower limit for when the font is drawn. When using font scaling, you can use this together with the maxVisible to first show labels of important nodes when zoomed out and only show the rest when zooming in. diff --git a/examples/network/categories/23_hierarchical_layout.html b/examples/network/categories/23_hierarchical_layout.html deleted file mode 100644 index 39356149..00000000 --- a/examples/network/categories/23_hierarchical_layout.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - Network | Hierarchical layout - - - - - - - - - - - -

Hierarchical Layout - Scale-Free-Network

-
- This example shows the randomly generated scale-free-network set of nodes and connected edges from example 2. - In this example, hierarchical layout has been enabled and the vertical levels are determined automatically. -
-
-
- - - -
-

- - - - - -

- - -
- -
- -

- - diff --git a/examples/network/categories/data/dynamic_data.html b/examples/network/categories/data/dynamic_data.html index b6c43036..edc458af 100644 --- a/examples/network/categories/data/dynamic_data.html +++ b/examples/network/categories/data/dynamic_data.html @@ -1,266 +1,265 @@ - Network | DataSet + Network | DataSet - + pre { + margin: 0; + padding: 5px; + font-size: 10pt; + } - - - + #network { + width: 100%; + height: 400px; + border: 1px solid lightgray; + } + - + - // convenience method to stringify a JSON object - function toJSON (obj) { - return JSON.stringify(obj, null, 4); - } + - + } + + + - +

- This example demonstrates dynamically adding, updating and removing nodes - and edges using a DataSet. + This example demonstrates dynamically adding, updating and removing nodes + and edges using a DataSet.

Adjust

- - - - + + + +
-

Node

- - - - - - - - - - - - - - - - -
Action - - - -
-
-

Edge

- - - - - - - - - - - - - - - - - - - - - -
Action - - - -
-
+

Node

+ + + + + + + + + + + + + + + + +
Action + + + +
+
+

Edge

+ + + + + + + + + + + + + + + + + + + + + +
Action + + + +
+

View

- - - - - - - + + + + + + + + + - + - +
+ +
-

Nodes

-

-    
+

Nodes

+

+        
+

Edges

+

+        
-

Edges

-

-    
+

Network

-
-

Network

-
-
diff --git a/examples/network/categories/32_hierarchicaLayoutMethods.html b/examples/network/categories/layout/hierarchica_layout_methods.html similarity index 88% rename from examples/network/categories/32_hierarchicaLayoutMethods.html rename to examples/network/categories/layout/hierarchica_layout_methods.html index 5b64fb7d..1e5ff569 100644 --- a/examples/network/categories/32_hierarchicaLayoutMethods.html +++ b/examples/network/categories/layout/hierarchica_layout_methods.html @@ -14,8 +14,8 @@ } - - + + - + diff --git a/examples/network/categories/layout/hierarchical_layout.html b/examples/network/categories/layout/hierarchical_layout.html new file mode 100644 index 00000000..8183a867 --- /dev/null +++ b/examples/network/categories/layout/hierarchical_layout.html @@ -0,0 +1,114 @@ + + + + Network | Hierarchical layout + + + + + + + + + + + + + +

Hierarchical Layout - Scale-Free-Network

+ +
+ This example shows the randomly generated scale-free-network set of nodes and connected edges from example 2. + In this example, hierarchical layout has been enabled and the vertical levels are determined automatically. +
+
+ +
+ + + +
+

+ + + + + +

+ + +
+ +
+ +

+ + diff --git a/examples/network/categories/24_hierarchical_layout_userdefined.html b/examples/network/categories/layout/hierarchical_layout_userdefined.html similarity index 60% rename from examples/network/categories/24_hierarchical_layout_userdefined.html rename to examples/network/categories/layout/hierarchical_layout_userdefined.html index 42ca80d4..74c69347 100644 --- a/examples/network/categories/24_hierarchical_layout_userdefined.html +++ b/examples/network/categories/layout/hierarchical_layout_userdefined.html @@ -13,9 +13,9 @@ border: 1px solid lightgray; } + + - - - + diff --git a/examples/network/categories/layout/randomSeed.html b/examples/network/categories/layout/randomSeed.html new file mode 100644 index 00000000..eebcaa60 --- /dev/null +++ b/examples/network/categories/layout/randomSeed.html @@ -0,0 +1,60 @@ + + + + Network | Setting the random seed + + + + + + + + +

+ Create a simple network with some nodes and edges but with a fixed seed. This means the layout will be the same every time the nodes + are settled. +

+ +
+ + + + + + diff --git a/lib/network/modules/EdgesHandler.js b/lib/network/modules/EdgesHandler.js index 0ecb2587..e63cadaa 100644 --- a/lib/network/modules/EdgesHandler.js +++ b/lib/network/modules/EdgesHandler.js @@ -57,7 +57,7 @@ class EdgesHandler { min: 14, max: 30, maxVisible: 30, - drawThreshold: 6 + drawThreshold: 5 }, customScalingFunction: function (min,max,total,value) { if (max === min) { diff --git a/lib/network/modules/NodesHandler.js b/lib/network/modules/NodesHandler.js index 211c6413..87d62170 100644 --- a/lib/network/modules/NodesHandler.js +++ b/lib/network/modules/NodesHandler.js @@ -72,7 +72,7 @@ class NodesHandler { min: 14, max: 30, maxVisible: 30, - drawThreshold: 6 + drawThreshold: 5 }, customScalingFunction: function (min,max,total,value) { if (max === min) { diff --git a/lib/shared/Validator.js b/lib/shared/Validator.js index 57b1b2ab..5bbb2d5e 100644 --- a/lib/shared/Validator.js +++ b/lib/shared/Validator.js @@ -170,7 +170,10 @@ class Validator { let localSearchThreshold = 8; let globalSearchThreshold = 4; - if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) { + if (localSearch.indexMatch !== undefined) { + console.log('%cUnknown option detected: "' + option + '" in ' + Validator.printLocation(localSearch.path, option,'') + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n', printStyle); + } + else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) { console.log('%cUnknown option detected: "' + option + '" in ' + Validator.printLocation(localSearch.path, option,'') + 'Perhaps it was misplaced? Matching option found at: ' + Validator.printLocation(globalSearch.path, globalSearch.closestMatch,''), printStyle); } else if (localSearch.distance <= localSearchThreshold) { @@ -196,6 +199,8 @@ class Validator { let min = 1e9; let closestMatch = ''; let closestMatchPath = []; + let lowerCaseOption = option.toLowerCase(); + let indexMatch = undefined; for (let op in options) { let type = Validator.getType(options[op]); let distance; @@ -205,9 +210,13 @@ class Validator { closestMatch = result.closestMatch; closestMatchPath = result.path; min = result.distance; + indexMatch = result.indexMatch; } } else { + if (op.toLowerCase().indexOf(lowerCaseOption) !== -1) { + indexMatch = op; + } distance = Validator.levenshteinDistance(option, op); if (min > distance) { closestMatch = op; @@ -216,7 +225,7 @@ class Validator { } } } - return {closestMatch:closestMatch, path:closestMatchPath, distance:min} + return {closestMatch:closestMatch, path:closestMatchPath, distance:min, indexMatch: indexMatch} } static printLocation(path, option, prefix = 'Problem value found at: \n') {