Browse Source

fixed clustering phantom edge problem

flowchartTest
Alex de Mulder 9 years ago
parent
commit
5f486ee56b
3 changed files with 210 additions and 241 deletions
  1. +117
    -114
      dist/vis.js
  2. +6
    -2
      lib/network/modules/Clustering.js
  3. +87
    -125
      test/networkTest.html

+ 117
- 114
dist/vis.js View File

@ -4,7 +4,7 @@
*
* A dynamic, browser-based visualization library.
*
* @version 4.5.0
* @version 4.5.1--snapshot
* @date 2015-07-17
*
* @license
@ -3501,7 +3501,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param value
*/
exports.fillIfDefined = function (a, b) {
var allowDeletion = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var allowDeletion = arguments[2] === undefined ? false : arguments[2];
for (var prop in a) {
if (b[prop] !== undefined) {
@ -3591,7 +3591,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @return {Object} a
*/
exports.selectiveDeepExtend = function (props, a, b) {
var allowDeletion = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var allowDeletion = arguments[3] === undefined ? false : arguments[3];
// TODO: add support for Arrays to deepExtend
if (Array.isArray(b)) {
@ -3635,7 +3635,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @return {Object} a
*/
exports.selectiveNotDeepExtend = function (props, a, b) {
var allowDeletion = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var allowDeletion = arguments[3] === undefined ? false : arguments[3];
// TODO: add support for Arrays to deepExtend
if (Array.isArray(b)) {
@ -4559,7 +4559,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
exports.mergeOptions = function (mergeTarget, options, option) {
var allowDeletion = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var allowDeletion = arguments[3] === undefined ? false : arguments[3];
if (options[option] === null) {
mergeTarget[option] = undefined;
@ -21092,7 +21092,7 @@ return /******/ (function(modules) { // webpackBootstrap
var Configurator = (function () {
function Configurator(parentModule, defaultContainer, configureOptions) {
var pixelRatio = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3];
var pixelRatio = arguments[3] === undefined ? 1 : arguments[3];
_classCallCheck(this, Configurator);
@ -21354,7 +21354,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _makeLabel(name, path) {
var objectLabel = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var objectLabel = arguments[2] === undefined ? false : arguments[2];
var div = document.createElement('div');
div.className = 'vis-network-configuration label s' + path.length;
@ -21587,8 +21587,8 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _handleObject(obj) {
var path = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
var checkOnly = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var path = arguments[1] === undefined ? [] : arguments[1];
var checkOnly = arguments[2] === undefined ? false : arguments[2];
var show = false;
var filter = this.options.filter;
@ -21706,7 +21706,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: '_constructOptions',
value: function _constructOptions(value, path) {
var optionsObj = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var optionsObj = arguments[2] === undefined ? {} : arguments[2];
var pointer = optionsObj;
@ -21771,7 +21771,7 @@ return /******/ (function(modules) { // webpackBootstrap
var ColorPicker = (function () {
function ColorPicker() {
var pixelRatio = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];
var pixelRatio = arguments[0] === undefined ? 1 : arguments[0];
_classCallCheck(this, ColorPicker);
@ -21848,7 +21848,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param setInitial
*/
value: function setColor(color) {
var setInitial = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var setInitial = arguments[1] === undefined ? true : arguments[1];
if (color === 'none') {
return;
@ -21917,7 +21917,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _hide() {
var storePrevious = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var storePrevious = arguments[0] === undefined ? true : arguments[0];
// store the previous color for next time;
if (storePrevious === true) {
@ -21978,7 +21978,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _setColor(rgba) {
var setInitial = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var setInitial = arguments[1] === undefined ? true : arguments[1];
// store the initial color
if (setInitial === true) {
@ -22035,7 +22035,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _updatePicker() {
var rgba = arguments.length <= 0 || arguments[0] === undefined ? this.color : arguments[0];
var rgba = arguments[0] === undefined ? this.color : arguments[0];
var hsv = util.RGBToHSV(rgba.r, rgba.g, rgba.b);
var ctx = this.colorPickerCanvas.getContext('2d');
@ -22539,7 +22539,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @returns {{closestMatch: string, path: Array, distance: number}}
*/
value: function findInOptions(option, options, path) {
var recursive = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var recursive = arguments[3] === undefined ? false : arguments[3];
var min = 1e9;
var closestMatch = '';
@ -22573,7 +22573,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'printLocation',
value: function printLocation(path, option) {
var prefix = arguments.length <= 2 || arguments[2] === undefined ? 'Problem value found at: \n' : arguments[2];
var prefix = arguments[2] === undefined ? 'Problem value found at: \n' : arguments[2];
var str = '\n\n' + prefix + 'options = {\n';
for (var i = 0; i < path.length; i++) {
@ -22606,9 +22606,9 @@ return /******/ (function(modules) { // webpackBootstrap
// http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#JavaScript
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
value: function levenshteinDistance(a, b) {
if (a.length === 0) return b.length;
@ -27293,7 +27293,7 @@ return /******/ (function(modules) { // webpackBootstrap
value: function setData(nodes) {
var _this3 = this;
var doNotEmit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var doNotEmit = arguments[1] === undefined ? false : arguments[1];
var oldNodesData = this.body.data.nodes;
@ -27345,7 +27345,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function add(ids) {
var doNotEmit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var doNotEmit = arguments[1] === undefined ? false : arguments[1];
var id = undefined;
var newNodes = [];
@ -27421,7 +27421,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param constructorClass
*/
value: function create(properties) {
var constructorClass = arguments.length <= 1 || arguments[1] === undefined ? _componentsNode2['default'] : arguments[1];
var constructorClass = arguments[1] === undefined ? _componentsNode2['default'] : arguments[1];
return new constructorClass(properties, this.body, this.images, this.groups, this.options);
}
@ -28048,7 +28048,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param newOptions
*/
value: function parseOptions(parentOptions, newOptions) {
var allowDeletion = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var allowDeletion = arguments[2] === undefined ? false : arguments[2];
var fields = ['color', 'font', 'fixed', 'shadow'];
util.selectiveNotDeepExtend(fields, parentOptions, newOptions, allowDeletion);
@ -28131,7 +28131,7 @@ return /******/ (function(modules) { // webpackBootstrap
_createClass(Label, [{
key: 'setOptions',
value: function setOptions(options) {
var allowDeletion = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var allowDeletion = arguments[1] === undefined ? false : arguments[1];
this.options = options;
@ -28162,7 +28162,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param baseline
*/
value: function draw(ctx, x, y, selected) {
var baseline = arguments.length <= 4 || arguments[4] === undefined ? 'middle' : arguments[4];
var baseline = arguments[4] === undefined ? 'middle' : arguments[4];
// if no label, return
if (this.options.label === undefined) return;
@ -28220,7 +28220,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _drawText(ctx, selected, x, y) {
var baseline = arguments.length <= 4 || arguments[4] === undefined ? 'middle' : arguments[4];
var baseline = arguments[4] === undefined ? 'middle' : arguments[4];
var fontSize = this.options.font.size;
var viewFontSize = fontSize * this.body.view.scale;
@ -28322,7 +28322,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @returns {{width: number, height: number}}
*/
value: function getTextSize(ctx) {
var selected = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var selected = arguments[1] === undefined ? false : arguments[1];
var size = {
width: this._processLabel(ctx, selected),
@ -28343,9 +28343,9 @@ return /******/ (function(modules) { // webpackBootstrap
* @param baseline
*/
value: function calculateLabelSize(ctx, selected) {
var x = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
var y = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
var baseline = arguments.length <= 4 || arguments[4] === undefined ? 'middle' : arguments[4];
var x = arguments[2] === undefined ? 0 : arguments[2];
var y = arguments[3] === undefined ? 0 : arguments[3];
var baseline = arguments[4] === undefined ? 'middle' : arguments[4];
if (this.labelDirty === true) {
this.size.width = this._processLabel(ctx, selected);
@ -28394,7 +28394,7 @@ return /******/ (function(modules) { // webpackBootstrap
}], [{
key: 'parseOptions',
value: function parseOptions(parentOptions, newOptions) {
var allowDeletion = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var allowDeletion = arguments[2] === undefined ? false : arguments[2];
if (typeof newOptions.font === 'string') {
var newOptionsArray = newOptions.font.split(' ');
@ -28439,14 +28439,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var Box = (function (_NodeBase) {
_inherits(Box, _NodeBase);
function Box(options, body, labelModule) {
_classCallCheck(this, Box);
_get(Object.getPrototypeOf(Box.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Box, _NodeBase);
_createClass(Box, [{
key: 'resize',
value: function resize(ctx, selected) {
@ -28630,14 +28630,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilCircleImageBase2 = _interopRequireDefault(_utilCircleImageBase);
var Circle = (function (_CircleImageBase) {
_inherits(Circle, _CircleImageBase);
function Circle(options, body, labelModule) {
_classCallCheck(this, Circle);
_get(Object.getPrototypeOf(Circle.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Circle, _CircleImageBase);
_createClass(Circle, [{
key: 'resize',
value: function resize(ctx, selected) {
@ -28720,8 +28720,6 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var CircleImageBase = (function (_NodeBase) {
_inherits(CircleImageBase, _NodeBase);
function CircleImageBase(options, body, labelModule) {
_classCallCheck(this, CircleImageBase);
@ -28730,6 +28728,8 @@ return /******/ (function(modules) { // webpackBootstrap
this.imageLoaded = false;
}
_inherits(CircleImageBase, _NodeBase);
_createClass(CircleImageBase, [{
key: '_resizeImage',
@ -28872,8 +28872,6 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilCircleImageBase2 = _interopRequireDefault(_utilCircleImageBase);
var CircularImage = (function (_CircleImageBase) {
_inherits(CircularImage, _CircleImageBase);
function CircularImage(options, body, labelModule, imageObj) {
_classCallCheck(this, CircularImage);
@ -28882,6 +28880,8 @@ return /******/ (function(modules) { // webpackBootstrap
this._swapToImageResizeWhenImageLoaded = true;
}
_inherits(CircularImage, _CircleImageBase);
_createClass(CircularImage, [{
key: 'resize',
value: function resize() {
@ -28977,14 +28977,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var Database = (function (_NodeBase) {
_inherits(Database, _NodeBase);
function Database(options, body, labelModule) {
_classCallCheck(this, Database);
_get(Object.getPrototypeOf(Database.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Database, _NodeBase);
_createClass(Database, [{
key: 'resize',
value: function resize(ctx, selected) {
@ -29088,14 +29088,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilShapeBase2 = _interopRequireDefault(_utilShapeBase);
var Diamond = (function (_ShapeBase) {
_inherits(Diamond, _ShapeBase);
function Diamond(options, body, labelModule) {
_classCallCheck(this, Diamond);
_get(Object.getPrototypeOf(Diamond.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Diamond, _ShapeBase);
_createClass(Diamond, [{
key: 'resize',
value: function resize(ctx) {
@ -29144,14 +29144,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var ShapeBase = (function (_NodeBase) {
_inherits(ShapeBase, _NodeBase);
function ShapeBase(options, body, labelModule) {
_classCallCheck(this, ShapeBase);
_get(Object.getPrototypeOf(ShapeBase.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(ShapeBase, _NodeBase);
_createClass(ShapeBase, [{
key: '_resizeShape',
value: function _resizeShape() {
@ -29247,14 +29247,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilShapeBase2 = _interopRequireDefault(_utilShapeBase);
var Dot = (function (_ShapeBase) {
_inherits(Dot, _ShapeBase);
function Dot(options, body, labelModule) {
_classCallCheck(this, Dot);
_get(Object.getPrototypeOf(Dot.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Dot, _ShapeBase);
_createClass(Dot, [{
key: 'resize',
value: function resize(ctx) {
@ -29303,14 +29303,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var Ellipse = (function (_NodeBase) {
_inherits(Ellipse, _NodeBase);
function Ellipse(options, body, labelModule) {
_classCallCheck(this, Ellipse);
_get(Object.getPrototypeOf(Ellipse.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Ellipse, _NodeBase);
_createClass(Ellipse, [{
key: 'resize',
value: function resize(ctx, selected) {
@ -29416,14 +29416,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var Icon = (function (_NodeBase) {
_inherits(Icon, _NodeBase);
function Icon(options, body, labelModule) {
_classCallCheck(this, Icon);
_get(Object.getPrototypeOf(Icon.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Icon, _NodeBase);
_createClass(Icon, [{
key: 'resize',
value: function resize(ctx) {
@ -29532,8 +29532,6 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilCircleImageBase2 = _interopRequireDefault(_utilCircleImageBase);
var Image = (function (_CircleImageBase) {
_inherits(Image, _CircleImageBase);
function Image(options, body, labelModule, imageObj) {
_classCallCheck(this, Image);
@ -29541,6 +29539,8 @@ return /******/ (function(modules) { // webpackBootstrap
this.imageObj = imageObj;
}
_inherits(Image, _CircleImageBase);
_createClass(Image, [{
key: 'resize',
value: function resize() {
@ -29620,14 +29620,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilShapeBase2 = _interopRequireDefault(_utilShapeBase);
var Square = (function (_ShapeBase) {
_inherits(Square, _ShapeBase);
function Square(options, body, labelModule) {
_classCallCheck(this, Square);
_get(Object.getPrototypeOf(Square.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Square, _ShapeBase);
_createClass(Square, [{
key: 'resize',
value: function resize() {
@ -29677,14 +29677,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilShapeBase2 = _interopRequireDefault(_utilShapeBase);
var Star = (function (_ShapeBase) {
_inherits(Star, _ShapeBase);
function Star(options, body, labelModule) {
_classCallCheck(this, Star);
_get(Object.getPrototypeOf(Star.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Star, _ShapeBase);
_createClass(Star, [{
key: 'resize',
value: function resize(ctx) {
@ -29733,14 +29733,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilNodeBase2 = _interopRequireDefault(_utilNodeBase);
var Text = (function (_NodeBase) {
_inherits(Text, _NodeBase);
function Text(options, body, labelModule) {
_classCallCheck(this, Text);
_get(Object.getPrototypeOf(Text.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Text, _NodeBase);
_createClass(Text, [{
key: 'resize',
value: function resize(ctx, selected) {
@ -29820,14 +29820,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilShapeBase2 = _interopRequireDefault(_utilShapeBase);
var Triangle = (function (_ShapeBase) {
_inherits(Triangle, _ShapeBase);
function Triangle(options, body, labelModule) {
_classCallCheck(this, Triangle);
_get(Object.getPrototypeOf(Triangle.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(Triangle, _ShapeBase);
_createClass(Triangle, [{
key: 'resize',
value: function resize(ctx) {
@ -29876,14 +29876,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilShapeBase2 = _interopRequireDefault(_utilShapeBase);
var TriangleDown = (function (_ShapeBase) {
_inherits(TriangleDown, _ShapeBase);
function TriangleDown(options, body, labelModule) {
_classCallCheck(this, TriangleDown);
_get(Object.getPrototypeOf(TriangleDown.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(TriangleDown, _ShapeBase);
_createClass(TriangleDown, [{
key: 'resize',
value: function resize(ctx) {
@ -30138,7 +30138,7 @@ return /******/ (function(modules) { // webpackBootstrap
value: function setData(edges) {
var _this3 = this;
var doNotEmit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var doNotEmit = arguments[1] === undefined ? false : arguments[1];
var oldEdgesData = this.body.data.edges;
@ -30189,7 +30189,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function add(ids) {
var doNotEmit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var doNotEmit = arguments[1] === undefined ? false : arguments[1];
var edges = this.body.edges;
var edgesData = this.body.data.edges;
@ -30804,7 +30804,7 @@ return /******/ (function(modules) { // webpackBootstrap
}], [{
key: 'parseOptions',
value: function parseOptions(parentOptions, newOptions) {
var allowDeletion = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var allowDeletion = arguments[2] === undefined ? false : arguments[2];
var fields = ['id', 'from', 'hidden', 'hoverWidth', 'label', 'labelHighlightBold', 'length', 'line', 'opacity', 'physics', 'selectionWidth', 'selfReferenceSize', 'to', 'title', 'value', 'width'];
@ -30932,8 +30932,6 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilBezierEdgeBase2 = _interopRequireDefault(_utilBezierEdgeBase);
var BezierEdgeDynamic = (function (_BezierEdgeBase) {
_inherits(BezierEdgeDynamic, _BezierEdgeBase);
function BezierEdgeDynamic(options, body, labelModule) {
_classCallCheck(this, BezierEdgeDynamic);
@ -30941,6 +30939,8 @@ return /******/ (function(modules) { // webpackBootstrap
_get(Object.getPrototypeOf(BezierEdgeDynamic.prototype), 'constructor', this).call(this, options, body, labelModule); // --> this calls the setOptions below
}
_inherits(BezierEdgeDynamic, _BezierEdgeBase);
_createClass(BezierEdgeDynamic, [{
key: 'setOptions',
value: function setOptions(options) {
@ -31097,14 +31097,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _EdgeBase3 = _interopRequireDefault(_EdgeBase2);
var BezierEdgeBase = (function (_EdgeBase) {
_inherits(BezierEdgeBase, _EdgeBase);
function BezierEdgeBase(options, body, labelModule) {
_classCallCheck(this, BezierEdgeBase);
_get(Object.getPrototypeOf(BezierEdgeBase.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(BezierEdgeBase, _EdgeBase);
_createClass(BezierEdgeBase, [{
key: '_findBorderPositionBezier',
@ -31122,7 +31122,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param viaNode
*/
value: function _findBorderPositionBezier(nearNode, ctx) {
var viaNode = arguments.length <= 2 || arguments[2] === undefined ? this._getViaCoordinates() : arguments[2];
var viaNode = arguments[2] === undefined ? this._getViaCoordinates() : arguments[2];
var maxIterations = 10;
var iteration = 0;
@ -31841,14 +31841,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilBezierEdgeBase2 = _interopRequireDefault(_utilBezierEdgeBase);
var BezierEdgeStatic = (function (_BezierEdgeBase) {
_inherits(BezierEdgeStatic, _BezierEdgeBase);
function BezierEdgeStatic(options, body, labelModule) {
_classCallCheck(this, BezierEdgeStatic);
_get(Object.getPrototypeOf(BezierEdgeStatic.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(BezierEdgeStatic, _BezierEdgeBase);
_createClass(BezierEdgeStatic, [{
key: '_line',
@ -32037,14 +32037,14 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: '_findBorderPosition',
value: function _findBorderPosition(nearNode, ctx) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments[2] === undefined ? {} : arguments[2];
return this._findBorderPositionBezier(nearNode, ctx, options.via);
}
}, {
key: '_getDistanceToEdge',
value: function _getDistanceToEdge(x1, y1, x2, y2, x3, y3) {
var via = arguments.length <= 6 || arguments[6] === undefined ? this._getViaCoordinates() : arguments[6];
var via = arguments[6] === undefined ? this._getViaCoordinates() : arguments[6];
// x3,y3 is the point
return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via);
}
@ -32059,7 +32059,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function getPoint(percentage) {
var via = arguments.length <= 1 || arguments[1] === undefined ? this._getViaCoordinates() : arguments[1];
var via = arguments[1] === undefined ? this._getViaCoordinates() : arguments[1];
var t = percentage;
var x = Math.pow(1 - t, 2) * this.from.x + 2 * t * (1 - t) * via.x + Math.pow(t, 2) * this.to.x;
@ -32100,14 +32100,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _utilEdgeBase2 = _interopRequireDefault(_utilEdgeBase);
var StraightEdge = (function (_EdgeBase) {
_inherits(StraightEdge, _EdgeBase);
function StraightEdge(options, body, labelModule) {
_classCallCheck(this, StraightEdge);
_get(Object.getPrototypeOf(StraightEdge.prototype), 'constructor', this).call(this, options, body, labelModule);
}
_inherits(StraightEdge, _EdgeBase);
_createClass(StraightEdge, [{
key: '_line',
@ -32436,7 +32436,7 @@ return /******/ (function(modules) { // webpackBootstrap
* Stop the simulation, force stabilization.
*/
value: function stopSimulation() {
var emit = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var emit = arguments[0] === undefined ? true : arguments[0];
this.stabilized = true;
if (emit === true) {
@ -32737,7 +32737,7 @@ return /******/ (function(modules) { // webpackBootstrap
value: function stabilize() {
var _this3 = this;
var iterations = arguments.length <= 0 || arguments[0] === undefined ? this.options.stabilization.iterations : arguments[0];
var iterations = arguments[0] === undefined ? this.options.stabilization.iterations : arguments[0];
if (typeof iterations !== 'number') {
console.log('The stabilize method needs a numeric amount of iterations. Switching to default: ', this.options.stabilization.iterations);
@ -33838,14 +33838,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _BarnesHutSolver3 = _interopRequireDefault(_BarnesHutSolver2);
var ForceAtlas2BasedRepulsionSolver = (function (_BarnesHutSolver) {
_inherits(ForceAtlas2BasedRepulsionSolver, _BarnesHutSolver);
function ForceAtlas2BasedRepulsionSolver(body, physicsBody, options) {
_classCallCheck(this, ForceAtlas2BasedRepulsionSolver);
_get(Object.getPrototypeOf(ForceAtlas2BasedRepulsionSolver.prototype), "constructor", this).call(this, body, physicsBody, options);
}
_inherits(ForceAtlas2BasedRepulsionSolver, _BarnesHutSolver);
_createClass(ForceAtlas2BasedRepulsionSolver, [{
key: "_calculateForces",
@ -33912,14 +33912,14 @@ return /******/ (function(modules) { // webpackBootstrap
var _CentralGravitySolver3 = _interopRequireDefault(_CentralGravitySolver2);
var ForceAtlas2BasedCentralGravitySolver = (function (_CentralGravitySolver) {
_inherits(ForceAtlas2BasedCentralGravitySolver, _CentralGravitySolver);
function ForceAtlas2BasedCentralGravitySolver(body, physicsBody, options) {
_classCallCheck(this, ForceAtlas2BasedCentralGravitySolver);
_get(Object.getPrototypeOf(ForceAtlas2BasedCentralGravitySolver.prototype), "constructor", this).call(this, body, physicsBody, options);
}
_inherits(ForceAtlas2BasedCentralGravitySolver, _CentralGravitySolver);
_createClass(ForceAtlas2BasedCentralGravitySolver, [{
key: "_calculateForces",
@ -34026,8 +34026,8 @@ return /******/ (function(modules) { // webpackBootstrap
* @param refreshData
*/
value: function cluster() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var refreshData = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var options = arguments[0] === undefined ? {} : arguments[0];
var refreshData = arguments[1] === undefined ? true : arguments[1];
if (options.joinCondition === undefined) {
throw new Error('Cannot call clusterByNodeData without a joinCondition function in the options.');
@ -34066,7 +34066,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param refreshData
*/
value: function clusterOutliers(options) {
var refreshData = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var refreshData = arguments[1] === undefined ? true : arguments[1];
options = this._checkOptions(options);
var clusters = [];
@ -34144,7 +34144,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param refreshData
*/
value: function clusterByConnection(nodeId, options) {
var refreshData = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
var refreshData = arguments[2] === undefined ? true : arguments[2];
// kill conditions
if (nodeId === undefined) {
@ -34285,7 +34285,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _checkOptions() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var options = arguments[0] === undefined ? {} : arguments[0];
if (options.clusterEdgeProperties === undefined) {
options.clusterEdgeProperties = {};
@ -34308,7 +34308,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _cluster(childNodesObj, childEdgesObj, options) {
var refreshData = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3];
var refreshData = arguments[3] === undefined ? true : arguments[3];
// kill condition: no children so cant cluster
if (Object.keys(childNodesObj).length === 0) {
@ -34415,6 +34415,9 @@ return /******/ (function(modules) { // webpackBootstrap
edge.disconnect();
delete childEdgesObj[edgeId];
delete this.body.edges[edgeId];
} else {
edge.togglePhysics(false);
edge.options.hidden = true;
}
} else {
edge.togglePhysics(false);
@ -34498,7 +34501,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {Boolean} refreshData | wrap up afterwards if not true
*/
value: function openCluster(clusterNodeId, options) {
var refreshData = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
var refreshData = arguments[2] === undefined ? true : arguments[2];
// kill conditions
if (clusterNodeId === undefined) {
@ -34718,8 +34721,8 @@ return /******/ (function(modules) { // webpackBootstrap
average = average / hubCounter;
averageSquared = averageSquared / hubCounter;
var letiance = averageSquared - Math.pow(average, 2);
var standardDeviation = Math.sqrt(letiance);
var variance = averageSquared - Math.pow(average, 2);
var standardDeviation = Math.sqrt(variance);
var hubThreshold = Math.floor(average + 2 * standardDeviation);
@ -34765,8 +34768,6 @@ return /******/ (function(modules) { // webpackBootstrap
*/
var Cluster = (function (_Node) {
_inherits(Cluster, _Node);
function Cluster(options, body, imagelist, grouplist, globalOptions) {
_classCallCheck(this, Cluster);
@ -34777,6 +34778,8 @@ return /******/ (function(modules) { // webpackBootstrap
this.containedEdges = {};
}
_inherits(Cluster, _Node);
return Cluster;
})(_Node3['default']);
@ -34956,7 +34959,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: '_redraw',
value: function _redraw() {
var hidden = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var hidden = arguments[0] === undefined ? false : arguments[0];
if (this.allowRedraw === true) {
this.body.emitter.emit('initRedraw');
@ -35061,7 +35064,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _drawNodes(ctx) {
var alwaysShow = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var alwaysShow = arguments[1] === undefined ? false : arguments[1];
var nodes = this.body.nodes;
var nodeIndices = this.body.nodeIndices;
@ -35416,8 +35419,8 @@ return /******/ (function(modules) { // webpackBootstrap
* or '30%')
*/
value: function setSize() {
var width = arguments.length <= 0 || arguments[0] === undefined ? this.options.width : arguments[0];
var height = arguments.length <= 1 || arguments[1] === undefined ? this.options.height : arguments[1];
var width = arguments[0] === undefined ? this.options.width : arguments[0];
var height = arguments[1] === undefined ? this.options.height : arguments[1];
width = this._prepareValue(width);
height = this._prepareValue(height);
@ -35597,7 +35600,7 @@ return /******/ (function(modules) { // webpackBootstrap
_createClass(View, [{
key: "setOptions",
value: function setOptions() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var options = arguments[0] === undefined ? {} : arguments[0];
this.options = options;
}
@ -35609,7 +35612,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _getRange() {
var specificNodes = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
var specificNodes = arguments[0] === undefined ? [] : arguments[0];
var minY = 1e9,
maxY = -1e9,
@ -35676,8 +35679,8 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false;
*/
value: function fit() {
var options = arguments.length <= 0 || arguments[0] === undefined ? { nodes: [] } : arguments[0];
var initialZoom = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var options = arguments[0] === undefined ? { nodes: [] } : arguments[0];
var initialZoom = arguments[1] === undefined ? false : arguments[1];
var range;
var zoomLevel;
@ -35741,7 +35744,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {Number} [options]
*/
value: function focus(nodeId) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments[1] === undefined ? {} : arguments[1];
if (this.body.nodes[nodeId] !== undefined) {
var nodePosition = { x: this.body.nodes[nodeId].x, y: this.body.nodes[nodeId].y };
@ -35909,7 +35912,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _transitionRedraw() {
var finished = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var finished = arguments[0] === undefined ? false : arguments[0];
this.easingTime += this.animationSpeed;
this.easingTime = finished === true ? 1.0 : this.easingTime;
@ -36163,7 +36166,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param add
*/
value: function checkSelectionChanges(pointer, event) {
var add = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var add = arguments[2] === undefined ? false : arguments[2];
var previouslySelectedEdgeCount = this.selectionHandler._getSelectedEdgeCount();
var previouslySelectedNodeCount = this.selectionHandler._getSelectedNodeCount();
@ -37265,7 +37268,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: "_generateClickEvent",
value: function _generateClickEvent(eventType, event, pointer, oldSelection) {
var emptySelection = arguments.length <= 4 || arguments[4] === undefined ? false : arguments[4];
var emptySelection = arguments[4] === undefined ? false : arguments[4];
var properties = undefined;
if (emptySelection === true) {
@ -37287,7 +37290,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: "selectObject",
value: function selectObject(obj) {
var highlightEdges = arguments.length <= 1 || arguments[1] === undefined ? this.options.selectConnectedEdges : arguments[1];
var highlightEdges = arguments[1] === undefined ? this.options.selectConnectedEdges : arguments[1];
if (obj !== undefined) {
if (obj instanceof Node) {
@ -37359,7 +37362,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function getNodeAt(pointer) {
var returnNode = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var returnNode = arguments[1] === undefined ? true : arguments[1];
// we first check if this is an navigation controls element
var positionObject = this._pointerToPositionObject(pointer);
@ -37420,7 +37423,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function getEdgeAt(pointer) {
var returnEdge = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var returnEdge = arguments[1] === undefined ? true : arguments[1];
var positionObject = this._pointerToPositionObject(pointer);
var overlappingEdges = this._getAllEdgesOverlappingWith(positionObject);
@ -37831,7 +37834,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {boolean} [highlightEdges]
*/
value: function selectNodes(selection) {
var highlightEdges = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var highlightEdges = arguments[1] === undefined ? true : arguments[1];
var i = undefined,
id = undefined;
@ -39133,7 +39136,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @private
*/
value: function _createSeperator() {
var index = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];
var index = arguments[0] === undefined ? 1 : arguments[0];
this.manipulationDOM['seperatorLineDiv' + index] = document.createElement('div');
this.manipulationDOM['seperatorLineDiv' + index].className = 'vis-separator-line';
@ -39187,7 +39190,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: '_createButton',
value: function _createButton(id, className, label) {
var labelClassName = arguments.length <= 3 || arguments[3] === undefined ? 'vis-label' : arguments[3];
var labelClassName = arguments[3] === undefined ? 'vis-label' : arguments[3];
this.manipulationDOM[id + 'Div'] = document.createElement('div');
this.manipulationDOM[id + 'Div'].className = className;

+ 6
- 2
lib/network/modules/Clustering.js View File

@ -407,6 +407,10 @@ class ClusterEngine {
delete childEdgesObj[edgeId];
delete this.body.edges[edgeId];
}
else {
edge.togglePhysics(false);
edge.options.hidden = true;
}
}
else {
edge.togglePhysics(false);
@ -702,8 +706,8 @@ class ClusterEngine {
average = average / hubCounter;
averageSquared = averageSquared / hubCounter;
let letiance = averageSquared - Math.pow(average,2);
let standardDeviation = Math.sqrt(letiance);
let variance = averageSquared - Math.pow(average,2);
let standardDeviation = Math.sqrt(variance);
let hubThreshold = Math.floor(average + 2*standardDeviation);

+ 87
- 125
test/networkTest.html View File

@ -1,148 +1,110 @@
<!doctype html>
<html>
<head>
<title>Network | Hierarchical layout</title>
<title>Network | Clustering</title>
<script type="text/javascript" src="../dist/vis.js"></script>
<style type="text/css">
body {
font: 10pt sans;
}
<style type="text/css">
#mynetwork {
width: 600px;
height: 600px;
border: 1px solid lightgray;
}
p {
max-width: 600px;
}
h4 {
margin-bottom: 3px;
}
</style>
</head>
<script type="text/javascript" src="../dist/vis.js"></script>
<body>
<script type="text/javascript">
var nodes = null;
var edges = null;
var network = null;
function destroy() {
if (network !== null) {
network.destroy();
network = null;
}
}
<div id="mynetwork"></div>
function draw() {
destroy();
// randomly create some nodes and edges
var nodeCount = document.getElementById('nodeCount').value;
//var data = getScaleFreeNetwork(nodeCount)
var nodes = [
{id: 4, label: '4'},
{id: 5, label: '5'},
{id: 7, label: '7'},
{id: 9, label: '9'},
{id: 10, label: '10'},
{id: 101, label: '101'},
{id: 102, label: '102'},
{id: 103, label: '103'}
];
// create an array with edges
var edges = [
{from: 10, to: 4},
{from: 7, to: 5},
{from: 9, to: 7},
{from: 10, to: 9},
{from: 101, to: 102},
{from: 102, to: 103}
];
var data = {
nodes: nodes,
edges: edges
};
// create a network
var container = document.getElementById('mynetwork');
var directionInput = document.getElementById("direction").value;
var options = {
interaction: {
navigationButtons: true
},
layout: {
hierarchical: {
direction: directionInput
}
}
};
network = new vis.Network(container, data, options);
// add event listeners
network.on('select', function (params) {
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes;
});
}
<script type="text/javascript">
// create an array with nodes
var nodes = [
{id: 4, label: '4'},
{id: 5, label: '5'},
{id: 7, label: '7'},
{id: 9, label: '9'},
{id: 10, label: '10'},
{id: 101, label: '101'},
{id: 102, label: '102'},
{id: 103, label: '103'}
];
// create an array with edges
var edges = [
{from: 10, to: 4},
{from: 7, to: 5},
{from: 9, to: 7},
{from: 10, to: 9},
{from: 101, to: 102},
{from: 102, to: 103}
];
// create a network
var container = document.getElementById('mynetwork');
var data = {
nodes: nodes,
edges: edges
};
var options = {layout: {randomSeed: 8}};
var network = new vis.Network(container, data, options);
function changeOptions(directionInputValue) {
network.setOptions({
layout: {
hierarchical: {
direction: directionInputValue
}
}
});
}
</script>
</head>
<body onload="draw();">
<h2>Hierarchical Layout - Scale-Free-Network</h2>
<div style="width:700px; font-size:14px; text-align: justify;">
This example shows the randomly generated <b>scale-free-network</b> set of nodes and connected edges from example 2.
In this example, hierarchical layout has been enabled and the vertical levels are determined automatically.
</div>
<br/>
<form onsubmit="draw(); return false;">
<label for="nodeCount">Number of nodes:</label>
<input id="nodeCount" type="text" value="25" style="width: 50px;">
<input type="submit" value="Go">
</form>
<p>
<input type="button" id="btn-UD" value="Up-Down">
<input type="button" id="btn-DU" value="Down-Up">
<input type="button" id="btn-LR" value="Left-Right">
<input type="button" id="btn-RL" value="Right-Left">
<input type="hidden" id='direction' value="UD">
</p>
<script language="javascript">
var directionInput = document.getElementById("direction");
var btnUD = document.getElementById("btn-UD");
btnUD.onclick = function () {
directionInput.value = "UD";
changeOptions(directionInput.value);
}
var btnDU = document.getElementById("btn-DU");
btnDU.onclick = function () {
directionInput.value = "DU";
changeOptions(directionInput.value);
};
var btnLR = document.getElementById("btn-LR");
btnLR.onclick = function () {
directionInput.value = "LR";
changeOptions(directionInput.value);
};
var btnRL = document.getElementById("btn-RL");
btnRL.onclick = function () {
directionInput.value = "RL";
changeOptions(directionInput.value);
};
// if we click on a node, we want to open it up!
network.on("selectNode", function (params) {
if (params.nodes.length == 1) {
if (network.isCluster(params.nodes[0]) == true) {
network.openCluster(params.nodes[0])
}
}
});
setTimeout(function() {
// alert("clustering 4 and 101")
var clusterOptionsByData = {
joinCondition: function(node) {
if (node.id == 4 || node.id == 101)
return true;
return false;
},
clusterNodeProperties: {id:"c1", label:'c1'}
}
network.cluster(clusterOptionsByData);
network.stabilize()
},500)
setTimeout(function() {
// alert("clustering c1 and 5")
var clusterOptionsByData2 = {
joinCondition: function(node) {
if (node.id == 'c1' || node.id == 5)
return true;
return false;
},
clusterNodeProperties: {id:"c2", label:'c2'}
}
network.cluster(clusterOptionsByData2);
},2000)
/*
setTimeout(function () {
alert("opening c2")
network.openCluster("c2")
},3000)
*/
</script>
<br>
<div id="mynetwork"></div>
<p id="selection"></p>
</body>
</html>

Loading…
Cancel
Save