diff --git a/HISTORY.md b/HISTORY.md index 2b83e5a4..f6526269 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,11 @@ # vis.js history http://visjs.org +## 2015-09-07, version 4.8.2-SNAPSHOT NOT YET RELEASED + +### Network + +- Fixed Phantom Edges during clustering. ## 2015-09-07, version 4.8.1 diff --git a/dist/vis.js b/dist/vis.js index 651aee3d..237349e2 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-07 + * @date 2015-09-08 * * @license * Copyright (C) 2011-2015 Almende B.V, http://almende.com @@ -29,7 +29,7 @@ if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) - define([], factory); + define(factory); else if(typeof exports === 'object') exports["vis"] = factory(); else @@ -97,8 +97,8 @@ return /******/ (function(modules) { // webpackBootstrap exports.graph3d = { Camera: __webpack_require__(15), Filter: __webpack_require__(16), - Point2d: __webpack_require__(14), - Point3d: __webpack_require__(13), + Point2d: __webpack_require__(12), + Point3d: __webpack_require__(14), Slider: __webpack_require__(17), StepNumber: __webpack_require__(18) }; @@ -110,16 +110,16 @@ return /******/ (function(modules) { // webpackBootstrap DateUtil: __webpack_require__(27), DataStep: __webpack_require__(52), Range: __webpack_require__(24), - stack: __webpack_require__(32), - TimeStep: __webpack_require__(30), + stack: __webpack_require__(31), + TimeStep: __webpack_require__(34), components: { items: { - Item: __webpack_require__(34), + Item: __webpack_require__(33), BackgroundItem: __webpack_require__(38), BoxItem: __webpack_require__(36), PointItem: __webpack_require__(37), - RangeItem: __webpack_require__(33) + RangeItem: __webpack_require__(32) }, Component: __webpack_require__(26), @@ -127,7 +127,7 @@ return /******/ (function(modules) { // webpackBootstrap CustomTime: __webpack_require__(42), DataAxis: __webpack_require__(51), GraphGroup: __webpack_require__(53), - Group: __webpack_require__(31), + Group: __webpack_require__(30), BackgroundGroup: __webpack_require__(35), ItemSet: __webpack_require__(29), Legend: __webpack_require__(57), @@ -551,11 +551,11 @@ return /******/ (function(modules) { // webpackBootstrap // object is an ASP date return new Date(Number(match[1])); // parse number } else { - return moment(object).toDate(); // parse string - } + return moment(object).toDate(); // parse string + } } else { - throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type Date'); - } + throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type Date'); + } case 'Moment': if (exports.isNumber(object)) { @@ -572,11 +572,11 @@ return /******/ (function(modules) { // webpackBootstrap // object is an ASP date return moment(Number(match[1])); // parse number } else { - return moment(object); // parse string - } + return moment(object); // parse string + } } else { - throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type Date'); - } + throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type Date'); + } case 'ISODate': if (exports.isNumber(object)) { @@ -591,11 +591,11 @@ return /******/ (function(modules) { // webpackBootstrap // object is an ASP date return new Date(Number(match[1])).toISOString(); // parse number } else { - return new Date(object).toISOString(); // parse string - } + return new Date(object).toISOString(); // parse string + } } else { - throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type ISODate'); - } + throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type ISODate'); + } case 'ASPDate': if (exports.isNumber(object)) { @@ -609,8 +609,8 @@ return /******/ (function(modules) { // webpackBootstrap // object is an ASP date value = new Date(Number(match[1])).valueOf(); // parse number } else { - value = new Date(object).valueOf(); // parse string - } + value = new Date(object).valueOf(); // parse string + } return '/Date(' + value + ')/'; } else { throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type ASPDate'); @@ -842,13 +842,13 @@ return /******/ (function(modules) { // webpackBootstrap if (element.addEventListener) { if (useCapture === undefined) useCapture = false; - if (action === 'mousewheel' && navigator.userAgent.indexOf('Firefox') >= 0) { - action = 'DOMMouseScroll'; // For Firefox + if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) { + action = "DOMMouseScroll"; // For Firefox } element.addEventListener(action, listener, useCapture); } else { - element.attachEvent('on' + action, listener); // IE browsers + element.attachEvent("on" + action, listener); // IE browsers } }; @@ -864,14 +864,14 @@ return /******/ (function(modules) { // webpackBootstrap // non-IE browsers if (useCapture === undefined) useCapture = false; - if (action === 'mousewheel' && navigator.userAgent.indexOf('Firefox') >= 0) { - action = 'DOMMouseScroll'; // For Firefox + if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) { + action = "DOMMouseScroll"; // For Firefox } element.removeEventListener(action, listener, useCapture); } else { // IE browsers - element.detachEvent('on' + action, listener); + element.detachEvent("on" + action, listener); } }; @@ -884,8 +884,8 @@ return /******/ (function(modules) { // webpackBootstrap if (event.preventDefault) { event.preventDefault(); // non-IE browsers } else { - event.returnValue = false; // IE browsers - } + event.returnValue = false; // IE browsers + } }; /** @@ -1050,17 +1050,17 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} */ exports.overrideOpacity = function (color, opacity) { - if (color.indexOf('rgba') != -1) { + if (color.indexOf("rgba") != -1) { return color; - } else if (color.indexOf('rgb') != -1) { - var rgb = color.substr(color.indexOf('(') + 1).replace(')', '').split(','); - return 'rgba(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ',' + opacity + ')'; + } else if (color.indexOf("rgb") != -1) { + var rgb = color.substr(color.indexOf("(") + 1).replace(")", "").split(","); + return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + opacity + ")"; } else { var rgb = exports.hexToRGB(color); if (rgb == null) { return color; } else { - return 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + opacity + ')'; + return "rgba(" + rgb.r + "," + rgb.g + "," + rgb.b + "," + opacity + ")"; } } }; @@ -1074,7 +1074,7 @@ return /******/ (function(modules) { // webpackBootstrap * @constructor */ exports.RGBToHex = function (red, green, blue) { - return '#' + ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1); + return "#" + ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1); }; /** @@ -1290,12 +1290,12 @@ return /******/ (function(modules) { // webpackBootstrap }; exports.isValidRGB = function (rgb) { - rgb = rgb.replace(' ', ''); + rgb = rgb.replace(" ", ""); var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(rgb); return isOk; }; exports.isValidRGBA = function (rgba) { - rgba = rgba.replace(' ', ''); + rgba = rgba.replace(" ", ""); var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(rgba); return isOk; }; @@ -1308,11 +1308,11 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} */ exports.selectiveBridgeObject = function (fields, referenceObject) { - if (typeof referenceObject == 'object') { + if (typeof referenceObject == "object") { var objectTo = Object.create(referenceObject); for (var i = 0; i < fields.length; i++) { if (referenceObject.hasOwnProperty(fields[i])) { - if (typeof referenceObject[fields[i]] == 'object') { + if (typeof referenceObject[fields[i]] == "object") { objectTo[fields[i]] = exports.bridgeObject(referenceObject[fields[i]]); } } @@ -1331,11 +1331,11 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} */ exports.bridgeObject = function (referenceObject) { - if (typeof referenceObject == 'object') { + if (typeof referenceObject == "object") { var objectTo = Object.create(referenceObject); for (var i in referenceObject) { if (referenceObject.hasOwnProperty(i)) { - if (typeof referenceObject[i] == 'object') { + if (typeof referenceObject[i] == "object") { objectTo[i] = exports.bridgeObject(referenceObject[i]); } } @@ -1547,13 +1547,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {//! moment.js - //! version : 2.10.6 + //! version : 2.10.3 //! authors : Tim Wood, Iskren Chernev, Moment.js contributors //! license : MIT //! momentjs.com (function (global, factory) { - true ? module.exports = factory() : + true ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.moment = factory() }(this, function () { 'use strict'; @@ -1642,7 +1642,6 @@ return /******/ (function(modules) { // webpackBootstrap flags.overflow < 0 && !flags.empty && !flags.invalidMonth && - !flags.invalidWeekday && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated; @@ -1723,7 +1722,7 @@ return /******/ (function(modules) { // webpackBootstrap // Moment prototype object function Moment(config) { copyConfig(this, config); - this._d = new Date(config._d != null ? config._d.getTime() : NaN); + this._d = new Date(+config._d); // Prevent infinite loop in case updateOffset creates new moment // objects. if (updateInProgress === false) { @@ -1737,20 +1736,16 @@ return /******/ (function(modules) { // webpackBootstrap return obj instanceof Moment || (obj != null && obj._isAMomentObject != null); } - function absFloor (number) { - if (number < 0) { - return Math.ceil(number); - } else { - return Math.floor(number); - } - } - function toInt(argumentForCoercion) { var coercedNumber = +argumentForCoercion, value = 0; if (coercedNumber !== 0 && isFinite(coercedNumber)) { - value = absFloor(coercedNumber); + if (coercedNumber >= 0) { + value = Math.floor(coercedNumber); + } else { + value = Math.ceil(coercedNumber); + } } return value; @@ -1848,7 +1843,9 @@ return /******/ (function(modules) { // webpackBootstrap function defineLocale (name, values) { if (values !== null) { values.abbr = name; - locales[name] = locales[name] || new Locale(); + if (!locales[name]) { + locales[name] = new Locale(); + } locales[name].set(values); // backwards compat for now: also set the locale @@ -1952,14 +1949,16 @@ return /******/ (function(modules) { // webpackBootstrap } function zeroFill(number, targetLength, forceSign) { - var absNumber = '' + Math.abs(number), - zerosToFill = targetLength - absNumber.length, + var output = '' + Math.abs(number), sign = number >= 0; - return (sign ? (forceSign ? '+' : '') : '-') + - Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber; + + while (output.length < targetLength) { + output = '0' + output; + } + return (sign ? (forceSign ? '+' : '') : '-') + output; } - var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g; + var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g; var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g; @@ -2027,7 +2026,10 @@ return /******/ (function(modules) { // webpackBootstrap } format = expandFormat(format, m.localeData()); - formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format); + + if (!formatFunctions[format]) { + formatFunctions[format] = makeFormatFunction(format); + } return formatFunctions[format](m); } @@ -2071,15 +2073,8 @@ return /******/ (function(modules) { // webpackBootstrap var regexes = {}; - function isFunction (sth) { - // https://github.com/moment/moment/issues/2325 - return typeof sth === 'function' && - Object.prototype.toString.call(sth) === '[object Function]'; - } - - function addRegexToken (token, regex, strictRegex) { - regexes[token] = isFunction(regex) ? regex : function (isStrict) { + regexes[token] = typeof regex === 'function' ? regex : function (isStrict) { return (isStrict && strictRegex) ? strictRegex : regex; }; } @@ -2287,11 +2282,12 @@ return /******/ (function(modules) { // webpackBootstrap } function deprecate(msg, fn) { - var firstTime = true; + var firstTime = true, + msgWithStack = msg + '\n' + (new Error()).stack; return extend(function () { if (firstTime) { - warn(msg + '\n' + (new Error()).stack); + warn(msgWithStack); firstTime = false; } return fn.apply(this, arguments); @@ -2339,14 +2335,14 @@ return /******/ (function(modules) { // webpackBootstrap getParsingFlags(config).iso = true; for (i = 0, l = isoDates.length; i < l; i++) { if (isoDates[i][1].exec(string)) { - config._f = isoDates[i][0]; + // match[5] should be 'T' or undefined + config._f = isoDates[i][0] + (match[6] || ' '); break; } } for (i = 0, l = isoTimes.length; i < l; i++) { if (isoTimes[i][1].exec(string)) { - // match[6] should be 'T' or space - config._f += (match[6] || ' ') + isoTimes[i][0]; + config._f += isoTimes[i][0]; break; } } @@ -2425,10 +2421,7 @@ return /******/ (function(modules) { // webpackBootstrap addRegexToken('YYYYY', match1to6, match6); addRegexToken('YYYYYY', match1to6, match6); - addParseToken(['YYYYY', 'YYYYYY'], YEAR); - addParseToken('YYYY', function (input, array) { - array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input); - }); + addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR); addParseToken('YY', function (input, array) { array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input); }); @@ -2555,18 +2548,18 @@ return /******/ (function(modules) { // webpackBootstrap //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { - var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear; - if (d < firstDayOfWeek) { - d += 7; - } + var d = createUTCDate(year, 0, 1).getUTCDay(); + var daysToAdd; + var dayOfYear; - weekday = weekday != null ? 1 * weekday : firstDayOfWeek; - - dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday; + d = d === 0 ? 7 : d; + weekday = weekday != null ? weekday : firstDayOfWeek; + daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); + dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; return { - year: dayOfYear > 0 ? year : year - 1, - dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear + year : dayOfYear > 0 ? year : year - 1, + dayOfYear : dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear }; } @@ -2852,19 +2845,9 @@ return /******/ (function(modules) { // webpackBootstrap } function createFromConfig (config) { - var res = new Moment(checkOverflow(prepareConfig(config))); - if (res._nextDay) { - // Adding is smart enough around DST - res.add(1, 'd'); - res._nextDay = undefined; - } - - return res; - } - - function prepareConfig (config) { var input = config._i, - format = config._f; + format = config._f, + res; config._locale = config._locale || locale_locales__getLocale(config._l); @@ -2888,7 +2871,14 @@ return /******/ (function(modules) { // webpackBootstrap configFromInput(config); } - return config; + res = new Moment(checkOverflow(config)); + if (res._nextDay) { + // Adding is smart enough around DST + res.add(1, 'd'); + res._nextDay = undefined; + } + + return res; } function configFromInput(config) { @@ -2968,7 +2958,7 @@ return /******/ (function(modules) { // webpackBootstrap } res = moments[0]; for (i = 1; i < moments.length; ++i) { - if (!moments[i].isValid() || moments[i][fn](res)) { + if (moments[i][fn](res)) { res = moments[i]; } } @@ -3080,6 +3070,7 @@ return /******/ (function(modules) { // webpackBootstrap } else { return local__createLocal(input).local(); } + return model._isUTC ? local__createLocal(input).zone(model._offset || 0) : local__createLocal(input).local(); } function getDateOffset (m) { @@ -3179,7 +3170,12 @@ return /******/ (function(modules) { // webpackBootstrap } function hasAlignedHourOffset (input) { - input = input ? local__createLocal(input).utcOffset() : 0; + if (!input) { + input = 0; + } + else { + input = local__createLocal(input).utcOffset(); + } return (this.utcOffset() - input) % 60 === 0; } @@ -3192,24 +3188,12 @@ return /******/ (function(modules) { // webpackBootstrap } function isDaylightSavingTimeShifted () { - if (typeof this._isDSTShifted !== 'undefined') { - return this._isDSTShifted; + if (this._a) { + var other = this._isUTC ? create_utc__createUTC(this._a) : local__createLocal(this._a); + return this.isValid() && compareArrays(this._a, other.toArray()) > 0; } - var c = {}; - - copyConfig(c, this); - c = prepareConfig(c); - - if (c._a) { - var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a); - this._isDSTShifted = this.isValid() && - compareArrays(c._a, other.toArray()) > 0; - } else { - this._isDSTShifted = false; - } - - return this._isDSTShifted; + return false; } function isLocal () { @@ -3369,7 +3353,7 @@ return /******/ (function(modules) { // webpackBootstrap var add_subtract__add = createAdder(1, 'add'); var add_subtract__subtract = createAdder(-1, 'subtract'); - function moment_calendar__calendar (time, formats) { + function moment_calendar__calendar (time) { // We want to compare the start of today, vs this. // Getting start-of-today depends on whether we're local/utc/offset or not. var now = time || local__createLocal(), @@ -3381,7 +3365,7 @@ return /******/ (function(modules) { // webpackBootstrap diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse'; - return this.format(formats && formats[format] || this.localeData().calendar(format, this, local__createLocal(now))); + return this.format(this.localeData().calendar(format, this, local__createLocal(now))); } function clone () { @@ -3428,6 +3412,14 @@ return /******/ (function(modules) { // webpackBootstrap } } + function absFloor (number) { + if (number < 0) { + return Math.ceil(number); + } else { + return Math.floor(number); + } + } + function diff (input, units, asFloat) { var that = cloneWithOffset(input, this), zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4, @@ -3618,19 +3610,6 @@ return /******/ (function(modules) { // webpackBootstrap return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()]; } - function toObject () { - var m = this; - return { - years: m.year(), - months: m.month(), - date: m.date(), - hours: m.hours(), - minutes: m.minutes(), - seconds: m.seconds(), - milliseconds: m.milliseconds() - }; - } - function moment_valid__isValid () { return valid__isValid(this); } @@ -3802,20 +3781,18 @@ return /******/ (function(modules) { // webpackBootstrap // HELPERS function parseWeekday(input, locale) { - if (typeof input !== 'string') { - return input; - } - - if (!isNaN(input)) { - return parseInt(input, 10); - } - - input = locale.weekdaysParse(input); - if (typeof input === 'number') { - return input; + if (typeof input === 'string') { + if (!isNaN(input)) { + input = parseInt(input, 10); + } + else { + input = locale.weekdaysParse(input); + if (typeof input !== 'number') { + return null; + } + } } - - return null; + return input; } // LOCALES @@ -3838,7 +3815,9 @@ return /******/ (function(modules) { // webpackBootstrap function localeWeekdaysParse (weekdayName) { var i, mom, regex; - this._weekdaysParse = this._weekdaysParse || []; + if (!this._weekdaysParse) { + this._weekdaysParse = []; + } for (i = 0; i < 7; i++) { // make the regex if we don't have it already @@ -3985,26 +3964,12 @@ return /******/ (function(modules) { // webpackBootstrap return ~~(this.millisecond() / 10); }); - addFormatToken(0, ['SSS', 3], 0, 'millisecond'); - addFormatToken(0, ['SSSS', 4], 0, function () { - return this.millisecond() * 10; - }); - addFormatToken(0, ['SSSSS', 5], 0, function () { - return this.millisecond() * 100; - }); - addFormatToken(0, ['SSSSSS', 6], 0, function () { - return this.millisecond() * 1000; - }); - addFormatToken(0, ['SSSSSSS', 7], 0, function () { - return this.millisecond() * 10000; - }); - addFormatToken(0, ['SSSSSSSS', 8], 0, function () { - return this.millisecond() * 100000; - }); - addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { - return this.millisecond() * 1000000; - }); + function millisecond__milliseconds (token) { + addFormatToken(0, [token, 3], 0, 'millisecond'); + } + millisecond__milliseconds('SSS'); + millisecond__milliseconds('SSSS'); // ALIASES @@ -4015,19 +3980,11 @@ return /******/ (function(modules) { // webpackBootstrap addRegexToken('S', match1to3, match1); addRegexToken('SS', match1to3, match2); addRegexToken('SSS', match1to3, match3); - - var token; - for (token = 'SSSS'; token.length <= 9; token += 'S') { - addRegexToken(token, matchUnsigned); - } - - function parseMs(input, array) { + addRegexToken('SSSS', matchUnsigned); + addParseToken(['S', 'SS', 'SSS', 'SSSS'], function (input, array) { array[MILLISECOND] = toInt(('0.' + input) * 1000); - } + }); - for (token = 'S'; token.length <= 9; token += 'S') { - addParseToken(token, parseMs); - } // MOMENTS var getSetMillisecond = makeGetSet('Milliseconds', false); @@ -4074,7 +4031,6 @@ return /******/ (function(modules) { // webpackBootstrap momentPrototype__proto.startOf = startOf; momentPrototype__proto.subtract = add_subtract__subtract; momentPrototype__proto.toArray = toArray; - momentPrototype__proto.toObject = toObject; momentPrototype__proto.toDate = toDate; momentPrototype__proto.toISOString = moment_format__toISOString; momentPrototype__proto.toJSON = moment_format__toISOString; @@ -4174,23 +4130,19 @@ return /******/ (function(modules) { // webpackBootstrap LT : 'h:mm A', L : 'MM/DD/YYYY', LL : 'MMMM D, YYYY', - LLL : 'MMMM D, YYYY h:mm A', - LLLL : 'dddd, MMMM D, YYYY h:mm A' + LLL : 'MMMM D, YYYY LT', + LLLL : 'dddd, MMMM D, YYYY LT' }; function longDateFormat (key) { - var format = this._longDateFormat[key], - formatUpper = this._longDateFormat[key.toUpperCase()]; - - if (format || !formatUpper) { - return format; + var output = this._longDateFormat[key]; + if (!output && this._longDateFormat[key.toUpperCase()]) { + output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) { + return val.slice(1); + }); + this._longDateFormat[key] = output; } - - this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) { - return val.slice(1); - }); - - return this._longDateFormat[key]; + return output; } var defaultInvalidDate = 'Invalid date'; @@ -4399,29 +4351,12 @@ return /******/ (function(modules) { // webpackBootstrap return duration_add_subtract__addSubtract(this, input, value, -1); } - function absCeil (number) { - if (number < 0) { - return Math.floor(number); - } else { - return Math.ceil(number); - } - } - function bubble () { var milliseconds = this._milliseconds; var days = this._days; var months = this._months; var data = this._data; - var seconds, minutes, hours, years, monthsFromDays; - - // if we have a mix of positive and negative values, bubble down first - // check: https://github.com/moment/moment/issues/2166 - if (!((milliseconds >= 0 && days >= 0 && months >= 0) || - (milliseconds <= 0 && days <= 0 && months <= 0))) { - milliseconds += absCeil(monthsToDays(months) + days) * 864e5; - days = 0; - months = 0; - } + var seconds, minutes, hours, years = 0; // The following code bubbles up values, see the tests for // examples of what that means. @@ -4438,13 +4373,17 @@ return /******/ (function(modules) { // webpackBootstrap days += absFloor(hours / 24); - // convert days to months - monthsFromDays = absFloor(daysToMonths(days)); - months += monthsFromDays; - days -= absCeil(monthsToDays(monthsFromDays)); + // Accurately convert days to years, assume start from year 0. + years = absFloor(daysToYears(days)); + days -= absFloor(yearsToDays(years)); + + // 30 days to a month + // TODO (iskren): Use anchor date (like 1st Jan) to compute this. + months += absFloor(days / 30); + days %= 30; // 12 months -> 1 year - years = absFloor(months / 12); + years += absFloor(months / 12); months %= 12; data.days = days; @@ -4454,15 +4393,15 @@ return /******/ (function(modules) { // webpackBootstrap return this; } - function daysToMonths (days) { + function daysToYears (days) { // 400 years have 146097 days (taking into account leap year rules) - // 400 years have 12 months === 4800 - return days * 4800 / 146097; + return days * 400 / 146097; } - function monthsToDays (months) { - // the reverse of daysToMonths - return months * 146097 / 4800; + function yearsToDays (years) { + // years * 365 + absFloor(years / 4) - + // absFloor(years / 100) + absFloor(years / 400); + return years * 146097 / 400; } function as (units) { @@ -4474,11 +4413,11 @@ return /******/ (function(modules) { // webpackBootstrap if (units === 'month' || units === 'year') { days = this._days + milliseconds / 864e5; - months = this._months + daysToMonths(days); + months = this._months + daysToYears(days) * 12; return units === 'month' ? months : months / 12; } else { // handle milliseconds separately because of floating point math errors (issue #1867) - days = this._days + Math.round(monthsToDays(this._months)); + days = this._days + Math.round(yearsToDays(this._months / 12)); switch (units) { case 'week' : return days / 7 + milliseconds / 6048e5; case 'day' : return days + milliseconds / 864e5; @@ -4528,7 +4467,7 @@ return /******/ (function(modules) { // webpackBootstrap }; } - var milliseconds = makeGetter('milliseconds'); + var duration_get__milliseconds = makeGetter('milliseconds'); var seconds = makeGetter('seconds'); var minutes = makeGetter('minutes'); var hours = makeGetter('hours'); @@ -4606,36 +4545,13 @@ return /******/ (function(modules) { // webpackBootstrap var iso_string__abs = Math.abs; function iso_string__toISOString() { - // for ISO strings we do not use the normal bubbling rules: - // * milliseconds bubble up until they become hours - // * days do not bubble at all - // * months bubble up until they become years - // This is because there is no context-free conversion between hours and days - // (think of clock changes) - // and also not between days and months (28-31 days per month) - var seconds = iso_string__abs(this._milliseconds) / 1000; - var days = iso_string__abs(this._days); - var months = iso_string__abs(this._months); - var minutes, hours, years; - - // 3600 seconds -> 60 minutes -> 1 hour - minutes = absFloor(seconds / 60); - hours = absFloor(minutes / 60); - seconds %= 60; - minutes %= 60; - - // 12 months -> 1 year - years = absFloor(months / 12); - months %= 12; - - // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js - var Y = years; - var M = months; - var D = days; - var h = hours; - var m = minutes; - var s = seconds; + var Y = iso_string__abs(this.years()); + var M = iso_string__abs(this.months()); + var D = iso_string__abs(this.days()); + var h = iso_string__abs(this.hours()); + var m = iso_string__abs(this.minutes()); + var s = iso_string__abs(this.seconds() + this.milliseconds() / 1000); var total = this.asSeconds(); if (!total) { @@ -4672,7 +4588,7 @@ return /******/ (function(modules) { // webpackBootstrap duration_prototype__proto.valueOf = duration_as__valueOf; duration_prototype__proto._bubble = bubble; duration_prototype__proto.get = duration_get__get; - duration_prototype__proto.milliseconds = milliseconds; + duration_prototype__proto.milliseconds = duration_get__milliseconds; duration_prototype__proto.seconds = seconds; duration_prototype__proto.minutes = minutes; duration_prototype__proto.hours = hours; @@ -4710,7 +4626,7 @@ return /******/ (function(modules) { // webpackBootstrap // Side effect imports - utils_hooks__hooks.version = '2.10.6'; + utils_hooks__hooks.version = '2.10.3'; setHookCallback(local__createLocal); @@ -5125,21 +5041,21 @@ return /******/ (function(modules) { // webpackBootstrap var point; if (groupTemplate.style == 'circle') { point = exports.getSVGElement('circle', JSONcontainer, svgContainer); - point.setAttributeNS(null, 'cx', x); - point.setAttributeNS(null, 'cy', y); - point.setAttributeNS(null, 'r', 0.5 * groupTemplate.size); + point.setAttributeNS(null, "cx", x); + point.setAttributeNS(null, "cy", y); + point.setAttributeNS(null, "r", 0.5 * groupTemplate.size); } else { point = exports.getSVGElement('rect', JSONcontainer, svgContainer); - point.setAttributeNS(null, 'x', x - 0.5 * groupTemplate.size); - point.setAttributeNS(null, 'y', y - 0.5 * groupTemplate.size); - point.setAttributeNS(null, 'width', groupTemplate.size); - point.setAttributeNS(null, 'height', groupTemplate.size); + point.setAttributeNS(null, "x", x - 0.5 * groupTemplate.size); + point.setAttributeNS(null, "y", y - 0.5 * groupTemplate.size); + point.setAttributeNS(null, "width", groupTemplate.size); + point.setAttributeNS(null, "height", groupTemplate.size); } if (groupTemplate.style !== undefined) { - point.setAttributeNS(null, 'style', groupTemplate.style); + point.setAttributeNS(null, "style", groupTemplate.style); } - point.setAttributeNS(null, 'class', groupTemplate.className + ' vis-point'); + point.setAttributeNS(null, "class", groupTemplate.className + " vis-point"); //handle label if (labelObj) { @@ -5156,10 +5072,10 @@ return /******/ (function(modules) { // webpackBootstrap } if (labelObj.className) { - label.setAttributeNS(null, 'class', labelObj.className + ' vis-label'); + label.setAttributeNS(null, "class", labelObj.className + " vis-label"); } - label.setAttributeNS(null, 'x', x); - label.setAttributeNS(null, 'y', y); + label.setAttributeNS(null, "x", x); + label.setAttributeNS(null, "y", y); } return point; @@ -5179,13 +5095,13 @@ return /******/ (function(modules) { // webpackBootstrap y -= height; } var rect = exports.getSVGElement('rect', JSONcontainer, svgContainer); - rect.setAttributeNS(null, 'x', x - 0.5 * width); - rect.setAttributeNS(null, 'y', y); - rect.setAttributeNS(null, 'width', width); - rect.setAttributeNS(null, 'height', height); - rect.setAttributeNS(null, 'class', className); + rect.setAttributeNS(null, "x", x - 0.5 * width); + rect.setAttributeNS(null, "y", y); + rect.setAttributeNS(null, "width", width); + rect.setAttributeNS(null, "height", height); + rect.setAttributeNS(null, "class", className); if (style) { - rect.setAttributeNS(null, 'style', style); + rect.setAttributeNS(null, "style", style); } } }; @@ -5815,8 +5731,8 @@ return /******/ (function(modules) { // webpackBootstrap // TODO: extend order by an Object {field:String, direction:String} // where direction can be 'asc' or 'desc' else { - throw new TypeError('Order must be a function or a string'); - } + throw new TypeError('Order must be a function or a string'); + } }; /** @@ -6592,7 +6508,9 @@ return /******/ (function(modules) { // webpackBootstrap if (this._ids[id]) { delete this._ids[id]; removed.push(id); - } else {} + } else { + // nothing interesting for me :-( + } } } @@ -6636,20 +6554,18 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = DataView; - // nothing interesting for me :-( - /***/ }, /* 11 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var Emitter = __webpack_require__(12); + var Emitter = __webpack_require__(13); var DataSet = __webpack_require__(8); var DataView = __webpack_require__(10); var util = __webpack_require__(1); - var Point3d = __webpack_require__(13); - var Point2d = __webpack_require__(14); + var Point3d = __webpack_require__(14); + var Point2d = __webpack_require__(12); var Camera = __webpack_require__(15); var Filter = __webpack_require__(16); var Slider = __webpack_require__(17); @@ -6881,9 +6797,11 @@ return /******/ (function(modules) { // webpackBootstrap if (backgroundColor.fill !== undefined) fill = backgroundColor.fill; if (backgroundColor.stroke !== undefined) stroke = backgroundColor.stroke; if (backgroundColor.strokeWidth !== undefined) strokeWidth = backgroundColor.strokeWidth; - } else if (backgroundColor === undefined) {} else { - throw 'Unsupported type of backgroundColor'; - } + } else if (backgroundColor === undefined) { + // use use defaults + } else { + throw 'Unsupported type of backgroundColor'; + } this.frame.style.backgroundColor = fill; this.frame.style.borderColor = stroke; @@ -7589,9 +7507,9 @@ return /******/ (function(modules) { // webpackBootstrap widthMin = dotSize / 2; // px widthMax = dotSize / 2 + dotSize * 2; // Todo: put this in one function } else { - widthMin = 20; // px - widthMax = 20; // px - } + widthMin = 20; // px + widthMax = 20; // px + } var height = Math.max(this.frame.clientHeight * 0.25, 100); var top = this.margin; @@ -8127,9 +8045,9 @@ return /******/ (function(modules) { // webpackBootstrap strokeStyle = this.axisColor; // TODO: should be customizable } } else { - fillStyle = 'gray'; - strokeStyle = this.axisColor; - } + fillStyle = 'gray'; + strokeStyle = this.axisColor; + } ctx.lineWidth = this._getStrokeWidth(point); ctx.fillStyle = fillStyle; @@ -8884,12 +8802,28 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Graph3d; - // use use defaults - /***/ }, /* 12 */ /***/ function(module, exports) { + /** + * @prototype Point2d + * @param {Number} [x] + * @param {Number} [y] + */ + "use strict"; + + function Point2d(x, y) { + this.x = x !== undefined ? x : 0; + this.y = y !== undefined ? y : 0; + } + + module.exports = Point2d; + +/***/ }, +/* 13 */ +/***/ function(module, exports) { + /** * Expose `Emitter`. @@ -9057,7 +8991,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 13 */ +/* 14 */ /***/ function(module, exports) { /** @@ -9139,31 +9073,13 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Point3d; -/***/ }, -/* 14 */ -/***/ function(module, exports) { - - /** - * @prototype Point2d - * @param {Number} [x] - * @param {Number} [y] - */ - "use strict"; - - function Point2d(x, y) { - this.x = x !== undefined ? x : 0; - this.y = y !== undefined ? y : 0; - } - - module.exports = Point2d; - /***/ }, /* 15 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var Point3d = __webpack_require__(13); + var Point3d = __webpack_require__(14); /** * @class Camera @@ -10007,7 +9923,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var Emitter = __webpack_require__(12); + var Emitter = __webpack_require__(13); var Hammer = __webpack_require__(20); var moment = __webpack_require__(2); var util = __webpack_require__(1); @@ -10404,7 +10320,10 @@ return /******/ (function(modules) { // webpackBootstrap var getEnd = function getEnd(item) { var end = item.data.end != undefined ? item.data.end : item.data.start; return util.convert(end, 'Date').valueOf(); - }; + } + + // calculate the date of the left side and right side of the items given + ; interval = max - min; // ms @@ -10412,8 +10331,6 @@ return /******/ (function(modules) { // webpackBootstrap interval = 10; } factor = interval / _this.props.center.width; - - // calculate the date of the left side and right side of the items given util.forEach(_this.itemSet.items, (function (item) { item.show(); @@ -14074,7 +13991,9 @@ return /******/ (function(modules) { // webpackBootstrap /** * Destroy the component. Cleanup DOM and event listeners */ - Component.prototype.destroy = function () {}; + Component.prototype.destroy = function () { + // should be implemented by the component + }; /** * Test whether the component is resized since the last time _isResized() was @@ -14093,8 +14012,6 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Component; - // should be implemented by the component - /***/ }, /* 27 */ /***/ function(module, exports) { @@ -14169,16 +14086,16 @@ return /******/ (function(modules) { // webpackBootstrap } startDate.dayOfYear(start.dayOfYear()); startDate.year(start.year()); - startDate.subtract(7, "days"); + startDate.subtract(7, 'days'); endDate.dayOfYear(start.dayOfYear()); endDate.year(start.year()); - endDate.subtract(7 - offset, "days"); + endDate.subtract(7 - offset, 'days'); - runUntil.add(1, "weeks"); + runUntil.add(1, 'weeks'); break; case "weekly": - var dayOffset = endDate.diff(startDate, "days"); + var dayOffset = endDate.diff(startDate, 'days'); var day = startDate.day(); // set the start date to the range.start @@ -14190,12 +14107,12 @@ return /******/ (function(modules) { // webpackBootstrap // force startDate.day(day); endDate.day(day); - endDate.add(dayOffset, "days"); + endDate.add(dayOffset, 'days'); - startDate.subtract(1, "weeks"); - endDate.subtract(1, "weeks"); + startDate.subtract(1, 'weeks'); + endDate.subtract(1, 'weeks'); - runUntil.add(1, "weeks"); + runUntil.add(1, 'weeks'); break; case "monthly": if (startDate.month() != endDate.month()) { @@ -14203,26 +14120,26 @@ return /******/ (function(modules) { // webpackBootstrap } startDate.month(start.month()); startDate.year(start.year()); - startDate.subtract(1, "months"); + startDate.subtract(1, 'months'); endDate.month(start.month()); endDate.year(start.year()); - endDate.subtract(1, "months"); - endDate.add(offset, "months"); + endDate.subtract(1, 'months'); + endDate.add(offset, 'months'); - runUntil.add(1, "months"); + runUntil.add(1, 'months'); break; case "yearly": if (startDate.year() != endDate.year()) { offset = 1; } startDate.year(start.year()); - startDate.subtract(1, "years"); + startDate.subtract(1, 'years'); endDate.year(start.year()); - endDate.subtract(1, "years"); - endDate.add(offset, "years"); + endDate.subtract(1, 'years'); + endDate.add(offset, 'years'); - runUntil.add(1, "years"); + runUntil.add(1, 'years'); break; default: console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", hiddenDates[i].repeat); @@ -14232,20 +14149,20 @@ return /******/ (function(modules) { // webpackBootstrap body.hiddenDates.push({ start: startDate.valueOf(), end: endDate.valueOf() }); switch (hiddenDates[i].repeat) { case "daily": - startDate.add(1, "days"); - endDate.add(1, "days"); + startDate.add(1, 'days'); + endDate.add(1, 'days'); break; case "weekly": - startDate.add(1, "weeks"); - endDate.add(1, "weeks"); + startDate.add(1, 'weeks'); + endDate.add(1, 'weeks'); break; case "monthly": - startDate.add(1, "months"); - endDate.add(1, "months"); + startDate.add(1, 'months'); + endDate.add(1, 'months'); break; case "yearly": - startDate.add(1, "y"); - endDate.add(1, "y"); + startDate.add(1, 'y'); + endDate.add(1, 'y'); break; default: console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", hiddenDates[i].repeat); @@ -14292,14 +14209,14 @@ return /******/ (function(modules) { // webpackBootstrap } // j start inside i else if (hiddenDates[j].start >= hiddenDates[i].start && hiddenDates[j].start <= hiddenDates[i].end) { - hiddenDates[i].end = hiddenDates[j].end; - hiddenDates[j].remove = true; - } - // j end inside i - else if (hiddenDates[j].end >= hiddenDates[i].start && hiddenDates[j].end <= hiddenDates[i].end) { - hiddenDates[i].start = hiddenDates[j].start; - hiddenDates[j].remove = true; - } + hiddenDates[i].end = hiddenDates[j].end; + hiddenDates[j].remove = true; + } + // j end inside i + else if (hiddenDates[j].end >= hiddenDates[i].start && hiddenDates[j].end <= hiddenDates[i].end) { + hiddenDates[i].start = hiddenDates[j].start; + hiddenDates[j].remove = true; + } } } } @@ -14565,7 +14482,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var Emitter = __webpack_require__(12); + var Emitter = __webpack_require__(13); var Hammer = __webpack_require__(20); var hammerUtil = __webpack_require__(25); var util = __webpack_require__(1); @@ -15497,7 +15414,7 @@ return /******/ (function(modules) { // webpackBootstrap if (newScrollTop != oldScrollTop) { this._redraw(); // TODO: this causes two redraws when dragging, the other is triggered by rangechange already - this.emit('verticalDrag'); + this.emit("verticalDrag"); } }; @@ -15567,13 +15484,13 @@ return /******/ (function(modules) { // webpackBootstrap var util = __webpack_require__(1); var DataSet = __webpack_require__(8); var DataView = __webpack_require__(10); - var TimeStep = __webpack_require__(30); + var TimeStep = __webpack_require__(34); var Component = __webpack_require__(26); - var Group = __webpack_require__(31); + var Group = __webpack_require__(30); var BackgroundGroup = __webpack_require__(35); var BoxItem = __webpack_require__(36); var PointItem = __webpack_require__(37); - var RangeItem = __webpack_require__(33); + var RangeItem = __webpack_require__(32); var BackgroundItem = __webpack_require__(38); var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items @@ -17083,25 +17000,25 @@ return /******/ (function(modules) { // webpackBootstrap } // if dragged group was move downwards everything above should have an offset else if (origOrder[curPos + orgOffset] == draggedId) { - orgOffset = 1; - continue; - } - // found a group (apart from dragged group) that has the wrong position -> switch with the - // group at the position where other one should be, fix index arrays and continue - else { - var slippedPosition = newOrder.indexOf(origOrder[curPos + orgOffset]); - var switchGroup = groupsData.get(newOrder[curPos + newOffset]); - var shouldBeGroup = groupsData.get(origOrder[curPos + orgOffset]); - this.options.groupOrderSwap(switchGroup, shouldBeGroup, groupsData); - groupsData.update(switchGroup); - groupsData.update(shouldBeGroup); - - var switchGroupId = newOrder[curPos + newOffset]; - newOrder[curPos + newOffset] = origOrder[curPos + orgOffset]; - newOrder[slippedPosition] = switchGroupId; - - curPos++; - } + orgOffset = 1; + continue; + } + // found a group (apart from dragged group) that has the wrong position -> switch with the + // group at the position where other one should be, fix index arrays and continue + else { + var slippedPosition = newOrder.indexOf(origOrder[curPos + orgOffset]); + var switchGroup = groupsData.get(newOrder[curPos + newOffset]); + var shouldBeGroup = groupsData.get(origOrder[curPos + orgOffset]); + this.options.groupOrderSwap(switchGroup, shouldBeGroup, groupsData); + groupsData.update(switchGroup); + groupsData.update(shouldBeGroup); + + var switchGroupId = newOrder[curPos + newOffset]; + newOrder[curPos + newOffset] = origOrder[curPos + orgOffset]; + newOrder[slippedPosition] = switchGroupId; + + curPos++; + } } } } @@ -17456,872 +17373,165 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var moment = __webpack_require__(2); - var DateUtil = __webpack_require__(27); var util = __webpack_require__(1); + var stack = __webpack_require__(31); + var RangeItem = __webpack_require__(32); /** - * @constructor TimeStep - * The class TimeStep is an iterator for dates. You provide a start date and an - * end date. The class itself determines the best scale (step size) based on the - * provided start Date, end Date, and minimumStep. - * - * If minimumStep is provided, the step size is chosen as close as possible - * to the minimumStep but larger than minimumStep. If minimumStep is not - * provided, the scale is set to 1 DAY. - * The minimumStep should correspond with the onscreen size of about 6 characters - * - * Alternatively, you can set a scale by hand. - * After creation, you can initialize the class by executing first(). Then you - * can iterate from the start date to the end date via next(). You can check if - * the end date is reached with the function hasNext(). After each step, you can - * retrieve the current date via getCurrent(). - * The TimeStep has scales ranging from milliseconds, seconds, minutes, hours, - * days, to years. - * - * Version: 1.2 - * - * @param {Date} [start] The start date, for example new Date(2010, 9, 21) - * or new Date(2010, 9, 21, 23, 45, 00) - * @param {Date} [end] The end date - * @param {Number} [minimumStep] Optional. Minimum step size in milliseconds + * @constructor Group + * @param {Number | String} groupId + * @param {Object} data + * @param {ItemSet} itemSet */ - function TimeStep(start, end, minimumStep, hiddenDates) { - this.moment = moment; - - // variables - this.current = this.moment(); - this._start = this.moment(); - this._end = this.moment(); + function Group(groupId, data, itemSet) { + this.groupId = groupId; + this.subgroups = {}; + this.subgroupIndex = 0; + this.subgroupOrderer = data && data.subgroupOrder; + this.itemSet = itemSet; - this.autoScale = true; - this.scale = 'day'; - this.step = 1; + this.dom = {}; + this.props = { + label: { + width: 0, + height: 0 + } + }; + this.className = null; - // initialize the range - this.setRange(start, end, minimumStep); + this.items = {}; // items filtered by groupId of this group + this.visibleItems = []; // items currently visible in window + this.orderedItems = { + byStart: [], + byEnd: [] + }; + this.checkRangedItems = false; // needed to refresh the ranged items if the window is programatically changed with NO overlap. + var me = this; + this.itemSet.body.emitter.on("checkRangedItems", function () { + me.checkRangedItems = true; + }); - // hidden Dates options - this.switchedDay = false; - this.switchedMonth = false; - this.switchedYear = false; - this.hiddenDates = hiddenDates; - if (hiddenDates === undefined) { - this.hiddenDates = []; - } + this._create(); - this.format = TimeStep.FORMAT; // default formatting + this.setData(data); } - // Time formatting - TimeStep.FORMAT = { - minorLabels: { - millisecond: 'SSS', - second: 's', - minute: 'HH:mm', - hour: 'HH:mm', - weekday: 'ddd D', - day: 'D', - month: 'MMM', - year: 'YYYY' - }, - majorLabels: { - millisecond: 'HH:mm:ss', - second: 'D MMMM HH:mm', - minute: 'ddd D MMMM', - hour: 'ddd D MMMM', - weekday: 'MMMM YYYY', - day: 'MMMM YYYY', - month: 'YYYY', - year: '' - } - }; - /** - * Set custom constructor function for moment. Can be used to set dates - * to UTC or to set a utcOffset. - * @param {function} moment + * Create DOM elements for the group + * @private */ - TimeStep.prototype.setMoment = function (moment) { - this.moment = moment; + Group.prototype._create = function () { + var label = document.createElement('div'); + if (this.itemSet.options.groupEditable.order) { + label.className = 'vis-label draggable'; + } else { + label.className = 'vis-label'; + } + this.dom.label = label; - // update the date properties, can have a new utcOffset - this.current = this.moment(this.current); - this._start = this.moment(this._start); - this._end = this.moment(this._end); - }; + var inner = document.createElement('div'); + inner.className = 'vis-inner'; + label.appendChild(inner); + this.dom.inner = inner; - /** - * Set custom formatting for the minor an major labels of the TimeStep. - * Both `minorLabels` and `majorLabels` are an Object with properties: - * 'millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'month', 'year'. - * @param {{minorLabels: Object, majorLabels: Object}} format - */ - TimeStep.prototype.setFormat = function (format) { - var defaultFormat = util.deepExtend({}, TimeStep.FORMAT); - this.format = util.deepExtend(defaultFormat, format); + var foreground = document.createElement('div'); + foreground.className = 'vis-group'; + foreground['timeline-group'] = this; + this.dom.foreground = foreground; + + this.dom.background = document.createElement('div'); + this.dom.background.className = 'vis-group'; + + this.dom.axis = document.createElement('div'); + this.dom.axis.className = 'vis-group'; + + // create a hidden marker to detect when the Timelines container is attached + // to the DOM, or the style of a parent of the Timeline is changed from + // display:none is changed to visible. + this.dom.marker = document.createElement('div'); + this.dom.marker.style.visibility = 'hidden'; + this.dom.marker.innerHTML = '?'; + this.dom.background.appendChild(this.dom.marker); }; /** - * Set a new range - * If minimumStep is provided, the step size is chosen as close as possible - * to the minimumStep but larger than minimumStep. If minimumStep is not - * provided, the scale is set to 1 DAY. - * The minimumStep should correspond with the onscreen size of about 6 characters - * @param {Date} [start] The start date and time. - * @param {Date} [end] The end date and time. - * @param {int} [minimumStep] Optional. Minimum step size in milliseconds + * Set the group data for this group + * @param {Object} data Group data, can contain properties content and className */ - TimeStep.prototype.setRange = function (start, end, minimumStep) { - if (!(start instanceof Date) || !(end instanceof Date)) { - throw 'No legal start or end date in method setRange'; + Group.prototype.setData = function (data) { + // update contents + var content; + if (this.itemSet.options && this.itemSet.options.groupTemplate) { + content = this.itemSet.options.groupTemplate(data); + } else { + content = data && data.content; } - this._start = start != undefined ? this.moment(start.valueOf()) : new Date(); - this._end = end != undefined ? this.moment(end.valueOf()) : new Date(); - - if (this.autoScale) { - this.setMinimumStep(minimumStep); + if (content instanceof Element) { + this.dom.inner.appendChild(content); + while (this.dom.inner.firstChild) { + this.dom.inner.removeChild(this.dom.inner.firstChild); + } + this.dom.inner.appendChild(content); + } else if (content !== undefined && content !== null) { + this.dom.inner.innerHTML = content; + } else { + this.dom.inner.innerHTML = this.groupId || ''; // groupId can be null } - }; - /** - * Set the range iterator to the start date. - */ - TimeStep.prototype.start = function () { - this.current = this._start.clone(); - this.roundToMinor(); - }; + // update title + this.dom.label.title = data && data.title || ''; - /** - * Round the current date to the first minor date value - * This must be executed once when the current date is set to start Date - */ - TimeStep.prototype.roundToMinor = function () { - // round to floor - // IMPORTANT: we have no breaks in this switch! (this is no bug) - // noinspection FallThroughInSwitchStatementJS - switch (this.scale) { - case 'year': - this.current.year(this.step * Math.floor(this.current.year() / this.step)); - this.current.month(0); - case 'month': - this.current.date(1); - case 'day': // intentional fall through - case 'weekday': - this.current.hours(0); - case 'hour': - this.current.minutes(0); - case 'minute': - this.current.seconds(0); - case 'second': - this.current.milliseconds(0); - //case 'millisecond': // nothing to do for milliseconds + if (!this.dom.inner.firstChild) { + util.addClassName(this.dom.inner, 'vis-hidden'); + } else { + util.removeClassName(this.dom.inner, 'vis-hidden'); } - if (this.step != 1) { - // round down to the first minor value that is a multiple of the current step size - switch (this.scale) { - case 'millisecond': - this.current.subtract(this.current.milliseconds() % this.step, 'milliseconds');break; - case 'second': - this.current.subtract(this.current.seconds() % this.step, 'seconds');break; - case 'minute': - this.current.subtract(this.current.minutes() % this.step, 'minutes');break; - case 'hour': - this.current.subtract(this.current.hours() % this.step, 'hours');break; - case 'weekday': // intentional fall through - case 'day': - this.current.subtract((this.current.date() - 1) % this.step, 'day');break; - case 'month': - this.current.subtract(this.current.month() % this.step, 'month');break; - case 'year': - this.current.subtract(this.current.year() % this.step, 'year');break; - default: - break; + // update className + var className = data && data.className || null; + if (className != this.className) { + if (this.className) { + util.removeClassName(this.dom.label, this.className); + util.removeClassName(this.dom.foreground, this.className); + util.removeClassName(this.dom.background, this.className); + util.removeClassName(this.dom.axis, this.className); } + util.addClassName(this.dom.label, className); + util.addClassName(this.dom.foreground, className); + util.addClassName(this.dom.background, className); + util.addClassName(this.dom.axis, className); + this.className = className; + } + + // update style + if (this.style) { + util.removeCssText(this.dom.label, this.style); + this.style = null; + } + if (data && data.style) { + util.addCssText(this.dom.label, data.style); + this.style = data.style; } }; /** - * Check if the there is a next step - * @return {boolean} true if the current date has not passed the end date + * Get the width of the group label + * @return {number} width */ - TimeStep.prototype.hasNext = function () { - return this.current.valueOf() <= this._end.valueOf(); + Group.prototype.getLabelWidth = function () { + return this.props.label.width; }; /** - * Do the next step + * Repaint this group + * @param {{start: number, end: number}} range + * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin + * @param {boolean} [restack=false] Force restacking of all items + * @return {boolean} Returns true if the group is resized */ - TimeStep.prototype.next = function () { - var prev = this.current.valueOf(); - - // Two cases, needed to prevent issues with switching daylight savings - // (end of March and end of October) - if (this.current.month() < 6) { - switch (this.scale) { - case 'millisecond': - this.current.add(this.step, 'millisecond');break; - case 'second': - this.current.add(this.step, 'second');break; - case 'minute': - this.current.add(this.step, 'minute');break; - case 'hour': - this.current.add(this.step, 'hour'); - // in case of skipping an hour for daylight savings, adjust the hour again (else you get: 0h 5h 9h ... instead of 0h 4h 8h ...) - // TODO: is this still needed now we use the function of moment.js? - this.current.subtract(this.current.hours() % this.step, 'hour'); - break; - case 'weekday': // intentional fall through - case 'day': - this.current.add(this.step, 'day');break; - case 'month': - this.current.add(this.step, 'month');break; - case 'year': - this.current.add(this.step, 'year');break; - default: - break; - } - } else { - switch (this.scale) { - case 'millisecond': - this.current.add(this.step, 'millisecond');break; - case 'second': - this.current.add(this.step, 'second');break; - case 'minute': - this.current.add(this.step, 'minute');break; - case 'hour': - this.current.add(this.step, 'hour');break; - case 'weekday': // intentional fall through - case 'day': - this.current.add(this.step, 'day');break; - case 'month': - this.current.add(this.step, 'month');break; - case 'year': - this.current.add(this.step, 'year');break; - default: - break; - } - } - - if (this.step != 1) { - // round down to the correct major value - switch (this.scale) { - case 'millisecond': - if (this.current.milliseconds() < this.step) this.current.milliseconds(0);break; - case 'second': - if (this.current.seconds() < this.step) this.current.seconds(0);break; - case 'minute': - if (this.current.minutes() < this.step) this.current.minutes(0);break; - case 'hour': - if (this.current.hours() < this.step) this.current.hours(0);break; - case 'weekday': // intentional fall through - case 'day': - if (this.current.date() < this.step + 1) this.current.date(1);break; - case 'month': - if (this.current.month() < this.step) this.current.month(0);break; - case 'year': - break; // nothing to do for year - default: - break; - } - } - - // safety mechanism: if current time is still unchanged, move to the end - if (this.current.valueOf() == prev) { - this.current = this._end.clone(); - } - - DateUtil.stepOverHiddenDates(this.moment, this, prev); - }; - - /** - * Get the current datetime - * @return {Moment} current The current date - */ - TimeStep.prototype.getCurrent = function () { - return this.current; - }; - - /** - * Set a custom scale. Autoscaling will be disabled. - * For example setScale('minute', 5) will result - * in minor steps of 5 minutes, and major steps of an hour. - * - * @param {{scale: string, step: number}} params - * An object containing two properties: - * - A string 'scale'. Choose from 'millisecond', 'second', - * 'minute', 'hour', 'weekday', 'day', 'month', 'year'. - * - A number 'step'. A step size, by default 1. - * Choose for example 1, 2, 5, or 10. - */ - TimeStep.prototype.setScale = function (params) { - if (params && typeof params.scale == 'string') { - this.scale = params.scale; - this.step = params.step > 0 ? params.step : 1; - this.autoScale = false; - } - }; - - /** - * Enable or disable autoscaling - * @param {boolean} enable If true, autoascaling is set true - */ - TimeStep.prototype.setAutoScale = function (enable) { - this.autoScale = enable; - }; - - /** - * Automatically determine the scale that bests fits the provided minimum step - * @param {Number} [minimumStep] The minimum step size in milliseconds - */ - TimeStep.prototype.setMinimumStep = function (minimumStep) { - if (minimumStep == undefined) { - return; - } - - //var b = asc + ds; - - var stepYear = 1000 * 60 * 60 * 24 * 30 * 12; - var stepMonth = 1000 * 60 * 60 * 24 * 30; - var stepDay = 1000 * 60 * 60 * 24; - var stepHour = 1000 * 60 * 60; - var stepMinute = 1000 * 60; - var stepSecond = 1000; - var stepMillisecond = 1; - - // find the smallest step that is larger than the provided minimumStep - if (stepYear * 1000 > minimumStep) { - this.scale = 'year';this.step = 1000; - } - if (stepYear * 500 > minimumStep) { - this.scale = 'year';this.step = 500; - } - if (stepYear * 100 > minimumStep) { - this.scale = 'year';this.step = 100; - } - if (stepYear * 50 > minimumStep) { - this.scale = 'year';this.step = 50; - } - if (stepYear * 10 > minimumStep) { - this.scale = 'year';this.step = 10; - } - if (stepYear * 5 > minimumStep) { - this.scale = 'year';this.step = 5; - } - if (stepYear > minimumStep) { - this.scale = 'year';this.step = 1; - } - if (stepMonth * 3 > minimumStep) { - this.scale = 'month';this.step = 3; - } - if (stepMonth > minimumStep) { - this.scale = 'month';this.step = 1; - } - if (stepDay * 5 > minimumStep) { - this.scale = 'day';this.step = 5; - } - if (stepDay * 2 > minimumStep) { - this.scale = 'day';this.step = 2; - } - if (stepDay > minimumStep) { - this.scale = 'day';this.step = 1; - } - if (stepDay / 2 > minimumStep) { - this.scale = 'weekday';this.step = 1; - } - if (stepHour * 4 > minimumStep) { - this.scale = 'hour';this.step = 4; - } - if (stepHour > minimumStep) { - this.scale = 'hour';this.step = 1; - } - if (stepMinute * 15 > minimumStep) { - this.scale = 'minute';this.step = 15; - } - if (stepMinute * 10 > minimumStep) { - this.scale = 'minute';this.step = 10; - } - if (stepMinute * 5 > minimumStep) { - this.scale = 'minute';this.step = 5; - } - if (stepMinute > minimumStep) { - this.scale = 'minute';this.step = 1; - } - if (stepSecond * 15 > minimumStep) { - this.scale = 'second';this.step = 15; - } - if (stepSecond * 10 > minimumStep) { - this.scale = 'second';this.step = 10; - } - if (stepSecond * 5 > minimumStep) { - this.scale = 'second';this.step = 5; - } - if (stepSecond > minimumStep) { - this.scale = 'second';this.step = 1; - } - if (stepMillisecond * 200 > minimumStep) { - this.scale = 'millisecond';this.step = 200; - } - if (stepMillisecond * 100 > minimumStep) { - this.scale = 'millisecond';this.step = 100; - } - if (stepMillisecond * 50 > minimumStep) { - this.scale = 'millisecond';this.step = 50; - } - if (stepMillisecond * 10 > minimumStep) { - this.scale = 'millisecond';this.step = 10; - } - if (stepMillisecond * 5 > minimumStep) { - this.scale = 'millisecond';this.step = 5; - } - if (stepMillisecond > minimumStep) { - this.scale = 'millisecond';this.step = 1; - } - }; - - /** - * Snap a date to a rounded value. - * The snap intervals are dependent on the current scale and step. - * Static function - * @param {Date} date the date to be snapped. - * @param {string} scale Current scale, can be 'millisecond', 'second', - * 'minute', 'hour', 'weekday, 'day', 'month', 'year'. - * @param {number} step Current step (1, 2, 4, 5, ... - * @return {Date} snappedDate - */ - TimeStep.snap = function (date, scale, step) { - var clone = moment(date); - - if (scale == 'year') { - var year = clone.year() + Math.round(clone.month() / 12); - clone.year(Math.round(year / step) * step); - clone.month(0); - clone.date(0); - clone.hours(0); - clone.minutes(0); - clone.seconds(0); - clone.milliseconds(0); - } else if (scale == 'month') { - if (clone.date() > 15) { - clone.date(1); - clone.add(1, 'month'); - // important: first set Date to 1, after that change the month. - } else { - clone.date(1); - } - - clone.hours(0); - clone.minutes(0); - clone.seconds(0); - clone.milliseconds(0); - } else if (scale == 'day') { - //noinspection FallthroughInSwitchStatementJS - switch (step) { - case 5: - case 2: - clone.hours(Math.round(clone.hours() / 24) * 24);break; - default: - clone.hours(Math.round(clone.hours() / 12) * 12);break; - } - clone.minutes(0); - clone.seconds(0); - clone.milliseconds(0); - } else if (scale == 'weekday') { - //noinspection FallthroughInSwitchStatementJS - switch (step) { - case 5: - case 2: - clone.hours(Math.round(clone.hours() / 12) * 12);break; - default: - clone.hours(Math.round(clone.hours() / 6) * 6);break; - } - clone.minutes(0); - clone.seconds(0); - clone.milliseconds(0); - } else if (scale == 'hour') { - switch (step) { - case 4: - clone.minutes(Math.round(clone.minutes() / 60) * 60);break; - default: - clone.minutes(Math.round(clone.minutes() / 30) * 30);break; - } - clone.seconds(0); - clone.milliseconds(0); - } else if (scale == 'minute') { - //noinspection FallthroughInSwitchStatementJS - switch (step) { - case 15: - case 10: - clone.minutes(Math.round(clone.minutes() / 5) * 5); - clone.seconds(0); - break; - case 5: - clone.seconds(Math.round(clone.seconds() / 60) * 60);break; - default: - clone.seconds(Math.round(clone.seconds() / 30) * 30);break; - } - clone.milliseconds(0); - } else if (scale == 'second') { - //noinspection FallthroughInSwitchStatementJS - switch (step) { - case 15: - case 10: - clone.seconds(Math.round(clone.seconds() / 5) * 5); - clone.milliseconds(0); - break; - case 5: - clone.milliseconds(Math.round(clone.milliseconds() / 1000) * 1000);break; - default: - clone.milliseconds(Math.round(clone.milliseconds() / 500) * 500);break; - } - } else if (scale == 'millisecond') { - var _step = step > 5 ? step / 2 : 1; - clone.milliseconds(Math.round(clone.milliseconds() / _step) * _step); - } - - return clone; - }; - - /** - * Check if the current value is a major value (for example when the step - * is DAY, a major value is each first day of the MONTH) - * @return {boolean} true if current date is major, else false. - */ - TimeStep.prototype.isMajor = function () { - if (this.switchedYear == true) { - this.switchedYear = false; - switch (this.scale) { - case 'year': - case 'month': - case 'weekday': - case 'day': - case 'hour': - case 'minute': - case 'second': - case 'millisecond': - return true; - default: - return false; - } - } else if (this.switchedMonth == true) { - this.switchedMonth = false; - switch (this.scale) { - case 'weekday': - case 'day': - case 'hour': - case 'minute': - case 'second': - case 'millisecond': - return true; - default: - return false; - } - } else if (this.switchedDay == true) { - this.switchedDay = false; - switch (this.scale) { - case 'millisecond': - case 'second': - case 'minute': - case 'hour': - return true; - default: - return false; - } - } - - var date = this.moment(this.current); - switch (this.scale) { - case 'millisecond': - return date.milliseconds() == 0; - case 'second': - return date.seconds() == 0; - case 'minute': - return date.hours() == 0 && date.minutes() == 0; - case 'hour': - return date.hours() == 0; - case 'weekday': // intentional fall through - case 'day': - return date.date() == 1; - case 'month': - return date.month() == 0; - case 'year': - return false; - default: - return false; - } - }; - - /** - * Returns formatted text for the minor axislabel, depending on the current - * date and the scale. For example when scale is MINUTE, the current time is - * formatted as "hh:mm". - * @param {Date} [date] custom date. if not provided, current date is taken - */ - TimeStep.prototype.getLabelMinor = function (date) { - if (date == undefined) { - date = this.current; - } - - var format = this.format.minorLabels[this.scale]; - return format && format.length > 0 ? this.moment(date).format(format) : ''; - }; - - /** - * Returns formatted text for the major axis label, depending on the current - * date and the scale. For example when scale is MINUTE, the major scale is - * hours, and the hour will be formatted as "hh". - * @param {Date} [date] custom date. if not provided, current date is taken - */ - TimeStep.prototype.getLabelMajor = function (date) { - if (date == undefined) { - date = this.current; - } - - var format = this.format.majorLabels[this.scale]; - return format && format.length > 0 ? this.moment(date).format(format) : ''; - }; - - TimeStep.prototype.getClassName = function () { - var _moment = this.moment; - var m = this.moment(this.current); - var current = m.locale ? m.locale('en') : m.lang('en'); // old versions of moment have .lang() function - var step = this.step; - - function even(value) { - return value / step % 2 == 0 ? ' vis-even' : ' vis-odd'; - } - - function today(date) { - if (date.isSame(new Date(), 'day')) { - return ' vis-today'; - } - if (date.isSame(_moment().add(1, 'day'), 'day')) { - return ' vis-tomorrow'; - } - if (date.isSame(_moment().add(-1, 'day'), 'day')) { - return ' vis-yesterday'; - } - return ''; - } - - function currentWeek(date) { - return date.isSame(new Date(), 'week') ? ' vis-current-week' : ''; - } - - function currentMonth(date) { - return date.isSame(new Date(), 'month') ? ' vis-current-month' : ''; - } - - function currentYear(date) { - return date.isSame(new Date(), 'year') ? ' vis-current-year' : ''; - } - - switch (this.scale) { - case 'millisecond': - return even(current.milliseconds()).trim(); - - case 'second': - return even(current.seconds()).trim(); - - case 'minute': - return even(current.minutes()).trim(); - - case 'hour': - var hours = current.hours(); - if (this.step == 4) { - hours = hours + '-h' + (hours + 4); - } - return 'vis-h' + hours + today(current) + even(current.hours()); - - case 'weekday': - return 'vis-' + current.format('dddd').toLowerCase() + today(current) + currentWeek(current) + even(current.date()); - - case 'day': - var day = current.date(); - var month = current.format('MMMM').toLowerCase(); - return 'vis-day' + day + ' vis-' + month + currentMonth(current) + even(day - 1); - - case 'month': - return 'vis-' + current.format('MMMM').toLowerCase() + currentMonth(current) + even(current.month()); - - case 'year': - var year = current.year(); - return 'vis-year' + year + currentYear(current) + even(year); - - default: - return ''; - } - }; - - module.exports = TimeStep; - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(1); - var stack = __webpack_require__(32); - var RangeItem = __webpack_require__(33); - - /** - * @constructor Group - * @param {Number | String} groupId - * @param {Object} data - * @param {ItemSet} itemSet - */ - function Group(groupId, data, itemSet) { - this.groupId = groupId; - this.subgroups = {}; - this.subgroupIndex = 0; - this.subgroupOrderer = data && data.subgroupOrder; - this.itemSet = itemSet; - - this.dom = {}; - this.props = { - label: { - width: 0, - height: 0 - } - }; - this.className = null; - - this.items = {}; // items filtered by groupId of this group - this.visibleItems = []; // items currently visible in window - this.orderedItems = { - byStart: [], - byEnd: [] - }; - this.checkRangedItems = false; // needed to refresh the ranged items if the window is programatically changed with NO overlap. - var me = this; - this.itemSet.body.emitter.on('checkRangedItems', function () { - me.checkRangedItems = true; - }); - - this._create(); - - this.setData(data); - } - - /** - * Create DOM elements for the group - * @private - */ - Group.prototype._create = function () { - var label = document.createElement('div'); - if (this.itemSet.options.groupEditable.order) { - label.className = 'vis-label draggable'; - } else { - label.className = 'vis-label'; - } - this.dom.label = label; - - var inner = document.createElement('div'); - inner.className = 'vis-inner'; - label.appendChild(inner); - this.dom.inner = inner; - - var foreground = document.createElement('div'); - foreground.className = 'vis-group'; - foreground['timeline-group'] = this; - this.dom.foreground = foreground; - - this.dom.background = document.createElement('div'); - this.dom.background.className = 'vis-group'; - - this.dom.axis = document.createElement('div'); - this.dom.axis.className = 'vis-group'; - - // create a hidden marker to detect when the Timelines container is attached - // to the DOM, or the style of a parent of the Timeline is changed from - // display:none is changed to visible. - this.dom.marker = document.createElement('div'); - this.dom.marker.style.visibility = 'hidden'; - this.dom.marker.innerHTML = '?'; - this.dom.background.appendChild(this.dom.marker); - }; - - /** - * Set the group data for this group - * @param {Object} data Group data, can contain properties content and className - */ - Group.prototype.setData = function (data) { - // update contents - var content; - if (this.itemSet.options && this.itemSet.options.groupTemplate) { - content = this.itemSet.options.groupTemplate(data); - } else { - content = data && data.content; - } - - if (content instanceof Element) { - this.dom.inner.appendChild(content); - while (this.dom.inner.firstChild) { - this.dom.inner.removeChild(this.dom.inner.firstChild); - } - this.dom.inner.appendChild(content); - } else if (content !== undefined && content !== null) { - this.dom.inner.innerHTML = content; - } else { - this.dom.inner.innerHTML = this.groupId || ''; // groupId can be null - } - - // update title - this.dom.label.title = data && data.title || ''; - - if (!this.dom.inner.firstChild) { - util.addClassName(this.dom.inner, 'vis-hidden'); - } else { - util.removeClassName(this.dom.inner, 'vis-hidden'); - } - - // update className - var className = data && data.className || null; - if (className != this.className) { - if (this.className) { - util.removeClassName(this.dom.label, this.className); - util.removeClassName(this.dom.foreground, this.className); - util.removeClassName(this.dom.background, this.className); - util.removeClassName(this.dom.axis, this.className); - } - util.addClassName(this.dom.label, className); - util.addClassName(this.dom.foreground, className); - util.addClassName(this.dom.background, className); - util.addClassName(this.dom.axis, className); - this.className = className; - } - - // update style - if (this.style) { - util.removeCssText(this.dom.label, this.style); - this.style = null; - } - if (data && data.style) { - util.addCssText(this.dom.label, data.style); - this.style = data.style; - } - }; - - /** - * Get the width of the group label - * @return {number} width - */ - Group.prototype.getLabelWidth = function () { - return this.props.label.width; - }; - - /** - * Repaint this group - * @param {{start: number, end: number}} range - * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin - * @param {boolean} [restack=false] Force restacking of all items - * @return {boolean} Returns true if the group is resized - */ - Group.prototype.redraw = function (range, margin, restack) { - var resized = false; + Group.prototype.redraw = function (range, margin, restack) { + var resized = false; // force recalculation of the height of the items when the marker height changed // (due to the Timeline being attached to the DOM or changed from display:none to visible) @@ -18723,771 +17933,1478 @@ return /******/ (function(modules) { // webpackBootstrap }; /** - * this function is very similar to the _checkIfInvisible() but it does not - * return booleans, hides the item if it should not be seen and always adds to - * the visibleItems. - * this one is for brute forcing and hiding. - * - * @param {Item} item - * @param {Array} visibleItems - * @param {{start:number, end:number}} range - * @private + * this function is very similar to the _checkIfInvisible() but it does not + * return booleans, hides the item if it should not be seen and always adds to + * the visibleItems. + * this one is for brute forcing and hiding. + * + * @param {Item} item + * @param {Array} visibleItems + * @param {{start:number, end:number}} range + * @private + */ + Group.prototype._checkIfVisible = function (item, visibleItems, range) { + if (item.isVisible(range)) { + if (!item.displayed) item.show(); + // reposition item horizontally + item.repositionX(); + visibleItems.push(item); + } else { + if (item.displayed) item.hide(); + } + }; + + /** + * this function is very similar to the _checkIfInvisible() but it does not + * return booleans, hides the item if it should not be seen and always adds to + * the visibleItems. + * this one is for brute forcing and hiding. + * + * @param {Item} item + * @param {Array} visibleItems + * @param {{start:number, end:number}} range + * @private + */ + Group.prototype._checkIfVisibleWithReference = function (item, visibleItems, visibleItemsLookup, range) { + if (item.isVisible(range)) { + if (visibleItemsLookup[item.id] === undefined) { + visibleItemsLookup[item.id] = true; + visibleItems.push(item); + } + } else { + if (item.displayed) item.hide(); + } + }; + + module.exports = Group; + +/***/ }, +/* 31 */ +/***/ function(module, exports) { + + // Utility functions for ordering and stacking of items + 'use strict'; + + var EPSILON = 0.001; // used when checking collisions, to prevent round-off errors + + /** + * Order items by their start data + * @param {Item[]} items + */ + exports.orderByStart = function (items) { + items.sort(function (a, b) { + return a.data.start - b.data.start; + }); + }; + + /** + * Order items by their end date. If they have no end date, their start date + * is used. + * @param {Item[]} items + */ + exports.orderByEnd = function (items) { + items.sort(function (a, b) { + var aTime = 'end' in a.data ? a.data.end : a.data.start, + bTime = 'end' in b.data ? b.data.end : b.data.start; + + return aTime - bTime; + }); + }; + + /** + * Adjust vertical positions of the items such that they don't overlap each + * other. + * @param {Item[]} items + * All visible items + * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin + * Margins between items and between items and the axis. + * @param {boolean} [force=false] + * If true, all items will be repositioned. If false (default), only + * items having a top===null will be re-stacked + */ + exports.stack = function (items, margin, force) { + var i, iMax; + + if (force) { + // reset top position of all items + for (i = 0, iMax = items.length; i < iMax; i++) { + items[i].top = null; + } + } + + // calculate new, non-overlapping positions + for (i = 0, iMax = items.length; i < iMax; i++) { + var item = items[i]; + if (item.stack && item.top === null) { + // initialize top position + item.top = margin.axis; + + do { + // TODO: optimize checking for overlap. when there is a gap without items, + // you only need to check for items from the next item on, not from zero + var collidingItem = null; + for (var j = 0, jj = items.length; j < jj; j++) { + var other = items[j]; + if (other.top !== null && other !== item && other.stack && exports.collision(item, other, margin.item)) { + collidingItem = other; + break; + } + } + + if (collidingItem != null) { + // There is a collision. Reposition the items above the colliding element + item.top = collidingItem.top + collidingItem.height + margin.item.vertical; + } + } while (collidingItem); + } + } + }; + + /** + * Adjust vertical positions of the items without stacking them + * @param {Item[]} items + * All visible items + * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin + * Margins between items and between items and the axis. + */ + exports.nostack = function (items, margin, subgroups) { + var i, iMax, newTop; + + // reset top position of all items + for (i = 0, iMax = items.length; i < iMax; i++) { + if (items[i].data.subgroup !== undefined) { + newTop = margin.axis; + for (var subgroup in subgroups) { + if (subgroups.hasOwnProperty(subgroup)) { + if (subgroups[subgroup].visible == true && subgroups[subgroup].index < subgroups[items[i].data.subgroup].index) { + newTop += subgroups[subgroup].height + margin.item.vertical; + } + } + } + items[i].top = newTop; + } else { + items[i].top = margin.axis; + } + } + }; + + /** + * Test if the two provided items collide + * The items must have parameters left, width, top, and height. + * @param {Item} a The first item + * @param {Item} b The second item + * @param {{horizontal: number, vertical: number}} margin + * An object containing a horizontal and vertical + * minimum required margin. + * @return {boolean} true if a and b collide, else false + */ + exports.collision = function (a, b, margin) { + return a.left - margin.horizontal + EPSILON < b.left + b.width && a.left + a.width + margin.horizontal - EPSILON > b.left && a.top - margin.vertical + EPSILON < b.top + b.height && a.top + a.height + margin.vertical - EPSILON > b.top; + }; + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Hammer = __webpack_require__(20); + var Item = __webpack_require__(33); + + /** + * @constructor RangeItem + * @extends Item + * @param {Object} data Object containing parameters start, end + * content, className. + * @param {{toScreen: function, toTime: function}} conversion + * Conversion functions from time to screen and vice versa + * @param {Object} [options] Configuration options + * // TODO: describe options + */ + function RangeItem(data, conversion, options) { + this.props = { + content: { + width: 0 + } + }; + this.overflow = false; // if contents can overflow (css styling), this flag is set to true + + // validate data + if (data) { + if (data.start == undefined) { + throw new Error('Property "start" missing in item ' + data.id); + } + if (data.end == undefined) { + throw new Error('Property "end" missing in item ' + data.id); + } + } + + Item.call(this, data, conversion, options); + } + + RangeItem.prototype = new Item(null, null, null); + + RangeItem.prototype.baseClassName = 'vis-item vis-range'; + + /** + * Check whether this item is visible inside given range + * @returns {{start: Number, end: Number}} range with a timestamp for start and end + * @returns {boolean} True if visible + */ + RangeItem.prototype.isVisible = function (range) { + // determine visibility + return this.data.start < range.end && this.data.end > range.start; + }; + + /** + * Repaint the item + */ + RangeItem.prototype.redraw = function () { + var dom = this.dom; + if (!dom) { + // create DOM + this.dom = {}; + dom = this.dom; + + // background box + dom.box = document.createElement('div'); + // className is updated in redraw() + + // frame box (to prevent the item contents from overflowing + dom.frame = document.createElement('div'); + dom.frame.className = 'vis-item-overflow'; + dom.box.appendChild(dom.frame); + + // contents box + dom.content = document.createElement('div'); + dom.content.className = 'vis-item-content'; + dom.frame.appendChild(dom.content); + + // attach this item as attribute + dom.box['timeline-item'] = this; + + this.dirty = true; + } + + // append DOM to parent DOM + if (!this.parent) { + throw new Error('Cannot redraw item: no parent attached'); + } + if (!dom.box.parentNode) { + var foreground = this.parent.dom.foreground; + if (!foreground) { + throw new Error('Cannot redraw item: parent has no foreground container element'); + } + foreground.appendChild(dom.box); + } + this.displayed = true; + + // Update DOM when item is marked dirty. An item is marked dirty when: + // - the item is not yet rendered + // - the item's data is changed + // - the item is selected/deselected + if (this.dirty) { + this._updateContents(this.dom.content); + this._updateTitle(this.dom.box); + this._updateDataAttributes(this.dom.box); + this._updateStyle(this.dom.box); + + var editable = (this.options.editable.updateTime || this.options.editable.updateGroup || this.editable === true) && this.editable !== false; + + // update class + var className = (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '') + (editable ? ' vis-editable' : ' vis-readonly'); + dom.box.className = this.baseClassName + className; + + // determine from css whether this box has overflow + this.overflow = window.getComputedStyle(dom.frame).overflow !== 'hidden'; + + // recalculate size + // turn off max-width to be able to calculate the real width + // this causes an extra browser repaint/reflow, but so be it + this.dom.content.style.maxWidth = 'none'; + this.props.content.width = this.dom.content.offsetWidth; + this.height = this.dom.box.offsetHeight; + this.dom.content.style.maxWidth = ''; + + this.dirty = false; + } + + this._repaintDeleteButton(dom.box); + this._repaintDragLeft(); + this._repaintDragRight(); + }; + + /** + * Show the item in the DOM (when not already visible). The items DOM will + * be created when needed. + */ + RangeItem.prototype.show = function () { + if (!this.displayed) { + this.redraw(); + } + }; + + /** + * Hide the item from the DOM (when visible) + * @return {Boolean} changed + */ + RangeItem.prototype.hide = function () { + if (this.displayed) { + var box = this.dom.box; + + if (box.parentNode) { + box.parentNode.removeChild(box); + } + + this.displayed = false; + } + }; + + /** + * Reposition the item horizontally + * @param {boolean} [limitSize=true] If true (default), the width of the range + * item will be limited, as the browser cannot + * display very wide divs. This means though + * that the applied left and width may + * not correspond to the ranges start and end + * @Override + */ + RangeItem.prototype.repositionX = function (limitSize) { + var parentWidth = this.parent.width; + var start = this.conversion.toScreen(this.data.start); + var end = this.conversion.toScreen(this.data.end); + var contentLeft; + var contentWidth; + + // limit the width of the range, as browsers cannot draw very wide divs + if (limitSize === undefined || limitSize === true) { + if (start < -parentWidth) { + start = -parentWidth; + } + if (end > 2 * parentWidth) { + end = 2 * parentWidth; + } + } + var boxWidth = Math.max(end - start, 1); + + if (this.overflow) { + this.left = start; + this.width = boxWidth + this.props.content.width; + contentWidth = this.props.content.width; + + // Note: The calculation of width is an optimistic calculation, giving + // a width which will not change when moving the Timeline + // So no re-stacking needed, which is nicer for the eye; + } else { + this.left = start; + this.width = boxWidth; + contentWidth = Math.min(end - start, this.props.content.width); + } + + this.dom.box.style.left = this.left + 'px'; + this.dom.box.style.width = boxWidth + 'px'; + + switch (this.options.align) { + case 'left': + this.dom.content.style.left = '0'; + break; + + case 'right': + this.dom.content.style.left = Math.max(boxWidth - contentWidth, 0) + 'px'; + break; + + case 'center': + this.dom.content.style.left = Math.max((boxWidth - contentWidth) / 2, 0) + 'px'; + break; + + default: + // 'auto' + // when range exceeds left of the window, position the contents at the left of the visible area + if (this.overflow) { + if (end > 0) { + contentLeft = Math.max(-start, 0); + } else { + contentLeft = -contentWidth; // ensure it's not visible anymore + } + } else { + if (start < 0) { + contentLeft = -start; + } else { + contentLeft = 0; + } + } + this.dom.content.style.left = contentLeft + 'px'; + } + }; + + /** + * Reposition the item vertically + * @Override + */ + RangeItem.prototype.repositionY = function () { + var orientation = this.options.orientation.item; + var box = this.dom.box; + + if (orientation == 'top') { + box.style.top = this.top + 'px'; + } else { + box.style.top = this.parent.height - this.top - this.height + 'px'; + } + }; + + /** + * Repaint a drag area on the left side of the range when the range is selected + * @protected + */ + RangeItem.prototype._repaintDragLeft = function () { + if (this.selected && this.options.editable.updateTime && !this.dom.dragLeft) { + // create and show drag area + var dragLeft = document.createElement('div'); + dragLeft.className = 'vis-drag-left'; + dragLeft.dragLeftItem = this; + + this.dom.box.appendChild(dragLeft); + this.dom.dragLeft = dragLeft; + } else if (!this.selected && this.dom.dragLeft) { + // delete drag area + if (this.dom.dragLeft.parentNode) { + this.dom.dragLeft.parentNode.removeChild(this.dom.dragLeft); + } + this.dom.dragLeft = null; + } + }; + + /** + * Repaint a drag area on the right side of the range when the range is selected + * @protected + */ + RangeItem.prototype._repaintDragRight = function () { + if (this.selected && this.options.editable.updateTime && !this.dom.dragRight) { + // create and show drag area + var dragRight = document.createElement('div'); + dragRight.className = 'vis-drag-right'; + dragRight.dragRightItem = this; + + this.dom.box.appendChild(dragRight); + this.dom.dragRight = dragRight; + } else if (!this.selected && this.dom.dragRight) { + // delete drag area + if (this.dom.dragRight.parentNode) { + this.dom.dragRight.parentNode.removeChild(this.dom.dragRight); + } + this.dom.dragRight = null; + } + }; + + module.exports = RangeItem; + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Hammer = __webpack_require__(20); + var util = __webpack_require__(1); + + /** + * @constructor Item + * @param {Object} data Object containing (optional) parameters type, + * start, end, content, group, className. + * @param {{toScreen: function, toTime: function}} conversion + * Conversion functions from time to screen and vice versa + * @param {Object} options Configuration options + * // TODO: describe available options + */ + function Item(data, conversion, options) { + this.id = null; + this.parent = null; + this.data = data; + this.dom = null; + this.conversion = conversion || {}; + this.options = options || {}; + + this.selected = false; + this.displayed = false; + this.dirty = true; + + this.top = null; + this.left = null; + this.width = null; + this.height = null; + + this.editable = null; + if (this.data && this.data.hasOwnProperty('editable') && typeof this.data.editable === 'boolean') { + this.editable = data.editable; + } + } + + Item.prototype.stack = true; + + /** + * Select current item + */ + Item.prototype.select = function () { + this.selected = true; + this.dirty = true; + if (this.displayed) this.redraw(); + }; + + /** + * Unselect current item */ - Group.prototype._checkIfVisible = function (item, visibleItems, range) { - if (item.isVisible(range)) { - if (!item.displayed) item.show(); - // reposition item horizontally - item.repositionX(); - visibleItems.push(item); - } else { - if (item.displayed) item.hide(); + Item.prototype.unselect = function () { + this.selected = false; + this.dirty = true; + if (this.displayed) this.redraw(); + }; + + /** + * Set data for the item. Existing data will be updated. The id should not + * be changed. When the item is displayed, it will be redrawn immediately. + * @param {Object} data + */ + Item.prototype.setData = function (data) { + var groupChanged = data.group != undefined && this.data.group != data.group; + if (groupChanged) { + this.parent.itemSet._moveToGroup(this, data.group); } + + if (data.hasOwnProperty('editable') && typeof data.editable === 'boolean') { + this.editable = data.editable; + } + + this.data = data; + this.dirty = true; + if (this.displayed) this.redraw(); }; /** - * this function is very similar to the _checkIfInvisible() but it does not - * return booleans, hides the item if it should not be seen and always adds to - * the visibleItems. - * this one is for brute forcing and hiding. - * - * @param {Item} item - * @param {Array} visibleItems - * @param {{start:number, end:number}} range - * @private + * Set a parent for the item + * @param {ItemSet | Group} parent */ - Group.prototype._checkIfVisibleWithReference = function (item, visibleItems, visibleItemsLookup, range) { - if (item.isVisible(range)) { - if (visibleItemsLookup[item.id] === undefined) { - visibleItemsLookup[item.id] = true; - visibleItems.push(item); + Item.prototype.setParent = function (parent) { + if (this.displayed) { + this.hide(); + this.parent = parent; + if (this.parent) { + this.show(); } } else { - if (item.displayed) item.hide(); + this.parent = parent; } }; - module.exports = Group; - -/***/ }, -/* 32 */ -/***/ function(module, exports) { + /** + * Check whether this item is visible inside given range + * @returns {{start: Number, end: Number}} range with a timestamp for start and end + * @returns {boolean} True if visible + */ + Item.prototype.isVisible = function (range) { + // Should be implemented by Item implementations + return false; + }; - // Utility functions for ordering and stacking of items - 'use strict'; + /** + * Show the Item in the DOM (when not already visible) + * @return {Boolean} changed + */ + Item.prototype.show = function () { + return false; + }; - var EPSILON = 0.001; // used when checking collisions, to prevent round-off errors + /** + * Hide the Item from the DOM (when visible) + * @return {Boolean} changed + */ + Item.prototype.hide = function () { + return false; + }; /** - * Order items by their start data - * @param {Item[]} items + * Repaint the item */ - exports.orderByStart = function (items) { - items.sort(function (a, b) { - return a.data.start - b.data.start; - }); + Item.prototype.redraw = function () { + // should be implemented by the item }; /** - * Order items by their end date. If they have no end date, their start date - * is used. - * @param {Item[]} items + * Reposition the Item horizontally */ - exports.orderByEnd = function (items) { - items.sort(function (a, b) { - var aTime = 'end' in a.data ? a.data.end : a.data.start, - bTime = 'end' in b.data ? b.data.end : b.data.start; + Item.prototype.repositionX = function () { + // should be implemented by the item + }; - return aTime - bTime; - }); + /** + * Reposition the Item vertically + */ + Item.prototype.repositionY = function () { + // should be implemented by the item }; /** - * Adjust vertical positions of the items such that they don't overlap each - * other. - * @param {Item[]} items - * All visible items - * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin - * Margins between items and between items and the axis. - * @param {boolean} [force=false] - * If true, all items will be repositioned. If false (default), only - * items having a top===null will be re-stacked + * Repaint a delete button on the top right of the item when the item is selected + * @param {HTMLElement} anchor + * @protected */ - exports.stack = function (items, margin, force) { - var i, iMax; + Item.prototype._repaintDeleteButton = function (anchor) { + var editable = (this.options.editable.remove || this.data.editable === true) && this.data.editable !== false; - if (force) { - // reset top position of all items - for (i = 0, iMax = items.length; i < iMax; i++) { - items[i].top = null; - } - } + if (this.selected && editable && !this.dom.deleteButton) { + // create and show button + var me = this; - // calculate new, non-overlapping positions - for (i = 0, iMax = items.length; i < iMax; i++) { - var item = items[i]; - if (item.stack && item.top === null) { - // initialize top position - item.top = margin.axis; + var deleteButton = document.createElement('div'); + deleteButton.className = 'vis-delete'; + deleteButton.title = 'Delete this item'; - do { - // TODO: optimize checking for overlap. when there is a gap without items, - // you only need to check for items from the next item on, not from zero - var collidingItem = null; - for (var j = 0, jj = items.length; j < jj; j++) { - var other = items[j]; - if (other.top !== null && other !== item && other.stack && exports.collision(item, other, margin.item)) { - collidingItem = other; - break; - } - } + // TODO: be able to destroy the delete button + new Hammer(deleteButton).on('tap', function (event) { + event.stopPropagation(); + me.parent.removeFromDataSet(me); + }); - if (collidingItem != null) { - // There is a collision. Reposition the items above the colliding element - item.top = collidingItem.top + collidingItem.height + margin.item.vertical; - } - } while (collidingItem); + anchor.appendChild(deleteButton); + this.dom.deleteButton = deleteButton; + } else if (!this.selected && this.dom.deleteButton) { + // remove button + if (this.dom.deleteButton.parentNode) { + this.dom.deleteButton.parentNode.removeChild(this.dom.deleteButton); } + this.dom.deleteButton = null; } }; /** - * Adjust vertical positions of the items without stacking them - * @param {Item[]} items - * All visible items - * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin - * Margins between items and between items and the axis. + * Set HTML contents for the item + * @param {Element} element HTML element to fill with the contents + * @private */ - exports.nostack = function (items, margin, subgroups) { - var i, iMax, newTop; + Item.prototype._updateContents = function (element) { + var content; + if (this.options.template) { + var itemData = this.parent.itemSet.itemsData.get(this.id); // get a clone of the data from the dataset + content = this.options.template(itemData); + } else { + content = this.data.content; + } - // reset top position of all items - for (i = 0, iMax = items.length; i < iMax; i++) { - if (items[i].data.subgroup !== undefined) { - newTop = margin.axis; - for (var subgroup in subgroups) { - if (subgroups.hasOwnProperty(subgroup)) { - if (subgroups[subgroup].visible == true && subgroups[subgroup].index < subgroups[items[i].data.subgroup].index) { - newTop += subgroups[subgroup].height + margin.item.vertical; - } - } - } - items[i].top = newTop; + var changed = this._contentToString(this.content) !== this._contentToString(content); + if (changed) { + // only replace the content when changed + if (content instanceof Element) { + element.innerHTML = ''; + element.appendChild(content); + } else if (content != undefined) { + element.innerHTML = content; } else { - items[i].top = margin.axis; + if (!(this.data.type == 'background' && this.data.content === undefined)) { + throw new Error('Property "content" missing in item ' + this.id); + } } + + this.content = content; } }; /** - * Test if the two provided items collide - * The items must have parameters left, width, top, and height. - * @param {Item} a The first item - * @param {Item} b The second item - * @param {{horizontal: number, vertical: number}} margin - * An object containing a horizontal and vertical - * minimum required margin. - * @return {boolean} true if a and b collide, else false + * Set HTML contents for the item + * @param {Element} element HTML element to fill with the contents + * @private */ - exports.collision = function (a, b, margin) { - return a.left - margin.horizontal + EPSILON < b.left + b.width && a.left + a.width + margin.horizontal - EPSILON > b.left && a.top - margin.vertical + EPSILON < b.top + b.height && a.top + a.height + margin.vertical - EPSILON > b.top; + Item.prototype._updateTitle = function (element) { + if (this.data.title != null) { + element.title = this.data.title || ''; + } else { + element.removeAttribute('vis-title'); + } }; -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Hammer = __webpack_require__(20); - var Item = __webpack_require__(34); - /** - * @constructor RangeItem - * @extends Item - * @param {Object} data Object containing parameters start, end - * content, className. - * @param {{toScreen: function, toTime: function}} conversion - * Conversion functions from time to screen and vice versa - * @param {Object} [options] Configuration options - * // TODO: describe options + * Process dataAttributes timeline option and set as data- attributes on dom.content + * @param {Element} element HTML element to which the attributes will be attached + * @private */ - function RangeItem(data, conversion, options) { - this.props = { - content: { - width: 0 - } - }; - this.overflow = false; // if contents can overflow (css styling), this flag is set to true + Item.prototype._updateDataAttributes = function (element) { + if (this.options.dataAttributes && this.options.dataAttributes.length > 0) { + var attributes = []; - // validate data - if (data) { - if (data.start == undefined) { - throw new Error('Property "start" missing in item ' + data.id); + if (Array.isArray(this.options.dataAttributes)) { + attributes = this.options.dataAttributes; + } else if (this.options.dataAttributes == 'all') { + attributes = Object.keys(this.data); + } else { + return; } - if (data.end == undefined) { - throw new Error('Property "end" missing in item ' + data.id); + + for (var i = 0; i < attributes.length; i++) { + var name = attributes[i]; + var value = this.data[name]; + + if (value != null) { + element.setAttribute('data-' + name, value); + } else { + element.removeAttribute('data-' + name); + } } } + }; - Item.call(this, data, conversion, options); - } + /** + * Update custom styles of the element + * @param element + * @private + */ + Item.prototype._updateStyle = function (element) { + // remove old styles + if (this.style) { + util.removeCssText(element, this.style); + this.style = null; + } - RangeItem.prototype = new Item(null, null, null); + // append new styles + if (this.data.style) { + util.addCssText(element, this.data.style); + this.style = this.data.style; + } + }; - RangeItem.prototype.baseClassName = 'vis-item vis-range'; + /** + * Stringify the items contents + * @param {string | Element | undefined} content + * @returns {string | undefined} + * @private + */ + Item.prototype._contentToString = function (content) { + if (typeof content === 'string') return content; + if (content && 'outerHTML' in content) return content.outerHTML; + return content; + }; /** - * Check whether this item is visible inside given range - * @returns {{start: Number, end: Number}} range with a timestamp for start and end - * @returns {boolean} True if visible + * Return the width of the item left from its start date + * @return {number} */ - RangeItem.prototype.isVisible = function (range) { - // determine visibility - return this.data.start < range.end && this.data.end > range.start; + Item.prototype.getWidthLeft = function () { + return 0; }; /** - * Repaint the item + * Return the width of the item right from the max of its start and end date + * @return {number} */ - RangeItem.prototype.redraw = function () { - var dom = this.dom; - if (!dom) { - // create DOM - this.dom = {}; - dom = this.dom; + Item.prototype.getWidthRight = function () { + return 0; + }; - // background box - dom.box = document.createElement('div'); - // className is updated in redraw() + module.exports = Item; - // frame box (to prevent the item contents from overflowing - dom.frame = document.createElement('div'); - dom.frame.className = 'vis-item-overflow'; - dom.box.appendChild(dom.frame); +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { - // contents box - dom.content = document.createElement('div'); - dom.content.className = 'vis-item-content'; - dom.frame.appendChild(dom.content); + 'use strict'; - // attach this item as attribute - dom.box['timeline-item'] = this; + var moment = __webpack_require__(2); + var DateUtil = __webpack_require__(27); + var util = __webpack_require__(1); - this.dirty = true; - } + /** + * @constructor TimeStep + * The class TimeStep is an iterator for dates. You provide a start date and an + * end date. The class itself determines the best scale (step size) based on the + * provided start Date, end Date, and minimumStep. + * + * If minimumStep is provided, the step size is chosen as close as possible + * to the minimumStep but larger than minimumStep. If minimumStep is not + * provided, the scale is set to 1 DAY. + * The minimumStep should correspond with the onscreen size of about 6 characters + * + * Alternatively, you can set a scale by hand. + * After creation, you can initialize the class by executing first(). Then you + * can iterate from the start date to the end date via next(). You can check if + * the end date is reached with the function hasNext(). After each step, you can + * retrieve the current date via getCurrent(). + * The TimeStep has scales ranging from milliseconds, seconds, minutes, hours, + * days, to years. + * + * Version: 1.2 + * + * @param {Date} [start] The start date, for example new Date(2010, 9, 21) + * or new Date(2010, 9, 21, 23, 45, 00) + * @param {Date} [end] The end date + * @param {Number} [minimumStep] Optional. Minimum step size in milliseconds + */ + function TimeStep(start, end, minimumStep, hiddenDates) { + this.moment = moment; - // append DOM to parent DOM - if (!this.parent) { - throw new Error('Cannot redraw item: no parent attached'); - } - if (!dom.box.parentNode) { - var foreground = this.parent.dom.foreground; - if (!foreground) { - throw new Error('Cannot redraw item: parent has no foreground container element'); - } - foreground.appendChild(dom.box); + // variables + this.current = this.moment(); + this._start = this.moment(); + this._end = this.moment(); + + this.autoScale = true; + this.scale = 'day'; + this.step = 1; + + // initialize the range + this.setRange(start, end, minimumStep); + + // hidden Dates options + this.switchedDay = false; + this.switchedMonth = false; + this.switchedYear = false; + this.hiddenDates = hiddenDates; + if (hiddenDates === undefined) { + this.hiddenDates = []; } - this.displayed = true; - // Update DOM when item is marked dirty. An item is marked dirty when: - // - the item is not yet rendered - // - the item's data is changed - // - the item is selected/deselected - if (this.dirty) { - this._updateContents(this.dom.content); - this._updateTitle(this.dom.box); - this._updateDataAttributes(this.dom.box); - this._updateStyle(this.dom.box); + this.format = TimeStep.FORMAT; // default formatting + } - var editable = (this.options.editable.updateTime || this.options.editable.updateGroup || this.editable === true) && this.editable !== false; + // Time formatting + TimeStep.FORMAT = { + minorLabels: { + millisecond: 'SSS', + second: 's', + minute: 'HH:mm', + hour: 'HH:mm', + weekday: 'ddd D', + day: 'D', + month: 'MMM', + year: 'YYYY' + }, + majorLabels: { + millisecond: 'HH:mm:ss', + second: 'D MMMM HH:mm', + minute: 'ddd D MMMM', + hour: 'ddd D MMMM', + weekday: 'MMMM YYYY', + day: 'MMMM YYYY', + month: 'YYYY', + year: '' + } + }; - // update class - var className = (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '') + (editable ? ' vis-editable' : ' vis-readonly'); - dom.box.className = this.baseClassName + className; + /** + * Set custom constructor function for moment. Can be used to set dates + * to UTC or to set a utcOffset. + * @param {function} moment + */ + TimeStep.prototype.setMoment = function (moment) { + this.moment = moment; - // determine from css whether this box has overflow - this.overflow = window.getComputedStyle(dom.frame).overflow !== 'hidden'; + // update the date properties, can have a new utcOffset + this.current = this.moment(this.current); + this._start = this.moment(this._start); + this._end = this.moment(this._end); + }; - // recalculate size - // turn off max-width to be able to calculate the real width - // this causes an extra browser repaint/reflow, but so be it - this.dom.content.style.maxWidth = 'none'; - this.props.content.width = this.dom.content.offsetWidth; - this.height = this.dom.box.offsetHeight; - this.dom.content.style.maxWidth = ''; + /** + * Set custom formatting for the minor an major labels of the TimeStep. + * Both `minorLabels` and `majorLabels` are an Object with properties: + * 'millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'month', 'year'. + * @param {{minorLabels: Object, majorLabels: Object}} format + */ + TimeStep.prototype.setFormat = function (format) { + var defaultFormat = util.deepExtend({}, TimeStep.FORMAT); + this.format = util.deepExtend(defaultFormat, format); + }; - this.dirty = false; + /** + * Set a new range + * If minimumStep is provided, the step size is chosen as close as possible + * to the minimumStep but larger than minimumStep. If minimumStep is not + * provided, the scale is set to 1 DAY. + * The minimumStep should correspond with the onscreen size of about 6 characters + * @param {Date} [start] The start date and time. + * @param {Date} [end] The end date and time. + * @param {int} [minimumStep] Optional. Minimum step size in milliseconds + */ + TimeStep.prototype.setRange = function (start, end, minimumStep) { + if (!(start instanceof Date) || !(end instanceof Date)) { + throw "No legal start or end date in method setRange"; } - this._repaintDeleteButton(dom.box); - this._repaintDragLeft(); - this._repaintDragRight(); + this._start = start != undefined ? this.moment(start.valueOf()) : new Date(); + this._end = end != undefined ? this.moment(end.valueOf()) : new Date(); + + if (this.autoScale) { + this.setMinimumStep(minimumStep); + } }; /** - * Show the item in the DOM (when not already visible). The items DOM will - * be created when needed. + * Set the range iterator to the start date. */ - RangeItem.prototype.show = function () { - if (!this.displayed) { - this.redraw(); - } + TimeStep.prototype.start = function () { + this.current = this._start.clone(); + this.roundToMinor(); }; /** - * Hide the item from the DOM (when visible) - * @return {Boolean} changed + * Round the current date to the first minor date value + * This must be executed once when the current date is set to start Date */ - RangeItem.prototype.hide = function () { - if (this.displayed) { - var box = this.dom.box; + TimeStep.prototype.roundToMinor = function () { + // round to floor + // IMPORTANT: we have no breaks in this switch! (this is no bug) + // noinspection FallThroughInSwitchStatementJS + switch (this.scale) { + case 'year': + this.current.year(this.step * Math.floor(this.current.year() / this.step)); + this.current.month(0); + case 'month': + this.current.date(1); + case 'day': // intentional fall through + case 'weekday': + this.current.hours(0); + case 'hour': + this.current.minutes(0); + case 'minute': + this.current.seconds(0); + case 'second': + this.current.milliseconds(0); + //case 'millisecond': // nothing to do for milliseconds + } - if (box.parentNode) { - box.parentNode.removeChild(box); + if (this.step != 1) { + // round down to the first minor value that is a multiple of the current step size + switch (this.scale) { + case 'millisecond': + this.current.subtract(this.current.milliseconds() % this.step, 'milliseconds');break; + case 'second': + this.current.subtract(this.current.seconds() % this.step, 'seconds');break; + case 'minute': + this.current.subtract(this.current.minutes() % this.step, 'minutes');break; + case 'hour': + this.current.subtract(this.current.hours() % this.step, 'hours');break; + case 'weekday': // intentional fall through + case 'day': + this.current.subtract((this.current.date() - 1) % this.step, 'day');break; + case 'month': + this.current.subtract(this.current.month() % this.step, 'month');break; + case 'year': + this.current.subtract(this.current.year() % this.step, 'year');break; + default: + break; } - - this.displayed = false; } }; /** - * Reposition the item horizontally - * @param {boolean} [limitSize=true] If true (default), the width of the range - * item will be limited, as the browser cannot - * display very wide divs. This means though - * that the applied left and width may - * not correspond to the ranges start and end - * @Override + * Check if the there is a next step + * @return {boolean} true if the current date has not passed the end date */ - RangeItem.prototype.repositionX = function (limitSize) { - var parentWidth = this.parent.width; - var start = this.conversion.toScreen(this.data.start); - var end = this.conversion.toScreen(this.data.end); - var contentLeft; - var contentWidth; + TimeStep.prototype.hasNext = function () { + return this.current.valueOf() <= this._end.valueOf(); + }; - // limit the width of the range, as browsers cannot draw very wide divs - if (limitSize === undefined || limitSize === true) { - if (start < -parentWidth) { - start = -parentWidth; + /** + * Do the next step + */ + TimeStep.prototype.next = function () { + var prev = this.current.valueOf(); + + // Two cases, needed to prevent issues with switching daylight savings + // (end of March and end of October) + if (this.current.month() < 6) { + switch (this.scale) { + case 'millisecond': + this.current.add(this.step, 'millisecond');break; + case 'second': + this.current.add(this.step, 'second');break; + case 'minute': + this.current.add(this.step, 'minute');break; + case 'hour': + this.current.add(this.step, 'hour'); + // in case of skipping an hour for daylight savings, adjust the hour again (else you get: 0h 5h 9h ... instead of 0h 4h 8h ...) + // TODO: is this still needed now we use the function of moment.js? + this.current.subtract(this.current.hours() % this.step, 'hour'); + break; + case 'weekday': // intentional fall through + case 'day': + this.current.add(this.step, 'day');break; + case 'month': + this.current.add(this.step, 'month');break; + case 'year': + this.current.add(this.step, 'year');break; + default: + break; } - if (end > 2 * parentWidth) { - end = 2 * parentWidth; + } else { + switch (this.scale) { + case 'millisecond': + this.current.add(this.step, 'millisecond');break; + case 'second': + this.current.add(this.step, 'second');break; + case 'minute': + this.current.add(this.step, 'minute');break; + case 'hour': + this.current.add(this.step, 'hour');break; + case 'weekday': // intentional fall through + case 'day': + this.current.add(this.step, 'day');break; + case 'month': + this.current.add(this.step, 'month');break; + case 'year': + this.current.add(this.step, 'year');break; + default: + break; } } - var boxWidth = Math.max(end - start, 1); - - if (this.overflow) { - this.left = start; - this.width = boxWidth + this.props.content.width; - contentWidth = this.props.content.width; - // Note: The calculation of width is an optimistic calculation, giving - // a width which will not change when moving the Timeline - // So no re-stacking needed, which is nicer for the eye; - } else { - this.left = start; - this.width = boxWidth; - contentWidth = Math.min(end - start, this.props.content.width); + if (this.step != 1) { + // round down to the correct major value + switch (this.scale) { + case 'millisecond': + if (this.current.milliseconds() < this.step) this.current.milliseconds(0);break; + case 'second': + if (this.current.seconds() < this.step) this.current.seconds(0);break; + case 'minute': + if (this.current.minutes() < this.step) this.current.minutes(0);break; + case 'hour': + if (this.current.hours() < this.step) this.current.hours(0);break; + case 'weekday': // intentional fall through + case 'day': + if (this.current.date() < this.step + 1) this.current.date(1);break; + case 'month': + if (this.current.month() < this.step) this.current.month(0);break; + case 'year': + break; // nothing to do for year + default: + break; + } } - this.dom.box.style.left = this.left + 'px'; - this.dom.box.style.width = boxWidth + 'px'; - - switch (this.options.align) { - case 'left': - this.dom.content.style.left = '0'; - break; - - case 'right': - this.dom.content.style.left = Math.max(boxWidth - contentWidth, 0) + 'px'; - break; - - case 'center': - this.dom.content.style.left = Math.max((boxWidth - contentWidth) / 2, 0) + 'px'; - break; - - default: - // 'auto' - // when range exceeds left of the window, position the contents at the left of the visible area - if (this.overflow) { - if (end > 0) { - contentLeft = Math.max(-start, 0); - } else { - contentLeft = -contentWidth; // ensure it's not visible anymore - } - } else { - if (start < 0) { - contentLeft = -start; - } else { - contentLeft = 0; - } - } - this.dom.content.style.left = contentLeft + 'px'; + // safety mechanism: if current time is still unchanged, move to the end + if (this.current.valueOf() == prev) { + this.current = this._end.clone(); } + + DateUtil.stepOverHiddenDates(this.moment, this, prev); }; /** - * Reposition the item vertically - * @Override + * Get the current datetime + * @return {Moment} current The current date */ - RangeItem.prototype.repositionY = function () { - var orientation = this.options.orientation.item; - var box = this.dom.box; - - if (orientation == 'top') { - box.style.top = this.top + 'px'; - } else { - box.style.top = this.parent.height - this.top - this.height + 'px'; - } + TimeStep.prototype.getCurrent = function () { + return this.current; }; /** - * Repaint a drag area on the left side of the range when the range is selected - * @protected + * Set a custom scale. Autoscaling will be disabled. + * For example setScale('minute', 5) will result + * in minor steps of 5 minutes, and major steps of an hour. + * + * @param {{scale: string, step: number}} params + * An object containing two properties: + * - A string 'scale'. Choose from 'millisecond', 'second', + * 'minute', 'hour', 'weekday', 'day', 'month', 'year'. + * - A number 'step'. A step size, by default 1. + * Choose for example 1, 2, 5, or 10. */ - RangeItem.prototype._repaintDragLeft = function () { - if (this.selected && this.options.editable.updateTime && !this.dom.dragLeft) { - // create and show drag area - var dragLeft = document.createElement('div'); - dragLeft.className = 'vis-drag-left'; - dragLeft.dragLeftItem = this; - - this.dom.box.appendChild(dragLeft); - this.dom.dragLeft = dragLeft; - } else if (!this.selected && this.dom.dragLeft) { - // delete drag area - if (this.dom.dragLeft.parentNode) { - this.dom.dragLeft.parentNode.removeChild(this.dom.dragLeft); - } - this.dom.dragLeft = null; + TimeStep.prototype.setScale = function (params) { + if (params && typeof params.scale == 'string') { + this.scale = params.scale; + this.step = params.step > 0 ? params.step : 1; + this.autoScale = false; } }; /** - * Repaint a drag area on the right side of the range when the range is selected - * @protected + * Enable or disable autoscaling + * @param {boolean} enable If true, autoascaling is set true */ - RangeItem.prototype._repaintDragRight = function () { - if (this.selected && this.options.editable.updateTime && !this.dom.dragRight) { - // create and show drag area - var dragRight = document.createElement('div'); - dragRight.className = 'vis-drag-right'; - dragRight.dragRightItem = this; - - this.dom.box.appendChild(dragRight); - this.dom.dragRight = dragRight; - } else if (!this.selected && this.dom.dragRight) { - // delete drag area - if (this.dom.dragRight.parentNode) { - this.dom.dragRight.parentNode.removeChild(this.dom.dragRight); - } - this.dom.dragRight = null; - } + TimeStep.prototype.setAutoScale = function (enable) { + this.autoScale = enable; }; - module.exports = RangeItem; + /** + * Automatically determine the scale that bests fits the provided minimum step + * @param {Number} [minimumStep] The minimum step size in milliseconds + */ + TimeStep.prototype.setMinimumStep = function (minimumStep) { + if (minimumStep == undefined) { + return; + } -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { + //var b = asc + ds; - 'use strict'; + var stepYear = 1000 * 60 * 60 * 24 * 30 * 12; + var stepMonth = 1000 * 60 * 60 * 24 * 30; + var stepDay = 1000 * 60 * 60 * 24; + var stepHour = 1000 * 60 * 60; + var stepMinute = 1000 * 60; + var stepSecond = 1000; + var stepMillisecond = 1; - var Hammer = __webpack_require__(20); - var util = __webpack_require__(1); + // find the smallest step that is larger than the provided minimumStep + if (stepYear * 1000 > minimumStep) { + this.scale = 'year';this.step = 1000; + } + if (stepYear * 500 > minimumStep) { + this.scale = 'year';this.step = 500; + } + if (stepYear * 100 > minimumStep) { + this.scale = 'year';this.step = 100; + } + if (stepYear * 50 > minimumStep) { + this.scale = 'year';this.step = 50; + } + if (stepYear * 10 > minimumStep) { + this.scale = 'year';this.step = 10; + } + if (stepYear * 5 > minimumStep) { + this.scale = 'year';this.step = 5; + } + if (stepYear > minimumStep) { + this.scale = 'year';this.step = 1; + } + if (stepMonth * 3 > minimumStep) { + this.scale = 'month';this.step = 3; + } + if (stepMonth > minimumStep) { + this.scale = 'month';this.step = 1; + } + if (stepDay * 5 > minimumStep) { + this.scale = 'day';this.step = 5; + } + if (stepDay * 2 > minimumStep) { + this.scale = 'day';this.step = 2; + } + if (stepDay > minimumStep) { + this.scale = 'day';this.step = 1; + } + if (stepDay / 2 > minimumStep) { + this.scale = 'weekday';this.step = 1; + } + if (stepHour * 4 > minimumStep) { + this.scale = 'hour';this.step = 4; + } + if (stepHour > minimumStep) { + this.scale = 'hour';this.step = 1; + } + if (stepMinute * 15 > minimumStep) { + this.scale = 'minute';this.step = 15; + } + if (stepMinute * 10 > minimumStep) { + this.scale = 'minute';this.step = 10; + } + if (stepMinute * 5 > minimumStep) { + this.scale = 'minute';this.step = 5; + } + if (stepMinute > minimumStep) { + this.scale = 'minute';this.step = 1; + } + if (stepSecond * 15 > minimumStep) { + this.scale = 'second';this.step = 15; + } + if (stepSecond * 10 > minimumStep) { + this.scale = 'second';this.step = 10; + } + if (stepSecond * 5 > minimumStep) { + this.scale = 'second';this.step = 5; + } + if (stepSecond > minimumStep) { + this.scale = 'second';this.step = 1; + } + if (stepMillisecond * 200 > minimumStep) { + this.scale = 'millisecond';this.step = 200; + } + if (stepMillisecond * 100 > minimumStep) { + this.scale = 'millisecond';this.step = 100; + } + if (stepMillisecond * 50 > minimumStep) { + this.scale = 'millisecond';this.step = 50; + } + if (stepMillisecond * 10 > minimumStep) { + this.scale = 'millisecond';this.step = 10; + } + if (stepMillisecond * 5 > minimumStep) { + this.scale = 'millisecond';this.step = 5; + } + if (stepMillisecond > minimumStep) { + this.scale = 'millisecond';this.step = 1; + } + }; /** - * @constructor Item - * @param {Object} data Object containing (optional) parameters type, - * start, end, content, group, className. - * @param {{toScreen: function, toTime: function}} conversion - * Conversion functions from time to screen and vice versa - * @param {Object} options Configuration options - * // TODO: describe available options + * Snap a date to a rounded value. + * The snap intervals are dependent on the current scale and step. + * Static function + * @param {Date} date the date to be snapped. + * @param {string} scale Current scale, can be 'millisecond', 'second', + * 'minute', 'hour', 'weekday, 'day', 'month', 'year'. + * @param {number} step Current step (1, 2, 4, 5, ... + * @return {Date} snappedDate */ - function Item(data, conversion, options) { - this.id = null; - this.parent = null; - this.data = data; - this.dom = null; - this.conversion = conversion || {}; - this.options = options || {}; - - this.selected = false; - this.displayed = false; - this.dirty = true; + TimeStep.snap = function (date, scale, step) { + var clone = moment(date); - this.top = null; - this.left = null; - this.width = null; - this.height = null; + if (scale == 'year') { + var year = clone.year() + Math.round(clone.month() / 12); + clone.year(Math.round(year / step) * step); + clone.month(0); + clone.date(0); + clone.hours(0); + clone.minutes(0); + clone.seconds(0); + clone.milliseconds(0); + } else if (scale == 'month') { + if (clone.date() > 15) { + clone.date(1); + clone.add(1, 'month'); + // important: first set Date to 1, after that change the month. + } else { + clone.date(1); + } - this.editable = null; - if (this.data && this.data.hasOwnProperty('editable') && typeof this.data.editable === 'boolean') { - this.editable = data.editable; + clone.hours(0); + clone.minutes(0); + clone.seconds(0); + clone.milliseconds(0); + } else if (scale == 'day') { + //noinspection FallthroughInSwitchStatementJS + switch (step) { + case 5: + case 2: + clone.hours(Math.round(clone.hours() / 24) * 24);break; + default: + clone.hours(Math.round(clone.hours() / 12) * 12);break; + } + clone.minutes(0); + clone.seconds(0); + clone.milliseconds(0); + } else if (scale == 'weekday') { + //noinspection FallthroughInSwitchStatementJS + switch (step) { + case 5: + case 2: + clone.hours(Math.round(clone.hours() / 12) * 12);break; + default: + clone.hours(Math.round(clone.hours() / 6) * 6);break; + } + clone.minutes(0); + clone.seconds(0); + clone.milliseconds(0); + } else if (scale == 'hour') { + switch (step) { + case 4: + clone.minutes(Math.round(clone.minutes() / 60) * 60);break; + default: + clone.minutes(Math.round(clone.minutes() / 30) * 30);break; + } + clone.seconds(0); + clone.milliseconds(0); + } else if (scale == 'minute') { + //noinspection FallthroughInSwitchStatementJS + switch (step) { + case 15: + case 10: + clone.minutes(Math.round(clone.minutes() / 5) * 5); + clone.seconds(0); + break; + case 5: + clone.seconds(Math.round(clone.seconds() / 60) * 60);break; + default: + clone.seconds(Math.round(clone.seconds() / 30) * 30);break; + } + clone.milliseconds(0); + } else if (scale == 'second') { + //noinspection FallthroughInSwitchStatementJS + switch (step) { + case 15: + case 10: + clone.seconds(Math.round(clone.seconds() / 5) * 5); + clone.milliseconds(0); + break; + case 5: + clone.milliseconds(Math.round(clone.milliseconds() / 1000) * 1000);break; + default: + clone.milliseconds(Math.round(clone.milliseconds() / 500) * 500);break; + } + } else if (scale == 'millisecond') { + var _step = step > 5 ? step / 2 : 1; + clone.milliseconds(Math.round(clone.milliseconds() / _step) * _step); } - } - - Item.prototype.stack = true; - - /** - * Select current item - */ - Item.prototype.select = function () { - this.selected = true; - this.dirty = true; - if (this.displayed) this.redraw(); - }; - /** - * Unselect current item - */ - Item.prototype.unselect = function () { - this.selected = false; - this.dirty = true; - if (this.displayed) this.redraw(); + return clone; }; /** - * Set data for the item. Existing data will be updated. The id should not - * be changed. When the item is displayed, it will be redrawn immediately. - * @param {Object} data + * Check if the current value is a major value (for example when the step + * is DAY, a major value is each first day of the MONTH) + * @return {boolean} true if current date is major, else false. */ - Item.prototype.setData = function (data) { - var groupChanged = data.group != undefined && this.data.group != data.group; - if (groupChanged) { - this.parent.itemSet._moveToGroup(this, data.group); + TimeStep.prototype.isMajor = function () { + if (this.switchedYear == true) { + this.switchedYear = false; + switch (this.scale) { + case 'year': + case 'month': + case 'weekday': + case 'day': + case 'hour': + case 'minute': + case 'second': + case 'millisecond': + return true; + default: + return false; + } + } else if (this.switchedMonth == true) { + this.switchedMonth = false; + switch (this.scale) { + case 'weekday': + case 'day': + case 'hour': + case 'minute': + case 'second': + case 'millisecond': + return true; + default: + return false; + } + } else if (this.switchedDay == true) { + this.switchedDay = false; + switch (this.scale) { + case 'millisecond': + case 'second': + case 'minute': + case 'hour': + return true; + default: + return false; + } } - if (data.hasOwnProperty('editable') && typeof data.editable === 'boolean') { - this.editable = data.editable; + var date = this.moment(this.current); + switch (this.scale) { + case 'millisecond': + return date.milliseconds() == 0; + case 'second': + return date.seconds() == 0; + case 'minute': + return date.hours() == 0 && date.minutes() == 0; + case 'hour': + return date.hours() == 0; + case 'weekday': // intentional fall through + case 'day': + return date.date() == 1; + case 'month': + return date.month() == 0; + case 'year': + return false; + default: + return false; } - - this.data = data; - this.dirty = true; - if (this.displayed) this.redraw(); }; /** - * Set a parent for the item - * @param {ItemSet | Group} parent + * Returns formatted text for the minor axislabel, depending on the current + * date and the scale. For example when scale is MINUTE, the current time is + * formatted as "hh:mm". + * @param {Date} [date] custom date. if not provided, current date is taken */ - Item.prototype.setParent = function (parent) { - if (this.displayed) { - this.hide(); - this.parent = parent; - if (this.parent) { - this.show(); - } - } else { - this.parent = parent; + TimeStep.prototype.getLabelMinor = function (date) { + if (date == undefined) { + date = this.current; } - }; - /** - * Check whether this item is visible inside given range - * @returns {{start: Number, end: Number}} range with a timestamp for start and end - * @returns {boolean} True if visible - */ - Item.prototype.isVisible = function (range) { - // Should be implemented by Item implementations - return false; + var format = this.format.minorLabels[this.scale]; + return format && format.length > 0 ? this.moment(date).format(format) : ''; }; /** - * Show the Item in the DOM (when not already visible) - * @return {Boolean} changed + * Returns formatted text for the major axis label, depending on the current + * date and the scale. For example when scale is MINUTE, the major scale is + * hours, and the hour will be formatted as "hh". + * @param {Date} [date] custom date. if not provided, current date is taken */ - Item.prototype.show = function () { - return false; - }; + TimeStep.prototype.getLabelMajor = function (date) { + if (date == undefined) { + date = this.current; + } - /** - * Hide the Item from the DOM (when visible) - * @return {Boolean} changed - */ - Item.prototype.hide = function () { - return false; + var format = this.format.majorLabels[this.scale]; + return format && format.length > 0 ? this.moment(date).format(format) : ''; }; - /** - * Repaint the item - */ - Item.prototype.redraw = function () {}; - - /** - * Reposition the Item horizontally - */ - Item.prototype.repositionX = function () {}; - - /** - * Reposition the Item vertically - */ - Item.prototype.repositionY = function () {}; - - /** - * Repaint a delete button on the top right of the item when the item is selected - * @param {HTMLElement} anchor - * @protected - */ - Item.prototype._repaintDeleteButton = function (anchor) { - var editable = (this.options.editable.remove || this.data.editable === true) && this.data.editable !== false; - - if (this.selected && editable && !this.dom.deleteButton) { - // create and show button - var me = this; - - var deleteButton = document.createElement('div'); - deleteButton.className = 'vis-delete'; - deleteButton.title = 'Delete this item'; + TimeStep.prototype.getClassName = function () { + var _moment = this.moment; + var m = this.moment(this.current); + var current = m.locale ? m.locale('en') : m.lang('en'); // old versions of moment have .lang() function + var step = this.step; - // TODO: be able to destroy the delete button - new Hammer(deleteButton).on('tap', function (event) { - event.stopPropagation(); - me.parent.removeFromDataSet(me); - }); + function even(value) { + return value / step % 2 == 0 ? ' vis-even' : ' vis-odd'; + } - anchor.appendChild(deleteButton); - this.dom.deleteButton = deleteButton; - } else if (!this.selected && this.dom.deleteButton) { - // remove button - if (this.dom.deleteButton.parentNode) { - this.dom.deleteButton.parentNode.removeChild(this.dom.deleteButton); + function today(date) { + if (date.isSame(new Date(), 'day')) { + return ' vis-today'; } - this.dom.deleteButton = null; + if (date.isSame(_moment().add(1, 'day'), 'day')) { + return ' vis-tomorrow'; + } + if (date.isSame(_moment().add(-1, 'day'), 'day')) { + return ' vis-yesterday'; + } + return ''; } - }; - /** - * Set HTML contents for the item - * @param {Element} element HTML element to fill with the contents - * @private - */ - Item.prototype._updateContents = function (element) { - var content; - if (this.options.template) { - var itemData = this.parent.itemSet.itemsData.get(this.id); // get a clone of the data from the dataset - content = this.options.template(itemData); - } else { - content = this.data.content; + function currentWeek(date) { + return date.isSame(new Date(), 'week') ? ' vis-current-week' : ''; } - var changed = this._contentToString(this.content) !== this._contentToString(content); - if (changed) { - // only replace the content when changed - if (content instanceof Element) { - element.innerHTML = ''; - element.appendChild(content); - } else if (content != undefined) { - element.innerHTML = content; - } else { - if (!(this.data.type == 'background' && this.data.content === undefined)) { - throw new Error('Property "content" missing in item ' + this.id); - } - } - - this.content = content; + function currentMonth(date) { + return date.isSame(new Date(), 'month') ? ' vis-current-month' : ''; } - }; - /** - * Set HTML contents for the item - * @param {Element} element HTML element to fill with the contents - * @private - */ - Item.prototype._updateTitle = function (element) { - if (this.data.title != null) { - element.title = this.data.title || ''; - } else { - element.removeAttribute('vis-title'); + function currentYear(date) { + return date.isSame(new Date(), 'year') ? ' vis-current-year' : ''; } - }; - /** - * Process dataAttributes timeline option and set as data- attributes on dom.content - * @param {Element} element HTML element to which the attributes will be attached - * @private - */ - Item.prototype._updateDataAttributes = function (element) { - if (this.options.dataAttributes && this.options.dataAttributes.length > 0) { - var attributes = []; + switch (this.scale) { + case 'millisecond': + return even(current.milliseconds()).trim(); - if (Array.isArray(this.options.dataAttributes)) { - attributes = this.options.dataAttributes; - } else if (this.options.dataAttributes == 'all') { - attributes = Object.keys(this.data); - } else { - return; - } + case 'second': + return even(current.seconds()).trim(); - for (var i = 0; i < attributes.length; i++) { - var name = attributes[i]; - var value = this.data[name]; + case 'minute': + return even(current.minutes()).trim(); - if (value != null) { - element.setAttribute('data-' + name, value); - } else { - element.removeAttribute('data-' + name); + case 'hour': + var hours = current.hours(); + if (this.step == 4) { + hours = hours + '-h' + (hours + 4); } - } - } - }; + return 'vis-h' + hours + today(current) + even(current.hours()); - /** - * Update custom styles of the element - * @param element - * @private - */ - Item.prototype._updateStyle = function (element) { - // remove old styles - if (this.style) { - util.removeCssText(element, this.style); - this.style = null; - } + case 'weekday': + return 'vis-' + current.format('dddd').toLowerCase() + today(current) + currentWeek(current) + even(current.date()); - // append new styles - if (this.data.style) { - util.addCssText(element, this.data.style); - this.style = this.data.style; - } - }; + case 'day': + var day = current.date(); + var month = current.format('MMMM').toLowerCase(); + return 'vis-day' + day + ' vis-' + month + currentMonth(current) + even(day - 1); - /** - * Stringify the items contents - * @param {string | Element | undefined} content - * @returns {string | undefined} - * @private - */ - Item.prototype._contentToString = function (content) { - if (typeof content === 'string') return content; - if (content && 'outerHTML' in content) return content.outerHTML; - return content; - }; + case 'month': + return 'vis-' + current.format('MMMM').toLowerCase() + currentMonth(current) + even(current.month()); - /** - * Return the width of the item left from its start date - * @return {number} - */ - Item.prototype.getWidthLeft = function () { - return 0; - }; + case 'year': + var year = current.year(); + return 'vis-year' + year + currentYear(current) + even(year); - /** - * Return the width of the item right from the max of its start and end date - * @return {number} - */ - Item.prototype.getWidthRight = function () { - return 0; + default: + return ''; + } }; - module.exports = Item; - - // should be implemented by the item - - // should be implemented by the item - - // should be implemented by the item + module.exports = TimeStep; /***/ }, /* 35 */ @@ -19496,7 +19413,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; var util = __webpack_require__(1); - var Group = __webpack_require__(31); + var Group = __webpack_require__(30); /** * @constructor BackgroundGroup @@ -19559,7 +19476,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var Item = __webpack_require__(34); + var Item = __webpack_require__(33); var util = __webpack_require__(1); /** @@ -19799,7 +19716,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var Item = __webpack_require__(34); + var Item = __webpack_require__(33); /** * @constructor PointItem @@ -20005,9 +19922,9 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; var Hammer = __webpack_require__(20); - var Item = __webpack_require__(34); + var Item = __webpack_require__(33); var BackgroundGroup = __webpack_require__(35); - var RangeItem = __webpack_require__(33); + var RangeItem = __webpack_require__(32); /** * @constructor BackgroundItem @@ -20181,23 +20098,23 @@ return /******/ (function(modules) { // webpackBootstrap } // and when the orientation is bottom: else { - var newTop = this.parent.top; - var totalHeight = 0; - for (var subgroup in subgroups) { - if (subgroups.hasOwnProperty(subgroup)) { - if (subgroups[subgroup].visible == true) { - var newHeight = subgroups[subgroup].height + margin.item.vertical; - totalHeight += newHeight; - if (subgroups[subgroup].index > subgroupIndex) { - newTop += newHeight; + var newTop = this.parent.top; + var totalHeight = 0; + for (var subgroup in subgroups) { + if (subgroups.hasOwnProperty(subgroup)) { + if (subgroups[subgroup].visible == true) { + var newHeight = subgroups[subgroup].height + margin.item.vertical; + totalHeight += newHeight; + if (subgroups[subgroup].index > subgroupIndex) { + newTop += newHeight; + } } } } + height = this.parent.subgroups[itemSubgroup].height + margin.item.vertical; + this.dom.box.style.top = this.parent.height - totalHeight + newTop + 'px'; + this.dom.box.style.bottom = ''; } - height = this.parent.subgroups[itemSubgroup].height + margin.item.vertical; - this.dom.box.style.top = this.parent.height - totalHeight + newTop + 'px'; - this.dom.box.style.bottom = ''; - } } // and in the case of no subgroups: else { @@ -20227,7 +20144,7 @@ return /******/ (function(modules) { // webpackBootstrap var util = __webpack_require__(1); var Component = __webpack_require__(26); - var TimeStep = __webpack_require__(30); + var TimeStep = __webpack_require__(34); var DateUtil = __webpack_require__(27); var moment = __webpack_require__(2); @@ -20688,7 +20605,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; var keycharm = __webpack_require__(41); - var Emitter = __webpack_require__(12); + var Emitter = __webpack_require__(13); var Hammer = __webpack_require__(20); var util = __webpack_require__(1); @@ -21494,10 +21411,6 @@ return /******/ (function(modules) { // webpackBootstrap var _ColorPicker = __webpack_require__(46); - var _ColorPicker2 = _interopRequireDefault(_ColorPicker); - - var util = __webpack_require__(1); - /** * The way this works is for all properties of this.possible options, you can supply the property name in any form to list the options. * Boolean options are recognised as Boolean @@ -21513,6 +21426,10 @@ return /******/ (function(modules) { // webpackBootstrap * @param pixelRatio | canvas pixel ratio */ + var _ColorPicker2 = _interopRequireDefault(_ColorPicker); + + var util = __webpack_require__(1); + var Configurator = (function () { function Configurator(parentModule, defaultContainer, configureOptions) { var pixelRatio = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; @@ -21545,15 +21462,15 @@ return /******/ (function(modules) { // webpackBootstrap this.wrapper = undefined; } + /** + * refresh all options. + * Because all modules parse their options by themselves, we just use their options. We copy them here. + * + * @param options + */ + _createClass(Configurator, [{ key: 'setOptions', - - /** - * refresh all options. - * Because all modules parse their options by themselves, we just use their options. We copy them here. - * - * @param options - */ value: function setOptions(options) { if (options !== undefined) { // reset the popup history because the indices may have been changed. @@ -21605,13 +21522,13 @@ return /******/ (function(modules) { // webpackBootstrap this._create(); } } - }, { - key: '_create', /** * Create all DOM elements * @private */ + }, { + key: '_create', value: function _create() { var _this = this; @@ -21675,13 +21592,13 @@ return /******/ (function(modules) { // webpackBootstrap this._push(); this.colorPicker.insertTo(this.container); } - }, { - key: '_push', /** * draw all DOM elements on the screen * @private */ + }, { + key: '_push', value: function _push() { this.wrapper = document.createElement('div'); this.wrapper.className = 'vis-configuration-wrapper'; @@ -21692,13 +21609,13 @@ return /******/ (function(modules) { // webpackBootstrap this._showPopupIfNeeded(); } - }, { - key: '_clean', /** * delete all DOM elements * @private */ + }, { + key: '_clean', value: function _clean() { for (var i = 0; i < this.domElements.length; i++) { this.wrapper.removeChild(this.domElements[i]); @@ -21712,8 +21629,6 @@ return /******/ (function(modules) { // webpackBootstrap this._removePopup(); } - }, { - key: '_getValue', /** * get the value from the actualOptions if it exists @@ -21721,6 +21636,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} * @private */ + }, { + key: '_getValue', value: function _getValue(path) { var base = this.moduleOptions; for (var i = 0; i < path.length; i++) { @@ -21733,8 +21650,6 @@ return /******/ (function(modules) { // webpackBootstrap } return base; } - }, { - key: '_makeItem', /** * all option elements are wrapped in an item @@ -21742,6 +21657,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param domElements * @private */ + }, { + key: '_makeItem', value: function _makeItem(path) { var _arguments = arguments, _this2 = this; @@ -21770,22 +21687,20 @@ return /******/ (function(modules) { // webpackBootstrap } return 0; } - }, { - key: '_makeHeader', /** * header for major subjects * @param name * @private */ + }, { + key: '_makeHeader', value: function _makeHeader(name) { var div = document.createElement('div'); div.className = 'vis-configuration vis-config-header'; div.innerHTML = name; this._makeItem([], div); } - }, { - key: '_makeLabel', /** * make a label, if it is an object label, it gets different styling. @@ -21795,6 +21710,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {HTMLElement} * @private */ + }, { + key: '_makeLabel', value: function _makeLabel(name, path) { var objectLabel = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; @@ -21807,8 +21724,6 @@ return /******/ (function(modules) { // webpackBootstrap } return div; } - }, { - key: '_makeDropdown', /** * make a dropdown list for multiple possible string optoins @@ -21817,6 +21732,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_makeDropdown', value: function _makeDropdown(arr, value, path) { var select = document.createElement('select'); select.className = 'vis-configuration vis-config-select'; @@ -21845,8 +21762,6 @@ return /******/ (function(modules) { // webpackBootstrap var label = this._makeLabel(path[path.length - 1], path); this._makeItem(path, label, select); } - }, { - key: '_makeRange', /** * make a range object for numeric options @@ -21855,6 +21770,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_makeRange', value: function _makeRange(arr, value, path) { var defaultValue = arr[0]; var min = arr[1]; @@ -21915,8 +21832,6 @@ return /******/ (function(modules) { // webpackBootstrap this._setupPopup(popupString, itemIndex); } } - }, { - key: '_setupPopup', /** * prepare the popup @@ -21924,13 +21839,15 @@ return /******/ (function(modules) { // webpackBootstrap * @param index * @private */ + }, { + key: '_setupPopup', value: function _setupPopup(string, index) { var _this3 = this; if (this.initialized === true && this.allowCreation === true && this.popupCounter < this.popupLimit) { - var div = document.createElement('div'); - div.id = 'vis-configuration-popup'; - div.className = 'vis-configuration-popup'; + var div = document.createElement("div"); + div.id = "vis-configuration-popup"; + div.className = "vis-configuration-popup"; div.innerHTML = string; div.onclick = function () { _this3._removePopup(); @@ -21939,13 +21856,13 @@ return /******/ (function(modules) { // webpackBootstrap this.popupDiv = { html: div, index: index }; } } - }, { - key: '_removePopup', /** * remove the popup from the dom * @private */ + }, { + key: '_removePopup', value: function _removePopup() { if (this.popupDiv.html !== undefined) { this.popupDiv.html.parentNode.removeChild(this.popupDiv.html); @@ -21954,21 +21871,21 @@ return /******/ (function(modules) { // webpackBootstrap this.popupDiv = {}; } } - }, { - key: '_showPopupIfNeeded', /** * Show the popup if it is needed. * @private */ + }, { + key: '_showPopupIfNeeded', value: function _showPopupIfNeeded() { var _this4 = this; if (this.popupDiv.html !== undefined) { var correspondingElement = this.domElements[this.popupDiv.index]; var rect = correspondingElement.getBoundingClientRect(); - this.popupDiv.html.style.left = rect.left + 'px'; - this.popupDiv.html.style.top = rect.top - 30 + 'px'; // 30 is the height; + this.popupDiv.html.style.left = rect.left + "px"; + this.popupDiv.html.style.top = rect.top - 30 + "px"; // 30 is the height; document.body.appendChild(this.popupDiv.html); this.popupDiv.hideTimeout = setTimeout(function () { _this4.popupDiv.html.style.opacity = 0; @@ -21978,8 +21895,6 @@ return /******/ (function(modules) { // webpackBootstrap }, 1800); } } - }, { - key: '_makeCheckbox', /** * make a checkbox for boolean options. @@ -21988,6 +21903,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_makeCheckbox', value: function _makeCheckbox(defaultValue, value, path) { var checkbox = document.createElement('input'); checkbox.type = 'checkbox'; @@ -22014,8 +21931,6 @@ return /******/ (function(modules) { // webpackBootstrap var label = this._makeLabel(path[path.length - 1], path); this._makeItem(path, label, checkbox); } - }, { - key: '_makeTextInput', /** * make a text input field for string options. @@ -22024,6 +21939,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_makeTextInput', value: function _makeTextInput(defaultValue, value, path) { var checkbox = document.createElement('input'); checkbox.type = 'text'; @@ -22041,8 +21958,6 @@ return /******/ (function(modules) { // webpackBootstrap var label = this._makeLabel(path[path.length - 1], path); this._makeItem(path, label, checkbox); } - }, { - key: '_makeColorField', /** * make a color field with a color picker for color fields @@ -22051,6 +21966,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_makeColorField', value: function _makeColorField(arr, value, path) { var _this5 = this; @@ -22073,8 +21990,6 @@ return /******/ (function(modules) { // webpackBootstrap var label = this._makeLabel(path[path.length - 1], path); this._makeItem(path, label, div); } - }, { - key: '_showColorPicker', /** * used by the color buttons to call the color picker. @@ -22084,6 +21999,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_showColorPicker', value: function _showColorPicker(value, div, path) { var _this6 = this; @@ -22099,8 +22016,6 @@ return /******/ (function(modules) { // webpackBootstrap _this6._update(colorString, path); }); } - }, { - key: '_handleObject', /** * parse an object and draw the correct items @@ -22108,6 +22023,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_handleObject', 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]; @@ -22178,8 +22095,6 @@ return /******/ (function(modules) { // webpackBootstrap } return visibleInSet; } - }, { - key: '_handleArray', /** * handle the array type of option @@ -22189,6 +22104,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_handleArray', value: function _handleArray(arr, value, path) { if (typeof arr[0] === 'string' && arr[0] === 'color') { this._makeColorField(arr, value, path); @@ -22207,8 +22124,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_update', /** * called to update the network with the new settings. @@ -22216,11 +22131,13 @@ return /******/ (function(modules) { // webpackBootstrap * @param path * @private */ + }, { + key: '_update', value: function _update(value, path) { var options = this._constructOptions(value, path); if (this.parent.body && this.parent.body.emitter && this.parent.body.emitter.emit) { - this.parent.body.emitter.emit('configChange', options); + this.parent.body.emitter.emit("configChange", options); } this.initialized = true; this.parent.setOptions(options); @@ -22314,13 +22231,13 @@ return /******/ (function(modules) { // webpackBootstrap this._create(); } + /** + * this inserts the colorPicker into a div from the DOM + * @param container + */ + _createClass(ColorPicker, [{ key: 'insertTo', - - /** - * this inserts the colorPicker into a div from the DOM - * @param container - */ value: function insertTo(container) { if (this.hammer !== undefined) { this.hammer.destroy(); @@ -22332,18 +22249,18 @@ return /******/ (function(modules) { // webpackBootstrap this._setSize(); } - }, { - key: 'setCallback', /** * the callback is executed on apply and save. Bind it to the application * @param callback */ + }, { + key: 'setCallback', value: function setCallback(callback) { if (typeof callback === 'function') { this.updateCallback = callback; } else { - throw new Error('Function attempted to set as colorPicker callback is not a function.'); + throw new Error("Function attempted to set as colorPicker callback is not a function."); } } }, { @@ -22354,8 +22271,6 @@ return /******/ (function(modules) { // webpackBootstrap return htmlColors[color]; } } - }, { - key: 'setColor', /** * Set the color of the colorPicker @@ -22369,6 +22284,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param color * @param setInitial */ + }, { + key: 'setColor', value: function setColor(color) { var setInitial = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; @@ -22407,19 +22324,19 @@ return /******/ (function(modules) { // webpackBootstrap // set color if (rgba === undefined) { - throw new Error('Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: ' + JSON.stringify(color)); + throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: " + JSON.stringify(color)); } else { this._setColor(rgba, setInitial); } } - }, { - key: 'show', /** * this shows the color picker at a location. The hue circle is constructed once and stored. * @param x * @param y */ + }, { + key: 'show', value: function show(x, y) { this.applied = false; this.frame.style.display = 'block'; @@ -22427,8 +22344,6 @@ return /******/ (function(modules) { // webpackBootstrap this.frame.style.left = x + 'px'; this._generateHueCircle(); } - }, { - key: '_hide', // ------------------------------------------ PRIVATE ----------------------------- // @@ -22438,6 +22353,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param storePrevious * @private */ + }, { + key: '_hide', value: function _hide() { var storePrevious = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; @@ -22452,46 +22369,44 @@ return /******/ (function(modules) { // webpackBootstrap this.frame.style.display = 'none'; } - }, { - key: '_save', /** * bound to the save button. Saves and hides. * @private */ + }, { + key: '_save', value: function _save() { this.updateCallback(this.color); this.applied = false; this._hide(); } - }, { - key: '_apply', /** * Bound to apply button. Saves but does not close. Is undone by the cancel button. * @private */ + }, { + key: '_apply', value: function _apply() { this.applied = true; this.updateCallback(this.color); this._updatePicker(this.color); } - }, { - key: '_loadLast', /** * load the color from the previous session. * @private */ + }, { + key: '_loadLast', value: function _loadLast() { if (this.previousColor !== undefined) { this.setColor(this.previousColor, false); } else { - alert('There is no last color to load...'); + alert("There is no last color to load..."); } } - }, { - key: '_setColor', /** * set the color, place the picker @@ -22499,6 +22414,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param setInitial * @private */ + }, { + key: '_setColor', value: function _setColor(rgba) { var setInitial = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; @@ -22520,26 +22437,26 @@ return /******/ (function(modules) { // webpackBootstrap this._updatePicker(rgba); } - }, { - key: '_setOpacity', /** * bound to opacity control * @param value * @private */ + }, { + key: '_setOpacity', value: function _setOpacity(value) { this.color.a = value / 100; this._updatePicker(this.color); } - }, { - key: '_setBrightness', /** * bound to brightness control * @param value * @private */ + }, { + key: '_setBrightness', value: function _setBrightness(value) { var hsv = util.RGBToHSV(this.color.r, this.color.g, this.color.b); hsv.v = value / 100; @@ -22548,14 +22465,14 @@ return /******/ (function(modules) { // webpackBootstrap this.color = rgba; this._updatePicker(); } - }, { - key: '_updatePicker', /** * update the colorpicker. A black circle overlays the hue circle to mimic the brightness decreasing. * @param rgba * @private */ + }, { + key: '_updatePicker', value: function _updatePicker() { var rgba = arguments.length <= 0 || arguments[0] === undefined ? this.color : arguments[0]; @@ -22582,13 +22499,13 @@ return /******/ (function(modules) { // webpackBootstrap this.initialColorDiv.style.backgroundColor = 'rgba(' + this.initialColor.r + ',' + this.initialColor.g + ',' + this.initialColor.b + ',' + this.initialColor.a + ')'; this.newColorDiv.style.backgroundColor = 'rgba(' + this.color.r + ',' + this.color.g + ',' + this.color.b + ',' + this.color.a + ')'; } - }, { - key: '_setSize', /** * used by create to set the size of the canvas. * @private */ + }, { + key: '_setSize', value: function _setSize() { this.colorPickerCanvas.style.width = '100%'; this.colorPickerCanvas.style.height = '100%'; @@ -22596,14 +22513,14 @@ return /******/ (function(modules) { // webpackBootstrap this.colorPickerCanvas.width = 289 * this.pixelRatio; this.colorPickerCanvas.height = 289 * this.pixelRatio; } - }, { - key: '_create', /** * create all dom elements * TODO: cleanup, lots of similar dom elements * @private */ + }, { + key: '_create', value: function _create() { this.frame = document.createElement('div'); this.frame.className = 'vis-color-picker'; @@ -22624,10 +22541,10 @@ return /******/ (function(modules) { // webpackBootstrap noCanvas.innerHTML = 'Error: your browser does not support HTML canvas'; this.colorPickerCanvas.appendChild(noCanvas); } else { - var ctx = this.colorPickerCanvas.getContext('2d'); + var ctx = this.colorPickerCanvas.getContext("2d"); this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1); - this.colorPickerCanvas.getContext('2d').setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0); + this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0); } this.colorPickerDiv.className = 'vis-color'; @@ -22676,39 +22593,39 @@ return /******/ (function(modules) { // webpackBootstrap me._setBrightness(this.value); }; - this.brightnessLabel = document.createElement('div'); - this.brightnessLabel.className = 'vis-label vis-brightness'; + this.brightnessLabel = document.createElement("div"); + this.brightnessLabel.className = "vis-label vis-brightness"; this.brightnessLabel.innerHTML = 'brightness:'; - this.opacityLabel = document.createElement('div'); - this.opacityLabel.className = 'vis-label vis-opacity'; + this.opacityLabel = document.createElement("div"); + this.opacityLabel.className = "vis-label vis-opacity"; this.opacityLabel.innerHTML = 'opacity:'; - this.newColorDiv = document.createElement('div'); - this.newColorDiv.className = 'vis-new-color'; + this.newColorDiv = document.createElement("div"); + this.newColorDiv.className = "vis-new-color"; this.newColorDiv.innerHTML = 'new'; - this.initialColorDiv = document.createElement('div'); - this.initialColorDiv.className = 'vis-initial-color'; + this.initialColorDiv = document.createElement("div"); + this.initialColorDiv.className = "vis-initial-color"; this.initialColorDiv.innerHTML = 'initial'; - this.cancelButton = document.createElement('div'); - this.cancelButton.className = 'vis-button vis-cancel'; + this.cancelButton = document.createElement("div"); + this.cancelButton.className = "vis-button vis-cancel"; this.cancelButton.innerHTML = 'cancel'; this.cancelButton.onclick = this._hide.bind(this, false); - this.applyButton = document.createElement('div'); - this.applyButton.className = 'vis-button vis-apply'; + this.applyButton = document.createElement("div"); + this.applyButton.className = "vis-button vis-apply"; this.applyButton.innerHTML = 'apply'; this.applyButton.onclick = this._apply.bind(this); - this.saveButton = document.createElement('div'); - this.saveButton.className = 'vis-button vis-save'; + this.saveButton = document.createElement("div"); + this.saveButton.className = "vis-button vis-save"; this.saveButton.innerHTML = 'save'; this.saveButton.onclick = this._save.bind(this); - this.loadButton = document.createElement('div'); - this.loadButton.className = 'vis-button vis-load'; + this.loadButton = document.createElement("div"); + this.loadButton.className = "vis-button vis-load"; this.loadButton.innerHTML = 'load last'; this.loadButton.onclick = this._loadLast.bind(this); @@ -22726,13 +22643,13 @@ return /******/ (function(modules) { // webpackBootstrap this.frame.appendChild(this.saveButton); this.frame.appendChild(this.loadButton); } - }, { - key: '_bindHammer', /** * bind hammer to the color picker * @private */ + }, { + key: '_bindHammer', value: function _bindHammer() { var _this = this; @@ -22757,13 +22674,13 @@ return /******/ (function(modules) { // webpackBootstrap _this._moveSelector(event); }); } - }, { - key: '_generateHueCircle', /** * generate the hue circle. This is relatively heavy (200ms) and is done only once on the first time it is shown. * @private */ + }, { + key: '_generateHueCircle', value: function _generateHueCircle() { if (this.generated === false) { var ctx = this.colorPickerCanvas.getContext('2d'); @@ -22805,8 +22722,6 @@ return /******/ (function(modules) { // webpackBootstrap } this.generated = true; } - }, { - key: '_moveSelector', /** * move the selector. This is called by hammer functions. @@ -22814,6 +22729,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param event * @private */ + }, { + key: '_moveSelector', value: function _moveSelector(event) { var rect = this.colorPickerDiv.getBoundingClientRect(); var left = event.center.x - rect.left; @@ -22885,15 +22802,15 @@ return /******/ (function(modules) { // webpackBootstrap _classCallCheck(this, Validator); } + /** + * Main function to be called + * @param options + * @param subObject + * @returns {boolean} + */ + _createClass(Validator, null, [{ key: 'validate', - - /** - * Main function to be called - * @param options - * @param subObject - * @returns {boolean} - */ value: function validate(options, referenceOptions, subObject) { errorFound = false; allOptions = referenceOptions; @@ -22904,8 +22821,6 @@ return /******/ (function(modules) { // webpackBootstrap Validator.parse(options, usedOptions, []); return errorFound; } - }, { - key: 'parse', /** * Will traverse an object recursively and check every value @@ -22913,6 +22828,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param referenceOptions * @param path */ + }, { + key: 'parse', value: function parse(options, referenceOptions, path) { for (var option in options) { if (options.hasOwnProperty(option)) { @@ -22920,8 +22837,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'check', /** * Check every value. If the value is an object, call the parse function on that object. @@ -22930,6 +22845,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param referenceOptions * @param path */ + }, { + key: 'check', value: function check(option, options, referenceOptions, path) { if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) { Validator.getSuggestion(option, referenceOptions, path); @@ -22951,8 +22868,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'checkFields', /** * @@ -22963,6 +22878,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {String} refOptionType | This is the type object from the reference options * @param {Array} path | where in the object is the option */ + }, { + key: 'checkFields', value: function checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) { var optionType = Validator.getType(options[option]); var refOptionType = refOptionObj[optionType]; @@ -22972,11 +22889,11 @@ return /******/ (function(modules) { // webpackBootstrap if (refOptionType.indexOf(options[option]) === -1) { console.log('%cInvalid option detected in "' + option + '".' + ' Allowed values are:' + Validator.print(refOptionType) + ' not "' + options[option] + '". ' + Validator.printLocation(path, option), printStyle); errorFound = true; - } else if (optionType === 'object' && referenceOption !== '__any__') { + } else if (optionType === 'object' && referenceOption !== "__any__") { path = util.copyAndExtendArray(path, option); Validator.parse(options[option], referenceOptions[referenceOption], path); } - } else if (optionType === 'object' && referenceOption !== '__any__') { + } else if (optionType === 'object' && referenceOption !== "__any__") { path = util.copyAndExtendArray(path, option); Validator.parse(options[option], referenceOptions[referenceOption], path); } @@ -23049,8 +22966,6 @@ return /******/ (function(modules) { // webpackBootstrap errorFound = true; } - }, { - key: 'findInOptions', /** * traverse the options in search for a match. @@ -23060,6 +22975,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param recursive * @returns {{closestMatch: string, path: Array, distance: number}} */ + }, { + key: 'findInOptions', value: function findInOptions(option, options, path) { var recursive = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; @@ -23119,10 +23036,8 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'print', value: function print(options) { - return JSON.stringify(options).replace(/(\")|(\[)|(\])|(,"__type__")/g, '').replace(/(\,)/g, ', '); + return JSON.stringify(options).replace(/(\")|(\[)|(\])|(,"__type__")/g, "").replace(/(\,)/g, ', '); } - }, { - key: 'levenshteinDistance', // Compute the edit distance between the two given strings // http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#JavaScript @@ -23132,6 +23047,8 @@ return /******/ (function(modules) { // webpackBootstrap 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. */ + }, { + key: 'levenshteinDistance', value: function levenshteinDistance(a, b) { if (a.length === 0) return b.length; if (b.length === 0) return a.length; @@ -23410,7 +23327,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var Emitter = __webpack_require__(12); + var Emitter = __webpack_require__(13); var Hammer = __webpack_require__(20); var moment = __webpack_require__(2); var util = __webpack_require__(1); @@ -23626,7 +23543,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.linegraph.groups[groupId] !== undefined) { return this.linegraph.groups[groupId].getLegend(width, height); } else { - return 'cannot find group:' + groupId; + return "cannot find group:" + groupId; } }; @@ -23943,7 +23860,7 @@ return /******/ (function(modules) { // webpackBootstrap this.updateSVGheight = true; this.updateSVGheightOnResize = true; } else if (this.body.domProps.centerContainer.height !== undefined && options.graphHeight !== undefined) { - if (parseInt((options.graphHeight + '').replace('px', '')) < this.body.domProps.centerContainer.height) { + if (parseInt((options.graphHeight + '').replace("px", '')) < this.body.domProps.centerContainer.height) { this.updateSVGheight = true; } } @@ -24297,7 +24214,7 @@ return /******/ (function(modules) { // webpackBootstrap this.svg.style.left = util.option.asSize(-this.props.width); // if the height of the graph is set as proportional, change the height of the svg - if ((this.options.height + '').indexOf('%') != -1 || this.updateSVGheightOnResize == true) { + if ((this.options.height + '').indexOf("%") != -1 || this.updateSVGheightOnResize == true) { this.updateSVGheight = true; } } @@ -24389,7 +24306,7 @@ return /******/ (function(modules) { // webpackBootstrap return true; } else { if (this.COUNTER > MAX_CYCLES) { - console.log('WARNING: there may be an infinite loop in the _updateGraph emitter cycle.'); + console.log("WARNING: there may be an infinite loop in the _updateGraph emitter cycle."); } this.COUNTER = 0; this.abortedGraphUpdate = false; @@ -24788,7 +24705,7 @@ return /******/ (function(modules) { // webpackBootstrap this.conversionFactor = 1; this.setOptions(options); - this.width = Number(('' + this.options.width).replace('px', '')); + this.width = Number(('' + this.options.width).replace("px", "")); this.minWidth = this.width; this.height = this.linegraphSVG.offsetHeight; this.hidden = false; @@ -24809,7 +24726,7 @@ return /******/ (function(modules) { // webpackBootstrap this._create(); var me = this; - this.body.emitter.on('verticalDrag', function () { + this.body.emitter.on("verticalDrag", function () { me.dom.lineContainer.style.top = me.body.domProps.scrollTop + 'px'; }); } @@ -24843,7 +24760,7 @@ return /******/ (function(modules) { // webpackBootstrap var fields = ['orientation', 'showMinorLabels', 'showMajorLabels', 'icons', 'majorLinesOffset', 'minorLinesOffset', 'labelOffsetX', 'labelOffsetY', 'iconWidth', 'width', 'visible', 'left', 'right', 'alignZeros']; util.selectiveExtend(fields, this.options, options); - this.minWidth = Number(('' + this.options.width).replace('px', '')); + this.minWidth = Number(('' + this.options.width).replace("px", "")); if (redraw === true && this.dom.frame) { this.hide(); @@ -24866,12 +24783,12 @@ return /******/ (function(modules) { // webpackBootstrap this.dom.lineContainer.style.position = 'relative'; // create svg element for graph drawing. - this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - this.svg.style.position = 'absolute'; + this.svg = document.createElementNS('http://www.w3.org/2000/svg', "svg"); + this.svg.style.position = "absolute"; this.svg.style.top = '0px'; this.svg.style.height = '100%'; this.svg.style.width = '100%'; - this.svg.style.display = 'block'; + this.svg.style.display = "block"; this.dom.frame.appendChild(this.svg); }; @@ -24985,11 +24902,11 @@ return /******/ (function(modules) { // webpackBootstrap this.hide(); } else { this.show(); - this.height = Number(this.linegraphSVG.style.height.replace('px', '')); + this.height = Number(this.linegraphSVG.style.height.replace("px", "")); // svg offsetheight did not work in firefox and explorer... this.dom.lineContainer.style.height = this.height + 'px'; - this.width = this.options.visible === true ? Number(('' + this.options.width).replace('px', '')) : 0; + this.width = this.options.visible === true ? Number(('' + this.options.width).replace("px", "")) : 0; var props = this.props; var frame = this.dom.frame; @@ -25019,7 +24936,7 @@ return /******/ (function(modules) { // webpackBootstrap frame.style.left = '0'; frame.style.bottom = ''; frame.style.width = this.width + 'px'; - frame.style.height = this.height + 'px'; + frame.style.height = this.height + "px"; this.props.width = this.body.domProps.left.width; this.props.height = this.body.domProps.left.height; } else { @@ -25028,7 +24945,7 @@ return /******/ (function(modules) { // webpackBootstrap frame.style.bottom = '0'; frame.style.left = '0'; frame.style.width = this.width + 'px'; - frame.style.height = this.height + 'px'; + frame.style.height = this.height + "px"; this.props.width = this.body.domProps.right.width; this.props.height = this.body.domProps.right.height; } @@ -25152,7 +25069,7 @@ return /******/ (function(modules) { // webpackBootstrap // this will resize the yAxis to accommodate the labels. if (this.maxLabelSize > this.width - offset && this.options.visible === true) { this.width = this.maxLabelSize + offset; - this.options.width = this.width + 'px'; + this.options.width = this.width + "px"; DOMutil.cleanupElements(this.DOMelements.lines); DOMutil.cleanupElements(this.DOMelements.labels); this.redraw(); @@ -25160,17 +25077,17 @@ return /******/ (function(modules) { // webpackBootstrap } // this will resize the yAxis if it is too big for the labels. else if (this.maxLabelSize < this.width - offset && this.options.visible === true && this.width > this.minWidth) { - this.width = Math.max(this.minWidth, this.maxLabelSize + offset); - this.options.width = this.width + 'px'; - DOMutil.cleanupElements(this.DOMelements.lines); - DOMutil.cleanupElements(this.DOMelements.labels); - this.redraw(); - resized = true; - } else { - DOMutil.cleanupElements(this.DOMelements.lines); - DOMutil.cleanupElements(this.DOMelements.labels); - resized = false; - } + this.width = Math.max(this.minWidth, this.maxLabelSize + offset); + this.options.width = this.width + "px"; + DOMutil.cleanupElements(this.DOMelements.lines); + DOMutil.cleanupElements(this.DOMelements.labels); + this.redraw(); + resized = true; + } else { + DOMutil.cleanupElements(this.DOMelements.lines); + DOMutil.cleanupElements(this.DOMelements.labels); + resized = false; + } return resized; }; @@ -25201,10 +25118,10 @@ return /******/ (function(modules) { // webpackBootstrap label.innerHTML = text; if (orientation === 'left') { label.style.left = '-' + this.options.labelOffsetX + 'px'; - label.style.textAlign = 'right'; + label.style.textAlign = "right"; } else { label.style.right = '-' + this.options.labelOffsetX + 'px'; - label.style.textAlign = 'left'; + label.style.textAlign = "left"; } label.style.top = y - 0.5 * characterHeight + this.options.labelOffsetY + 'px'; @@ -25688,29 +25605,29 @@ return /******/ (function(modules) { // webpackBootstrap var fillHeight = iconHeight * 0.5; var path, fillPath; - var outline = DOMutil.getSVGElement('rect', JSONcontainer, SVGcontainer); - outline.setAttributeNS(null, 'x', x); - outline.setAttributeNS(null, 'y', y - fillHeight); - outline.setAttributeNS(null, 'width', iconWidth); - outline.setAttributeNS(null, 'height', 2 * fillHeight); - outline.setAttributeNS(null, 'class', 'vis-outline'); + var outline = DOMutil.getSVGElement("rect", JSONcontainer, SVGcontainer); + outline.setAttributeNS(null, "x", x); + outline.setAttributeNS(null, "y", y - fillHeight); + outline.setAttributeNS(null, "width", iconWidth); + outline.setAttributeNS(null, "height", 2 * fillHeight); + outline.setAttributeNS(null, "class", "vis-outline"); if (this.options.style == 'line') { - path = DOMutil.getSVGElement('path', JSONcontainer, SVGcontainer); - path.setAttributeNS(null, 'class', this.className); + path = DOMutil.getSVGElement("path", JSONcontainer, SVGcontainer); + path.setAttributeNS(null, "class", this.className); if (this.style !== undefined) { - path.setAttributeNS(null, 'style', this.style); + path.setAttributeNS(null, "style", this.style); } - path.setAttributeNS(null, 'd', 'M' + x + ',' + y + ' L' + (x + iconWidth) + ',' + y + ''); + path.setAttributeNS(null, "d", "M" + x + "," + y + " L" + (x + iconWidth) + "," + y + ""); if (this.options.shaded.enabled == true) { - fillPath = DOMutil.getSVGElement('path', JSONcontainer, SVGcontainer); + fillPath = DOMutil.getSVGElement("path", JSONcontainer, SVGcontainer); if (this.options.shaded.orientation == 'top') { - fillPath.setAttributeNS(null, 'd', 'M' + x + ', ' + (y - fillHeight) + 'L' + x + ',' + y + ' L' + (x + iconWidth) + ',' + y + ' L' + (x + iconWidth) + ',' + (y - fillHeight)); + fillPath.setAttributeNS(null, "d", "M" + x + ", " + (y - fillHeight) + "L" + x + "," + y + " L" + (x + iconWidth) + "," + y + " L" + (x + iconWidth) + "," + (y - fillHeight)); } else { - fillPath.setAttributeNS(null, 'd', 'M' + x + ',' + y + ' ' + 'L' + x + ',' + (y + fillHeight) + ' ' + 'L' + (x + iconWidth) + ',' + (y + fillHeight) + 'L' + (x + iconWidth) + ',' + y); + fillPath.setAttributeNS(null, "d", "M" + x + "," + y + " " + "L" + x + "," + (y + fillHeight) + " " + "L" + (x + iconWidth) + "," + (y + fillHeight) + "L" + (x + iconWidth) + "," + y); } - fillPath.setAttributeNS(null, 'class', this.className + ' vis-icon-fill'); + fillPath.setAttributeNS(null, "class", this.className + " vis-icon-fill"); } if (this.options.drawPoints.enabled == true) { @@ -25741,7 +25658,7 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{icon: HTMLElement, label: (group.content|*|string), orientation: (.options.yAxisOrientation|*)}} */ GraphGroup.prototype.getLegend = function (iconWidth, iconHeight) { - var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + var svg = document.createElementNS('http://www.w3.org/2000/svg', "svg"); this.drawIcon(0, 0.5 * iconHeight, [], svg, iconWidth, iconHeight); return { icon: svg, label: this.content, orientation: this.options.yAxisOrientation }; }; @@ -25881,9 +25798,9 @@ return /******/ (function(modules) { // webpackBootstrap var path, d; var svgHeight = Number(framework.svg.style.height.replace('px', '')); path = DOMutil.getSVGElement('path', framework.svgElements, framework.svg); - path.setAttributeNS(null, 'class', group.className); + path.setAttributeNS(null, "class", group.className); if (group.style !== undefined) { - path.setAttributeNS(null, 'style', group.style); + path.setAttributeNS(null, "style", group.style); } // construct path from dataset @@ -26462,16 +26379,16 @@ return /******/ (function(modules) { // webpackBootstrap Legend.prototype._create = function () { this.dom.frame = document.createElement('div'); this.dom.frame.className = 'vis-legend'; - this.dom.frame.style.position = 'absolute'; - this.dom.frame.style.top = '10px'; - this.dom.frame.style.display = 'block'; + this.dom.frame.style.position = "absolute"; + this.dom.frame.style.top = "10px"; + this.dom.frame.style.display = "block"; this.dom.textArea = document.createElement('div'); this.dom.textArea.className = 'vis-legend-text'; - this.dom.textArea.style.position = 'relative'; - this.dom.textArea.style.top = '0px'; + this.dom.textArea.style.position = "relative"; + this.dom.textArea.style.top = "0px"; - this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.svg = document.createElementNS('http://www.w3.org/2000/svg', "svg"); this.svg.style.position = 'absolute'; this.svg.style.top = 0 + 'px'; this.svg.style.width = this.options.iconSize + 5 + 'px'; @@ -26527,16 +26444,16 @@ return /******/ (function(modules) { // webpackBootstrap this.show(); if (this.options[this.side].position == 'top-left' || this.options[this.side].position == 'bottom-left') { this.dom.frame.style.left = '4px'; - this.dom.frame.style.textAlign = 'left'; - this.dom.textArea.style.textAlign = 'left'; + this.dom.frame.style.textAlign = "left"; + this.dom.textArea.style.textAlign = "left"; this.dom.textArea.style.left = this.options.iconSize + 15 + 'px'; this.dom.textArea.style.right = ''; this.svg.style.left = 0 + 'px'; this.svg.style.right = ''; } else { this.dom.frame.style.right = '4px'; - this.dom.frame.style.textAlign = 'right'; - this.dom.textArea.style.textAlign = 'right'; + this.dom.frame.style.textAlign = "right"; + this.dom.textArea.style.textAlign = "right"; this.dom.textArea.style.right = this.options.iconSize + 15 + 'px'; this.dom.textArea.style.left = ''; this.svg.style.right = 0 + 'px'; @@ -26544,11 +26461,11 @@ return /******/ (function(modules) { // webpackBootstrap } if (this.options[this.side].position == 'top-left' || this.options[this.side].position == 'top-right') { - this.dom.frame.style.top = 4 - Number(this.body.dom.center.style.top.replace('px', '')) + 'px'; + this.dom.frame.style.top = 4 - Number(this.body.dom.center.style.top.replace("px", "")) + 'px'; this.dom.frame.style.bottom = ''; } else { var scrollableHeight = this.body.domProps.center.height - this.body.domProps.centerContainer.height; - this.dom.frame.style.bottom = 4 + scrollableHeight + Number(this.body.dom.center.style.top.replace('px', '')) + 'px'; + this.dom.frame.style.bottom = 4 + scrollableHeight + Number(this.body.dom.center.style.top.replace("px", "")) + 'px'; this.dom.frame.style.top = ''; } @@ -26948,11 +26865,23 @@ return /******/ (function(modules) { // webpackBootstrap var _modulesKamadaKawaiJs = __webpack_require__(112); + /** + * @constructor Network + * Create a network visualization, displaying nodes and edges. + * + * @param {Element} container The DOM element in which the Network will + * be created. Normally a div element. + * @param {Object} data An object containing parameters + * {Array} nodes + * {Array} edges + * @param {Object} options Options + */ + var _modulesKamadaKawaiJs2 = _interopRequireDefault(_modulesKamadaKawaiJs); __webpack_require__(114); - var Emitter = __webpack_require__(12); + var Emitter = __webpack_require__(13); var Hammer = __webpack_require__(20); var util = __webpack_require__(1); var DataSet = __webpack_require__(8); @@ -26963,17 +26892,6 @@ return /******/ (function(modules) { // webpackBootstrap var Activator = __webpack_require__(40); var locales = __webpack_require__(118); - /** - * @constructor Network - * Create a network visualization, displaying nodes and edges. - * - * @param {Element} container The DOM element in which the Network will - * be created. Normally a div element. - * @param {Object} data An object containing parameters - * {Array} nodes - * {Array} edges - * @param {Object} options Options - */ function Network(container, data, options) { var _this = this; @@ -27038,7 +26956,7 @@ return /******/ (function(modules) { // webpackBootstrap // setting up all modules this.images = new Images(function () { - return _this.body.emitter.emit('_requestRedraw'); + return _this.body.emitter.emit("_requestRedraw"); }); // object with images this.groups = new _modulesGroups2['default'](); // object with groups this.canvas = new _modulesCanvas2['default'](this.body); // DOM handler @@ -27054,8 +26972,8 @@ return /******/ (function(modules) { // webpackBootstrap this.nodesHandler = new _modulesNodesHandler2['default'](this.body, this.images, this.groups, this.layoutEngine); // Handle adding, deleting and updating of nodes as well as global options this.edgesHandler = new _modulesEdgesHandler2['default'](this.body, this.images, this.groups); // Handle adding, deleting and updating of edges as well as global options - this.body.modules['kamadaKawai'] = new _modulesKamadaKawaiJs2['default'](this.body, 150, 0.05); // Layouting algorithm. - this.body.modules['clustering'] = this.clustering; + this.body.modules["kamadaKawai"] = new _modulesKamadaKawaiJs2['default'](this.body, 150, 0.05); // Layouting algorithm. + this.body.modules["clustering"] = this.clustering; // create the DOM elements this.canvas._create(); @@ -27106,7 +27024,7 @@ return /******/ (function(modules) { // webpackBootstrap // reload the settings of the nodes to apply changes in groups that are not referenced by pointer. if (options.groups !== undefined) { - this.body.emitter.emit('refreshNodes'); + this.body.emitter.emit("refreshNodes"); } // these two do not have options at the moment, here for completeness //this.view.setOptions(options.view); @@ -27147,7 +27065,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.activator === undefined) { this.activator = new Activator(this.canvas.frame); this.activator.on('change', function () { - _this2.body.emitter.emit('activate'); + _this2.body.emitter.emit("activate"); }); } } else { @@ -27155,15 +27073,15 @@ return /******/ (function(modules) { // webpackBootstrap this.activator.destroy(); delete this.activator; } - this.body.emitter.emit('activate'); + this.body.emitter.emit("activate"); } } else { - this.body.emitter.emit('activate'); + this.body.emitter.emit("activate"); } this.canvas.setSize(); // start the physics simulation. Can be safely called multiple times. - this.body.emitter.emit('startSimulation'); + this.body.emitter.emit("startSimulation"); } }; @@ -27201,23 +27119,23 @@ return /******/ (function(modules) { // webpackBootstrap var _this3 = this; // 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 () { + this.body.emitter.on("_dataChanged", function () { // update shortcut lists _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 - _this3.body.emitter.emit('_dataUpdated'); + _this3.body.emitter.emit("_dataUpdated"); }); // this is called when options of EXISTING nodes or edges have changed. - this.body.emitter.on('_dataUpdated', function () { + this.body.emitter.on("_dataUpdated", function () { // update values _this3._updateValueRange(_this3.body.nodes); _this3._updateValueRange(_this3.body.edges); // start simulation (can be called safely, even if already running) - _this3.body.emitter.emit('startSimulation'); - _this3.body.emitter.emit('_requestRedraw'); + _this3.body.emitter.emit("startSimulation"); + _this3.body.emitter.emit("_requestRedraw"); }); }; @@ -27233,8 +27151,8 @@ return /******/ (function(modules) { // webpackBootstrap */ Network.prototype.setData = function (data) { // reset the physics engine. - this.body.emitter.emit('resetPhysics'); - this.body.emitter.emit('_resetData'); + this.body.emitter.emit("resetPhysics"); + this.body.emitter.emit("_resetData"); // unselect all to ensure no selections from old data are carried over. this.selectionHandler.unselectAll(); @@ -27264,13 +27182,13 @@ return /******/ (function(modules) { // webpackBootstrap } // emit change in data - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); // emit data loaded - this.body.emitter.emit('_dataLoaded'); + this.body.emitter.emit("_dataLoaded"); // find a stable position or start animating to a stable position - this.body.emitter.emit('initPhysics'); + this.body.emitter.emit("initPhysics"); }; /** @@ -27280,7 +27198,7 @@ return /******/ (function(modules) { // webpackBootstrap * network = null; */ Network.prototype.destroy = function () { - this.body.emitter.emit('destroy'); + this.body.emitter.emit("destroy"); // clear events this.body.emitter.off(); this.off(); @@ -27405,7 +27323,7 @@ return /******/ (function(modules) { // webpackBootstrap return this.manipulation.editNode.apply(this.manipulation, arguments); }; Network.prototype.editNodeMode = function () { - console.log('Deprecated: Please use editNode instead of editNodeMode.');return this.manipulation.editNode.apply(this.manipulation, arguments); + console.log("Deprecated: Please use editNode instead of editNodeMode.");return this.manipulation.editNode.apply(this.manipulation, arguments); }; Network.prototype.addEdgeMode = function () { return this.manipulation.addEdgeMode.apply(this.manipulation, arguments); @@ -27576,7 +27494,7 @@ return /******/ (function(modules) { // webpackBootstrap _createClass(Groups, [{ key: "setOptions", value: function setOptions(options) { - var optionFields = ["useDefaultGroups"]; + var optionFields = ['useDefaultGroups']; if (options !== undefined) { for (var groupName in options) { @@ -27589,18 +27507,16 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "clear", /** * Clear all groups */ + }, { + key: "clear", value: function clear() { this.groups = {}; this.groupsArray = []; } - }, { - key: "get", /** * get group options of a groupname. If groupname is not found, a new group @@ -27608,6 +27524,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {*} groupname Can be a number, string, Date, etc. * @return {Object} group The created group, containing all group options */ + }, { + key: "get", value: function get(groupname) { var group = this.groups[groupname]; if (group === undefined) { @@ -27630,8 +27548,6 @@ return /******/ (function(modules) { // webpackBootstrap return group; } - }, { - key: "add", /** * Add a custom group style @@ -27640,6 +27556,8 @@ return /******/ (function(modules) { // webpackBootstrap * backgroundColor, etc. * @return {Object} group The created group object */ + }, { + key: "add", value: function add(groupName, style) { this.groups[groupName] = style; this.groupsArray.push(groupName); @@ -27850,14 +27768,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'setData', /** * Set a data set with nodes for the network * @param {Array | DataSet | DataView} nodes The data containing the nodes. * @private */ + }, { + key: 'setData', value: function setData(nodes) { var _this3 = this; @@ -27901,17 +27819,17 @@ return /******/ (function(modules) { // webpackBootstrap } if (doNotEmit === false) { - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } } - }, { - key: 'add', /** * Add nodes * @param {Number[] | String[]} ids * @private */ + }, { + key: 'add', value: function add(ids) { var doNotEmit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; @@ -27928,17 +27846,17 @@ return /******/ (function(modules) { // webpackBootstrap this.layoutEngine.positionInitially(newNodes); if (doNotEmit === false) { - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } } - }, { - key: 'update', /** * Update existing nodes, or create them when not yet existing * @param {Number[] | String[]} ids * @private */ + }, { + key: 'update', value: function update(ids, changedData) { var nodes = this.body.nodes; var dataChanged = false; @@ -27957,19 +27875,19 @@ return /******/ (function(modules) { // webpackBootstrap } } if (dataChanged === true) { - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } else { - this.body.emitter.emit('_dataUpdated'); + this.body.emitter.emit("_dataUpdated"); } } - }, { - key: 'remove', /** * Remove existing nodes. If nodes do not exist, the method will just ignore it. * @param {Number[] | String[]} ids * @private */ + }, { + key: 'remove', value: function remove(ids) { var nodes = this.body.nodes; @@ -27978,16 +27896,16 @@ return /******/ (function(modules) { // webpackBootstrap delete nodes[id]; } - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } - }, { - key: 'create', /** * create a node * @param properties * @param constructorClass */ + }, { + key: 'create', value: function create(properties) { var constructorClass = arguments.length <= 1 || arguments[1] === undefined ? _componentsNode2['default'] : arguments[1]; @@ -28014,14 +27932,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'getPositions', /** * Returns the positions of the nodes. * @param ids --> optional, can be array of nodeIds, can be string * @returns {{}} */ + }, { + key: 'getPositions', value: function getPositions(ids) { var dataArray = {}; if (ids !== undefined) { @@ -28046,12 +27964,12 @@ return /******/ (function(modules) { // webpackBootstrap } return dataArray; } - }, { - key: 'storePositions', /** * Load the XY positions of the nodes into the dataset. */ + }, { + key: 'storePositions', value: function storePositions() { // todo: add support for clusters and hierarchical. var dataArray = []; @@ -28067,27 +27985,27 @@ return /******/ (function(modules) { // webpackBootstrap } dataset.update(dataArray); } - }, { - key: 'getBoundingBox', /** * get the bounding box of a node. * @param nodeId * @returns {j|*} */ + }, { + key: 'getBoundingBox', value: function getBoundingBox(nodeId) { if (this.body.nodes[nodeId] !== undefined) { return this.body.nodes[nodeId].shape.boundingBox; } } - }, { - key: 'getConnectedNodes', /** * Get the Ids of nodes connected to this node. * @param nodeId * @returns {Array} */ + }, { + key: 'getConnectedNodes', value: function getConnectedNodes(nodeId) { var nodeList = []; if (this.body.nodes[nodeId] !== undefined) { @@ -28112,14 +28030,14 @@ return /******/ (function(modules) { // webpackBootstrap } return nodeList; } - }, { - key: 'getConnectedEdges', /** * Get the ids of the edges connected to this node. * @param nodeId * @returns {*} */ + }, { + key: 'getConnectedEdges', value: function getConnectedEdges(nodeId) { var edgeList = []; if (this.body.nodes[nodeId] !== undefined) { @@ -28128,12 +28046,10 @@ return /******/ (function(modules) { // webpackBootstrap edgeList.push(node.edges[i].id); } } else { - console.log('NodeId provided for getConnectedEdges does not exist. Provided: ', nodeId); + console.log("NodeId provided for getConnectedEdges does not exist. Provided: ", nodeId); } return edgeList; } - }, { - key: 'moveNode', /** * Move a node. @@ -28141,6 +28057,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param Number x * @param Number y */ + }, { + key: 'moveNode', value: function moveNode(nodeId, x, y) { var _this4 = this; @@ -28148,10 +28066,10 @@ return /******/ (function(modules) { // webpackBootstrap this.body.nodes[nodeId].x = Number(x); this.body.nodes[nodeId].y = Number(y); setTimeout(function () { - _this4.body.emitter.emit('startSimulation'); + _this4.body.emitter.emit("startSimulation"); }, 0); } else { - console.log('Node id supplied to moveNode does not exist. Provided: ', nodeId); + console.log("Node id supplied to moveNode does not exist. Provided: ", nodeId); } } }]); @@ -28297,39 +28215,39 @@ return /******/ (function(modules) { // webpackBootstrap this.setOptions(options); } + /** + * Attach a edge to the node + * @param {Edge} edge + */ + _createClass(Node, [{ key: 'attachEdge', - - /** - * Attach a edge to the node - * @param {Edge} edge - */ value: function attachEdge(edge) { if (this.edges.indexOf(edge) === -1) { this.edges.push(edge); } } - }, { - key: 'detachEdge', /** * Detach a edge from the node * @param {Edge} edge */ + }, { + key: 'detachEdge', value: function detachEdge(edge) { var index = this.edges.indexOf(edge); if (index != -1) { this.edges.splice(index, 1); } } - }, { - key: 'setOptions', /** * Set or overwrite options for the node * @param {Object} options an object with options * @param {Object} constants and object with default, global options */ + }, { + key: 'setOptions', value: function setOptions(options) { var currentShape = this.options.shape; if (!options) { @@ -28341,7 +28259,7 @@ return /******/ (function(modules) { // webpackBootstrap } if (this.id === undefined) { - throw 'Node must have an id'; + throw "Node must have an id"; } // set these options locally @@ -28383,7 +28301,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.imagelist) { this.imageObj = this.imagelist.load(this.options.image, this.options.brokenImage, this.id); } else { - throw 'No imagelist provided'; + throw "No imagelist provided"; } } @@ -28395,6 +28313,13 @@ return /******/ (function(modules) { // webpackBootstrap } return false; } + + /** + * This process all possible shorthands in the new options and makes sure that the parentOptions are fully defined. + * Static so it can also be used by the handler. + * @param parentOptions + * @param newOptions + */ }, { key: 'updateLabelModule', value: function updateLabelModule() { @@ -28463,50 +28388,48 @@ return /******/ (function(modules) { // webpackBootstrap } this._reset(); } - }, { - key: 'select', /** * select this node */ + }, { + key: 'select', value: function select() { this.selected = true; this._reset(); } - }, { - key: 'unselect', /** * unselect this node */ + }, { + key: 'unselect', value: function unselect() { this.selected = false; this._reset(); } - }, { - key: '_reset', /** * Reset the calculated size of the node, forces it to recalculate its size * @private */ + }, { + key: '_reset', value: function _reset() { this.shape.width = undefined; this.shape.height = undefined; } - }, { - key: 'getTitle', /** * get the title of this node. * @return {string} title The title of the node, or undefined when no title * has been set. */ + }, { + key: 'getTitle', value: function getTitle() { return this.options.title; } - }, { - key: 'distanceToBorder', /** * Calculate the distance to the border of the Node @@ -28514,41 +28437,41 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Number} angle Angle in radians * @returns {number} distance Distance to the border in pixels */ + }, { + key: 'distanceToBorder', value: function distanceToBorder(ctx, angle) { return this.shape.distanceToBorder(ctx, angle); } - }, { - key: 'isFixed', /** * Check if this node has a fixed x and y position * @return {boolean} true if fixed, false if not */ + }, { + key: 'isFixed', value: function isFixed() { return this.options.fixed.x && this.options.fixed.y; } - }, { - key: 'isSelected', /** * check if this node is selecte * @return {boolean} selected True if node is selected, else false */ + }, { + key: 'isSelected', value: function isSelected() { return this.selected; } - }, { - key: 'getValue', /** * Retrieve the value of the node. Can be undefined * @return {Number} value */ + }, { + key: 'getValue', value: function getValue() { return this.options.value; } - }, { - key: 'setValueRange', /** * Adjust the value range of the node. The node will adjust it's size @@ -28556,6 +28479,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Number} min * @param {Number} max */ + }, { + key: 'setValueRange', value: function setValueRange(min, max, total) { if (this.options.value !== undefined) { var scale = this.options.scaling.customScalingFunction(min, max, total, this.options.value); @@ -28570,68 +28495,61 @@ return /******/ (function(modules) { // webpackBootstrap this.options.font.size = this.baseFontSize; } } - }, { - key: 'draw', /** * Draw this node in the given canvas * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d"); * @param {CanvasRenderingContext2D} ctx */ + }, { + key: 'draw', value: function draw(ctx) { this.shape.draw(ctx, this.x, this.y, this.selected, this.hover); } - }, { - key: 'updateBoundingBox', /** * Update the bounding box of the shape */ + }, { + key: 'updateBoundingBox', value: function updateBoundingBox(ctx) { this.shape.updateBoundingBox(this.x, this.y, ctx); } - }, { - key: 'resize', /** * Recalculate the size of this node in the given canvas * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d"); * @param {CanvasRenderingContext2D} ctx */ + }, { + key: 'resize', value: function resize(ctx) { this.shape.resize(ctx, this.selected); } - }, { - key: 'isOverlappingWith', /** * Check if this object is overlapping with the provided object * @param {Object} obj an object with parameters left, top, right, bottom * @return {boolean} True if location is located on node */ + }, { + key: 'isOverlappingWith', value: function isOverlappingWith(obj) { return this.shape.left < obj.right && this.shape.left + this.shape.width > obj.left && this.shape.top < obj.bottom && this.shape.top + this.shape.height > obj.top; } - }, { - key: 'isBoundingBoxOverlappingWith', /** * Check if this object is overlapping with the provided object * @param {Object} obj an object with parameters left, top, right, bottom * @return {boolean} True if location is located on node */ + }, { + key: 'isBoundingBoxOverlappingWith', value: function isBoundingBoxOverlappingWith(obj) { return this.shape.boundingBox.left < obj.right && this.shape.boundingBox.right > obj.left && this.shape.boundingBox.top < obj.bottom && this.shape.boundingBox.bottom > obj.top; } }], [{ key: 'parseOptions', - - /** - * This process all possible shorthands in the new options and makes sure that the parentOptions are fully defined. - * Static so it can also be used by the handler. - * @param parentOptions - * @param newOptions - */ value: function parseOptions(parentOptions, newOptions) { var allowDeletion = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; @@ -28769,16 +28687,16 @@ return /******/ (function(modules) { // webpackBootstrap // draw text this._drawText(ctx, selected, x, y, baseline); } - }, { - key: '_drawBackground', /** * Draws the label background * @param {CanvasRenderingContext2D} ctx * @private */ + }, { + key: '_drawBackground', value: function _drawBackground(ctx) { - if (this.fontOptions.background !== undefined && this.fontOptions.background !== 'none') { + if (this.fontOptions.background !== undefined && this.fontOptions.background !== "none") { ctx.fillStyle = this.fontOptions.background; var lineMargin = 2; @@ -28799,8 +28717,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_drawText', /** * @@ -28809,6 +28725,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param baseline * @private */ + }, { + key: '_drawText', value: function _drawText(ctx, selected, x, y) { var baseline = arguments.length <= 4 || arguments[4] === undefined ? 'middle' : arguments[4]; @@ -28828,15 +28746,15 @@ return /******/ (function(modules) { // webpackBootstrap var fontColor = _getColor22[0]; var strokeColor = _getColor22[1]; + // configure context for drawing the text + var _setAlignment2 = this._setAlignment(ctx, x, yLine, baseline); var _setAlignment22 = _slicedToArray(_setAlignment2, 2); x = _setAlignment22[0]; yLine = _setAlignment22[1]; - - // configure context for drawing the text - ctx.font = (selected && this.nodeOptions.labelHighlightBold ? 'bold ' : '') + fontSize + 'px ' + this.fontOptions.face; + ctx.font = (selected && this.nodeOptions.labelHighlightBold ? 'bold ' : '') + fontSize + "px " + this.fontOptions.face; ctx.fillStyle = fontColor; ctx.textAlign = 'center'; @@ -28870,19 +28788,17 @@ return /******/ (function(modules) { // webpackBootstrap ctx.textBaseline = 'alphabetic'; yLine -= 2 * lineMargin; // distance from edge, required because we use alphabetic. Alphabetic has less difference between browsers } else if (this.fontOptions.align === 'bottom') { - ctx.textBaseline = 'hanging'; - yLine += 2 * lineMargin; // distance from edge, required because we use hanging. Hanging has less difference between browsers - } else { - ctx.textBaseline = 'middle'; - } + ctx.textBaseline = 'hanging'; + yLine += 2 * lineMargin; // distance from edge, required because we use hanging. Hanging has less difference between browsers + } else { + ctx.textBaseline = 'middle'; + } } else { ctx.textBaseline = baseline; } return [x, yLine]; } - }, { - key: '_getColor', /** * fade in when relative scale is between threshold and threshold - 1. @@ -28892,6 +28808,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*[]} * @private */ + }, { + key: '_getColor', value: function _getColor(viewFontSize) { var fontColor = this.fontOptions.color || '#000000'; var strokeColor = this.fontOptions.strokeColor || '#ffffff'; @@ -28902,8 +28820,6 @@ return /******/ (function(modules) { // webpackBootstrap } return [fontColor, strokeColor]; } - }, { - key: 'getTextSize', /** * @@ -28911,6 +28827,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param selected * @returns {{width: number, height: number}} */ + }, { + key: 'getTextSize', value: function getTextSize(ctx) { var selected = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; @@ -28921,8 +28839,6 @@ return /******/ (function(modules) { // webpackBootstrap }; return size; } - }, { - key: 'calculateLabelSize', /** * @@ -28932,6 +28848,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param y * @param baseline */ + }, { + key: 'calculateLabelSize', 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]; @@ -28944,7 +28862,7 @@ return /******/ (function(modules) { // webpackBootstrap this.size.left = x - this.size.width * 0.5; this.size.top = y - this.size.height * 0.5; this.size.yLine = y + (1 - this.lineCount) * 0.5 * this.fontOptions.size; - if (baseline === 'hanging') { + if (baseline === "hanging") { this.size.top += 0.5 * this.fontOptions.size; this.size.top += 4; // distance from node, required because we use hanging. Hanging has less difference between browsers this.size.yLine += 4; // distance from node @@ -28952,8 +28870,6 @@ return /******/ (function(modules) { // webpackBootstrap this.labelDirty = false; } - }, { - key: '_processLabel', /** * This calculates the width as well as explodes the label string and calculates the amount of lines. @@ -28962,6 +28878,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: '_processLabel', value: function _processLabel(ctx, selected) { var width = 0; var lines = ['']; @@ -28969,7 +28887,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.nodeOptions.label !== undefined) { lines = String(this.nodeOptions.label).split('\n'); lineCount = lines.length; - ctx.font = (selected && this.nodeOptions.labelHighlightBold ? 'bold ' : '') + this.fontOptions.size + 'px ' + this.fontOptions.face; + ctx.font = (selected && this.nodeOptions.labelHighlightBold ? 'bold ' : '') + this.fontOptions.size + "px " + this.fontOptions.face; width = ctx.measureText(lines[0]).width; for (var i = 1; i < lineCount; i++) { var lineWidth = ctx.measureText(lines[i]).width; @@ -28987,8 +28905,8 @@ return /******/ (function(modules) { // webpackBootstrap var allowDeletion = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; if (typeof newOptions.font === 'string') { - var newOptionsArray = newOptions.font.split(' '); - parentOptions.size = newOptionsArray[0].replace('px', ''); + var newOptionsArray = newOptions.font.split(" "); + parentOptions.size = newOptionsArray[0].replace("px", ''); parentOptions.face = newOptionsArray[1]; parentOptions.color = newOptionsArray[2]; } else if (typeof newOptions.font === 'object') { @@ -29187,7 +29105,7 @@ return /******/ (function(modules) { // webpackBootstrap } ctx.setLineDash(dashes); } else { - console.warn('setLineDash is not supported in this browser. The dashed borders cannot be used.'); + console.warn("setLineDash is not supported in this browser. The dashed borders cannot be used."); this.options.shapeProperties.borderDashes = false; } } @@ -29199,7 +29117,7 @@ return /******/ (function(modules) { // webpackBootstrap if (ctx.setLineDash !== undefined) { ctx.setLineDash([0]); } else { - console.warn('setLineDash is not supported in this browser. The dashed borders cannot be used.'); + console.warn("setLineDash is not supported in this browser. The dashed borders cannot be used."); this.options.shapeProperties.borderDashes = false; } } @@ -29345,8 +29263,6 @@ return /******/ (function(modules) { // webpackBootstrap this.imageObj = imageObj; } } - }, { - key: '_resizeImage', /** * This function resizes the image by the options size when the image has not yet loaded. If the image has loaded, we @@ -29354,6 +29270,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: '_resizeImage', value: function _resizeImage() { var force = false; if (!this.imageObj.width || !this.imageObj.height) { @@ -30111,12 +30029,12 @@ return /******/ (function(modules) { // webpackBootstrap var iconSize = Number(this.options.icon.size); if (this.options.icon.code !== undefined) { - ctx.font = (selected ? 'bold ' : '') + iconSize + 'px ' + this.options.icon.face; + ctx.font = (selected ? "bold " : "") + iconSize + "px " + this.options.icon.face; // draw icon - ctx.fillStyle = this.options.icon.color || 'black'; - ctx.textAlign = 'center'; - ctx.textBaseline = 'middle'; + ctx.fillStyle = this.options.icon.color || "black"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; // draw shadow if enabled this.enableShadow(ctx); @@ -30654,7 +30572,7 @@ return /******/ (function(modules) { // webpackBootstrap }, smooth: { enabled: true, - type: 'dynamic', + type: "dynamic", forceDirection: 'none', roundness: 0.5 }, @@ -30674,7 +30592,7 @@ return /******/ (function(modules) { // webpackBootstrap var _this2 = this; // this allows external modules to force all dynamic curves to turn static. - this.body.emitter.on('_forceDisableDynamicCurves', function (type) { + this.body.emitter.on("_forceDisableDynamicCurves", function (type) { if (type === 'dynamic') { type = 'continuous'; } @@ -30702,20 +30620,20 @@ return /******/ (function(modules) { // webpackBootstrap } } if (emitChange === true) { - _this2.body.emitter.emit('_dataChanged'); + _this2.body.emitter.emit("_dataChanged"); } }); // this is called when options of EXISTING nodes or edges have changed. - this.body.emitter.on('_dataUpdated', function () { + this.body.emitter.on("_dataUpdated", function () { _this2.reconnectEdges(); _this2.markAllEdgesAsDirty(); }); // refresh the edges. Used when reverting from hierarchical layout - this.body.emitter.on('refreshEdges', this.refresh.bind(this)); - this.body.emitter.on('refresh', this.refresh.bind(this)); - this.body.emitter.on('destroy', function () { + this.body.emitter.on("refreshEdges", this.refresh.bind(this)); + this.body.emitter.on("refresh", this.refresh.bind(this)); + this.body.emitter.on("destroy", function () { delete _this2.body.functions.createEdge; delete _this2.edgesListeners.add; delete _this2.edgesListeners.update; @@ -30762,8 +30680,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'setData', /** * Load edges by reading the data table @@ -30771,6 +30687,8 @@ return /******/ (function(modules) { // webpackBootstrap * @private * @private */ + }, { + key: 'setData', value: function setData(edges) { var _this3 = this; @@ -30813,17 +30731,17 @@ return /******/ (function(modules) { // webpackBootstrap } if (doNotEmit === false) { - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } } - }, { - key: 'add', /** * Add edges * @param {Number[] | String[]} ids * @private */ + }, { + key: 'add', value: function add(ids) { var doNotEmit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; @@ -30838,22 +30756,22 @@ return /******/ (function(modules) { // webpackBootstrap oldEdge.disconnect(); } - var data = edgesData.get(id, { 'showInternalIds': true }); + var data = edgesData.get(id, { "showInternalIds": true }); edges[id] = this.create(data); } if (doNotEmit === false) { - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } } - }, { - key: 'update', /** * Update existing edges, or create them when not yet existing * @param {Number[] | String[]} ids * @private */ + }, { + key: 'update', value: function update(ids) { var edges = this.body.edges; var edgesData = this.body.data.edges; @@ -30875,19 +30793,19 @@ return /******/ (function(modules) { // webpackBootstrap } if (dataChanged === true) { - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } else { - this.body.emitter.emit('_dataUpdated'); + this.body.emitter.emit("_dataUpdated"); } } - }, { - key: 'remove', /** * Remove existing edges. Non existing ids will be ignored * @param {Number[] | String[]} ids * @private */ + }, { + key: 'remove', value: function remove(ids) { var edges = this.body.edges; for (var i = 0; i < ids.length; i++) { @@ -30900,7 +30818,7 @@ return /******/ (function(modules) { // webpackBootstrap } } - this.body.emitter.emit('_dataChanged'); + this.body.emitter.emit("_dataChanged"); } }, { key: 'refresh', @@ -30929,13 +30847,13 @@ return /******/ (function(modules) { // webpackBootstrap this.body.edges[edgeId].edgeType.colorDirty = true; } } - }, { - key: 'reconnectEdges', /** * Reconnect all edges * @private */ + }, { + key: 'reconnectEdges', value: function reconnectEdges() { var id; var nodes = this.body.nodes; @@ -30999,24 +30917,20 @@ return /******/ (function(modules) { // webpackBootstrap var _sharedLabel2 = _interopRequireDefault(_sharedLabel); - var _edgesCubicBezierEdge = __webpack_require__(83); + var _edgesCubicBezierEdge = __webpack_require__(86); var _edgesCubicBezierEdge2 = _interopRequireDefault(_edgesCubicBezierEdge); - var _edgesBezierEdgeDynamic = __webpack_require__(87); + var _edgesBezierEdgeDynamic = __webpack_require__(88); var _edgesBezierEdgeDynamic2 = _interopRequireDefault(_edgesBezierEdgeDynamic); - var _edgesBezierEdgeStatic = __webpack_require__(88); + var _edgesBezierEdgeStatic = __webpack_require__(83); var _edgesBezierEdgeStatic2 = _interopRequireDefault(_edgesBezierEdgeStatic); var _edgesStraightEdge = __webpack_require__(89); - var _edgesStraightEdge2 = _interopRequireDefault(_edgesStraightEdge); - - var util = __webpack_require__(1); - /** * @class Edge * @@ -31033,12 +30947,16 @@ return /******/ (function(modules) { // webpackBootstrap * example for the color */ + var _edgesStraightEdge2 = _interopRequireDefault(_edgesStraightEdge); + + var util = __webpack_require__(1); + var Edge = (function () { function Edge(options, body, globalOptions) { _classCallCheck(this, Edge); if (body === undefined) { - throw 'No body provided'; + throw "No body provided"; } this.options = util.bridgeObject(globalOptions); this.body = body; @@ -31067,14 +30985,14 @@ return /******/ (function(modules) { // webpackBootstrap this.setOptions(options); } + /** + * Set or overwrite options for the edge + * @param {Object} options an object with options + * @param doNotEmit + */ + _createClass(Edge, [{ key: 'setOptions', - - /** - * Set or overwrite options for the edge - * @param {Object} options an object with options - * @param doNotEmit - */ value: function setOptions(options) { if (!options) { return; @@ -31128,13 +31046,13 @@ return /******/ (function(modules) { // webpackBootstrap this.baseFontSize = this.labelModule.baseSize; } } - }, { - key: 'updateEdgeType', /** * update the edge type, set the options * @returns {boolean} */ + }, { + key: 'updateEdgeType', value: function updateEdgeType() { var dataChanged = false; var changeInType = true; @@ -31178,12 +31096,12 @@ return /******/ (function(modules) { // webpackBootstrap return dataChanged; } - }, { - key: 'connect', /** * Connect an edge to its nodes */ + }, { + key: 'connect', value: function connect() { this.disconnect(); @@ -31205,12 +31123,12 @@ return /******/ (function(modules) { // webpackBootstrap this.edgeType.connect(); } - }, { - key: 'disconnect', /** * Disconnect an edge from its nodes */ + }, { + key: 'disconnect', value: function disconnect() { if (this.from) { this.from.detachEdge(this); @@ -31223,39 +31141,37 @@ return /******/ (function(modules) { // webpackBootstrap this.connected = false; } - }, { - key: 'getTitle', /** * get the title of this edge. * @return {string} title The title of the edge, or undefined when no title * has been set. */ + }, { + key: 'getTitle', value: function getTitle() { return this.title; } - }, { - key: 'isSelected', /** * check if this node is selecte * @return {boolean} selected True if node is selected, else false */ + }, { + key: 'isSelected', value: function isSelected() { return this.selected; } - }, { - key: 'getValue', /** * Retrieve the value of the edge. Can be undefined * @return {Number} value */ + }, { + key: 'getValue', value: function getValue() { return this.options.value; } - }, { - key: 'setValueRange', /** * Adjust the value range of the edge. The edge will adjust it's width @@ -31264,6 +31180,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Number} max * @param total */ + }, { + key: 'setValueRange', value: function setValueRange(min, max, total) { if (this.options.value !== undefined) { var scale = this.options.scaling.customScalingFunction(min, max, total, this.options.value); @@ -31295,8 +31213,6 @@ return /******/ (function(modules) { // webpackBootstrap this.edgeType.selectionWidth = this.options.selectionWidth + this.options.width; } } - }, { - key: 'draw', /** * Redraw a edge @@ -31304,6 +31220,8 @@ return /******/ (function(modules) { // webpackBootstrap * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d"); * @param {CanvasRenderingContext2D} ctx */ + }, { + key: 'draw', value: function draw(ctx) { var via = this.edgeType.drawLine(ctx, this.selected, this.hover); this.drawArrows(ctx, via); @@ -31336,7 +31254,7 @@ return /******/ (function(modules) { // webpackBootstrap ctx.save(); // if the label has to be rotated: - if (this.options.font.align !== 'horizontal') { + if (this.options.font.align !== "horizontal") { this.labelModule.calculateLabelSize(ctx, selected, point.x, point.y); ctx.translate(point.x, this.labelModule.size.yLine); this._rotateForLabelAlignment(ctx); @@ -31362,14 +31280,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'isOverlappingWith', /** * Check if this object is overlapping with the provided object * @param {Object} obj an object with parameters left, top * @return {boolean} True if location is located on the edge */ + }, { + key: 'isOverlappingWith', value: function isOverlappingWith(obj) { if (this.connected) { var distMax = 10; @@ -31387,14 +31305,14 @@ return /******/ (function(modules) { // webpackBootstrap return false; } } - }, { - key: '_rotateForLabelAlignment', /** * Rotates the canvas so the text is most readable * @param {CanvasRenderingContext2D} ctx * @private */ + }, { + key: '_rotateForLabelAlignment', value: function _rotateForLabelAlignment(ctx) { var dy = this.from.y - this.to.y; var dx = this.from.x - this.to.x; @@ -31407,8 +31325,6 @@ return /******/ (function(modules) { // webpackBootstrap ctx.rotate(angleInDegrees); } - }, { - key: '_pointOnCircle', /** * Get a point on a circle @@ -31419,6 +31335,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Object} point * @private */ + }, { + key: '_pointOnCircle', value: function _pointOnCircle(x, y, radius, percentage) { var angle = percentage * 2 * Math.PI; return { @@ -31436,13 +31354,13 @@ return /******/ (function(modules) { // webpackBootstrap value: function unselect() { this.selected = false; } - }, { - key: 'cleanup', /** * cleans all required things on delete * @returns {*} */ + }, { + key: 'cleanup', value: function cleanup() { return this.edgeType.cleanup(); } @@ -31484,13 +31402,13 @@ return /******/ (function(modules) { // webpackBootstrap if (newOptions.arrows !== undefined && newOptions.arrows !== null) { if (typeof newOptions.arrows === 'string') { var arrows = newOptions.arrows.toLowerCase(); - if (arrows.indexOf('to') != -1) { + if (arrows.indexOf("to") != -1) { parentOptions.arrows.to.enabled = true; } - if (arrows.indexOf('middle') != -1) { + if (arrows.indexOf("middle") != -1) { parentOptions.arrows.middle.enabled = true; } - if (arrows.indexOf('from') != -1) { + if (arrows.indexOf("from") != -1) { parentOptions.arrows.from.enabled = true; } } else if (typeof newOptions.arrows === 'object') { @@ -31498,7 +31416,7 @@ return /******/ (function(modules) { // webpackBootstrap util.mergeOptions(parentOptions.arrows, newOptions.arrows, 'middle'); util.mergeOptions(parentOptions.arrows, newOptions.arrows, 'from'); } else { - throw new Error('The arrow newOptions can only be an object or a string. Refer to the documentation. You used:' + JSON.stringify(newOptions.arrows)); + throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:" + JSON.stringify(newOptions.arrows)); } } else if (allowDeletion === true && newOptions.arrows === null) { parentOptions.arrows = undefined; @@ -31562,11 +31480,9 @@ return /******/ (function(modules) { // webpackBootstrap value: true }); - var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })(); - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + var _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -31574,49 +31490,40 @@ return /******/ (function(modules) { // webpackBootstrap function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - var _utilCubicBezierEdgeBase = __webpack_require__(84); + var _utilBezierEdgeBase = __webpack_require__(84); - var _utilCubicBezierEdgeBase2 = _interopRequireDefault(_utilCubicBezierEdgeBase); + var _utilBezierEdgeBase2 = _interopRequireDefault(_utilBezierEdgeBase); - var CubicBezierEdge = (function (_CubicBezierEdgeBase) { - _inherits(CubicBezierEdge, _CubicBezierEdgeBase); + var BezierEdgeStatic = (function (_BezierEdgeBase) { + _inherits(BezierEdgeStatic, _BezierEdgeBase); - function CubicBezierEdge(options, body, labelModule) { - _classCallCheck(this, CubicBezierEdge); + function BezierEdgeStatic(options, body, labelModule) { + _classCallCheck(this, BezierEdgeStatic); - _get(Object.getPrototypeOf(CubicBezierEdge.prototype), 'constructor', this).call(this, options, body, labelModule); + _get(Object.getPrototypeOf(BezierEdgeStatic.prototype), 'constructor', this).call(this, options, body, labelModule); } - _createClass(CubicBezierEdge, [{ - key: '_line', + /** + * Draw a line between two nodes + * @param {CanvasRenderingContext2D} ctx + * @private + */ - /** - * Draw a line between two nodes - * @param {CanvasRenderingContext2D} ctx - * @private - */ + _createClass(BezierEdgeStatic, [{ + key: '_line', value: function _line(ctx) { - // get the coordinates of the support points. - - var _getViaCoordinates2 = this._getViaCoordinates(); - - var _getViaCoordinates22 = _slicedToArray(_getViaCoordinates2, 2); - - var via1 = _getViaCoordinates22[0]; - var via2 = _getViaCoordinates22[1]; - - var returnValue = [via1, via2]; - - // start drawing the line. + // draw a straight line ctx.beginPath(); ctx.moveTo(this.from.x, this.from.y); + var via = this._getViaCoordinates(); + var returnValue = via; // fallback to normal straight edges - if (via1.x === undefined) { + if (via.x === undefined) { ctx.lineTo(this.to.x, this.to.y); returnValue = undefined; } else { - ctx.bezierCurveTo(via1.x, via1.y, via2.x, via2.y, this.to.x, this.to.y); + ctx.quadraticCurveTo(via.x, via.y, this.to.x, this.to.y); } // draw shadow if enabled this.enableShadow(ctx); @@ -31627,49 +31534,174 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: '_getViaCoordinates', value: function _getViaCoordinates() { - var dx = this.from.x - this.to.x; - var dy = this.from.y - this.to.y; + var xVia = undefined; + var yVia = undefined; + var factor = this.options.smooth.roundness; + var type = this.options.smooth.type; + var dx = Math.abs(this.from.x - this.to.x); + var dy = Math.abs(this.from.y - this.to.y); + if (type === 'discrete' || type === 'diagonalCross') { + if (Math.abs(this.from.x - this.to.x) <= Math.abs(this.from.y - this.to.y)) { + if (this.from.y >= this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dy; + yVia = this.from.y - factor * dy; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dy; + yVia = this.from.y - factor * dy; + } + } else if (this.from.y < this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dy; + yVia = this.from.y + factor * dy; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dy; + yVia = this.from.y + factor * dy; + } + } + if (type === "discrete") { + xVia = dx < factor * dy ? this.from.x : xVia; + } + } else if (Math.abs(this.from.x - this.to.x) > Math.abs(this.from.y - this.to.y)) { + if (this.from.y >= this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dx; + yVia = this.from.y - factor * dx; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dx; + yVia = this.from.y - factor * dx; + } + } else if (this.from.y < this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dx; + yVia = this.from.y + factor * dx; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dx; + yVia = this.from.y + factor * dx; + } + } + if (type === "discrete") { + yVia = dy < factor * dx ? this.from.y : yVia; + } + } + } else if (type === "straightCross") { + if (Math.abs(this.from.x - this.to.x) <= Math.abs(this.from.y - this.to.y)) { + // up - down + xVia = this.from.x; + if (this.from.y < this.to.y) { + yVia = this.to.y - (1 - factor) * dy; + } else { + yVia = this.to.y + (1 - factor) * dy; + } + } else if (Math.abs(this.from.x - this.to.x) > Math.abs(this.from.y - this.to.y)) { + // left - right + if (this.from.x < this.to.x) { + xVia = this.to.x - (1 - factor) * dx; + } else { + xVia = this.to.x + (1 - factor) * dx; + } + yVia = this.from.y; + } + } else if (type === 'horizontal') { + if (this.from.x < this.to.x) { + xVia = this.to.x - (1 - factor) * dx; + } else { + xVia = this.to.x + (1 - factor) * dx; + } + yVia = this.from.y; + } else if (type === 'vertical') { + xVia = this.from.x; + if (this.from.y < this.to.y) { + yVia = this.to.y - (1 - factor) * dy; + } else { + yVia = this.to.y + (1 - factor) * dy; + } + } else if (type === 'curvedCW') { + dx = this.to.x - this.from.x; + dy = this.from.y - this.to.y; + var radius = Math.sqrt(dx * dx + dy * dy); + var pi = Math.PI; - var x1 = undefined, - y1 = undefined, - x2 = undefined, - y2 = undefined; - var roundness = this.options.smooth.roundness;; + var originalAngle = Math.atan2(dy, dx); + var myAngle = (originalAngle + (factor * 0.5 + 0.5) * pi) % (2 * pi); - // horizontal if x > y or if direction is forced or if direction is horizontal - if ((Math.abs(dx) > Math.abs(dy) || this.options.smooth.forceDirection === true || this.options.smooth.forceDirection === 'horizontal') && this.options.smooth.forceDirection !== 'vertical') { - y1 = this.from.y; - y2 = this.to.y; - x1 = this.from.x - roundness * dx; - x2 = this.to.x + roundness * dx; + xVia = this.from.x + (factor * 0.5 + 0.5) * radius * Math.sin(myAngle); + yVia = this.from.y + (factor * 0.5 + 0.5) * radius * Math.cos(myAngle); + } else if (type === 'curvedCCW') { + dx = this.to.x - this.from.x; + dy = this.from.y - this.to.y; + var radius = Math.sqrt(dx * dx + dy * dy); + var pi = Math.PI; + + var originalAngle = Math.atan2(dy, dx); + var myAngle = (originalAngle + (-factor * 0.5 + 0.5) * pi) % (2 * pi); + + xVia = this.from.x + (factor * 0.5 + 0.5) * radius * Math.sin(myAngle); + yVia = this.from.y + (factor * 0.5 + 0.5) * radius * Math.cos(myAngle); } else { - y1 = this.from.y - roundness * dy; - y2 = this.to.y + roundness * dy; - x1 = this.from.x; - x2 = this.to.x; + // continuous + if (Math.abs(this.from.x - this.to.x) <= Math.abs(this.from.y - this.to.y)) { + if (this.from.y >= this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dy; + yVia = this.from.y - factor * dy; + xVia = this.to.x < xVia ? this.to.x : xVia; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dy; + yVia = this.from.y - factor * dy; + xVia = this.to.x > xVia ? this.to.x : xVia; + } + } else if (this.from.y < this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dy; + yVia = this.from.y + factor * dy; + xVia = this.to.x < xVia ? this.to.x : xVia; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dy; + yVia = this.from.y + factor * dy; + xVia = this.to.x > xVia ? this.to.x : xVia; + } + } + } else if (Math.abs(this.from.x - this.to.x) > Math.abs(this.from.y - this.to.y)) { + if (this.from.y >= this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dx; + yVia = this.from.y - factor * dx; + yVia = this.to.y > yVia ? this.to.y : yVia; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dx; + yVia = this.from.y - factor * dx; + yVia = this.to.y > yVia ? this.to.y : yVia; + } + } else if (this.from.y < this.to.y) { + if (this.from.x <= this.to.x) { + xVia = this.from.x + factor * dx; + yVia = this.from.y + factor * dx; + yVia = this.to.y < yVia ? this.to.y : yVia; + } else if (this.from.x > this.to.x) { + xVia = this.from.x - factor * dx; + yVia = this.from.y + factor * dx; + yVia = this.to.y < yVia ? this.to.y : yVia; + } + } + } } - - return [{ x: x1, y: y1 }, { x: x2, y: y2 }]; + return { x: xVia, y: yVia }; } }, { key: '_findBorderPosition', value: function _findBorderPosition(nearNode, ctx) { - return this._findBorderPositionBezier(nearNode, ctx); + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + return this._findBorderPositionBezier(nearNode, ctx, options.via); } }, { key: '_getDistanceToEdge', value: function _getDistanceToEdge(x1, y1, x2, y2, x3, y3) { - var _ref = arguments.length <= 6 || arguments[6] === undefined ? this._getViaCoordinates() : arguments[6]; - - var _ref2 = _slicedToArray(_ref, 2); - - var via1 = _ref2[0]; - var via2 = _ref2[1]; + var via = arguments.length <= 6 || arguments[6] === undefined ? this._getViaCoordinates() : arguments[6]; // x3,y3 is the point - return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via1, via2); + return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via); } - }, { - key: 'getPoint', /** * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way @@ -31678,31 +31710,23 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{x: number, y: number}} * @private */ + }, { + key: 'getPoint', value: function getPoint(percentage) { - var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? this._getViaCoordinates() : arguments[1]; - - var _ref32 = _slicedToArray(_ref3, 2); - - var via1 = _ref32[0]; - var via2 = _ref32[1]; + var via = arguments.length <= 1 || arguments[1] === undefined ? this._getViaCoordinates() : arguments[1]; var t = percentage; - var vec = []; - vec[0] = Math.pow(1 - t, 3); - vec[1] = 3 * t * Math.pow(1 - t, 2); - vec[2] = 3 * Math.pow(t, 2) * (1 - t); - vec[3] = Math.pow(t, 3); - var x = vec[0] * this.from.x + vec[1] * via1.x + vec[2] * via2.x + vec[3] * this.to.x; - var y = vec[0] * this.from.y + vec[1] * via1.y + vec[2] * via2.y + vec[3] * this.to.y; + var x = Math.pow(1 - t, 2) * this.from.x + 2 * t * (1 - t) * via.x + Math.pow(t, 2) * this.to.x; + var y = Math.pow(1 - t, 2) * this.from.y + 2 * t * (1 - t) * via.y + Math.pow(t, 2) * this.to.y; return { x: x, y: y }; } }]); - return CubicBezierEdge; - })(_utilCubicBezierEdgeBase2['default']); + return BezierEdgeStatic; + })(_utilBezierEdgeBase2['default']); - exports['default'] = CubicBezierEdge; + exports['default'] = BezierEdgeStatic; module.exports = exports['default']; /***/ }, @@ -31717,92 +31741,6 @@ return /******/ (function(modules) { // webpackBootstrap var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - - function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - - var _BezierEdgeBase2 = __webpack_require__(85); - - var _BezierEdgeBase3 = _interopRequireDefault(_BezierEdgeBase2); - - var CubicBezierEdgeBase = (function (_BezierEdgeBase) { - _inherits(CubicBezierEdgeBase, _BezierEdgeBase); - - function CubicBezierEdgeBase(options, body, labelModule) { - _classCallCheck(this, CubicBezierEdgeBase); - - _get(Object.getPrototypeOf(CubicBezierEdgeBase.prototype), 'constructor', this).call(this, options, body, labelModule); - } - - _createClass(CubicBezierEdgeBase, [{ - key: '_getDistanceToBezierEdge', - - /** - * Calculate the distance between a point (x3,y3) and a line segment from - * (x1,y1) to (x2,y2). - * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment - * https://en.wikipedia.org/wiki/B%C3%A9zier_curve - * @param {number} x1 from x - * @param {number} y1 from y - * @param {number} x2 to x - * @param {number} y2 to y - * @param {number} x3 point to check x - * @param {number} y3 point to check y - * @private - */ - value: function _getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via1, via2) { - // x3,y3 is the point - var minDistance = 1e9; - var distance = undefined; - var i = undefined, - t = undefined, - x = undefined, - y = undefined; - var lastX = x1; - var lastY = y1; - var vec = [0, 0, 0, 0]; - for (i = 1; i < 10; i++) { - t = 0.1 * i; - vec[0] = Math.pow(1 - t, 3); - vec[1] = 3 * t * Math.pow(1 - t, 2); - vec[2] = 3 * Math.pow(t, 2) * (1 - t); - vec[3] = Math.pow(t, 3); - x = vec[0] * x1 + vec[1] * via1.x + vec[2] * via2.x + vec[3] * x2; - y = vec[0] * y1 + vec[1] * via1.y + vec[2] * via2.y + vec[3] * y2; - if (i > 0) { - distance = this._getDistanceToLine(lastX, lastY, x, y, x3, y3); - minDistance = distance < minDistance ? distance : minDistance; - } - lastX = x; - lastY = y; - } - - return minDistance; - } - }]); - - return CubicBezierEdgeBase; - })(_BezierEdgeBase3['default']); - - exports['default'] = CubicBezierEdgeBase; - module.exports = exports['default']; - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -31811,7 +31749,7 @@ return /******/ (function(modules) { // webpackBootstrap function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - var _EdgeBase2 = __webpack_require__(86); + var _EdgeBase2 = __webpack_require__(85); var _EdgeBase3 = _interopRequireDefault(_EdgeBase2); @@ -31824,22 +31762,22 @@ return /******/ (function(modules) { // webpackBootstrap _get(Object.getPrototypeOf(BezierEdgeBase.prototype), 'constructor', this).call(this, options, body, labelModule); } + /** + * This function uses binary search to look for the point where the bezier curve crosses the border of the node. + * + * @param nearNode + * @param ctx + * @param viaNode + * @param nearNode + * @param ctx + * @param viaNode + * @param nearNode + * @param ctx + * @param viaNode + */ + _createClass(BezierEdgeBase, [{ key: '_findBorderPositionBezier', - - /** - * This function uses binary search to look for the point where the bezier curve crosses the border of the node. - * - * @param nearNode - * @param ctx - * @param viaNode - * @param nearNode - * @param ctx - * @param viaNode - * @param nearNode - * @param ctx - * @param viaNode - */ value: function _findBorderPositionBezier(nearNode, ctx) { var viaNode = arguments.length <= 2 || arguments[2] === undefined ? this._getViaCoordinates() : arguments[2]; @@ -31867,19 +31805,19 @@ return /******/ (function(modules) { // webpackBootstrap if (Math.abs(difference) < threshold) { break; // found } else if (difference < 0) { - // distance to nodes is larger than distance to border --> t needs to be bigger if we're looking at the to node. - if (from === false) { - low = middle; - } else { - high = middle; - } - } else { - if (from === false) { - high = middle; + // distance to nodes is larger than distance to border --> t needs to be bigger if we're looking at the to node. + if (from === false) { + low = middle; + } else { + high = middle; + } } else { - low = middle; + if (from === false) { + high = middle; + } else { + low = middle; + } } - } iteration++; } @@ -31887,8 +31825,6 @@ return /******/ (function(modules) { // webpackBootstrap return pos; } - }, { - key: '_getDistanceToBezierEdge', /** * Calculate the distance between a point (x3,y3) and a line segment from @@ -31902,6 +31838,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {number} y3 point to check y * @private */ + }, { + key: '_getDistanceToBezierEdge', value: function _getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via) { // x3,y3 is the point var minDistance = 1e9; @@ -31935,7 +31873,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 86 */ +/* 85 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -31984,8 +31922,6 @@ return /******/ (function(modules) { // webpackBootstrap this.to = this.body.nodes[this.options.to]; this.id = this.options.id; } - }, { - key: 'drawLine', /** * Redraw a edge as a line @@ -31994,6 +31930,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {CanvasRenderingContext2D} ctx * @private */ + }, { + key: 'drawLine', value: function drawLine(ctx, selected, hover) { // set style ctx.strokeStyle = this.getColor(ctx, selected, hover); @@ -32145,8 +32083,6 @@ return /******/ (function(modules) { // webpackBootstrap } return [x, y, radius]; } - }, { - key: '_pointOnCircle', /** * Get a point on a circle @@ -32157,6 +32093,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Object} point * @private */ + }, { + key: '_pointOnCircle', value: function _pointOnCircle(x, y, radius, percentage) { var angle = percentage * 2 * Math.PI; return { @@ -32164,8 +32102,6 @@ return /******/ (function(modules) { // webpackBootstrap y: y - radius * Math.sin(angle) }; } - }, { - key: '_findBorderPositionCircle', /** * This function uses binary search to look for the point where the circle crosses the border of the node. @@ -32175,6 +32111,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} * @private */ + }, { + key: '_findBorderPositionCircle', value: function _findBorderPositionCircle(node, ctx, options) { var x = options.x; var y = options.y; @@ -32204,27 +32142,25 @@ return /******/ (function(modules) { // webpackBootstrap if (Math.abs(difference) < threshold) { break; // found } else if (difference > 0) { - // distance to nodes is larger than distance to border --> t needs to be bigger if we're looking at the to node. - if (direction > 0) { - low = middle; - } else { - high = middle; - } - } else { - if (direction > 0) { - high = middle; + // distance to nodes is larger than distance to border --> t needs to be bigger if we're looking at the to node. + if (direction > 0) { + low = middle; + } else { + high = middle; + } } else { - low = middle; + if (direction > 0) { + high = middle; + } else { + low = middle; + } } - } iteration++; } pos.t = middle; return pos; } - }, { - key: 'getLineWidth', /** * Get the line width of the edge. Depends on width and whether one of the @@ -32232,6 +32168,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Number} width * @private */ + }, { + key: 'getLineWidth', value: function getLineWidth(selected, hover) { if (selected === true) { return Math.max(this.selectionWidth, 0.3 / this.body.view.scale); @@ -32272,7 +32210,7 @@ return /******/ (function(modules) { // webpackBootstrap } if (this.colorDirty === true) { - if (colorOptions.inherit === 'to') { + if (colorOptions.inherit === "to") { this.color.highlight = this.to.options.color.highlight.border; this.color.hover = this.to.options.color.hover.border; this.color.color = util.overrideOpacity(this.to.options.color.border, colorOptions.opacity); @@ -32300,8 +32238,6 @@ return /******/ (function(modules) { // webpackBootstrap return this.color.color; } } - }, { - key: '_circle', /** * Draw a line from a node to itself, a circle @@ -32311,6 +32247,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Number} radius * @private */ + }, { + key: '_circle', value: function _circle(ctx, x, y, radius) { // draw shadow if enabled this.enableShadow(ctx); @@ -32323,8 +32261,6 @@ return /******/ (function(modules) { // webpackBootstrap // disable shadows for other elements. this.disableShadow(ctx); } - }, { - key: 'getDistanceToEdge', /** * Calculate the distance between a point (x3,y3) and a line segment from @@ -32338,6 +32274,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {number} y3 * @private */ + }, { + key: 'getDistanceToEdge', value: function getDistanceToEdge(x1, y1, x2, y2, x3, y3, via) { // x3,y3 is the point var returnValue = 0; @@ -32363,167 +32301,406 @@ return /******/ (function(modules) { // webpackBootstrap return returnValue; } } - }, { - key: '_getDistanceToLine', - value: function _getDistanceToLine(x1, y1, x2, y2, x3, y3) { - var px = x2 - x1; - var py = y2 - y1; - var something = px * px + py * py; - var u = ((x3 - x1) * px + (y3 - y1) * py) / something; + }, { + key: '_getDistanceToLine', + value: function _getDistanceToLine(x1, y1, x2, y2, x3, y3) { + var px = x2 - x1; + var py = y2 - y1; + var something = px * px + py * py; + var u = ((x3 - x1) * px + (y3 - y1) * py) / something; + + if (u > 1) { + u = 1; + } else if (u < 0) { + u = 0; + } + + var x = x1 + u * px; + var y = y1 + u * py; + var dx = x - x3; + var dy = y - y3; + + //# Note: If the actual distance does not matter, + //# if you only want to compare what this function + //# returns to other results of this function, you + //# can just return the squared distance instead + //# (i.e. remove the sqrt) to gain a little performance + + return Math.sqrt(dx * dx + dy * dy); + } + + /** + * + * @param ctx + * @param position + * @param viaNode + */ + }, { + key: 'drawArrowHead', + value: function drawArrowHead(ctx, position, viaNode, selected, hover) { + // set style + ctx.strokeStyle = this.getColor(ctx, selected, hover); + ctx.fillStyle = ctx.strokeStyle; + ctx.lineWidth = this.getLineWidth(selected, hover); + + // set lets + var angle = undefined; + var length = undefined; + var arrowPos = undefined; + var node1 = undefined; + var node2 = undefined; + var guideOffset = undefined; + var scaleFactor = undefined; + + if (position === 'from') { + node1 = this.from; + node2 = this.to; + guideOffset = 0.1; + scaleFactor = this.options.arrows.from.scaleFactor; + } else if (position === 'to') { + node1 = this.to; + node2 = this.from; + guideOffset = -0.1; + scaleFactor = this.options.arrows.to.scaleFactor; + } else { + node1 = this.to; + node2 = this.from; + scaleFactor = this.options.arrows.middle.scaleFactor; + } + + // if not connected to itself + if (node1 != node2) { + if (position !== 'middle') { + // draw arrow head + if (this.options.smooth.enabled === true) { + arrowPos = this.findBorderPosition(node1, ctx, { via: viaNode }); + var guidePos = this.getPoint(Math.max(0.0, Math.min(1.0, arrowPos.t + guideOffset)), viaNode); + angle = Math.atan2(arrowPos.y - guidePos.y, arrowPos.x - guidePos.x); + } else { + angle = Math.atan2(node1.y - node2.y, node1.x - node2.x); + arrowPos = this.findBorderPosition(node1, ctx); + } + } else { + angle = Math.atan2(node1.y - node2.y, node1.x - node2.x); + arrowPos = this.getPoint(0.6, viaNode); // this is 0.6 to account for the size of the arrow. + } + // draw arrow at the end of the line + length = (10 + 5 * this.options.width) * scaleFactor; + ctx.arrow(arrowPos.x, arrowPos.y, angle, length); + + // draw shadow if enabled + this.enableShadow(ctx); + ctx.fill(); + + // disable shadows for other elements. + this.disableShadow(ctx); + ctx.stroke(); + } else { + // draw circle + var _angle = undefined, + point = undefined; + + var _getCircleData7 = this._getCircleData(ctx); + + var _getCircleData72 = _slicedToArray(_getCircleData7, 3); + + var x = _getCircleData72[0]; + var y = _getCircleData72[1]; + var radius = _getCircleData72[2]; + + if (position === 'from') { + point = this.findBorderPosition(this.from, ctx, { x: x, y: y, low: 0.25, high: 0.6, direction: -1 }); + _angle = point.t * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI; + } else if (position === 'to') { + point = this.findBorderPosition(this.from, ctx, { x: x, y: y, low: 0.6, high: 1.0, direction: 1 }); + _angle = point.t * -2 * Math.PI + 1.5 * Math.PI - 1.1 * Math.PI; + } else { + point = this._pointOnCircle(x, y, radius, 0.175); + _angle = 3.9269908169872414; // === 0.175 * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI; + } + + // draw the arrowhead + var _length = (10 + 5 * this.options.width) * scaleFactor; + ctx.arrow(point.x, point.y, _angle, _length); + + // draw shadow if enabled + this.enableShadow(ctx); + ctx.fill(); + + // disable shadows for other elements. + this.disableShadow(ctx); + ctx.stroke(); + } + } + }, { + key: 'enableShadow', + value: function enableShadow(ctx) { + if (this.options.shadow.enabled === true) { + ctx.shadowColor = 'rgba(0,0,0,0.5)'; + ctx.shadowBlur = this.options.shadow.size; + ctx.shadowOffsetX = this.options.shadow.x; + ctx.shadowOffsetY = this.options.shadow.y; + } + } + }, { + key: 'disableShadow', + value: function disableShadow(ctx) { + if (this.options.shadow.enabled === true) { + ctx.shadowColor = 'rgba(0,0,0,0)'; + ctx.shadowBlur = 0; + ctx.shadowOffsetX = 0; + ctx.shadowOffsetY = 0; + } + } + }]); + + return EdgeBase; + })(); + + exports['default'] = EdgeBase; + module.exports = exports['default']; + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })(); + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } + + var _utilCubicBezierEdgeBase = __webpack_require__(87); + + var _utilCubicBezierEdgeBase2 = _interopRequireDefault(_utilCubicBezierEdgeBase); + + var CubicBezierEdge = (function (_CubicBezierEdgeBase) { + _inherits(CubicBezierEdge, _CubicBezierEdgeBase); + + function CubicBezierEdge(options, body, labelModule) { + _classCallCheck(this, CubicBezierEdge); + + _get(Object.getPrototypeOf(CubicBezierEdge.prototype), 'constructor', this).call(this, options, body, labelModule); + } + + /** + * Draw a line between two nodes + * @param {CanvasRenderingContext2D} ctx + * @private + */ + + _createClass(CubicBezierEdge, [{ + key: '_line', + value: function _line(ctx) { + var _getViaCoordinates2 = this._getViaCoordinates(); + + var _getViaCoordinates22 = _slicedToArray(_getViaCoordinates2, 2); + + var via1 = _getViaCoordinates22[0]; + var via2 = _getViaCoordinates22[1]; + + var returnValue = [via1, via2]; + + // start drawing the line. + ctx.beginPath(); + ctx.moveTo(this.from.x, this.from.y); + + // fallback to normal straight edges + if (via1.x === undefined) { + ctx.lineTo(this.to.x, this.to.y); + returnValue = undefined; + } else { + ctx.bezierCurveTo(via1.x, via1.y, via2.x, via2.y, this.to.x, this.to.y); + } + // draw shadow if enabled + this.enableShadow(ctx); + ctx.stroke(); + this.disableShadow(ctx); + return returnValue; + } + }, { + key: '_getViaCoordinates', + value: function _getViaCoordinates() { + var dx = this.from.x - this.to.x; + var dy = this.from.y - this.to.y; + + var x1 = undefined, + y1 = undefined, + x2 = undefined, + y2 = undefined; + var roundness = this.options.smooth.roundness;; + + // horizontal if x > y or if direction is forced or if direction is horizontal + if ((Math.abs(dx) > Math.abs(dy) || this.options.smooth.forceDirection === true || this.options.smooth.forceDirection === 'horizontal') && this.options.smooth.forceDirection !== 'vertical') { + y1 = this.from.y; + y2 = this.to.y; + x1 = this.from.x - roundness * dx; + x2 = this.to.x + roundness * dx; + } else { + y1 = this.from.y - roundness * dy; + y2 = this.to.y + roundness * dy; + x1 = this.from.x; + x2 = this.to.x; + } + + return [{ x: x1, y: y1 }, { x: x2, y: y2 }]; + } + }, { + key: '_findBorderPosition', + value: function _findBorderPosition(nearNode, ctx) { + return this._findBorderPositionBezier(nearNode, ctx); + } + }, { + key: '_getDistanceToEdge', + value: function _getDistanceToEdge(x1, y1, x2, y2, x3, y3) { + var _ref = arguments.length <= 6 || arguments[6] === undefined ? this._getViaCoordinates() : arguments[6]; + + var _ref2 = _slicedToArray(_ref, 2); + + var via1 = _ref2[0]; + var via2 = _ref2[1]; + // x3,y3 is the point + return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via1, via2); + } + + /** + * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way + * @param percentage + * @param via + * @returns {{x: number, y: number}} + * @private + */ + }, { + key: 'getPoint', + value: function getPoint(percentage) { + var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? this._getViaCoordinates() : arguments[1]; + + var _ref32 = _slicedToArray(_ref3, 2); + + var via1 = _ref32[0]; + var via2 = _ref32[1]; + + var t = percentage; + var vec = []; + vec[0] = Math.pow(1 - t, 3); + vec[1] = 3 * t * Math.pow(1 - t, 2); + vec[2] = 3 * Math.pow(t, 2) * (1 - t); + vec[3] = Math.pow(t, 3); + var x = vec[0] * this.from.x + vec[1] * via1.x + vec[2] * via2.x + vec[3] * this.to.x; + var y = vec[0] * this.from.y + vec[1] * via1.y + vec[2] * via2.y + vec[3] * this.to.y; + + return { x: x, y: y }; + } + }]); - if (u > 1) { - u = 1; - } else if (u < 0) { - u = 0; - } + return CubicBezierEdge; + })(_utilCubicBezierEdgeBase2['default']); - var x = x1 + u * px; - var y = y1 + u * py; - var dx = x - x3; - var dy = y - y3; + exports['default'] = CubicBezierEdge; + module.exports = exports['default']; - //# Note: If the actual distance does not matter, - //# if you only want to compare what this function - //# returns to other results of this function, you - //# can just return the squared distance instead - //# (i.e. remove the sqrt) to gain a little performance + // get the coordinates of the support points. - return Math.sqrt(dx * dx + dy * dy); - } - }, { - key: 'drawArrowHead', +/***/ }, +/* 87 */ +/***/ function(module, exports, __webpack_require__) { - /** - * - * @param ctx - * @param position - * @param viaNode - */ - value: function drawArrowHead(ctx, position, viaNode, selected, hover) { - // set style - ctx.strokeStyle = this.getColor(ctx, selected, hover); - ctx.fillStyle = ctx.strokeStyle; - ctx.lineWidth = this.getLineWidth(selected, hover); + 'use strict'; - // set lets - var angle = undefined; - var length = undefined; - var arrowPos = undefined; - var node1 = undefined; - var node2 = undefined; - var guideOffset = undefined; - var scaleFactor = undefined; + Object.defineProperty(exports, '__esModule', { + value: true + }); - if (position === 'from') { - node1 = this.from; - node2 = this.to; - guideOffset = 0.1; - scaleFactor = this.options.arrows.from.scaleFactor; - } else if (position === 'to') { - node1 = this.to; - node2 = this.from; - guideOffset = -0.1; - scaleFactor = this.options.arrows.to.scaleFactor; - } else { - node1 = this.to; - node2 = this.from; - scaleFactor = this.options.arrows.middle.scaleFactor; - } + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - // if not connected to itself - if (node1 != node2) { - if (position !== 'middle') { - // draw arrow head - if (this.options.smooth.enabled === true) { - arrowPos = this.findBorderPosition(node1, ctx, { via: viaNode }); - var guidePos = this.getPoint(Math.max(0.0, Math.min(1.0, arrowPos.t + guideOffset)), viaNode); - angle = Math.atan2(arrowPos.y - guidePos.y, arrowPos.x - guidePos.x); - } else { - angle = Math.atan2(node1.y - node2.y, node1.x - node2.x); - arrowPos = this.findBorderPosition(node1, ctx); - } - } else { - angle = Math.atan2(node1.y - node2.y, node1.x - node2.x); - arrowPos = this.getPoint(0.6, viaNode); // this is 0.6 to account for the size of the arrow. - } - // draw arrow at the end of the line - length = (10 + 5 * this.options.width) * scaleFactor; - ctx.arrow(arrowPos.x, arrowPos.y, angle, length); + var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - // draw shadow if enabled - this.enableShadow(ctx); - ctx.fill(); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - // disable shadows for other elements. - this.disableShadow(ctx); - ctx.stroke(); - } else { - // draw circle - var _angle = undefined, - point = undefined; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - var _getCircleData7 = this._getCircleData(ctx); + function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - var _getCircleData72 = _slicedToArray(_getCircleData7, 3); + var _BezierEdgeBase2 = __webpack_require__(84); - var x = _getCircleData72[0]; - var y = _getCircleData72[1]; - var radius = _getCircleData72[2]; + var _BezierEdgeBase3 = _interopRequireDefault(_BezierEdgeBase2); - if (position === 'from') { - point = this.findBorderPosition(this.from, ctx, { x: x, y: y, low: 0.25, high: 0.6, direction: -1 }); - _angle = point.t * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI; - } else if (position === 'to') { - point = this.findBorderPosition(this.from, ctx, { x: x, y: y, low: 0.6, high: 1.0, direction: 1 }); - _angle = point.t * -2 * Math.PI + 1.5 * Math.PI - 1.1 * Math.PI; - } else { - point = this._pointOnCircle(x, y, radius, 0.175); - _angle = 3.9269908169872414; // === 0.175 * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI; - } + var CubicBezierEdgeBase = (function (_BezierEdgeBase) { + _inherits(CubicBezierEdgeBase, _BezierEdgeBase); - // draw the arrowhead - var _length = (10 + 5 * this.options.width) * scaleFactor; - ctx.arrow(point.x, point.y, _angle, _length); + function CubicBezierEdgeBase(options, body, labelModule) { + _classCallCheck(this, CubicBezierEdgeBase); - // draw shadow if enabled - this.enableShadow(ctx); - ctx.fill(); + _get(Object.getPrototypeOf(CubicBezierEdgeBase.prototype), 'constructor', this).call(this, options, body, labelModule); + } - // disable shadows for other elements. - this.disableShadow(ctx); - ctx.stroke(); - } - } - }, { - key: 'enableShadow', - value: function enableShadow(ctx) { - if (this.options.shadow.enabled === true) { - ctx.shadowColor = 'rgba(0,0,0,0.5)'; - ctx.shadowBlur = this.options.shadow.size; - ctx.shadowOffsetX = this.options.shadow.x; - ctx.shadowOffsetY = this.options.shadow.y; - } - } - }, { - key: 'disableShadow', - value: function disableShadow(ctx) { - if (this.options.shadow.enabled === true) { - ctx.shadowColor = 'rgba(0,0,0,0)'; - ctx.shadowBlur = 0; - ctx.shadowOffsetX = 0; - ctx.shadowOffsetY = 0; + /** + * Calculate the distance between a point (x3,y3) and a line segment from + * (x1,y1) to (x2,y2). + * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment + * https://en.wikipedia.org/wiki/B%C3%A9zier_curve + * @param {number} x1 from x + * @param {number} y1 from y + * @param {number} x2 to x + * @param {number} y2 to y + * @param {number} x3 point to check x + * @param {number} y3 point to check y + * @private + */ + + _createClass(CubicBezierEdgeBase, [{ + key: '_getDistanceToBezierEdge', + value: function _getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via1, via2) { + // x3,y3 is the point + var minDistance = 1e9; + var distance = undefined; + var i = undefined, + t = undefined, + x = undefined, + y = undefined; + var lastX = x1; + var lastY = y1; + var vec = [0, 0, 0, 0]; + for (i = 1; i < 10; i++) { + t = 0.1 * i; + vec[0] = Math.pow(1 - t, 3); + vec[1] = 3 * t * Math.pow(1 - t, 2); + vec[2] = 3 * Math.pow(t, 2) * (1 - t); + vec[3] = Math.pow(t, 3); + x = vec[0] * x1 + vec[1] * via1.x + vec[2] * via2.x + vec[3] * x2; + y = vec[0] * y1 + vec[1] * via1.y + vec[2] * via2.y + vec[3] * y2; + if (i > 0) { + distance = this._getDistanceToLine(lastX, lastY, x, y, x3, y3); + minDistance = distance < minDistance ? distance : minDistance; + } + lastX = x; + lastY = y; } + + return minDistance; } }]); - return EdgeBase; - })(); + return CubicBezierEdgeBase; + })(_BezierEdgeBase3['default']); - exports['default'] = EdgeBase; + exports['default'] = CubicBezierEdgeBase; module.exports = exports['default']; /***/ }, -/* 87 */ +/* 88 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -32542,7 +32719,7 @@ return /******/ (function(modules) { // webpackBootstrap function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - var _utilBezierEdgeBase = __webpack_require__(85); + var _utilBezierEdgeBase = __webpack_require__(84); var _utilBezierEdgeBase2 = _interopRequireDefault(_utilBezierEdgeBase); @@ -32592,13 +32769,13 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "cleanup", /** * remove the support nodes * @returns {boolean} */ + }, { + key: "cleanup", value: function cleanup() { this.body.emitter.off("_repositionBezierNodes", this._boundFunction); if (this.via !== undefined) { @@ -32608,8 +32785,6 @@ return /******/ (function(modules) { // webpackBootstrap } return false; } - }, { - key: "setupSupportNode", /** * Bezier curves require an anchor point to calculate the smooth flow. These points are nodes. These nodes are invisible but @@ -32618,12 +32793,14 @@ return /******/ (function(modules) { // webpackBootstrap * The changed data is not called, if needed, it is returned by the main edge constructor. * @private */ + }, { + key: "setupSupportNode", value: function setupSupportNode() { if (this.via === undefined) { var nodeId = "edgeId:" + this.id; var node = this.body.functions.createNode({ id: nodeId, - shape: "circle", + shape: 'circle', physics: true, hidden: true }); @@ -32644,14 +32821,14 @@ return /******/ (function(modules) { // webpackBootstrap this.via.y = 0; } } - }, { - key: "_line", /** * Draw a line between two nodes * @param {CanvasRenderingContext2D} ctx * @private */ + }, { + key: "_line", value: function _line(ctx) { // draw a straight line ctx.beginPath(); @@ -32663,8 +32840,6 @@ return /******/ (function(modules) { // webpackBootstrap this.disableShadow(ctx); return this.via; } - }, { - key: "getPoint", /** * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way @@ -32673,6 +32848,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{x: number, y: number}} * @private */ + }, { + key: "getPoint", value: function getPoint(percentage) { var t = percentage; var x = Math.pow(1 - t, 2) * this.from.x + 2 * t * (1 - t) * this.via.x + Math.pow(t, 2) * this.to.x; @@ -32699,265 +32876,6 @@ return /******/ (function(modules) { // webpackBootstrap exports["default"] = BezierEdgeDynamic; module.exports = exports["default"]; -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - - var _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - - function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - - var _utilBezierEdgeBase = __webpack_require__(85); - - 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); - } - - _createClass(BezierEdgeStatic, [{ - key: '_line', - - /** - * Draw a line between two nodes - * @param {CanvasRenderingContext2D} ctx - * @private - */ - value: function _line(ctx) { - // draw a straight line - ctx.beginPath(); - ctx.moveTo(this.from.x, this.from.y); - var via = this._getViaCoordinates(); - var returnValue = via; - - // fallback to normal straight edges - if (via.x === undefined) { - ctx.lineTo(this.to.x, this.to.y); - returnValue = undefined; - } else { - ctx.quadraticCurveTo(via.x, via.y, this.to.x, this.to.y); - } - // draw shadow if enabled - this.enableShadow(ctx); - ctx.stroke(); - this.disableShadow(ctx); - return returnValue; - } - }, { - key: '_getViaCoordinates', - value: function _getViaCoordinates() { - var xVia = undefined; - var yVia = undefined; - var factor = this.options.smooth.roundness; - var type = this.options.smooth.type; - var dx = Math.abs(this.from.x - this.to.x); - var dy = Math.abs(this.from.y - this.to.y); - if (type === 'discrete' || type === 'diagonalCross') { - if (Math.abs(this.from.x - this.to.x) <= Math.abs(this.from.y - this.to.y)) { - if (this.from.y >= this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dy; - yVia = this.from.y - factor * dy; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dy; - yVia = this.from.y - factor * dy; - } - } else if (this.from.y < this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dy; - yVia = this.from.y + factor * dy; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dy; - yVia = this.from.y + factor * dy; - } - } - if (type === 'discrete') { - xVia = dx < factor * dy ? this.from.x : xVia; - } - } else if (Math.abs(this.from.x - this.to.x) > Math.abs(this.from.y - this.to.y)) { - if (this.from.y >= this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dx; - yVia = this.from.y - factor * dx; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dx; - yVia = this.from.y - factor * dx; - } - } else if (this.from.y < this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dx; - yVia = this.from.y + factor * dx; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dx; - yVia = this.from.y + factor * dx; - } - } - if (type === 'discrete') { - yVia = dy < factor * dx ? this.from.y : yVia; - } - } - } else if (type === 'straightCross') { - if (Math.abs(this.from.x - this.to.x) <= Math.abs(this.from.y - this.to.y)) { - // up - down - xVia = this.from.x; - if (this.from.y < this.to.y) { - yVia = this.to.y - (1 - factor) * dy; - } else { - yVia = this.to.y + (1 - factor) * dy; - } - } else if (Math.abs(this.from.x - this.to.x) > Math.abs(this.from.y - this.to.y)) { - // left - right - if (this.from.x < this.to.x) { - xVia = this.to.x - (1 - factor) * dx; - } else { - xVia = this.to.x + (1 - factor) * dx; - } - yVia = this.from.y; - } - } else if (type === 'horizontal') { - if (this.from.x < this.to.x) { - xVia = this.to.x - (1 - factor) * dx; - } else { - xVia = this.to.x + (1 - factor) * dx; - } - yVia = this.from.y; - } else if (type === 'vertical') { - xVia = this.from.x; - if (this.from.y < this.to.y) { - yVia = this.to.y - (1 - factor) * dy; - } else { - yVia = this.to.y + (1 - factor) * dy; - } - } else if (type === 'curvedCW') { - dx = this.to.x - this.from.x; - dy = this.from.y - this.to.y; - var radius = Math.sqrt(dx * dx + dy * dy); - var pi = Math.PI; - - var originalAngle = Math.atan2(dy, dx); - var myAngle = (originalAngle + (factor * 0.5 + 0.5) * pi) % (2 * pi); - - xVia = this.from.x + (factor * 0.5 + 0.5) * radius * Math.sin(myAngle); - yVia = this.from.y + (factor * 0.5 + 0.5) * radius * Math.cos(myAngle); - } else if (type === 'curvedCCW') { - dx = this.to.x - this.from.x; - dy = this.from.y - this.to.y; - var radius = Math.sqrt(dx * dx + dy * dy); - var pi = Math.PI; - - var originalAngle = Math.atan2(dy, dx); - var myAngle = (originalAngle + (-factor * 0.5 + 0.5) * pi) % (2 * pi); - - xVia = this.from.x + (factor * 0.5 + 0.5) * radius * Math.sin(myAngle); - yVia = this.from.y + (factor * 0.5 + 0.5) * radius * Math.cos(myAngle); - } else { - // continuous - if (Math.abs(this.from.x - this.to.x) <= Math.abs(this.from.y - this.to.y)) { - if (this.from.y >= this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dy; - yVia = this.from.y - factor * dy; - xVia = this.to.x < xVia ? this.to.x : xVia; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dy; - yVia = this.from.y - factor * dy; - xVia = this.to.x > xVia ? this.to.x : xVia; - } - } else if (this.from.y < this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dy; - yVia = this.from.y + factor * dy; - xVia = this.to.x < xVia ? this.to.x : xVia; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dy; - yVia = this.from.y + factor * dy; - xVia = this.to.x > xVia ? this.to.x : xVia; - } - } - } else if (Math.abs(this.from.x - this.to.x) > Math.abs(this.from.y - this.to.y)) { - if (this.from.y >= this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dx; - yVia = this.from.y - factor * dx; - yVia = this.to.y > yVia ? this.to.y : yVia; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dx; - yVia = this.from.y - factor * dx; - yVia = this.to.y > yVia ? this.to.y : yVia; - } - } else if (this.from.y < this.to.y) { - if (this.from.x <= this.to.x) { - xVia = this.from.x + factor * dx; - yVia = this.from.y + factor * dx; - yVia = this.to.y < yVia ? this.to.y : yVia; - } else if (this.from.x > this.to.x) { - xVia = this.from.x - factor * dx; - yVia = this.from.y + factor * dx; - yVia = this.to.y < yVia ? this.to.y : yVia; - } - } - } - } - return { x: xVia, y: yVia }; - } - }, { - key: '_findBorderPosition', - value: function _findBorderPosition(nearNode, ctx) { - var options = arguments.length <= 2 || 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]; - // x3,y3 is the point - return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via); - } - }, { - key: 'getPoint', - - /** - * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way - * @param percentage - * @param via - * @returns {{x: number, y: number}} - * @private - */ - value: function getPoint(percentage) { - var via = arguments.length <= 1 || 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; - var y = Math.pow(1 - t, 2) * this.from.y + 2 * t * (1 - t) * via.y + Math.pow(t, 2) * this.to.y; - - return { x: x, y: y }; - } - }]); - - return BezierEdgeStatic; - })(_utilBezierEdgeBase2['default']); - - exports['default'] = BezierEdgeStatic; - module.exports = exports['default']; - /***/ }, /* 89 */ /***/ function(module, exports, __webpack_require__) { @@ -32978,7 +32896,7 @@ return /******/ (function(modules) { // webpackBootstrap function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } - var _utilEdgeBase = __webpack_require__(86); + var _utilEdgeBase = __webpack_require__(85); var _utilEdgeBase2 = _interopRequireDefault(_utilEdgeBase); @@ -32991,14 +32909,14 @@ return /******/ (function(modules) { // webpackBootstrap _get(Object.getPrototypeOf(StraightEdge.prototype), 'constructor', this).call(this, options, body, labelModule); } + /** + * Draw a line between two nodes + * @param {CanvasRenderingContext2D} ctx + * @private + */ + _createClass(StraightEdge, [{ key: '_line', - - /** - * Draw a line between two nodes - * @param {CanvasRenderingContext2D} ctx - * @private - */ value: function _line(ctx) { // draw a straight line ctx.beginPath(); @@ -33010,8 +32928,6 @@ return /******/ (function(modules) { // webpackBootstrap this.disableShadow(ctx); return undefined; } - }, { - key: 'getPoint', /** * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way @@ -33020,6 +32936,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{x: number, y: number}} * @private */ + }, { + key: 'getPoint', value: function getPoint(percentage) { return { x: (1 - percentage) * this.from.x + percentage * this.to.x, @@ -33232,13 +33150,13 @@ return /******/ (function(modules) { // webpackBootstrap _this.body.emitter.off(); }); } - }, { - key: 'setOptions', /** * set the physics options * @param options */ + }, { + key: 'setOptions', value: function setOptions(options) { if (options !== undefined) { if (options === false) { @@ -33265,12 +33183,12 @@ return /******/ (function(modules) { // webpackBootstrap } this.init(); } - }, { - key: 'init', /** * configure the engine. */ + }, { + key: 'init', value: function init() { var options; if (this.options.solver === 'forceAtlas2Based') { @@ -33298,12 +33216,12 @@ return /******/ (function(modules) { // webpackBootstrap this.modelOptions = options; } - }, { - key: 'initPhysics', /** * initialize the engine */ + }, { + key: 'initPhysics', value: function initPhysics() { if (this.physicsEnabled === true && this.options.enabled === true) { if (this.options.stabilization.enabled === true) { @@ -33319,12 +33237,12 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('fit'); } } - }, { - key: 'startSimulation', /** * Start the simulation */ + }, { + key: 'startSimulation', value: function startSimulation() { if (this.physicsEnabled === true && this.options.enabled === true) { this.stabilized = false; @@ -33333,7 +33251,7 @@ return /******/ (function(modules) { // webpackBootstrap this.adaptiveTimestep = false; // this sets the width of all nodes initially which could be required for the avoidOverlap - this.body.emitter.emit('_resizeNodes'); + this.body.emitter.emit("_resizeNodes"); if (this.viewFunction === undefined) { this.viewFunction = this.simulationStep.bind(this); this.body.emitter.on('initRedraw', this.viewFunction); @@ -33343,12 +33261,12 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('_redraw'); } } - }, { - key: 'stopSimulation', /** * Stop the simulation, force stabilization. */ + }, { + key: 'stopSimulation', value: function stopSimulation() { var emit = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; @@ -33364,13 +33282,13 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'simulationStep', /** * The viewFunction inserts this step into each renderloop. It calls the physics tick and handles the cleanup at stabilized. * */ + }, { + key: 'simulationStep', value: function simulationStep() { // check if the physics have settled var startTime = Date.now(); @@ -33389,13 +33307,13 @@ return /******/ (function(modules) { // webpackBootstrap this.stopSimulation(); } } - }, { - key: '_emitStabilized', /** * trigger the stabilized event. * @private */ + }, { + key: '_emitStabilized', value: function _emitStabilized() { var _this2 = this; @@ -33406,14 +33324,14 @@ return /******/ (function(modules) { // webpackBootstrap }, 0); } } - }, { - key: 'physicsTick', /** * A single simulation step (or 'tick') in the physics simulation * * @private */ + }, { + key: 'physicsTick', value: function physicsTick() { if (this.stabilized === false) { // adaptivity means the timestep adapts to the situation, only applicable for stabilization @@ -33484,14 +33402,14 @@ return /******/ (function(modules) { // webpackBootstrap this.stabilizationIterations++; } } - }, { - key: 'updatePhysicsData', /** * Nodes and edges can have the physics toggles on or off. A collection of indices is created here so we can skip the check all the time. * * @private */ + }, { + key: 'updatePhysicsData', value: function updatePhysicsData() { this.physicsBody.forces = {}; this.physicsBody.physicsNodeIndices = []; @@ -33535,12 +33453,12 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'revert', /** * Revert the simulation one step. This is done so after stabilization, every new start of the simulation will also say stabilized. */ + }, { + key: 'revert', value: function revert() { var nodeIds = Object.keys(this.previousStates); var nodes = this.body.nodes; @@ -33564,12 +33482,12 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_evaluateStepQuality', /** * This compares the reference state to the current state */ + }, { + key: '_evaluateStepQuality', value: function _evaluateStepQuality() { var dx = undefined, dy = undefined, @@ -33592,13 +33510,13 @@ return /******/ (function(modules) { // webpackBootstrap } return true; } - }, { - key: 'moveNodes', /** * move the nodes one timestap and check if they are stabilized * @returns {boolean} */ + }, { + key: 'moveNodes', value: function moveNodes() { var nodeIndices = this.physicsBody.physicsNodeIndices; var maxVelocity = this.options.maxVelocity ? this.options.maxVelocity : 1e9; @@ -33620,8 +33538,6 @@ return /******/ (function(modules) { // webpackBootstrap this.adaptiveTimestepEnabled = averageNodeVelocity / nodeIndices.length < velocityAdaptiveThreshold; this.stabilized = maxNodeVelocity < this.options.minVelocity; } - }, { - key: '_performStep', /** * Perform the actual step @@ -33631,6 +33547,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: '_performStep', value: function _performStep(nodeId, maxVelocity) { var node = this.body.nodes[nodeId]; var timestep = this.timestep; @@ -33647,9 +33565,9 @@ return /******/ (function(modules) { // webpackBootstrap velocities[nodeId].x = Math.abs(velocities[nodeId].x) > maxVelocity ? velocities[nodeId].x > 0 ? maxVelocity : -maxVelocity : velocities[nodeId].x; node.x += velocities[nodeId].x * timestep; // position } else { - forces[nodeId].x = 0; - velocities[nodeId].x = 0; - } + forces[nodeId].x = 0; + velocities[nodeId].x = 0; + } if (node.options.fixed.y === false) { var dy = this.modelOptions.damping * velocities[nodeId].y; // damping force @@ -33658,26 +33576,24 @@ return /******/ (function(modules) { // webpackBootstrap velocities[nodeId].y = Math.abs(velocities[nodeId].y) > maxVelocity ? velocities[nodeId].y > 0 ? maxVelocity : -maxVelocity : velocities[nodeId].y; node.y += velocities[nodeId].y * timestep; // position } else { - forces[nodeId].y = 0; - velocities[nodeId].y = 0; - } + forces[nodeId].y = 0; + velocities[nodeId].y = 0; + } var totalVelocity = Math.sqrt(Math.pow(velocities[nodeId].x, 2) + Math.pow(velocities[nodeId].y, 2)); return totalVelocity; } - }, { - key: 'calculateForces', /** * calculate the forces for one physics iteration. */ + }, { + key: 'calculateForces', value: function calculateForces() { this.gravitySolver.solve(); this.nodesSolver.solve(); this.edgesSolver.solve(); } - }, { - key: '_freezeNodes', /** * When initializing and stabilizing, we can freeze nodes with a predefined position. This greatly speeds up stabilization @@ -33685,6 +33601,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: '_freezeNodes', value: function _freezeNodes() { var nodes = this.body.nodes; for (var id in nodes) { @@ -33697,14 +33615,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_restoreFrozenNodes', /** * Unfreezes the nodes that have been frozen by _freezeDefinedNodes. * * @private */ + }, { + key: '_restoreFrozenNodes', value: function _restoreFrozenNodes() { var nodes = this.body.nodes; for (var id in nodes) { @@ -33717,13 +33635,13 @@ return /******/ (function(modules) { // webpackBootstrap } this.freezeCache = {}; } - }, { - key: 'stabilize', /** * Find a stable position for all nodes * @private */ + }, { + key: 'stabilize', value: function stabilize() { var _this3 = this; @@ -33743,7 +33661,7 @@ return /******/ (function(modules) { // webpackBootstrap this.adaptiveTimestep = true && this.options.adaptiveTimestep; // this sets the width of all nodes initially which could be required for the avoidOverlap - this.body.emitter.emit('_resizeNodes'); + this.body.emitter.emit("_resizeNodes"); // stop the render loop this.stopSimulation(); @@ -33765,13 +33683,13 @@ return /******/ (function(modules) { // webpackBootstrap return _this3._stabilizationBatch(); }, 0); } - }, { - key: '_stabilizationBatch', /** * One batch of stabilization * @private */ + }, { + key: '_stabilizationBatch', value: function _stabilizationBatch() { var count = 0; while (this.stabilized === false && count < this.options.stabilization.updateInterval && this.stabilizationIterations < this.targetIterations) { @@ -33786,13 +33704,13 @@ return /******/ (function(modules) { // webpackBootstrap this._finalizeStabilization(); } } - }, { - key: '_finalizeStabilization', /** * Wrap up the stabilization, fit and emit the events. * @private */ + }, { + key: '_finalizeStabilization', value: function _finalizeStabilization() { this.body.emitter.emit('_allowRedraw'); if (this.options.stabilization.fit === true) { @@ -33860,8 +33778,6 @@ return /******/ (function(modules) { // webpackBootstrap var x = Math.sin(this.randomSeed++) * 10000; return x - Math.floor(x); } - }, { - key: "solve", /** * This function calculates the forces the nodes apply on eachother based on a gravitational model. @@ -33869,6 +33785,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: "solve", value: function solve() { if (this.options.gravitationalConstant !== 0 && this.physicsBody.physicsNodeIndices.length > 0) { var node = undefined; @@ -33895,8 +33813,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_getForceContribution", /** * This function traverses the barnesHutTree. It checks when it can approximate distant nodes with their center of mass. @@ -33906,6 +33822,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param node * @private */ + }, { + key: "_getForceContribution", value: function _getForceContribution(parentBranch, node) { // we get no force contribution from an empty region if (parentBranch.childrenCount > 0) { @@ -33940,8 +33858,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_calculateForces", /** * Calculate the forces based on the distance. @@ -33953,6 +33869,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param parentBranch * @private */ + }, { + key: "_calculateForces", value: function _calculateForces(distance, dx, dy, node, parentBranch) { if (distance === 0) { distance = 0.1; @@ -33972,8 +33890,6 @@ return /******/ (function(modules) { // webpackBootstrap this.physicsBody.forces[node.id].x += fx; this.physicsBody.forces[node.id].y += fy; } - }, { - key: "_formBarnesHutTree", /** * This function constructs the barnesHut tree recursively. It creates the root, splits it and starts placing the nodes. @@ -33982,6 +33898,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param nodeIndices * @private */ + }, { + key: "_formBarnesHutTree", value: function _formBarnesHutTree(nodes, nodeIndices) { var node = undefined; var nodeCount = nodeIndices.length; @@ -34017,9 +33935,9 @@ return /******/ (function(modules) { // webpackBootstrap maxY += 0.5 * sizeDiff; } // xSize > ySize else { - minX += 0.5 * sizeDiff; - maxX -= 0.5 * sizeDiff; - } // xSize < ySize + minX += 0.5 * sizeDiff; + maxX -= 0.5 * sizeDiff; + } // xSize < ySize var minimumTreeSize = 1e-5; var rootSize = Math.max(minimumTreeSize, Math.abs(maxX - minX)); @@ -34057,8 +33975,6 @@ return /******/ (function(modules) { // webpackBootstrap // make global return barnesHutTree; } - }, { - key: "_updateBranchMass", /** * this updates the mass of a branch. this is increased by adding a node. @@ -34067,6 +33983,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param node * @private */ + }, { + key: "_updateBranchMass", value: function _updateBranchMass(parentBranch, node) { var totalMass = parentBranch.mass + node.options.mass; var totalMassInv = 1 / totalMass; @@ -34081,8 +33999,6 @@ return /******/ (function(modules) { // webpackBootstrap var biggestSize = Math.max(Math.max(node.height, node.radius), node.width); parentBranch.maxWidth = parentBranch.maxWidth < biggestSize ? biggestSize : parentBranch.maxWidth; } - }, { - key: "_placeInTree", /** * determine in which branch the node will be placed. @@ -34092,6 +34008,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param skipMassUpdate * @private */ + }, { + key: "_placeInTree", value: function _placeInTree(parentBranch, node, skipMassUpdate) { if (skipMassUpdate != true || skipMassUpdate === undefined) { // update the mass of the branch. @@ -34118,8 +34036,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_placeInRegion", /** * actually place the node in a region (or branch) @@ -34129,6 +34045,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param region * @private */ + }, { + key: "_placeInRegion", value: function _placeInRegion(parentBranch, node, region) { switch (parentBranch.children[region].childrenCount) { case 0: @@ -34155,8 +34073,6 @@ return /******/ (function(modules) { // webpackBootstrap break; } } - }, { - key: "_splitBranch", /** * this function splits a branch into 4 sub branches. If the branch contained a node, we place it in the subbranch @@ -34165,6 +34081,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param parentBranch * @private */ + }, { + key: "_splitBranch", value: function _splitBranch(parentBranch) { // if the branch is shaded with a node, replace the node in the new subset. var containedNode = null; @@ -34185,8 +34103,6 @@ return /******/ (function(modules) { // webpackBootstrap this._placeInTree(parentBranch, containedNode); } } - }, { - key: "_insertRegion", /** * This function subdivides the region into four new segments. @@ -34198,6 +34114,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param parentRange * @private */ + }, { + key: "_insertRegion", value: function _insertRegion(parentBranch, region) { var minX = undefined, maxX = undefined, @@ -34243,8 +34161,6 @@ return /******/ (function(modules) { // webpackBootstrap childrenCount: 0 }; } - }, { - key: "_debug", //--------------------------- DEBUGGING BELOW ---------------------------// @@ -34255,6 +34171,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param color * @private */ + }, { + key: "_debug", value: function _debug(ctx, color) { if (this.barnesHutTree !== undefined) { @@ -34263,8 +34181,6 @@ return /******/ (function(modules) { // webpackBootstrap this._drawBranch(this.barnesHutTree.root, ctx, color); } } - }, { - key: "_drawBranch", /** * This function is for debugging purposes. It draws the branches recursively. @@ -34274,6 +34190,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param color * @private */ + }, { + key: "_drawBranch", value: function _drawBranch(branch, ctx, color) { if (color === undefined) { color = "#FF0000"; @@ -34349,8 +34267,6 @@ return /******/ (function(modules) { // webpackBootstrap value: function setOptions(options) { this.options = options; } - }, { - key: "solve", /** * Calculate the forces the nodes apply on each other based on a repulsion field. @@ -34358,6 +34274,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: "solve", value: function solve() { var dx, dy, distance, fx, fy, repulsingForce, node1, node2; @@ -34444,8 +34362,6 @@ return /******/ (function(modules) { // webpackBootstrap value: function setOptions(options) { this.options = options; } - }, { - key: "solve", /** * Calculate the forces the nodes apply on each other based on a repulsion field. @@ -34453,6 +34369,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: "solve", value: function solve() { var dx, dy, distance, fx, fy, repulsingForce, node1, node2, i, j; @@ -34535,14 +34453,14 @@ return /******/ (function(modules) { // webpackBootstrap value: function setOptions(options) { this.options = options; } - }, { - key: "solve", /** * This function calculates the springforces on the nodes, accounting for the support nodes. * * @private */ + }, { + key: "solve", value: function solve() { var edgeLength = undefined, edge = undefined; @@ -34576,8 +34494,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_calculateSpringForce", /** * This is the code actually performing the calculation for the function above. @@ -34587,6 +34503,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param edgeLength * @private */ + }, { + key: "_calculateSpringForce", value: function _calculateSpringForce(node1, node2, edgeLength) { var dx = node1.x - node2.x; var dy = node1.y - node2.y; @@ -34645,14 +34563,14 @@ return /******/ (function(modules) { // webpackBootstrap value: function setOptions(options) { this.options = options; } - }, { - key: "solve", /** * This function calculates the springforces on the nodes, accounting for the support nodes. * * @private */ + }, { + key: "solve", value: function solve() { var edgeLength, edge; var dx, dy, fx, fy, springForce, distance; @@ -34795,13 +34713,13 @@ return /******/ (function(modules) { // webpackBootstrap this._calculateForces(distance, dx, dy, forces, node); } } - }, { - key: "_calculateForces", /** * Calculate the forces based on the distance. * @private */ + }, { + key: "_calculateForces", value: function _calculateForces(distance, dx, dy, forces, node) { var gravityForce = distance === 0 ? 0 : this.options.centralGravity / distance; forces[node.id].x = dx * gravityForce; @@ -34848,19 +34766,19 @@ return /******/ (function(modules) { // webpackBootstrap _get(Object.getPrototypeOf(ForceAtlas2BasedRepulsionSolver.prototype), "constructor", this).call(this, body, physicsBody, options); } + /** + * Calculate the forces based on the distance. + * + * @param distance + * @param dx + * @param dy + * @param node + * @param parentBranch + * @private + */ + _createClass(ForceAtlas2BasedRepulsionSolver, [{ key: "_calculateForces", - - /** - * Calculate the forces based on the distance. - * - * @param distance - * @param dx - * @param dy - * @param node - * @param parentBranch - * @private - */ value: function _calculateForces(distance, dx, dy, node, parentBranch) { if (distance === 0) { distance = 0.1 * Math.random(); @@ -34922,13 +34840,13 @@ return /******/ (function(modules) { // webpackBootstrap _get(Object.getPrototypeOf(ForceAtlas2BasedCentralGravitySolver.prototype), "constructor", this).call(this, body, physicsBody, options); } + /** + * Calculate the forces based on the distance. + * @private + */ + _createClass(ForceAtlas2BasedCentralGravitySolver, [{ key: "_calculateForces", - - /** - * Calculate the forces based on the distance. - * @private - */ value: function _calculateForces(distance, dx, dy, forces, node) { if (distance > 0) { var degree = node.edges.length + 1; @@ -34990,18 +34908,18 @@ return /******/ (function(modules) { // webpackBootstrap value: function setOptions(options) { if (options !== undefined) {} } - }, { - key: 'clusterByHubsize', /** * * @param hubsize * @param options */ + }, { + key: 'clusterByHubsize', value: function clusterByHubsize(hubsize, options) { if (hubsize === undefined) { hubsize = this._getHubSize(); - } else if (typeof hubsize === 'object') { + } else if (typeof hubsize === "object") { options = this._checkOptions(hubsize); hubsize = this._getHubSize(); } @@ -35020,20 +34938,20 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('_dataChanged'); } - }, { - key: 'cluster', /** * loop over all nodes, check if they adhere to the condition and cluster if needed. * @param options * @param refreshData */ + }, { + key: 'cluster', value: function cluster() { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; var refreshData = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; if (options.joinCondition === undefined) { - throw new Error('Cannot call clusterByNodeData without a joinCondition function in the options.'); + throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options."); } // check if the options object is fine, append if needed @@ -35062,8 +34980,6 @@ return /******/ (function(modules) { // webpackBootstrap this._cluster(childNodesObj, childEdgesObj, options, refreshData); } - }, { - key: 'clusterByEdgeCount', /** * Cluster all nodes in the network that have only X edges @@ -35071,6 +34987,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param options * @param refreshData */ + }, { + key: 'clusterByEdgeCount', value: function clusterByEdgeCount(edgeCount, options) { var refreshData = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; @@ -35149,34 +35067,32 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('_dataChanged'); } } - }, { - key: 'clusterOutliers', /** * Cluster all nodes in the network that have only 1 edge * @param options * @param refreshData */ + }, { + key: 'clusterOutliers', value: function clusterOutliers(options) { var refreshData = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; this.clusterByEdgeCount(1, options, refreshData); } - }, { - key: 'clusterBridges', /** * Cluster all nodes in the network that have only 2 edge * @param options * @param refreshData */ + }, { + key: 'clusterBridges', value: function clusterBridges(options) { var refreshData = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; this.clusterByEdgeCount(2, options, refreshData); } - }, { - key: 'clusterByConnection', /** * suck all connected nodes of a node into the node. @@ -35184,15 +35100,17 @@ return /******/ (function(modules) { // webpackBootstrap * @param options * @param refreshData */ + }, { + key: 'clusterByConnection', value: function clusterByConnection(nodeId, options) { var refreshData = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; // kill conditions if (nodeId === undefined) { - throw new Error('No nodeId supplied to clusterByConnection!'); + throw new Error("No nodeId supplied to clusterByConnection!"); } if (this.body.nodes[nodeId] === undefined) { - throw new Error('The nodeId given to clusterByConnection does not exist!'); + throw new Error("The nodeId given to clusterByConnection does not exist!"); } var node = this.body.nodes[nodeId]; @@ -35245,8 +35163,6 @@ return /******/ (function(modules) { // webpackBootstrap this._cluster(childNodesObj, childEdgesObj, options, refreshData); } - }, { - key: '_cloneOptions', /** * This returns a clone of the options or options of the edge or node to be used for construction of new edges or check functions for new nodes. @@ -35255,6 +35171,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{}} * @private */ + }, { + key: '_cloneOptions', value: function _cloneOptions(item, type) { var clonedOptions = {}; if (type === undefined || type === 'node') { @@ -35267,8 +35185,6 @@ return /******/ (function(modules) { // webpackBootstrap } return clonedOptions; } - }, { - key: '_createClusterEdges', /** * This function creates the edges that will be attached to the cluster @@ -35279,6 +35195,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param options * @private */ + }, { + key: '_createClusterEdges', value: function _createClusterEdges(childNodesObj, clusterNodeProperties, clusterEdgeProperties) { var edge = undefined, childNodeId = undefined, @@ -35348,8 +35266,6 @@ return /******/ (function(modules) { // webpackBootstrap _edge.hiddenByCluster = true; } } - }, { - key: '_checkOptions', /** * This function checks the options that can be supplied to the different cluster functions @@ -35358,6 +35274,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} * @private */ + }, { + key: '_checkOptions', value: function _checkOptions() { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; @@ -35370,8 +35288,6 @@ return /******/ (function(modules) { // webpackBootstrap return options; } - }, { - key: '_cluster', /** * @@ -35381,6 +35297,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Boolean} refreshData | when true, do not wrap up * @private */ + }, { + key: '_cluster', value: function _cluster(childNodesObj, childEdgesObj, options) { var refreshData = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3]; @@ -35416,7 +35334,7 @@ return /******/ (function(modules) { // webpackBootstrap for (var edgeId in childEdgesObj) { if (childEdgesObj.hasOwnProperty(edgeId)) { // these cluster edges will be removed on creation of the cluster. - if (edgeId.substr(0, 12) !== 'clusterEdge:') { + if (edgeId.substr(0, 12) !== "clusterEdge:") { var clonedOptions = this._cloneOptions(childEdgesObj[edgeId], 'edge'); childEdgesOptions.push(clonedOptions); } @@ -35425,7 +35343,7 @@ return /******/ (function(modules) { // webpackBootstrap clusterNodeProperties = options.processProperties(clusterNodeProperties, childNodesOptions, childEdgesOptions); if (!clusterNodeProperties) { - throw new Error('The processProperties function does not return properties!'); + throw new Error("The processProperties function does not return properties!"); } } @@ -35496,24 +35414,22 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('_dataChanged'); } } - }, { - key: 'isCluster', /** * Check if a node is a cluster. * @param nodeId * @returns {*} */ + }, { + key: 'isCluster', value: function isCluster(nodeId) { if (this.body.nodes[nodeId] !== undefined) { return this.body.nodes[nodeId].isCluster === true; } else { - console.log('Node does not exist.'); + console.log("Node does not exist."); return false; } } - }, { - key: '_getClusterPosition', /** * get the position of the cluster node based on what's inside @@ -35521,6 +35437,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{x: number, y: number}} * @private */ + }, { + key: '_getClusterPosition', value: function _getClusterPosition(childNodesObj) { var childKeys = Object.keys(childNodesObj); var minX = childNodesObj[childKeys[0]].x; @@ -35538,26 +35456,26 @@ return /******/ (function(modules) { // webpackBootstrap return { x: 0.5 * (minX + maxX), y: 0.5 * (minY + maxY) }; } - }, { - key: 'openCluster', /** * Open a cluster by calling this function. * @param {String} clusterNodeId | the ID of the cluster node * @param {Boolean} refreshData | wrap up afterwards if not true */ + }, { + key: 'openCluster', value: function openCluster(clusterNodeId, options) { var refreshData = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; // kill conditions if (clusterNodeId === undefined) { - throw new Error('No clusterNodeId supplied to openCluster.'); + throw new Error("No clusterNodeId supplied to openCluster."); } if (this.body.nodes[clusterNodeId] === undefined) { - throw new Error('The clusterNodeId supplied to openCluster does not exist.'); + throw new Error("The clusterNodeId supplied to openCluster does not exist."); } if (this.body.nodes[clusterNodeId].containedNodes === undefined) { - console.log('The node:' + clusterNodeId + ' is not a cluster.'); + console.log("The node:" + clusterNodeId + " is not a cluster."); return; } var clusterNode = this.body.nodes[clusterNodeId]; @@ -35678,6 +35596,8 @@ return /******/ (function(modules) { // webpackBootstrap if (containedEdges.hasOwnProperty(edgeId)) { var edge = containedEdges[edgeId]; edge.setOptions({ physics: true, hidden: false }); + edge.hiddenByCluster = undefined; + delete edge.hiddenByCluster; } } @@ -35703,8 +35623,6 @@ return /******/ (function(modules) { // webpackBootstrap return nodesArray; } - }, { - key: 'findNode', /** * Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node @@ -35712,6 +35630,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {Array} * @private */ + }, { + key: 'findNode', value: function findNode(nodeId) { var stack = []; var max = 100; @@ -35725,8 +35645,6 @@ return /******/ (function(modules) { // webpackBootstrap stack.push(this.body.nodes[nodeId]); return stack; } - }, { - key: '_getConnectedId', /** * Get the Id the node is connected to @@ -35735,6 +35653,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} * @private */ + }, { + key: '_getConnectedId', value: function _getConnectedId(edge, nodeId) { if (edge.toId != nodeId) { return edge.toId; @@ -35744,8 +35664,6 @@ return /******/ (function(modules) { // webpackBootstrap return edge.fromId; } } - }, { - key: '_getHubSize', /** * We determine how many connections denote an important hub. @@ -35753,6 +35671,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: '_getHubSize', value: function _getHubSize() { var average = 0; var averageSquared = 0; @@ -35811,12 +35731,12 @@ return /******/ (function(modules) { // webpackBootstrap var _Node2 = __webpack_require__(62); - var _Node3 = _interopRequireDefault(_Node2); - /** * */ + var _Node3 = _interopRequireDefault(_Node2); + var Cluster = (function (_Node) { _inherits(Cluster, _Node); @@ -35888,33 +35808,33 @@ return /******/ (function(modules) { // webpackBootstrap value: function bindEventListeners() { var _this = this; - this.body.emitter.on('dragStart', function () { + this.body.emitter.on("dragStart", function () { _this.dragging = true; }); - this.body.emitter.on('dragEnd', function () { + this.body.emitter.on("dragEnd", function () { return _this.dragging = false; }); - this.body.emitter.on('_resizeNodes', function () { + this.body.emitter.on("_resizeNodes", function () { return _this._resizeNodes(); }); - this.body.emitter.on('_redraw', function () { + this.body.emitter.on("_redraw", function () { if (_this.renderingActive === false) { _this._redraw(); } }); - this.body.emitter.on('_blockRedraw', function () { + this.body.emitter.on("_blockRedraw", function () { _this.allowRedraw = false; }); - this.body.emitter.on('_allowRedraw', function () { + this.body.emitter.on("_allowRedraw", function () { _this.allowRedraw = true;_this.redrawRequested = false; }); - this.body.emitter.on('_requestRedraw', this._requestRedraw.bind(this)); - this.body.emitter.on('_startRendering', function () { + this.body.emitter.on("_requestRedraw", this._requestRedraw.bind(this)); + this.body.emitter.on("_startRendering", function () { _this.renderRequests += 1; _this.renderingActive = true; _this._startRendering(); }); - this.body.emitter.on('_stopRendering', function () { + this.body.emitter.on("_stopRendering", function () { _this.renderRequests -= 1; _this.renderingActive = _this.renderRequests > 0; _this.renderTimer = undefined; @@ -35947,8 +35867,8 @@ return /******/ (function(modules) { // webpackBootstrap if (this.requiresTimeout === true) { this.renderTimer = window.setTimeout(this._renderStep.bind(this), this.simulationInterval); // wait this.renderTimeStep milliseconds and perform the animation step function } else { - this.renderTimer = window.requestAnimationFrame(this._renderStep.bind(this)); // wait this.renderTimeStep milliseconds and perform the animation step function - } + this.renderTimer = window.requestAnimationFrame(this._renderStep.bind(this)); // wait this.renderTimeStep milliseconds and perform the animation step function + } } } } @@ -35972,25 +35892,25 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'redraw', /** * Redraw the network with the current data * chart will be resized too. */ + }, { + key: 'redraw', value: function redraw() { this.body.emitter.emit('setSize'); this._redraw(); } - }, { - key: '_requestRedraw', /** * Redraw the network with the current data * @param hidden | used to get the first estimate of the node sizes. only the nodes are drawn after which they are quickly drawn over. * @private */ + }, { + key: '_requestRedraw', value: function _requestRedraw() { var _this2 = this; @@ -36013,7 +35933,7 @@ return /******/ (function(modules) { // webpackBootstrap var hidden = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; if (this.allowRedraw === true) { - this.body.emitter.emit('initRedraw'); + this.body.emitter.emit("initRedraw"); this.redrawRequested = false; var ctx = this.canvas.frame.canvas.getContext('2d'); @@ -36043,7 +35963,7 @@ return /******/ (function(modules) { // webpackBootstrap ctx.scale(this.body.view.scale, this.body.view.scale); ctx.beginPath(); - this.body.emitter.emit('beforeDrawing', ctx); + this.body.emitter.emit("beforeDrawing", ctx); ctx.closePath(); if (hidden === false) { @@ -36062,7 +35982,7 @@ return /******/ (function(modules) { // webpackBootstrap ctx.beginPath(); //this.physics.nodesSolver._debug(ctx,"#F00F0F"); - this.body.emitter.emit('afterDrawing', ctx); + this.body.emitter.emit("afterDrawing", ctx); ctx.closePath(); // restore original scaling and translation ctx.restore(); @@ -36072,8 +35992,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_resizeNodes', /** * Redraw all nodes @@ -36082,6 +36000,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Boolean} [alwaysShow] * @private */ + }, { + key: '_resizeNodes', value: function _resizeNodes() { var ctx = this.canvas.frame.canvas.getContext('2d'); if (this.pixelRatio === undefined) { @@ -36107,8 +36027,6 @@ return /******/ (function(modules) { // webpackBootstrap // restore original scaling and translation ctx.restore(); } - }, { - key: '_drawNodes', /** * Redraw all nodes @@ -36117,6 +36035,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Boolean} [alwaysShow] * @private */ + }, { + key: '_drawNodes', value: function _drawNodes(ctx) { var alwaysShow = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; @@ -36155,8 +36075,6 @@ return /******/ (function(modules) { // webpackBootstrap node.draw(ctx); } } - }, { - key: '_drawEdges', /** * Redraw all edges @@ -36164,6 +36082,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {CanvasRenderingContext2D} ctx * @private */ + }, { + key: '_drawEdges', value: function _drawEdges(ctx) { var edges = this.body.edges; var edgeIndices = this.body.edgeIndices; @@ -36176,8 +36096,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_drawControlNodes', /** * Redraw all edges @@ -36185,6 +36103,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {CanvasRenderingContext2D} ctx * @private */ + }, { + key: '_drawControlNodes', value: function _drawControlNodes(ctx) { var edges = this.body.edges; var edgeIndices = this.body.edgeIndices; @@ -36195,14 +36115,14 @@ return /******/ (function(modules) { // webpackBootstrap edge._drawControlNodes(ctx); } } - }, { - key: '_determineBrowserMethod', /** * Determine if the browser requires a setTimeout or a requestAnimationFrame. This was required because * some implementations (safari and IE9) did not support requestAnimationFrame * @private */ + }, { + key: '_determineBrowserMethod', value: function _determineBrowserMethod() { if (typeof window !== 'undefined') { var browserType = navigator.userAgent.toLowerCase(); @@ -36282,7 +36202,7 @@ return /******/ (function(modules) { // webpackBootstrap var _this = this; // bind the events - this.body.emitter.once('resize', function (obj) { + this.body.emitter.once("resize", function (obj) { if (obj.width !== 0) { _this.body.view.translation.x = obj.width * 0.5; } @@ -36290,8 +36210,8 @@ return /******/ (function(modules) { // webpackBootstrap _this.body.view.translation.y = obj.height * 0.5; } }); - this.body.emitter.on('setSize', this.setSize.bind(this)); - this.body.emitter.on('destroy', function () { + this.body.emitter.on("setSize", this.setSize.bind(this)); + this.body.emitter.on("destroy", function () { _this.hammerFrame.destroy(); _this.hammer.destroy(); _this._cleanUp(); @@ -36313,7 +36233,7 @@ return /******/ (function(modules) { // webpackBootstrap this.resizeTimer = setInterval(function () { var changed = _this2.setSize(); if (changed === true) { - _this2.body.emitter.emit('_requestRedraw'); + _this2.body.emitter.emit("_requestRedraw"); } }, 1000); this.resizeFunction = this._onResize.bind(this); @@ -36334,15 +36254,15 @@ return /******/ (function(modules) { // webpackBootstrap key: '_onResize', value: function _onResize() { this.setSize(); - this.body.emitter.emit('_redraw'); + this.body.emitter.emit("_redraw"); } - }, { - key: '_getCameraState', /** * Get and store the cameraState * @private */ + }, { + key: '_getCameraState', value: function _getCameraState() { var pixelRatio = arguments.length <= 0 || arguments[0] === undefined ? this.pixelRatio : arguments[0]; @@ -36350,13 +36270,13 @@ return /******/ (function(modules) { // webpackBootstrap this.cameraState.scale = this.body.view.scale; this.cameraState.position = this.DOMtoCanvas({ x: 0.5 * this.frame.canvas.width / pixelRatio, y: 0.5 * this.frame.canvas.height / pixelRatio }); } - }, { - key: '_setCameraState', /** * Set the cameraState * @private */ + }, { + key: '_setCameraState', value: function _setCameraState() { if (this.cameraState.scale !== undefined && this.frame.canvas.clientWidth !== 0 && this.frame.canvas.clientHeight !== 0 && this.pixelRatio !== 0 && this.cameraState.previousWidth > 0) { @@ -36390,12 +36310,12 @@ return /******/ (function(modules) { // webpackBootstrap } throw new Error('Could not use the value supplied for width or height:' + value); } - }, { - key: '_create', /** * Create the HTML */ + }, { + key: '_create', value: function _create() { // remove all elements from the container element. while (this.body.container.hasChildNodes()) { @@ -36410,7 +36330,7 @@ return /******/ (function(modules) { // webpackBootstrap ////////////////////////////////////////////////////////////////// - this.frame.canvas = document.createElement('canvas'); + this.frame.canvas = document.createElement("canvas"); this.frame.canvas.style.position = 'relative'; this.frame.appendChild(this.frame.canvas); @@ -36422,10 +36342,10 @@ return /******/ (function(modules) { // webpackBootstrap noCanvas.innerHTML = 'Error: your browser does not support HTML canvas'; this.frame.canvas.appendChild(noCanvas); } else { - var ctx = this.frame.canvas.getContext('2d'); + var ctx = this.frame.canvas.getContext("2d"); this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1); - this.frame.canvas.getContext('2d').setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0); + this.frame.canvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0); } // add the frame to the container element @@ -36436,13 +36356,13 @@ return /******/ (function(modules) { // webpackBootstrap this._bindHammer(); } - }, { - key: '_bindHammer', /** * This function binds hammer, it can be repeated over and over due to the uniqueness check. * @private */ + }, { + key: '_bindHammer', value: function _bindHammer() { var _this3 = this; @@ -36503,8 +36423,6 @@ return /******/ (function(modules) { // webpackBootstrap _this3.body.eventListeners.onRelease(event); }); } - }, { - key: 'setSize', /** * Set a new size for the network @@ -36513,6 +36431,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {string} height Height in pixels or percentage (for example '400px' * or '30%') */ + }, { + key: 'setSize', 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]; @@ -36525,7 +36445,7 @@ return /******/ (function(modules) { // webpackBootstrap var oldHeight = this.frame.canvas.height; // update the pixelratio - var ctx = this.frame.canvas.getContext('2d'); + var ctx = this.frame.canvas.getContext("2d"); var previousRation = this.pixelRatio; // we cache this because the camera state storage needs the old value this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1); @@ -36591,8 +36511,6 @@ return /******/ (function(modules) { // webpackBootstrap value: function _XconvertDOMtoCanvas(x) { return (x - this.body.view.translation.x) / this.body.view.scale; } - }, { - key: '_XconvertCanvasToDOM', /** * Convert the X coordinate in canvas-space (the simulation sandbox, which the camera looks upon) to @@ -36601,11 +36519,11 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: '_XconvertCanvasToDOM', value: function _XconvertCanvasToDOM(x) { return x * this.body.view.scale + this.body.view.translation.x; } - }, { - key: '_YconvertDOMtoCanvas', /** * Convert the Y coordinate in DOM-space (coordinate point in browser relative to the container div) to @@ -36614,11 +36532,11 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: '_YconvertDOMtoCanvas', value: function _YconvertDOMtoCanvas(y) { return (y - this.body.view.translation.y) / this.body.view.scale; } - }, { - key: '_YconvertCanvasToDOM', /** * Convert the Y coordinate in canvas-space (the simulation sandbox, which the camera looks upon) to @@ -36627,11 +36545,11 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: '_YconvertCanvasToDOM', value: function _YconvertCanvasToDOM(y) { return y * this.body.view.scale + this.body.view.translation.y; } - }, { - key: 'canvasToDOM', /** * @@ -36639,11 +36557,11 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{x: number, y: number}} * @constructor */ + }, { + key: 'canvasToDOM', value: function canvasToDOM(pos) { return { x: this._XconvertCanvasToDOM(pos.x), y: this._YconvertCanvasToDOM(pos.y) }; } - }, { - key: 'DOMtoCanvas', /** * @@ -36651,6 +36569,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{x: number, y: number}} * @constructor */ + }, { + key: 'DOMtoCanvas', value: function DOMtoCanvas(pos) { return { x: this._XconvertDOMtoCanvas(pos.x), y: this._YconvertDOMtoCanvas(pos.y) }; } @@ -36694,7 +36614,7 @@ return /******/ (function(modules) { // webpackBootstrap this.canvas = canvas; this.animationSpeed = 1 / this.renderRefreshRate; - this.animationEasingFunction = 'easeInOutQuint'; + this.animationEasingFunction = "easeInOutQuint"; this.easingTime = 0; this.sourceScale = 0; this.targetScale = 0; @@ -36706,11 +36626,11 @@ return /******/ (function(modules) { // webpackBootstrap this.viewFunction = undefined; - this.body.emitter.on('fit', this.fit.bind(this)); - this.body.emitter.on('animationFinished', function () { - _this.body.emitter.emit('_stopRendering'); + this.body.emitter.on("fit", this.fit.bind(this)); + this.body.emitter.on("animationFinished", function () { + _this.body.emitter.emit("_stopRendering"); }); - this.body.emitter.on('unlockNode', this.releaseNode.bind(this)); + this.body.emitter.on("unlockNode", this.releaseNode.bind(this)); } _createClass(View, [{ @@ -36720,14 +36640,14 @@ return /******/ (function(modules) { // webpackBootstrap this.options = options; } - }, { - key: 'fit', /** * This function zooms out to fit all data on screen based on amount of nodes * @param {Object} Options * @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false; */ + }, { + key: 'fit', 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]; @@ -36763,7 +36683,7 @@ return /******/ (function(modules) { // webpackBootstrap var factor = Math.min(this.canvas.frame.canvas.clientWidth / 600, this.canvas.frame.canvas.clientHeight / 600); zoomLevel *= factor; } else { - this.body.emitter.emit('_resizeNodes'); + this.body.emitter.emit("_resizeNodes"); range = _NetworkUtil2['default']._getRange(this.body.nodes, options.nodes); var xDistance = Math.abs(range.maxX - range.minX) * 1.1; @@ -36785,8 +36705,6 @@ return /******/ (function(modules) { // webpackBootstrap var animationOptions = { position: center, scale: zoomLevel, animation: options.animation }; this.moveTo(animationOptions); } - }, { - key: 'focus', // animation @@ -36796,6 +36714,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Number} nodeId * @param {Number} [options] */ + }, { + key: 'focus', value: function focus(nodeId) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; @@ -36806,11 +36726,9 @@ return /******/ (function(modules) { // webpackBootstrap this.moveTo(options); } else { - console.log('Node: ' + nodeId + ' cannot be found.'); + console.log("Node: " + nodeId + " cannot be found."); } } - }, { - key: 'moveTo', /** * @@ -36819,6 +36737,8 @@ return /******/ (function(modules) { // webpackBootstrap * | options.position = {x:Number, y:Number} // position to move to * | options.animation = {duration:Number, easingFunction:String} || Boolean // position to move to */ + }, { + key: 'moveTo', value: function moveTo(options) { if (options === undefined) { options = {}; @@ -36852,13 +36772,11 @@ return /******/ (function(modules) { // webpackBootstrap options.animation.duration = 1000; } // default duration if (options.animation.easingFunction === undefined) { - options.animation.easingFunction = 'easeInOutQuad'; + options.animation.easingFunction = "easeInOutQuad"; } // default easing function this.animateView(options); } - }, { - key: 'animateView', /** * @@ -36871,6 +36789,8 @@ return /******/ (function(modules) { // webpackBootstrap * // easeInQuart, easeOutQuart, easeInOutQuart, * // easeInQuint, easeOutQuint, easeInOutQuint */ + }, { + key: 'animateView', value: function animateView(options) { if (options === undefined) { return; @@ -36910,28 +36830,28 @@ return /******/ (function(modules) { // webpackBootstrap if (options.animation.duration === 0) { if (this.lockedOnNodeId != undefined) { this.viewFunction = this._lockedRedraw.bind(this); - this.body.emitter.on('initRedraw', this.viewFunction); + this.body.emitter.on("initRedraw", this.viewFunction); } else { this.body.view.scale = this.targetScale; this.body.view.translation = this.targetTranslation; - this.body.emitter.emit('_requestRedraw'); + this.body.emitter.emit("_requestRedraw"); } } else { this.animationSpeed = 1 / (60 * options.animation.duration * 0.001) || 1 / 60; // 60 for 60 seconds, 0.001 for milli's this.animationEasingFunction = options.animation.easingFunction; this.viewFunction = this._transitionRedraw.bind(this); - this.body.emitter.on('initRedraw', this.viewFunction); - this.body.emitter.emit('_startRendering'); + this.body.emitter.on("initRedraw", this.viewFunction); + this.body.emitter.emit("_startRendering"); } } - }, { - key: '_lockedRedraw', /** * used to animate smoothly by hijacking the redraw function. * @private */ + }, { + key: '_lockedRedraw', value: function _lockedRedraw() { var nodePosition = { x: this.body.nodes[this.lockedOnNodeId].x, y: this.body.nodes[this.lockedOnNodeId].y }; var viewCenter = this.canvas.DOMtoCanvas({ x: 0.5 * this.canvas.frame.canvas.clientWidth, y: 0.5 * this.canvas.frame.canvas.clientHeight }); @@ -36951,19 +36871,19 @@ return /******/ (function(modules) { // webpackBootstrap key: 'releaseNode', value: function releaseNode() { if (this.lockedOnNodeId !== undefined && this.viewFunction !== undefined) { - this.body.emitter.off('initRedraw', this.viewFunction); + this.body.emitter.off("initRedraw", this.viewFunction); this.lockedOnNodeId = undefined; this.lockedOnNodeOffset = undefined; } } - }, { - key: '_transitionRedraw', /** * * @param easingTime * @private */ + }, { + key: '_transitionRedraw', value: function _transitionRedraw() { var finished = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; @@ -36980,13 +36900,13 @@ return /******/ (function(modules) { // webpackBootstrap // cleanup if (this.easingTime >= 1.0) { - this.body.emitter.off('initRedraw', this.viewFunction); + this.body.emitter.off("initRedraw", this.viewFunction); this.easingTime = 0; if (this.lockedOnNodeId != undefined) { this.viewFunction = this._lockedRedraw.bind(this); - this.body.emitter.on('initRedraw', this.viewFunction); + this.body.emitter.on("initRedraw", this.viewFunction); } - this.body.emitter.emit('animationFinished'); + this.body.emitter.emit("animationFinished"); } } }, { @@ -37026,13 +36946,13 @@ return /******/ (function(modules) { // webpackBootstrap _classCallCheck(this, NetworkUtil); } + /** + * Find the center position of the network considering the bounding boxes + * @private + */ + _createClass(NetworkUtil, null, [{ key: "_getRange", - - /** - * Find the center position of the network considering the bounding boxes - * @private - */ value: function _getRange(allNodes) { var specificNodes = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; @@ -37064,13 +36984,13 @@ return /******/ (function(modules) { // webpackBootstrap } return { minX: minX, maxX: maxX, minY: minY, maxY: maxY }; } - }, { - key: "_getRangeCore", /** * Find the center position of the network * @private */ + }, { + key: "_getRangeCore", value: function _getRangeCore(allNodes) { var specificNodes = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; @@ -37102,14 +37022,14 @@ return /******/ (function(modules) { // webpackBootstrap } return { minX: minX, maxX: maxX, minY: minY, maxY: maxY }; } - }, { - key: "_findCenter", /** * @param {object} range = {minX: minX, maxX: maxX, minY: minY, maxY: maxY}; * @returns {{x: number, y: number}} * @private */ + }, { + key: "_findCenter", value: function _findCenter(range) { return { x: 0.5 * (range.maxX + range.minX), y: 0.5 * (range.maxY + range.minY) }; @@ -37230,8 +37150,6 @@ return /******/ (function(modules) { // webpackBootstrap this.navigationHandler.setOptions(this.options); } - }, { - key: 'getPointer', /** * Get the pointer location from a touch location @@ -37239,20 +37157,22 @@ return /******/ (function(modules) { // webpackBootstrap * @return {{x: Number, y: Number}} pointer * @private */ + }, { + key: 'getPointer', value: function getPointer(touch) { return { x: touch.x - util.getAbsoluteLeft(this.canvas.frame.canvas), y: touch.y - util.getAbsoluteTop(this.canvas.frame.canvas) }; } - }, { - key: 'onTouch', /** * On start of a touch gesture, store the pointer * @param event * @private */ + }, { + key: 'onTouch', value: function onTouch(event) { if (new Date().valueOf() - this.touchTime > 50) { this.drag.pointer = this.getPointer(event.center); @@ -37262,13 +37182,13 @@ return /******/ (function(modules) { // webpackBootstrap this.touchTime = new Date().valueOf(); } } - }, { - key: 'onTap', /** * handle tap/click event: select/unselect a node * @private */ + }, { + key: 'onTap', value: function onTap(event) { var pointer = this.getPointer(event.center); var multiselect = this.selectionHandler.options.multiselect && (event.changedPointers[0].ctrlKey || event.changedPointers[0].metaKey); @@ -37276,24 +37196,24 @@ return /******/ (function(modules) { // webpackBootstrap this.checkSelectionChanges(pointer, event, multiselect); this.selectionHandler._generateClickEvent('click', event, pointer); } - }, { - key: 'onDoubleTap', /** * handle doubletap event * @private */ + }, { + key: 'onDoubleTap', value: function onDoubleTap(event) { var pointer = this.getPointer(event.center); this.selectionHandler._generateClickEvent('doubleClick', event, pointer); } - }, { - key: 'onHold', /** * handle long tap event: multi select nodes * @private */ + }, { + key: 'onHold', value: function onHold(event) { var pointer = this.getPointer(event.center); var multiselect = this.selectionHandler.options.multiselect; @@ -37303,14 +37223,14 @@ return /******/ (function(modules) { // webpackBootstrap this.selectionHandler._generateClickEvent('click', event, pointer); this.selectionHandler._generateClickEvent('hold', event, pointer); } - }, { - key: 'onRelease', /** * handle the release of the screen * * @private */ + }, { + key: 'onRelease', value: function onRelease(event) { if (new Date().valueOf() - this.touchTime > 10) { var pointer = this.getPointer(event.center); @@ -37325,14 +37245,14 @@ return /******/ (function(modules) { // webpackBootstrap var pointer = this.getPointer({ x: event.clientX, y: event.clientY }); this.selectionHandler._generateClickEvent('oncontext', event, pointer); } - }, { - key: 'checkSelectionChanges', /** * * @param pointer * @param add */ + }, { + key: 'checkSelectionChanges', value: function checkSelectionChanges(pointer, event) { var add = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; @@ -37393,8 +37313,6 @@ return /******/ (function(modules) { // webpackBootstrap this.selectionHandler._generateClickEvent('select', event, pointer); } } - }, { - key: '_determineIfDifferent', /** * This function checks if the nodes and edges previously selected have changed. @@ -37403,6 +37321,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{nodesChanges: boolean, edgesChanges: boolean}} * @private */ + }, { + key: '_determineIfDifferent', value: function _determineIfDifferent(previousSelection, currentSelection) { var nodesChanges = false; var edgesChanges = false; @@ -37430,8 +37350,6 @@ return /******/ (function(modules) { // webpackBootstrap return { nodesChanges: nodesChanges, edgesChanges: edgesChanges }; } - }, { - key: 'onDragStart', /** * This function is called by onDragStart. @@ -37439,6 +37357,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: 'onDragStart', value: function onDragStart(event) { //in case the touch event was triggered on an external div, do the initial touch now. if (this.drag.pointer === undefined) { @@ -37491,13 +37411,13 @@ return /******/ (function(modules) { // webpackBootstrap this.selectionHandler._generateClickEvent('dragStart', event, this.drag.pointer, undefined, true); } } - }, { - key: 'onDrag', /** * handle drag event * @private */ + }, { + key: 'onDrag', value: function onDrag(event) { var _this2 = this; @@ -37553,13 +37473,13 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'onDragEnd', /** * handle drag start event * @private */ + }, { + key: 'onDragEnd', value: function onDragEnd(event) { this.drag.dragging = false; var selection = this.drag.selection; @@ -37576,14 +37496,14 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('_requestRedraw'); } } - }, { - key: 'onPinch', /** * Handle pinch event * @param event * @private */ + }, { + key: 'onPinch', value: function onPinch(event) { var pointer = this.getPointer(event.center); @@ -37596,8 +37516,6 @@ return /******/ (function(modules) { // webpackBootstrap var scale = this.pinch.scale * event.scale; this.zoom(scale, pointer); } - }, { - key: 'zoom', /** * Zoom the network in or out @@ -37606,6 +37524,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Number} appliedScale scale is limited within the boundaries * @private */ + }, { + key: 'zoom', value: function zoom(scale, pointer) { if (this.options.zoomView === true) { var scaleOld = this.body.view.scale; @@ -37647,8 +37567,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'onMouseWheel', /** * Event handler for mouse wheel event, used to zoom the timeline @@ -37657,6 +37575,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {MouseEvent} event * @private */ + }, { + key: 'onMouseWheel', value: function onMouseWheel(event) { // retrieve delta var delta = 0; @@ -37693,14 +37613,14 @@ return /******/ (function(modules) { // webpackBootstrap // Prevent default actions caused by mouse wheel. event.preventDefault(); } - }, { - key: 'onMouseMove', /** * Mouse move handler for checking whether the title moves over a node with a title. * @param {Event} event * @private */ + }, { + key: 'onMouseMove', value: function onMouseMove(event) { var _this3 = this; @@ -37751,8 +37671,6 @@ return /******/ (function(modules) { // webpackBootstrap this.selectionHandler.hoverObject(obj); } } - }, { - key: '_checkShowPopup', /** * Check if there is an element on the given position in the network @@ -37762,6 +37680,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {{x:Number, y:Number}} pointer * @private */ + }, { + key: '_checkShowPopup', value: function _checkShowPopup(pointer) { var x = this.canvas._XconvertDOMtoCanvas(pointer.x); var y = this.canvas._YconvertDOMtoCanvas(pointer.y); @@ -37846,8 +37766,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_checkHidePopup', /** * Check if the popup must be hidden, which is the case when the mouse is no @@ -37855,6 +37773,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {{x:Number, y:Number}} pointer * @private */ + }, { + key: '_checkHidePopup', value: function _checkHidePopup(pointer) { var pointerObj = this.selectionHandler._pointerToPositionObject(pointer); @@ -37926,13 +37846,13 @@ return /******/ (function(modules) { // webpackBootstrap this.touchTime = 0; this.activated = false; - this.body.emitter.on('activate', function () { + this.body.emitter.on("activate", function () { _this.activated = true;_this.configureKeyboardBindings(); }); - this.body.emitter.on('deactivate', function () { + this.body.emitter.on("deactivate", function () { _this.activated = false;_this.configureKeyboardBindings(); }); - this.body.emitter.on('destroy', function () { + this.body.emitter.on("destroy", function () { if (_this.keycharm !== undefined) { _this.keycharm.destroy(); } @@ -37980,8 +37900,6 @@ return /******/ (function(modules) { // webpackBootstrap this.iconsCreated = false; } - }, { - key: 'loadNavigationElements', /** * Creation of the navigation controls nodes. They are drawn over the rest of the nodes and are not affected by scale and translation @@ -37991,6 +37909,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: 'loadNavigationElements', value: function loadNavigationElements() { var _this2 = this; @@ -38010,7 +37930,7 @@ return /******/ (function(modules) { // webpackBootstrap this.navigationDOM['wrapper'].appendChild(this.navigationDOM[navigationDivs[i]]); var hammer = new Hammer(this.navigationDOM[navigationDivs[i]]); - if (navigationDivActions[i] === '_fit') { + if (navigationDivActions[i] === "_fit") { hammerUtil.onTouch(hammer, this._fit.bind(this)); } else { hammerUtil.onTouch(hammer, this.bindToRedraw.bind(this, navigationDivActions[i])); @@ -38034,47 +37954,47 @@ return /******/ (function(modules) { // webpackBootstrap value: function bindToRedraw(action) { if (this.boundFunctions[action] === undefined) { this.boundFunctions[action] = this[action].bind(this); - this.body.emitter.on('initRedraw', this.boundFunctions[action]); - this.body.emitter.emit('_startRendering'); + this.body.emitter.on("initRedraw", this.boundFunctions[action]); + this.body.emitter.emit("_startRendering"); } } }, { key: 'unbindFromRedraw', value: function unbindFromRedraw(action) { if (this.boundFunctions[action] !== undefined) { - this.body.emitter.off('initRedraw', this.boundFunctions[action]); - this.body.emitter.emit('_stopRendering'); + this.body.emitter.off("initRedraw", this.boundFunctions[action]); + this.body.emitter.emit("_stopRendering"); delete this.boundFunctions[action]; } } - }, { - key: '_fit', /** * this stops all movement induced by the navigation buttons * * @private */ + }, { + key: '_fit', value: function _fit() { if (new Date().valueOf() - this.touchTime > 700) { // TODO: fix ugly hack to avoid hammer's double fireing of event (because we use release?) - this.body.emitter.emit('fit', { duration: 700 }); + this.body.emitter.emit("fit", { duration: 700 }); this.touchTime = new Date().valueOf(); } } - }, { - key: '_stopMovement', /** * this stops all movement induced by the navigation buttons * * @private */ + }, { + key: '_stopMovement', value: function _stopMovement() { for (var boundAction in this.boundFunctions) { if (this.boundFunctions.hasOwnProperty(boundAction)) { - this.body.emitter.off('initRedraw', this.boundFunctions[boundAction]); - this.body.emitter.emit('_stopRendering'); + this.body.emitter.off("initRedraw", this.boundFunctions[boundAction]); + this.body.emitter.emit("_stopRendering"); } } this.boundFunctions = {}; @@ -38111,12 +38031,12 @@ return /******/ (function(modules) { // webpackBootstrap this.body.view.scale /= 1 + this.options.keyboard.speed.zoom; this.body.emitter.emit('zoom', { direction: '-', scale: this.body.view.scale }); } - }, { - key: 'configureKeyboardBindings', /** * bind all keys using keycharm. */ + }, { + key: 'configureKeyboardBindings', value: function configureKeyboardBindings() { var _this3 = this; @@ -38134,79 +38054,79 @@ return /******/ (function(modules) { // webpackBootstrap this.keycharm.reset(); if (this.activated === true) { - this.keycharm.bind('up', function () { - _this3.bindToRedraw('_moveUp'); - }, 'keydown'); - this.keycharm.bind('down', function () { - _this3.bindToRedraw('_moveDown'); - }, 'keydown'); - this.keycharm.bind('left', function () { - _this3.bindToRedraw('_moveLeft'); - }, 'keydown'); - this.keycharm.bind('right', function () { - _this3.bindToRedraw('_moveRight'); - }, 'keydown'); - this.keycharm.bind('=', function () { - _this3.bindToRedraw('_zoomIn'); - }, 'keydown'); - this.keycharm.bind('num+', function () { - _this3.bindToRedraw('_zoomIn'); - }, 'keydown'); - this.keycharm.bind('num-', function () { - _this3.bindToRedraw('_zoomOut'); - }, 'keydown'); - this.keycharm.bind('-', function () { - _this3.bindToRedraw('_zoomOut'); - }, 'keydown'); - this.keycharm.bind('[', function () { - _this3.bindToRedraw('_zoomOut'); - }, 'keydown'); - this.keycharm.bind(']', function () { - _this3.bindToRedraw('_zoomIn'); - }, 'keydown'); - this.keycharm.bind('pageup', function () { - _this3.bindToRedraw('_zoomIn'); - }, 'keydown'); - this.keycharm.bind('pagedown', function () { - _this3.bindToRedraw('_zoomOut'); - }, 'keydown'); - - this.keycharm.bind('up', function () { - _this3.unbindFromRedraw('_moveUp'); - }, 'keyup'); - this.keycharm.bind('down', function () { - _this3.unbindFromRedraw('_moveDown'); - }, 'keyup'); - this.keycharm.bind('left', function () { - _this3.unbindFromRedraw('_moveLeft'); - }, 'keyup'); - this.keycharm.bind('right', function () { - _this3.unbindFromRedraw('_moveRight'); - }, 'keyup'); - this.keycharm.bind('=', function () { - _this3.unbindFromRedraw('_zoomIn'); - }, 'keyup'); - this.keycharm.bind('num+', function () { - _this3.unbindFromRedraw('_zoomIn'); - }, 'keyup'); - this.keycharm.bind('num-', function () { - _this3.unbindFromRedraw('_zoomOut'); - }, 'keyup'); - this.keycharm.bind('-', function () { - _this3.unbindFromRedraw('_zoomOut'); - }, 'keyup'); - this.keycharm.bind('[', function () { - _this3.unbindFromRedraw('_zoomOut'); - }, 'keyup'); - this.keycharm.bind(']', function () { - _this3.unbindFromRedraw('_zoomIn'); - }, 'keyup'); - this.keycharm.bind('pageup', function () { - _this3.unbindFromRedraw('_zoomIn'); - }, 'keyup'); - this.keycharm.bind('pagedown', function () { - _this3.unbindFromRedraw('_zoomOut'); - }, 'keyup'); + this.keycharm.bind("up", function () { + _this3.bindToRedraw("_moveUp"); + }, "keydown"); + this.keycharm.bind("down", function () { + _this3.bindToRedraw("_moveDown"); + }, "keydown"); + this.keycharm.bind("left", function () { + _this3.bindToRedraw("_moveLeft"); + }, "keydown"); + this.keycharm.bind("right", function () { + _this3.bindToRedraw("_moveRight"); + }, "keydown"); + this.keycharm.bind("=", function () { + _this3.bindToRedraw("_zoomIn"); + }, "keydown"); + this.keycharm.bind("num+", function () { + _this3.bindToRedraw("_zoomIn"); + }, "keydown"); + this.keycharm.bind("num-", function () { + _this3.bindToRedraw("_zoomOut"); + }, "keydown"); + this.keycharm.bind("-", function () { + _this3.bindToRedraw("_zoomOut"); + }, "keydown"); + this.keycharm.bind("[", function () { + _this3.bindToRedraw("_zoomOut"); + }, "keydown"); + this.keycharm.bind("]", function () { + _this3.bindToRedraw("_zoomIn"); + }, "keydown"); + this.keycharm.bind("pageup", function () { + _this3.bindToRedraw("_zoomIn"); + }, "keydown"); + this.keycharm.bind("pagedown", function () { + _this3.bindToRedraw("_zoomOut"); + }, "keydown"); + + this.keycharm.bind("up", function () { + _this3.unbindFromRedraw("_moveUp"); + }, "keyup"); + this.keycharm.bind("down", function () { + _this3.unbindFromRedraw("_moveDown"); + }, "keyup"); + this.keycharm.bind("left", function () { + _this3.unbindFromRedraw("_moveLeft"); + }, "keyup"); + this.keycharm.bind("right", function () { + _this3.unbindFromRedraw("_moveRight"); + }, "keyup"); + this.keycharm.bind("=", function () { + _this3.unbindFromRedraw("_zoomIn"); + }, "keyup"); + this.keycharm.bind("num+", function () { + _this3.unbindFromRedraw("_zoomIn"); + }, "keyup"); + this.keycharm.bind("num-", function () { + _this3.unbindFromRedraw("_zoomOut"); + }, "keyup"); + this.keycharm.bind("-", function () { + _this3.unbindFromRedraw("_zoomOut"); + }, "keyup"); + this.keycharm.bind("[", function () { + _this3.unbindFromRedraw("_zoomOut"); + }, "keyup"); + this.keycharm.bind("]", function () { + _this3.unbindFromRedraw("_zoomIn"); + }, "keyup"); + this.keycharm.bind("pageup", function () { + _this3.unbindFromRedraw("_zoomIn"); + }, "keyup"); + this.keycharm.bind("pagedown", function () { + _this3.unbindFromRedraw("_zoomOut"); + }, "keyup"); } } } @@ -38258,24 +38178,24 @@ return /******/ (function(modules) { // webpackBootstrap this.container.appendChild(this.frame); } + /** + * @param {number} x Horizontal position of the popup window + * @param {number} y Vertical position of the popup window + */ + _createClass(Popup, [{ key: 'setPosition', - - /** - * @param {number} x Horizontal position of the popup window - * @param {number} y Vertical position of the popup window - */ value: function setPosition(x, y) { this.x = parseInt(x); this.y = parseInt(y); } - }, { - key: 'setText', /** * Set the content for the popup window. This can be HTML code or text. * @param {string | Element} content */ + }, { + key: 'setText', value: function setText(content) { if (content instanceof Element) { this.frame.innerHTML = ''; @@ -38284,13 +38204,13 @@ return /******/ (function(modules) { // webpackBootstrap this.frame.innerHTML = content; // string containing text or HTML } } - }, { - key: 'show', /** * Show the popup window * @param {boolean} [doShow] Show or hide the window */ + }, { + key: 'show', value: function show(doShow) { if (doShow === undefined) { doShow = true; @@ -38318,23 +38238,23 @@ return /******/ (function(modules) { // webpackBootstrap left = this.padding; } - this.frame.style.left = left + 'px'; - this.frame.style.top = top + 'px'; - this.frame.style.visibility = 'visible'; + this.frame.style.left = left + "px"; + this.frame.style.top = top + "px"; + this.frame.style.visibility = "visible"; this.hidden = false; } else { this.hide(); } } - }, { - key: 'hide', /** * Hide the popup window */ + }, { + key: 'hide', value: function hide() { this.hidden = true; - this.frame.style.visibility = 'hidden'; + this.frame.style.visibility = "hidden"; } }]); @@ -38391,12 +38311,10 @@ return /******/ (function(modules) { // webpackBootstrap key: "setOptions", value: function setOptions(options) { if (options !== undefined) { - var fields = ["multiselect", "hoverConnectedEdges", "selectable", "selectConnectedEdges"]; + var fields = ['multiselect', 'hoverConnectedEdges', 'selectable', 'selectConnectedEdges']; util.selectiveDeepExtend(fields, this.options, options); } } - }, { - key: "selectOnPoint", /** * handles the selection part of the tap; @@ -38404,6 +38322,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Object} pointer * @private */ + }, { + key: "selectOnPoint", value: function selectOnPoint(pointer) { var selected = false; if (this.options.selectable === true) { @@ -38450,14 +38370,14 @@ return /******/ (function(modules) { // webpackBootstrap } else { properties = this.getSelection(); } - properties["pointer"] = { + properties['pointer'] = { DOM: { x: pointer.x, y: pointer.y }, canvas: this.canvas.DOMtoCanvas(pointer) }; - properties["event"] = event; + properties['event'] = event; if (oldSelection !== undefined) { - properties["previousSelection"] = oldSelection; + properties['previousSelection'] = oldSelection; } this.body.emitter.emit(eventType, properties); } @@ -38486,8 +38406,6 @@ return /******/ (function(modules) { // webpackBootstrap this._removeFromSelection(obj); } } - }, { - key: "_getAllNodesOverlappingWith", /** * retrieve all nodes overlapping with given object @@ -38495,6 +38413,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Number[]} An array with id's of the overlapping nodes * @private */ + }, { + key: "_getAllNodesOverlappingWith", value: function _getAllNodesOverlappingWith(object) { var overlappingNodes = []; var nodes = this.body.nodes; @@ -38506,8 +38426,6 @@ return /******/ (function(modules) { // webpackBootstrap } return overlappingNodes; } - }, { - key: "_pointerToPositionObject", /** * Return a position object in canvasspace from a single point in screenspace @@ -38516,6 +38434,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {{left: number, top: number, right: number, bottom: number}} * @private */ + }, { + key: "_pointerToPositionObject", value: function _pointerToPositionObject(pointer) { var canvasPos = this.canvas.DOMtoCanvas(pointer); return { @@ -38525,8 +38445,6 @@ return /******/ (function(modules) { // webpackBootstrap bottom: canvasPos.y - 1 }; } - }, { - key: "getNodeAt", /** * Get the top node at the a specific point (like a click) @@ -38535,6 +38453,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Node | undefined} node * @private */ + }, { + key: "getNodeAt", value: function getNodeAt(pointer) { var returnNode = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; @@ -38553,8 +38473,6 @@ return /******/ (function(modules) { // webpackBootstrap return undefined; } } - }, { - key: "_getEdgesOverlappingWith", /** * retrieve all edges overlapping with given object, selector is around center @@ -38562,6 +38480,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Number[]} An array with id's of the overlapping nodes * @private */ + }, { + key: "_getEdgesOverlappingWith", value: function _getEdgesOverlappingWith(object, overlappingEdges) { var edges = this.body.edges; for (var i = 0; i < this.body.edgeIndices.length; i++) { @@ -38571,8 +38491,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_getAllEdgesOverlappingWith", /** * retrieve all nodes overlapping with given object @@ -38580,13 +38498,13 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Number[]} An array with id's of the overlapping nodes * @private */ + }, { + key: "_getAllEdgesOverlappingWith", value: function _getAllEdgesOverlappingWith(object) { var overlappingEdges = []; this._getEdgesOverlappingWith(object, overlappingEdges); return overlappingEdges; } - }, { - key: "getEdgeAt", /** * Place holder. To implement change the getNodeAt to a _getObjectAt. Have the _getObjectAt call @@ -38596,6 +38514,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {undefined} * @private */ + }, { + key: "getEdgeAt", value: function getEdgeAt(pointer) { var returnEdge = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; @@ -38612,8 +38532,6 @@ return /******/ (function(modules) { // webpackBootstrap return undefined; } } - }, { - key: "_addToSelection", /** * Add object to the selection array. @@ -38621,6 +38539,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param obj * @private */ + }, { + key: "_addToSelection", value: function _addToSelection(obj) { if (obj instanceof Node) { this.selectionObj.nodes[obj.id] = obj; @@ -38628,8 +38548,6 @@ return /******/ (function(modules) { // webpackBootstrap this.selectionObj.edges[obj.id] = obj; } } - }, { - key: "_addToHover", /** * Add object to the selection array. @@ -38637,6 +38555,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param obj * @private */ + }, { + key: "_addToHover", value: function _addToHover(obj) { if (obj instanceof Node) { this.hoverObj.nodes[obj.id] = obj; @@ -38644,8 +38564,6 @@ return /******/ (function(modules) { // webpackBootstrap this.hoverObj.edges[obj.id] = obj; } } - }, { - key: "_removeFromSelection", /** * Remove a single option from selection. @@ -38653,6 +38571,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Object} obj * @private */ + }, { + key: "_removeFromSelection", value: function _removeFromSelection(obj) { if (obj instanceof Node) { delete this.selectionObj.nodes[obj.id]; @@ -38660,14 +38580,14 @@ return /******/ (function(modules) { // webpackBootstrap delete this.selectionObj.edges[obj.id]; } } - }, { - key: "unselectAll", /** * Unselect all. The selectionObj is useful for this. * * @private */ + }, { + key: "unselectAll", value: function unselectAll() { for (var nodeId in this.selectionObj.nodes) { if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { @@ -38682,8 +38602,6 @@ return /******/ (function(modules) { // webpackBootstrap this.selectionObj = { nodes: {}, edges: {} }; } - }, { - key: "_getSelectedNodeCount", /** * return the number of selected nodes @@ -38691,6 +38609,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: "_getSelectedNodeCount", value: function _getSelectedNodeCount() { var count = 0; for (var nodeId in this.selectionObj.nodes) { @@ -38700,8 +38620,6 @@ return /******/ (function(modules) { // webpackBootstrap } return count; } - }, { - key: "_getSelectedNode", /** * return the selected node @@ -38709,6 +38627,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: "_getSelectedNode", value: function _getSelectedNode() { for (var nodeId in this.selectionObj.nodes) { if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { @@ -38717,8 +38637,6 @@ return /******/ (function(modules) { // webpackBootstrap } return undefined; } - }, { - key: "_getSelectedEdge", /** * return the selected edge @@ -38726,6 +38644,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: "_getSelectedEdge", value: function _getSelectedEdge() { for (var edgeId in this.selectionObj.edges) { if (this.selectionObj.edges.hasOwnProperty(edgeId)) { @@ -38734,8 +38654,6 @@ return /******/ (function(modules) { // webpackBootstrap } return undefined; } - }, { - key: "_getSelectedEdgeCount", /** * return the number of selected edges @@ -38743,6 +38661,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: "_getSelectedEdgeCount", value: function _getSelectedEdgeCount() { var count = 0; for (var edgeId in this.selectionObj.edges) { @@ -38752,8 +38672,6 @@ return /******/ (function(modules) { // webpackBootstrap } return count; } - }, { - key: "_getSelectedObjectCount", /** * return the number of selected objects. @@ -38761,6 +38679,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: "_getSelectedObjectCount", value: function _getSelectedObjectCount() { var count = 0; for (var nodeId in this.selectionObj.nodes) { @@ -38775,8 +38695,6 @@ return /******/ (function(modules) { // webpackBootstrap } return count; } - }, { - key: "_selectionIsEmpty", /** * Check if anything is selected @@ -38784,6 +38702,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {boolean} * @private */ + }, { + key: "_selectionIsEmpty", value: function _selectionIsEmpty() { for (var nodeId in this.selectionObj.nodes) { if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { @@ -38797,8 +38717,6 @@ return /******/ (function(modules) { // webpackBootstrap } return true; } - }, { - key: "_clusterInSelection", /** * check if one of the selected nodes is a cluster. @@ -38806,6 +38724,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {boolean} * @private */ + }, { + key: "_clusterInSelection", value: function _clusterInSelection() { for (var nodeId in this.selectionObj.nodes) { if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { @@ -38816,8 +38736,6 @@ return /******/ (function(modules) { // webpackBootstrap } return false; } - }, { - key: "_selectConnectedEdges", /** * select the edges connected to the node that is being selected @@ -38825,6 +38743,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Node} node * @private */ + }, { + key: "_selectConnectedEdges", value: function _selectConnectedEdges(node) { for (var i = 0; i < node.edges.length; i++) { var edge = node.edges[i]; @@ -38832,8 +38752,6 @@ return /******/ (function(modules) { // webpackBootstrap this._addToSelection(edge); } } - }, { - key: "_hoverConnectedEdges", /** * select the edges connected to the node that is being selected @@ -38841,6 +38759,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Node} node * @private */ + }, { + key: "_hoverConnectedEdges", value: function _hoverConnectedEdges(node) { for (var i = 0; i < node.edges.length; i++) { var edge = node.edges[i]; @@ -38848,8 +38768,6 @@ return /******/ (function(modules) { // webpackBootstrap this._addToHover(edge); } } - }, { - key: "_unselectConnectedEdges", /** * unselect the edges connected to the node that is being selected @@ -38857,6 +38775,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Node} node * @private */ + }, { + key: "_unselectConnectedEdges", value: function _unselectConnectedEdges(node) { for (var i = 0; i < node.edges.length; i++) { var edge = node.edges[i]; @@ -38864,8 +38784,6 @@ return /******/ (function(modules) { // webpackBootstrap this._removeFromSelection(edge); } } - }, { - key: "blurObject", /** * This is called when someone clicks on a node. either select or deselect it. @@ -38874,6 +38792,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Node || Edge} object * @private */ + }, { + key: "blurObject", value: function blurObject(object) { if (object.hover === true) { object.hover = false; @@ -38884,8 +38804,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "hoverObject", /** * This is called when someone clicks on a node. either select or deselect it. @@ -38894,6 +38812,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Node || Edge} object * @private */ + }, { + key: "hoverObject", value: function hoverObject(object) { var hoverChanged = false; // remove all node hover highlights @@ -38918,10 +38838,10 @@ return /******/ (function(modules) { // webpackBootstrap } // if the blur remains the same and the object is undefined (mouse off), we blur the edge else if (object === undefined) { - this.blurObject(this.hoverObj.edges[edgeId]); - delete this.hoverObj.edges[edgeId]; - hoverChanged = true; - } + this.blurObject(this.hoverObj.edges[edgeId]); + delete this.hoverObj.edges[edgeId]; + hoverChanged = true; + } } } @@ -38942,24 +38862,22 @@ return /******/ (function(modules) { // webpackBootstrap } if (hoverChanged === true) { - this.body.emitter.emit("_requestRedraw"); + this.body.emitter.emit('_requestRedraw'); } } - }, { - key: "getSelection", /** * * retrieve the currently selected objects * @return {{nodes: Array., edges: Array.}} selection */ + }, { + key: "getSelection", value: function getSelection() { var nodeIds = this.getSelectedNodes(); var edgeIds = this.getSelectedEdges(); return { nodes: nodeIds, edges: edgeIds }; } - }, { - key: "getSelectedNodes", /** * @@ -38967,6 +38885,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {String[]} selection An array with the ids of the * selected nodes. */ + }, { + key: "getSelectedNodes", value: function getSelectedNodes() { var idArray = []; if (this.options.selectable === true) { @@ -38978,8 +38898,6 @@ return /******/ (function(modules) { // webpackBootstrap } return idArray; } - }, { - key: "getSelectedEdges", /** * @@ -38987,6 +38905,8 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Array} selection An array with the ids of the * selected nodes. */ + }, { + key: "getSelectedEdges", value: function getSelectedEdges() { var idArray = []; if (this.options.selectable === true) { @@ -38998,8 +38918,6 @@ return /******/ (function(modules) { // webpackBootstrap } return idArray; } - }, { - key: "selectNodes", /** * select zero or more nodes with the option to highlight edges @@ -39007,13 +38925,15 @@ return /******/ (function(modules) { // webpackBootstrap * selected nodes. * @param {boolean} [highlightEdges] */ + }, { + key: "selectNodes", value: function selectNodes(selection) { var highlightEdges = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; var i = undefined, id = undefined; - if (!selection || selection.length === undefined) throw "Selection must be an array with ids"; + if (!selection || selection.length === undefined) throw 'Selection must be an array with ids'; // first unselect any selected node this.unselectAll(); @@ -39023,25 +38943,25 @@ return /******/ (function(modules) { // webpackBootstrap var node = this.body.nodes[id]; if (!node) { - throw new RangeError("Node with id \"" + id + "\" not found"); + throw new RangeError('Node with id "' + id + '" not found'); } this.selectObject(node, highlightEdges); } - this.body.emitter.emit("_requestRedraw"); + this.body.emitter.emit('_requestRedraw'); } - }, { - key: "selectEdges", /** * select zero or more edges * @param {Number[] | String[]} selection An array with the ids of the * selected nodes. */ + }, { + key: "selectEdges", value: function selectEdges(selection) { var i = undefined, id = undefined; - if (!selection || selection.length === undefined) throw "Selection must be an array with ids"; + if (!selection || selection.length === undefined) throw 'Selection must be an array with ids'; // first unselect any selected objects this.unselectAll(); @@ -39051,19 +38971,19 @@ return /******/ (function(modules) { // webpackBootstrap var edge = this.body.edges[id]; if (!edge) { - throw new RangeError("Edge with id \"" + id + "\" not found"); + throw new RangeError('Edge with id "' + id + '" not found'); } this.selectObject(edge); } - this.body.emitter.emit("_requestRedraw"); + this.body.emitter.emit('_requestRedraw'); } - }, { - key: "updateSelection", /** * Validate the selection: remove ids of nodes which no longer exist * @private */ + }, { + key: "updateSelection", value: function updateSelection() { for (var nodeId in this.selectionObj.nodes) { if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { @@ -39158,7 +39078,7 @@ return /******/ (function(modules) { // webpackBootstrap value: function setOptions(options, allOptions) { if (options !== undefined) { var prevHierarchicalState = this.options.hierarchical.enabled; - util.selectiveDeepExtend(['randomSeed', 'improvedLayout'], this.options, options); + util.selectiveDeepExtend(["randomSeed", "improvedLayout"], this.options, options); util.mergeOptions(this.options, options, 'hierarchical'); if (options.randomSeed !== undefined) { this.initialRandomSeed = options.randomSeed; @@ -39280,13 +39200,13 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'layoutNetwork', /** * Use KamadaKawai to position nodes. This is quite a heavy algorithm so if there are a lot of nodes we * cluster them first to reduce the amount. */ + }, { + key: 'layoutNetwork', value: function layoutNetwork() { if (this.options.hierarchical.enabled !== true && this.options.improvedLayout === true) { // first check if we should KamadaKawai to layout. The threshold is if less than half of the visible @@ -39319,8 +39239,8 @@ return /******/ (function(modules) { // webpackBootstrap var after = this.body.nodeIndices.length; if (before == after && levels % 3 !== 0 || levels > 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.'); + this.body.emitter.emit("_layoutFailed"); + console.info("This network could not be positioned by this version of the improved layout algorithm."); return; } } @@ -39344,17 +39264,17 @@ return /******/ (function(modules) { // webpackBootstrap this._declusterAll(); // reposition all bezier nodes. - this.body.emitter.emit('_repositionBezierNodes'); + this.body.emitter.emit("_repositionBezierNodes"); } } } - }, { - key: '_shiftToCenter', /** * Move all the nodes towards to the center so gravitational pull wil not move the nodes away from view * @private */ + }, { + key: '_shiftToCenter', value: function _shiftToCenter() { var range = _NetworkUtil2['default']._getRangeCore(this.body.nodes, this.body.nodeIndices); var center = _NetworkUtil2['default']._findCenter(range); @@ -39385,8 +39305,6 @@ return /******/ (function(modules) { // webpackBootstrap value: function getSeed() { return this.initialRandomSeed; } - }, { - key: 'setupHierarchicalLayout', /** * This is the main function to layout the nodes in a hierarchical way. @@ -39394,6 +39312,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: 'setupHierarchicalLayout', value: function setupHierarchicalLayout() { if (this.options.hierarchical.enabled === true && this.body.nodeIndices.length > 0) { // get the size of the largest hubs and check if the user has defined a level for a node. @@ -39441,8 +39361,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_placeNodesByHierarchy', /** * This function places the nodes on the canvas based on the hierarchial distribution. @@ -39450,6 +39368,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Object} distribution | obtained by the function this._getDistribution() * @private */ + }, { + key: '_placeNodesByHierarchy', value: function _placeNodesByHierarchy(distribution) { var nodeId = undefined, node = undefined; @@ -39481,8 +39401,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_getDistribution', /** * This function get the distribution of levels based on hubsize @@ -39490,6 +39408,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {Object} * @private */ + }, { + key: '_getDistribution', value: function _getDistribution() { var distribution = {}; var nodeId = undefined, @@ -39517,8 +39437,6 @@ return /******/ (function(modules) { // webpackBootstrap } return distribution; } - }, { - key: '_getHubSize', /** * Get the hubsize from all remaining unlevelled nodes. @@ -39526,6 +39444,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {number} * @private */ + }, { + key: '_getHubSize', value: function _getHubSize() { var hubSize = 0; for (var nodeId in this.body.nodes) { @@ -39538,8 +39458,6 @@ return /******/ (function(modules) { // webpackBootstrap } return hubSize; } - }, { - key: '_determineLevelsByHubsize', /** * this function allocates nodes in levels based on the recursive branching from the largest hubs. @@ -39547,6 +39465,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param hubsize * @private */ + }, { + key: '_determineLevelsByHubsize', value: function _determineLevelsByHubsize() { var nodeId = undefined, node = undefined; @@ -39567,8 +39487,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_setLevelByHubsize', /** * this function is called recursively to enumerate the barnches of the largest hubs and give each node a level. @@ -39578,6 +39496,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param parentId * @private */ + }, { + key: '_setLevelByHubsize', value: function _setLevelByHubsize(level, node) { if (this.hierarchicalLevels[node.id] !== undefined) return; @@ -39592,8 +39512,6 @@ return /******/ (function(modules) { // webpackBootstrap this._setLevelByHubsize(level + 1, childNode); } } - }, { - key: '_determineLevelsDirected', /** * this function allocates nodes in levels based on the direction of the edges @@ -39601,6 +39519,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param hubsize * @private */ + }, { + key: '_determineLevelsDirected', value: function _determineLevelsDirected() { var nodeId = undefined, node = undefined; @@ -39628,8 +39548,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_setLevelDirected', /** * this function is called recursively to enumerate the branched of the first node and give each node a level based on edge direction @@ -39639,6 +39557,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param parentId * @private */ + }, { + key: '_setLevelDirected', value: function _setLevelDirected(level, node) { if (this.hierarchicalLevels[node.id] !== undefined) return; @@ -39655,8 +39575,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: '_placeBranchNodes', /** * This is a recursively called function to enumerate the branches from the largest hubs and place the nodes @@ -39668,6 +39586,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param parentLevel * @private */ + }, { + key: '_placeBranchNodes', value: function _placeBranchNodes(edges, parentId, distribution, parentLevel) { for (var i = 0; i < edges.length; i++) { var childNode = undefined; @@ -39789,13 +39709,13 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.on('_resetData', this._restore.bind(this)); } + /** + * If something changes in the data during editing, switch back to the initial datamanipulation state and close all edit modes. + * @private + */ + _createClass(ManipulationSystem, [{ key: '_restore', - - /** - * If something changes in the data during editing, switch back to the initial datamanipulation state and close all edit modes. - * @private - */ value: function _restore() { if (this.inMode !== false) { if (this.options.initiallyActive === true) { @@ -39805,13 +39725,13 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: 'setOptions', /** * Set the Options * @param options */ + }, { + key: 'setOptions', value: function setOptions(options, allOptions, globalOptions) { if (allOptions !== undefined) { if (allOptions.locale !== undefined) { @@ -39839,14 +39759,14 @@ return /******/ (function(modules) { // webpackBootstrap this._setup(); } } - }, { - key: 'toggleEditMode', /** * Enable or disable edit-mode. Draws the DOM required and cleans up after itself. * * @private */ + }, { + key: 'toggleEditMode', value: function toggleEditMode() { if (this.editMode === true) { this.disableEditMode(); @@ -39880,14 +39800,14 @@ return /******/ (function(modules) { // webpackBootstrap this._createEditButton(); } } - }, { - key: 'showManipulatorToolbar', /** * Creates the main toolbar. Removes functions bound to the select event. Binds all the buttons of the toolbar. * * @private */ + }, { + key: 'showManipulatorToolbar', value: function showManipulatorToolbar() { // restore the state of any bound functions or events, remove control nodes, restore physics this._clean(); @@ -39962,14 +39882,14 @@ return /******/ (function(modules) { // webpackBootstrap // redraw to show any possible changes this.body.emitter.emit('_redraw'); } - }, { - key: 'addNodeMode', /** * Create the toolbar for adding Nodes * * @private */ + }, { + key: 'addNodeMode', value: function addNodeMode() { // when using the gui, enable edit mode if it wasnt already. if (this.editMode !== true) { @@ -39993,14 +39913,14 @@ return /******/ (function(modules) { // webpackBootstrap this._temporaryBindEvent('click', this._performAddNode.bind(this)); } - }, { - key: 'editNode', /** * call the bound function to handle the editing of the node. The node has to be selected. * * @private */ + }, { + key: 'editNode', value: function editNode() { var _this2 = this; @@ -40041,14 +39961,14 @@ return /******/ (function(modules) { // webpackBootstrap this.showManipulatorToolbar(); } } - }, { - key: 'addEdgeMode', /** * create the toolbar to connect nodes * * @private */ + }, { + key: 'addEdgeMode', value: function addEdgeMode() { // when using the gui, enable edit mode if it wasnt already. if (this.editMode !== true) { @@ -40079,14 +39999,14 @@ return /******/ (function(modules) { // webpackBootstrap this._temporaryBindUI('onDragStart', function () {}); this._temporaryBindUI('onHold', function () {}); } - }, { - key: 'editEdgeMode', /** * create the toolbar to edit edges * * @private */ + }, { + key: 'editEdgeMode', value: function editEdgeMode() { var _this3 = this; @@ -40156,14 +40076,14 @@ return /******/ (function(modules) { // webpackBootstrap this.showManipulatorToolbar(); } } - }, { - key: 'deleteSelected', /** * delete everything in the selection * * @private */ + }, { + key: 'deleteSelected', value: function deleteSelected() { var _this4 = this; @@ -40221,8 +40141,6 @@ return /******/ (function(modules) { // webpackBootstrap this.showManipulatorToolbar(); } } - }, { - key: '_setup', //********************************************** PRIVATE ***************************************// @@ -40230,6 +40148,8 @@ return /******/ (function(modules) { // webpackBootstrap * draw or remove the DOM * @private */ + }, { + key: '_setup', value: function _setup() { if (this.options.enabled === true) { // Enable the GUI @@ -40248,13 +40168,13 @@ return /******/ (function(modules) { // webpackBootstrap this.guiEnabled = false; } } - }, { - key: '_createWrappers', /** * create the div overlays that contain the DOM * @private */ + }, { + key: '_createWrappers', value: function _createWrappers() { // load the manipulator HTML elements. All styling done in css. if (this.manipulationDiv === undefined) { @@ -40288,8 +40208,6 @@ return /******/ (function(modules) { // webpackBootstrap this.canvas.frame.appendChild(this.closeDiv); } } - }, { - key: '_getNewTargetNode', /** * generate a new target node. Used for creating new edges and editing edges @@ -40298,6 +40216,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*} * @private */ + }, { + key: '_getNewTargetNode', value: function _getNewTargetNode(x, y) { var controlNodeStyle = util.deepExtend({}, this.options.controlNodeStyle); @@ -40309,12 +40229,12 @@ return /******/ (function(modules) { // webpackBootstrap return this.body.functions.createNode(controlNodeStyle); } - }, { - key: '_createEditButton', /** * Create the edit button */ + }, { + key: '_createEditButton', value: function _createEditButton() { // restore everything to it's original state (if applicable) this._clean(); @@ -40333,13 +40253,13 @@ return /******/ (function(modules) { // webpackBootstrap // bind a hammer listener to the button, calling the function toggleEditMode. this._bindHammerToDiv(button, this.toggleEditMode.bind(this)); } - }, { - key: '_clean', /** * this function cleans up after everything this module does. Temporary elements, functions and events are removed, physics restored, hammers removed. * @private */ + }, { + key: '_clean', value: function _clean() { // not in mode this.inMode = false; @@ -40365,13 +40285,13 @@ return /******/ (function(modules) { // webpackBootstrap // restore the physics if required this.body.emitter.emit('restorePhysics'); } - }, { - key: '_cleanManipulatorHammers', /** * Each dom element has it's own hammer. They are stored in this.manipulationHammers. This cleans them up. * @private */ + }, { + key: '_cleanManipulatorHammers', value: function _cleanManipulatorHammers() { // _clean hammer bindings if (this.manipulationHammers.length != 0) { @@ -40381,13 +40301,13 @@ return /******/ (function(modules) { // webpackBootstrap this.manipulationHammers = []; } } - }, { - key: '_removeManipulationDOM', /** * Remove all DOM elements created by this module. * @private */ + }, { + key: '_removeManipulationDOM', value: function _removeManipulationDOM() { // removes all the bindings and overloads this._clean(); @@ -40413,14 +40333,14 @@ return /******/ (function(modules) { // webpackBootstrap this.editModeDiv = undefined; this.closeDiv = undefined; } - }, { - key: '_createSeperator', /** * create a seperator line. the index is to differentiate in the manipulation dom * @param index * @private */ + }, { + key: '_createSeperator', value: function _createSeperator() { var index = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0]; @@ -40428,11 +40348,11 @@ return /******/ (function(modules) { // webpackBootstrap this.manipulationDOM['seperatorLineDiv' + index].className = 'vis-separator-line'; this.manipulationDiv.appendChild(this.manipulationDOM['seperatorLineDiv' + index]); } - }, { - key: '_createAddNodeButton', // ---------------------- DOM functions for buttons --------------------------// + }, { + key: '_createAddNodeButton', value: function _createAddNodeButton(locale) { var button = this._createButton('addNode', 'vis-button vis-add', locale['addNode'] || this.options.locales['en']['addNode']); this.manipulationDiv.appendChild(button); @@ -40491,8 +40411,6 @@ return /******/ (function(modules) { // webpackBootstrap value: function _createDescription(label) { this.manipulationDiv.appendChild(this._createButton('description', 'vis-button vis-none', label)); } - }, { - key: '_temporaryBindEvent', // -------------------------- End of DOM functions for buttons ------------------------------// @@ -40502,12 +40420,12 @@ return /******/ (function(modules) { // webpackBootstrap * @param newFunction * @private */ + }, { + key: '_temporaryBindEvent', value: function _temporaryBindEvent(event, newFunction) { this.temporaryEventFunctions.push({ event: event, boundFunction: newFunction }); this.body.emitter.on(event, newFunction); } - }, { - key: '_temporaryBindUI', /** * this overrides an UI function until cleanup by the clean function @@ -40515,6 +40433,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param newFunction * @private */ + }, { + key: '_temporaryBindUI', value: function _temporaryBindUI(UIfunctionName, newFunction) { if (this.body.eventListeners[UIfunctionName] !== undefined) { this.temporaryUIFunctions[UIfunctionName] = this.body.eventListeners[UIfunctionName]; @@ -40523,14 +40443,14 @@ return /******/ (function(modules) { // webpackBootstrap throw new Error('This UI function does not exist. Typo? You tried: ' + UIfunctionName + ' possible are: ' + JSON.stringify(Object.keys(this.body.eventListeners))); } } - }, { - key: '_unbindTemporaryUIs', /** * Restore the overridden UI functions to their original state. * * @private */ + }, { + key: '_unbindTemporaryUIs', value: function _unbindTemporaryUIs() { for (var functionName in this.temporaryUIFunctions) { if (this.temporaryUIFunctions.hasOwnProperty(functionName)) { @@ -40540,13 +40460,13 @@ return /******/ (function(modules) { // webpackBootstrap } this.temporaryUIFunctions = {}; } - }, { - key: '_unbindTemporaryEvents', /** * Unbind the events created by _temporaryBindEvent * @private */ + }, { + key: '_unbindTemporaryEvents', value: function _unbindTemporaryEvents() { for (var i = 0; i < this.temporaryEventFunctions.length; i++) { var eventName = this.temporaryEventFunctions[i].event; @@ -40555,26 +40475,26 @@ return /******/ (function(modules) { // webpackBootstrap } this.temporaryEventFunctions = []; } - }, { - key: '_bindHammerToDiv', /** * Bind an hammer instance to a DOM element. * @param domElement * @param funct */ + }, { + key: '_bindHammerToDiv', value: function _bindHammerToDiv(domElement, boundFunction) { var hammer = new Hammer(domElement, {}); hammerUtil.onTouch(hammer, boundFunction); this.manipulationHammers.push(hammer); } - }, { - key: '_cleanupTemporaryNodesAndEdges', /** * Neatly clean up temporary edges and nodes * @private */ + }, { + key: '_cleanupTemporaryNodesAndEdges', value: function _cleanupTemporaryNodesAndEdges() { // _clean temporary edges for (var i = 0; i < this.temporaryIds.edges.length; i++) { @@ -40597,8 +40517,6 @@ return /******/ (function(modules) { // webpackBootstrap this.temporaryIds = { nodes: [], edges: [] }; } - }, { - key: '_controlNodeTouch', // ------------------------------------------ EDIT EDGE FUNCTIONS -----------------------------------------// @@ -40607,19 +40525,21 @@ return /******/ (function(modules) { // webpackBootstrap * @param event * @private */ + }, { + key: '_controlNodeTouch', value: function _controlNodeTouch(event) { this.selectionHandler.unselectAll(); this.lastTouch = this.body.functions.getPointer(event.center); this.lastTouch.translation = util.extend({}, this.body.view.translation); // copy the object } - }, { - key: '_controlNodeDragStart', /** * the drag start is used to mark one of the control nodes as selected. * @param event * @private */ + }, { + key: '_controlNodeDragStart', value: function _controlNodeDragStart(event) { var pointer = this.lastTouch; var pointerObj = this.selectionHandler._pointerToPositionObject(pointer); @@ -40641,14 +40561,14 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.emit('_redraw'); } - }, { - key: '_controlNodeDrag', /** * dragging the control nodes or the canvas * @param event * @private */ + }, { + key: '_controlNodeDrag', value: function _controlNodeDrag(event) { this.body.emitter.emit('disablePhysics'); var pointer = this.body.functions.getPointer(event.center); @@ -40665,14 +40585,14 @@ return /******/ (function(modules) { // webpackBootstrap } this.body.emitter.emit('_redraw'); } - }, { - key: '_controlNodeDragEnd', /** * connecting or restoring the control nodes. * @param event * @private */ + }, { + key: '_controlNodeDragEnd', value: function _controlNodeDragEnd(event) { var pointer = this.body.functions.getPointer(event.center); var pointerObj = this.selectionHandler._pointerToPositionObject(pointer); @@ -40705,8 +40625,6 @@ return /******/ (function(modules) { // webpackBootstrap } this.body.emitter.emit('_redraw'); } - }, { - key: '_handleConnect', // ------------------------------------ END OF EDIT EDGE FUNCTIONS -----------------------------------------// @@ -40717,6 +40635,8 @@ return /******/ (function(modules) { // webpackBootstrap * * @private */ + }, { + key: '_handleConnect', value: function _handleConnect(event) { // check to avoid double fireing of this function. if (new Date().valueOf() - this.touchTime > 100) { @@ -40772,14 +40692,14 @@ return /******/ (function(modules) { // webpackBootstrap this.body.view.translation = { x: this.lastTouch.translation.x + diffX, y: this.lastTouch.translation.y + diffY }; } } - }, { - key: '_finishConnect', /** * Connect the new edge to the target if one exists, otherwise remove temp line * @param event * @private */ + }, { + key: '_finishConnect', value: function _finishConnect(event) { var pointer = this.body.functions.getPointer(event.center); var pointerObj = this.selectionHandler._pointerToPositionObject(pointer); @@ -40816,8 +40736,6 @@ return /******/ (function(modules) { // webpackBootstrap } this.body.emitter.emit('_redraw'); } - }, { - key: '_performAddNode', // --------------------------------------- END OF ADD EDGE FUNCTIONS -------------------------------------// @@ -40826,6 +40744,8 @@ return /******/ (function(modules) { // webpackBootstrap /** * Adds a node on the specified location */ + }, { + key: '_performAddNode', value: function _performAddNode(clickData) { var _this5 = this; @@ -40854,14 +40774,14 @@ return /******/ (function(modules) { // webpackBootstrap this.showManipulatorToolbar(); } } - }, { - key: '_performAddEdge', /** * connect two nodes with a new edge. * * @private */ + }, { + key: '_performAddEdge', value: function _performAddEdge(sourceNodeId, targetNodeId) { var _this6 = this; @@ -40885,14 +40805,14 @@ return /******/ (function(modules) { // webpackBootstrap this.showManipulatorToolbar(); } } - }, { - key: '_performEditEdge', /** * connect two nodes with a new edge. * * @private */ + }, { + key: '_performEditEdge', value: function _performEditEdge(sourceNodeId, targetNodeId) { var _this7 = this; @@ -41418,6 +41338,7 @@ return /******/ (function(modules) { // webpackBootstrap solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'], timestep: [0.5, 0.01, 1, 0.01] }, + //adaptiveTimestep: true global: { locale: ['en', 'nl'] } @@ -41425,7 +41346,6 @@ return /******/ (function(modules) { // webpackBootstrap exports.allOptions = allOptions; exports.configureOptions = configureOptions; - //adaptiveTimestep: true /***/ }, /* 112 */ @@ -41452,8 +41372,6 @@ return /******/ (function(modules) { // webpackBootstrap var _componentsAlgorithmsFloydWarshallJs = __webpack_require__(113); - var _componentsAlgorithmsFloydWarshallJs2 = _interopRequireDefault(_componentsAlgorithmsFloydWarshallJs); - /** * KamadaKawai positions the nodes initially based on * @@ -41463,6 +41381,8 @@ return /******/ (function(modules) { // webpackBootstrap * Possible optimizations in the distance calculation can be implemented. */ + var _componentsAlgorithmsFloydWarshallJs2 = _interopRequireDefault(_componentsAlgorithmsFloydWarshallJs); + var KamadaKawai = (function () { function KamadaKawai(body, edgeLength, edgeStrength) { _classCallCheck(this, KamadaKawai); @@ -41473,13 +41393,13 @@ return /******/ (function(modules) { // webpackBootstrap this.distanceSolver = new _componentsAlgorithmsFloydWarshallJs2["default"](); } + /** + * Not sure if needed but can be used to update the spring length and spring constant + * @param options + */ + _createClass(KamadaKawai, [{ key: "setOptions", - - /** - * Not sure if needed but can be used to update the spring length and spring constant - * @param options - */ value: function setOptions(options) { if (options) { if (options.springLength) { @@ -41490,14 +41410,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "solve", /** * Position the system * @param nodesArray * @param edgesArray */ + }, { + key: "solve", value: function solve(nodesArray, edgesArray) { var ignoreClusters = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; @@ -41552,14 +41472,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_getHighestEnergyNode", /** * get the node with the highest energy * @returns {*[]} * @private */ + }, { + key: "_getHighestEnergyNode", value: function _getHighestEnergyNode(ignoreClusters) { var nodesArray = this.body.nodeIndices; var nodes = this.body.nodes; @@ -41591,8 +41511,6 @@ return /******/ (function(modules) { // webpackBootstrap return [maxEnergyNodeId, maxEnergy, dE_dx_max, dE_dy_max]; } - }, { - key: "_getEnergy", /** * calculate the energy of a single node @@ -41600,6 +41518,8 @@ return /******/ (function(modules) { // webpackBootstrap * @returns {*[]} * @private */ + }, { + key: "_getEnergy", value: function _getEnergy(m) { var nodesArray = this.body.nodeIndices; var nodes = this.body.nodes; @@ -41622,8 +41542,6 @@ return /******/ (function(modules) { // webpackBootstrap var delta_m = Math.sqrt(Math.pow(dE_dx, 2) + Math.pow(dE_dy, 2)); return [delta_m, dE_dx, dE_dy]; } - }, { - key: "_moveNode", /** * move the node based on it's energy @@ -41633,6 +41551,8 @@ return /******/ (function(modules) { // webpackBootstrap * @param dE_dy * @private */ + }, { + key: "_moveNode", value: function _moveNode(m, dE_dx, dE_dy) { var nodesArray = this.body.nodeIndices; var nodes = this.body.nodes; @@ -41668,14 +41588,14 @@ return /******/ (function(modules) { // webpackBootstrap nodes[m].x += dx; nodes[m].y += dy; } - }, { - key: "_createL_matrix", /** * Create the L matrix: edge length times shortest path * @param D_matrix * @private */ + }, { + key: "_createL_matrix", value: function _createL_matrix(D_matrix) { var nodesArray = this.body.nodeIndices; var edgeLength = this.springLength; @@ -41688,14 +41608,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - }, { - key: "_createK_matrix", /** * Create the K matrix: spring constants times shortest path * @param D_matrix * @private */ + }, { + key: "_createK_matrix", value: function _createK_matrix(D_matrix) { var nodesArray = this.body.nodeIndices; var edgeStrength = this.springConstant; @@ -42422,10 +42342,10 @@ return /******/ (function(modules) { // webpackBootstrap if (token === 'false') { token = false; // convert to boolean } else if (token === 'true') { - token = true; // convert to boolean - } else if (!isNaN(Number(token))) { - token = Number(token); // convert to number - } + token = true; // convert to boolean + } else if (!isNaN(Number(token))) { + token = Number(token); // convert to number + } tokenType = TOKENTYPE.IDENTIFIER; return; } @@ -42567,8 +42487,8 @@ return /******/ (function(modules) { // webpackBootstrap getToken(); // TODO: implement comma separated list with "a_list: ID=ID [','] [a_list] " } else { - parseNodeStatement(graph, id); - } + parseNodeStatement(graph, id); + } } /** @@ -43074,13 +42994,13 @@ return /******/ (function(modules) { // webpackBootstrap this.callback = callback; } + /** + * @param {string} url The Url to cache the image as + * @return {Image} imageToLoadBrokenUrlOn The image object + */ + _createClass(Images, [{ key: "_addImageToCache", - - /** - * @param {string} url The Url to cache the image as - * @return {Image} imageToLoadBrokenUrlOn The image object - */ value: function _addImageToCache(url, imageToCache) { // IE11 fix -- thanks dponch! if (imageToCache.width === 0) { @@ -43092,14 +43012,14 @@ return /******/ (function(modules) { // webpackBootstrap this.images[url] = imageToCache; } - }, { - key: "_tryloadBrokenUrl", /** * @param {string} url The original Url that failed to load, if the broken image is successfully loaded it will be added to the cache using this Url as the key so that subsequent requests for this Url will return the broken image * @param {string} brokenUrl Url the broken image to try and load * @return {Image} imageToLoadBrokenUrlOn The image object */ + }, { + key: "_tryloadBrokenUrl", value: function _tryloadBrokenUrl(url, brokenUrl, imageToLoadBrokenUrlOn) { var _this = this; @@ -43116,25 +43036,25 @@ return /******/ (function(modules) { // webpackBootstrap //Set the source of the image to the brokenUrl, this is actually what kicks off the loading of the broken image imageToLoadBrokenUrlOn.src = brokenUrl; } - }, { - key: "_redrawWithImage", /** * @return {Image} imageToRedrawWith The images that will be passed to the callback when it is invoked */ + }, { + key: "_redrawWithImage", value: function _redrawWithImage(imageToRedrawWith) { if (this.callback) { this.callback(imageToRedrawWith); } } - }, { - key: "load", /** * @param {string} url Url of the image * @param {string} brokenUrl Url of an image to use if the url image is not found * @return {Image} img The image object */ + }, { + key: "load", value: function load(url, brokenUrl, id) { var _this2 = this; diff --git a/dist/vis.min.css b/dist/vis.min.css index 529a6b06..b61d9a40 100644 --- a/dist/vis.min.css +++ b/dist/vis.min.css @@ -1 +1 @@ -.vis-background,.vis-labelset,.vis-timeline{overflow:hidden}.vis .overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}.vis [class*=span]{min-height:0;width:auto}div.vis-configuration{position:relative;display:block;float:left;font-size:9pt}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration.vis-config-option-container{display:block;width:495px;background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;margin-top:20px;left:10px;padding-left:5px}div.vis-configuration.vis-config-button{display:block;width:495px;height:25px;vertical-align:middle;line-height:25px;background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;margin-top:20px;left:10px;padding-left:5px;cursor:pointer;margin-bottom:30px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;width:495px;height:25px;vertical-align:middle;line-height:25px}div.vis-configuration.vis-config-item.vis-config-s2{left:10px;background-color:#f7f8fa;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s3{left:20px;background-color:#e4e9f0;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s4{left:30px;background-color:#cfd8e6;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{width:90pt;height:25px;line-height:25px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:75pt}div.vis-configuration.vis-config-colorBlock{top:1px;width:30px;height:19px;border:1px solid #444;border-radius:2px;padding:0;margin:0;cursor:pointer}input.vis-configuration.vis-config-checkbox{left:-5px}input.vis-configuration.vis-config-rangeinput{position:relative;top:-5px;width:60px;height:13px;padding:1px;margin:0;pointer-events:none}.vis-panel,.vis-timeline{padding:0;box-sizing:border-box}input.vis-configuration.vis-config-range{-webkit-appearance:none;border:0 solid #fff;background-color:transparent;width:300px;height:20px}input.vis-configuration.vis-config-range::-webkit-slider-runnable-track{width:300px;height:5px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(to bottom,#dedede 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#c8c8c8', GradientType=0 );border:1px solid #999;box-shadow:#aaa 0 0 3px 0;border-radius:3px}input.vis-configuration.vis-config-range::-webkit-slider-thumb{-webkit-appearance:none;border:1px solid #14334b;height:17px;width:17px;border-radius:50%;background:#3876c2;background:-moz-linear-gradient(top,#3876c2 0,#385380 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#3876c2),color-stop(100%,#385380));background:-webkit-linear-gradient(top,#3876c2 0,#385380 100%);background:-o-linear-gradient(top,#3876c2 0,#385380 100%);background:-ms-linear-gradient(top,#3876c2 0,#385380 100%);background:linear-gradient(to bottom,#3876c2 0,#385380 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#3876c2', endColorstr='#385380', GradientType=0 );box-shadow:#111927 0 0 1px 0;margin-top:-7px}input.vis-configuration.vis-config-range:focus{outline:0}input.vis-configuration.vis-config-range:focus::-webkit-slider-runnable-track{background:#9d9d9d;background:-moz-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#9d9d9d),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-o-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:linear-gradient(to bottom,#9d9d9d 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#9d9d9d', endColorstr='#c8c8c8', GradientType=0 )}input.vis-configuration.vis-config-range::-moz-range-track{width:300px;height:10px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(to bottom,#dedede 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#c8c8c8', GradientType=0 );border:1px solid #999;box-shadow:#aaa 0 0 3px 0;border-radius:3px}input.vis-configuration.vis-config-range::-moz-range-thumb{border:none;height:1pc;width:1pc;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:-moz-focusring{outline:#fff solid 1px;outline-offset:-1px}input.vis-configuration.vis-config-range::-ms-track{width:300px;height:5px;background:0 0;border-color:transparent;border-width:6px 0;color:transparent}input.vis-configuration.vis-config-range::-ms-fill-lower{background:#777;border-radius:10px}input.vis-configuration.vis-config-range::-ms-fill-upper{background:#ddd;border-radius:10px}input.vis-configuration.vis-config-range::-ms-thumb{border:none;height:1pc;width:1pc;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:focus::-ms-fill-lower{background:#888}input.vis-configuration.vis-config-range:focus::-ms-fill-upper{background:#ccc}.vis-configuration-popup{position:absolute;background:rgba(57,76,89,.85);border:2px solid #f2faff;line-height:30px;height:30px;width:150px;text-align:center;color:#fff;font-size:14px;border-radius:4px;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.vis-configuration-popup:after,.vis-configuration-popup:before{left:100%;top:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}.vis-configuration-popup:after{border-color:rgba(136,183,213,0);border-left-color:rgba(57,76,89,.85);border-width:8px;margin-top:-8px}.vis-configuration-popup:before{border-color:rgba(194,225,245,0);border-left-color:#f2faff;border-width:9pt;margin-top:-9pt}.vis-timeline{position:relative;border:1px solid #bfbfbf;margin:0}.vis-panel{position:absolute;margin:0}.vis-panel.vis-bottom,.vis-panel.vis-center,.vis-panel.vis-left,.vis-panel.vis-right,.vis-panel.vis-top{border:1px #bfbfbf}.vis-panel.vis-center,.vis-panel.vis-left,.vis-panel.vis-right{border-top-style:solid;border-bottom-style:solid;overflow:hidden}.vis-panel.vis-bottom,.vis-panel.vis-center,.vis-panel.vis-top{border-left-style:solid;border-right-style:solid}.vis-panel>.vis-content{position:relative}.vis-panel .vis-shadow{position:absolute;width:100%;height:1px;box-shadow:0 0 10px rgba(0,0,0,.8)}.vis-itemset,.vis-labelset,.vis-labelset .vis-label{position:relative;box-sizing:border-box}.vis-panel .vis-shadow.vis-top{top:-1px;left:0}.vis-panel .vis-shadow.vis-bottom{bottom:-1px;left:0}.vis-labelset .vis-label{left:0;top:0;width:100%;color:#4d4d4d;border-bottom:1px solid #bfbfbf}.vis-labelset .vis-label.draggable{cursor:pointer}.vis-labelset .vis-label:last-child{border-bottom:none}.vis-labelset .vis-label .vis-inner{display:inline-block;padding:5px}.vis-labelset .vis-label .vis-inner.vis-hidden{padding:0}.vis-itemset{padding:0;margin:0}.vis-itemset .vis-background,.vis-itemset .vis-foreground{position:absolute;width:100%;height:100%;overflow:visible}.vis-axis{position:absolute;width:100%;height:0;left:0;z-index:1}.vis-foreground .vis-group{position:relative;box-sizing:border-box;border-bottom:1px solid #bfbfbf}.vis-foreground .vis-group:last-child{border-bottom:none}.vis-overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.vis-item{position:absolute;color:#1A1A1A;border-color:#97B0F8;border-width:1px;background-color:#D5DDF6;display:inline-block}.vis-item.vis-point.vis-selected,.vis-item.vis-selected{background-color:#FFF785}.vis-item.vis-selected{border-color:#FFC200;z-index:2}.vis-editable.vis-selected{cursor:move}.vis-item.vis-box{text-align:center;border-style:solid;border-radius:2px}.vis-item.vis-point{background:0 0}.vis-item.vis-dot{position:absolute;padding:0;border-width:4px;border-style:solid;border-radius:4px}.vis-item.vis-range{border-style:solid;border-radius:2px;box-sizing:border-box}.vis-item.vis-background{border:none;background-color:rgba(213,221,246,.4);box-sizing:border-box;padding:0;margin:0}.vis-item .vis-item-overflow{position:relative;width:100%;height:100%;padding:0;margin:0;overflow:hidden}.vis-item.vis-range .vis-item-content{position:relative;display:inline-block}.vis-item.vis-background .vis-item-content{position:absolute;display:inline-block}.vis-item.vis-line{padding:0;position:absolute;width:0;border-left-width:1px;border-left-style:solid}.vis-item .vis-item-content{white-space:nowrap;box-sizing:border-box;padding:5px}.vis-item .vis-delete{background:url(img/timeline/delete.png) center no-repeat;position:absolute;width:24px;height:24px;top:-4px;right:-24px;cursor:pointer}.vis-item.vis-range .vis-drag-left{position:absolute;width:24px;max-width:20%;min-width:2px;height:100%;top:0;left:-4px;cursor:w-resize}.vis-item.vis-range .vis-drag-right{position:absolute;width:24px;max-width:20%;min-width:2px;height:100%;top:0;right:-4px;cursor:e-resize}.vis-time-axis{position:relative;overflow:hidden}.vis-time-axis.vis-foreground{top:0;left:0;width:100%}.vis-time-axis.vis-background{position:absolute;top:0;left:0;width:100%;height:100%}.vis-time-axis .vis-text{position:absolute;color:#4d4d4d;padding:3px;overflow:hidden;box-sizing:border-box;white-space:nowrap}.vis-time-axis .vis-text.vis-measure{position:absolute;padding-left:0;padding-right:0;margin-left:0;margin-right:0;visibility:hidden}.vis-time-axis .vis-grid.vis-vertical{position:absolute;border-left:1px solid}.vis-time-axis .vis-grid.vis-minor{border-color:#e5e5e5}.vis-time-axis .vis-grid.vis-major{border-color:#bfbfbf}.vis-current-time{background-color:#FF7F6E;width:2px;z-index:1}.vis-custom-time{background-color:#6E94FF;width:2px;cursor:move;z-index:1}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-horizontal{position:absolute;width:100%;height:0;border-bottom:1px solid}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-minor{border-color:#e5e5e5}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-major{border-color:#bfbfbf}.vis-data-axis .vis-y-axis.vis-major{width:100%;position:absolute;color:#4d4d4d;white-space:nowrap}.vis-data-axis .vis-y-axis.vis-major.vis-measure{padding:0;margin:0;border:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-minor{position:absolute;width:100%;color:#bebebe;white-space:nowrap}.vis-data-axis .vis-y-axis.vis-minor.vis-measure{padding:0;margin:0;border:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-title{position:absolute;color:#4d4d4d;white-space:nowrap;bottom:20px;text-align:center}.vis-data-axis .vis-y-axis.vis-title.vis-measure{padding:0;margin:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-title.vis-left{bottom:0;-webkit-transform-origin:left top;-moz-transform-origin:left top;-ms-transform-origin:left top;-o-transform-origin:left top;transform-origin:left bottom;-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-ms-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg)}.vis-data-axis .vis-y-axis.vis-title.vis-right{bottom:0;-webkit-transform-origin:right bottom;-moz-transform-origin:right bottom;-ms-transform-origin:right bottom;-o-transform-origin:right bottom;transform-origin:right bottom;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.vis-legend{background-color:rgba(247,252,255,.65);padding:5px;border:1px solid #b3b3b3;box-shadow:2px 2px 10px rgba(154,154,154,.55)}.vis-legend-text{white-space:nowrap;display:inline-block}.vis-graph-group0{fill:#4f81bd;fill-opacity:0;stroke-width:2px;stroke:#4f81bd}.vis-graph-group1{fill:#f79646;fill-opacity:0;stroke-width:2px;stroke:#f79646}.vis-graph-group2{fill:#8c51cf;fill-opacity:0;stroke-width:2px;stroke:#8c51cf}.vis-graph-group3{fill:#75c841;fill-opacity:0;stroke-width:2px;stroke:#75c841}.vis-graph-group4{fill:#ff0100;fill-opacity:0;stroke-width:2px;stroke:#ff0100}.vis-graph-group5{fill:#37d8e6;fill-opacity:0;stroke-width:2px;stroke:#37d8e6}.vis-graph-group6{fill:#042662;fill-opacity:0;stroke-width:2px;stroke:#042662}.vis-graph-group7{fill:#00ff26;fill-opacity:0;stroke-width:2px;stroke:#00ff26}.vis-graph-group8{fill:#f0f;fill-opacity:0;stroke-width:2px;stroke:#f0f}.vis-graph-group9{fill:#8f3938;fill-opacity:0;stroke-width:2px;stroke:#8f3938}.vis-timeline .vis-fill{fill-opacity:.1;stroke:none}.vis-timeline .vis-bar{fill-opacity:.5;stroke-width:1px}.vis-timeline .vis-point{stroke-width:2px;fill-opacity:1}.vis-timeline .vis-legend-background{stroke-width:1px;fill-opacity:.9;fill:#fff;stroke:#c2c2c2}.vis-timeline .vis-outline{stroke-width:1px;fill-opacity:1;fill:#fff;stroke:#e5e5e5}.vis-timeline .vis-icon-fill{fill-opacity:.3;stroke:none}div.vis-network div.vis-manipulation{border-width:0;border-bottom:1px;border-style:solid;border-color:#d6d9d8;background:#fff;background:-moz-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#fff),color-stop(48%,#fcfcfc),color-stop(50%,#fafafa),color-stop(100%,#fcfcfc));background:-webkit-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-o-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-ms-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:linear-gradient(to bottom,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#fcfcfc', GradientType=0 );position:absolute;left:0;top:0;width:100%;height:30px}div.vis-network div.vis-edit-mode{position:absolute;left:0;top:15px;height:30px}div.vis-network div.vis-close{position:absolute;right:0;top:0;width:30px;height:30px;background-position:20px 3px;background-repeat:no-repeat;background-image:url(img/network/cross.png);cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-close:hover{opacity:.6}div.vis-network div.vis-edit-mode div.vis-button,div.vis-network div.vis-manipulation div.vis-button{position:relative;top:-7px;font-family:verdana;font-size:9pt;-moz-border-radius:15px;border-radius:15px;display:inline-block;background-position:0 0;background-repeat:no-repeat;height:24px;margin:0 0 0 10px;vertical-align:middle;cursor:pointer;padding:0 8px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-manipulation div.vis-button:hover{box-shadow:1px 1px 8px rgba(0,0,0,.2)}div.vis-network div.vis-manipulation div.vis-button:active{box-shadow:1px 1px 8px rgba(0,0,0,.5)}div.vis-network div.vis-manipulation div.vis-button.vis-back{background-image:url(img/network/backIcon.png)}div.vis-network div.vis-manipulation div.vis-button.vis-none:hover{box-shadow:1px 1px 8px transparent;cursor:default}div.vis-network div.vis-manipulation div.vis-button.vis-none:active{box-shadow:1px 1px 8px transparent}div.vis-network div.vis-manipulation div.vis-button.vis-none{padding:0}div.vis-network div.vis-manipulation div.notification{margin:2px;font-weight:700}div.vis-network div.vis-manipulation div.vis-button.vis-add{background-image:url(img/network/addNodeIcon.png)}div.vis-network div.vis-edit-mode div.vis-button.vis-edit,div.vis-network div.vis-manipulation div.vis-button.vis-edit{background-image:url(img/network/editIcon.png)}div.vis-network div.vis-edit-mode div.vis-button.vis-edit.vis-edit-mode{background-color:#fcfcfc;border:1px solid #ccc}div.vis-network div.vis-manipulation div.vis-button.vis-connect{background-image:url(img/network/connectIcon.png)}div.vis-network div.vis-manipulation div.vis-button.vis-delete{background-image:url(img/network/deleteIcon.png)}div.vis-network div.vis-edit-mode div.vis-label,div.vis-network div.vis-manipulation div.vis-label{margin:0 0 0 23px;line-height:25px}div.vis-network div.vis-manipulation div.vis-separator-line{display:inline-block;width:1px;height:20px;background-color:#bdbdbd;margin:5px 7px 0 15px}div.vis-network-tooltip{position:absolute;visibility:hidden;padding:5px;white-space:nowrap;font-family:verdana;font-size:14px;font-color:#000;background-color:#f5f4ed;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #808074;box-shadow:3px 3px 10px rgba(0,0,0,.2);pointer-events:none}div.vis-network div.vis-navigation div.vis-button{width:34px;height:34px;-moz-border-radius:17px;border-radius:17px;position:absolute;display:inline-block;background-position:2px 2px;background-repeat:no-repeat;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-navigation div.vis-button:hover{box-shadow:0 0 3px 3px rgba(56,207,21,.3)}div.vis-network div.vis-navigation div.vis-button:active{box-shadow:0 0 1px 3px rgba(56,207,21,.95)}div.vis-network div.vis-navigation div.vis-button.vis-up{background-image:url(img/network/upArrow.png);bottom:50px;left:55px}div.vis-network div.vis-navigation div.vis-button.vis-down{background-image:url(img/network/downArrow.png);bottom:10px;left:55px}div.vis-network div.vis-navigation div.vis-button.vis-left{background-image:url(img/network/leftArrow.png);bottom:10px;left:15px}div.vis-network div.vis-navigation div.vis-button.vis-right{background-image:url(img/network/rightArrow.png);bottom:10px;left:95px}div.vis-network div.vis-navigation div.vis-button.vis-zoomIn{background-image:url(img/network/plus.png);bottom:10px;right:15px}div.vis-network div.vis-navigation div.vis-button.vis-zoomOut{background-image:url(img/network/minus.png);bottom:10px;right:55px}div.vis-network div.vis-navigation div.vis-button.vis-zoomExtends{background-image:url(img/network/zoomExtends.png);bottom:50px;right:15px}div.vis-color-picker{position:absolute;margin-top:-140px;margin-left:30px;width:293px;height:425px;padding:10px;border-radius:15px;background-color:#fff;display:none;box-shadow:rgba(0,0,0,.5) 0 0 10px 0}div.vis-color-picker div.vis-arrow{position:absolute;top:147px;left:5px}div.vis-color-picker div.vis-arrow:after,div.vis-color-picker div.vis-arrow:before{right:100%;top:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.vis-color-picker div.vis-arrow:after{border-color:rgba(255,255,255,0);border-right-color:#fff;border-width:30px;margin-top:-30px}div.vis-color-picker div.vis-color{position:absolute;width:289px;height:289px;cursor:pointer}div.vis-color-picker div.vis-brightness{position:absolute;top:313px}div.vis-color-picker div.vis-opacity{position:absolute;top:350px}div.vis-color-picker div.vis-selector{position:absolute;top:137px;left:137px;width:15px;height:15px;border-radius:15px;border:1px solid #fff;background:#4c4c4c;background:-moz-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4c4c4c),color-stop(12%,#595959),color-stop(25%,#666),color-stop(39%,#474747),color-stop(50%,#2c2c2c),color-stop(51%,#000),color-stop(60%,#111),color-stop(76%,#2b2b2b),color-stop(91%,#1c1c1c),color-stop(100%,#131313));background:-webkit-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-o-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-ms-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:linear-gradient(to bottom,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313', GradientType=0 )}div.vis-color-picker div.vis-initial-color,div.vis-color-picker div.vis-new-color{width:140px;height:20px;top:380px;font-size:10px;color:rgba(0,0,0,.4);line-height:20px;position:absolute;vertical-align:middle}div.vis-color-picker div.vis-new-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;left:159px;text-align:right;padding-right:2px}div.vis-color-picker div.vis-initial-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;left:10px;text-align:left;padding-left:2px}div.vis-color-picker div.vis-label{position:absolute;width:300px;left:10px}div.vis-color-picker div.vis-label.vis-brightness{top:300px}div.vis-color-picker div.vis-label.vis-opacity{top:338px}div.vis-color-picker div.vis-button{position:absolute;width:68px;height:25px;border-radius:10px;vertical-align:middle;text-align:center;line-height:25px;top:410px;border:2px solid #d9d9d9;background-color:#f7f7f7;cursor:pointer}div.vis-color-picker div.vis-button.vis-cancel{left:5px}div.vis-color-picker div.vis-button.vis-load{left:82px}div.vis-color-picker div.vis-button.vis-apply{left:159px}div.vis-color-picker div.vis-button.vis-save{left:236px}div.vis-color-picker input.vis-range{width:290px;height:20px} \ No newline at end of file +.vis-background,.vis-labelset,.vis-timeline{overflow:hidden}.vis .overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}.vis [class*=span]{min-height:0;width:auto}div.vis-configuration{position:relative;display:block;float:left;font-size:12px}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration.vis-config-option-container{display:block;width:495px;background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;margin-top:20px;left:10px;padding-left:5px}div.vis-configuration.vis-config-button{display:block;width:495px;height:25px;vertical-align:middle;line-height:25px;background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;margin-top:20px;left:10px;padding-left:5px;cursor:pointer;margin-bottom:30px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;width:495px;height:25px;vertical-align:middle;line-height:25px}div.vis-configuration.vis-config-item.vis-config-s2{left:10px;background-color:#f7f8fa;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s3{left:20px;background-color:#e4e9f0;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s4{left:30px;background-color:#cfd8e6;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{width:120px;height:25px;line-height:25px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:100px}div.vis-configuration.vis-config-colorBlock{top:1px;width:30px;height:19px;border:1px solid #444;border-radius:2px;padding:0;margin:0;cursor:pointer}input.vis-configuration.vis-config-checkbox{left:-5px}input.vis-configuration.vis-config-rangeinput{position:relative;top:-5px;width:60px;height:13px;padding:1px;margin:0;pointer-events:none}.vis-panel,.vis-timeline{padding:0;box-sizing:border-box}input.vis-configuration.vis-config-range{-webkit-appearance:none;border:0 solid #fff;background-color:transparent;width:300px;height:20px}input.vis-configuration.vis-config-range::-webkit-slider-runnable-track{width:300px;height:5px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(to bottom,#dedede 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#c8c8c8', GradientType=0 );border:1px solid #999;box-shadow:#aaa 0 0 3px 0;border-radius:3px}input.vis-configuration.vis-config-range::-webkit-slider-thumb{-webkit-appearance:none;border:1px solid #14334b;height:17px;width:17px;border-radius:50%;background:#3876c2;background:-moz-linear-gradient(top,#3876c2 0,#385380 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#3876c2),color-stop(100%,#385380));background:-webkit-linear-gradient(top,#3876c2 0,#385380 100%);background:-o-linear-gradient(top,#3876c2 0,#385380 100%);background:-ms-linear-gradient(top,#3876c2 0,#385380 100%);background:linear-gradient(to bottom,#3876c2 0,#385380 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#3876c2', endColorstr='#385380', GradientType=0 );box-shadow:#111927 0 0 1px 0;margin-top:-7px}input.vis-configuration.vis-config-range:focus{outline:0}input.vis-configuration.vis-config-range:focus::-webkit-slider-runnable-track{background:#9d9d9d;background:-moz-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#9d9d9d),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-o-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:linear-gradient(to bottom,#9d9d9d 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#9d9d9d', endColorstr='#c8c8c8', GradientType=0 )}input.vis-configuration.vis-config-range::-moz-range-track{width:300px;height:10px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(to bottom,#dedede 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#c8c8c8', GradientType=0 );border:1px solid #999;box-shadow:#aaa 0 0 3px 0;border-radius:3px}input.vis-configuration.vis-config-range::-moz-range-thumb{border:none;height:16px;width:16px;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:-moz-focusring{outline:#fff solid 1px;outline-offset:-1px}input.vis-configuration.vis-config-range::-ms-track{width:300px;height:5px;background:0 0;border-color:transparent;border-width:6px 0;color:transparent}input.vis-configuration.vis-config-range::-ms-fill-lower{background:#777;border-radius:10px}input.vis-configuration.vis-config-range::-ms-fill-upper{background:#ddd;border-radius:10px}input.vis-configuration.vis-config-range::-ms-thumb{border:none;height:16px;width:16px;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:focus::-ms-fill-lower{background:#888}input.vis-configuration.vis-config-range:focus::-ms-fill-upper{background:#ccc}.vis-configuration-popup{position:absolute;background:rgba(57,76,89,.85);border:2px solid #f2faff;line-height:30px;height:30px;width:150px;text-align:center;color:#fff;font-size:14px;border-radius:4px;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.vis-configuration-popup:after,.vis-configuration-popup:before{left:100%;top:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}.vis-configuration-popup:after{border-color:rgba(136,183,213,0);border-left-color:rgba(57,76,89,.85);border-width:8px;margin-top:-8px}.vis-configuration-popup:before{border-color:rgba(194,225,245,0);border-left-color:#f2faff;border-width:12px;margin-top:-12px}.vis-timeline{position:relative;border:1px solid #bfbfbf;margin:0}.vis-panel{position:absolute;margin:0}.vis-panel.vis-bottom,.vis-panel.vis-center,.vis-panel.vis-left,.vis-panel.vis-right,.vis-panel.vis-top{border:1px #bfbfbf}.vis-panel.vis-center,.vis-panel.vis-left,.vis-panel.vis-right{border-top-style:solid;border-bottom-style:solid;overflow:hidden}.vis-panel.vis-bottom,.vis-panel.vis-center,.vis-panel.vis-top{border-left-style:solid;border-right-style:solid}.vis-panel>.vis-content{position:relative}.vis-panel .vis-shadow{position:absolute;width:100%;height:1px;box-shadow:0 0 10px rgba(0,0,0,.8)}.vis-itemset,.vis-labelset,.vis-labelset .vis-label{box-sizing:border-box;position:relative}.vis-panel .vis-shadow.vis-top{top:-1px;left:0}.vis-panel .vis-shadow.vis-bottom{bottom:-1px;left:0}.vis-labelset .vis-label{left:0;top:0;width:100%;color:#4d4d4d;border-bottom:1px solid #bfbfbf}.vis-labelset .vis-label.draggable{cursor:pointer}.vis-labelset .vis-label:last-child{border-bottom:none}.vis-labelset .vis-label .vis-inner{display:inline-block;padding:5px}.vis-labelset .vis-label .vis-inner.vis-hidden{padding:0}.vis-itemset{padding:0;margin:0}.vis-itemset .vis-background,.vis-itemset .vis-foreground{position:absolute;width:100%;height:100%;overflow:visible}.vis-axis{position:absolute;width:100%;height:0;left:0;z-index:1}.vis-foreground .vis-group{position:relative;box-sizing:border-box;border-bottom:1px solid #bfbfbf}.vis-foreground .vis-group:last-child{border-bottom:none}.vis-overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.vis-item{position:absolute;color:#1A1A1A;border-color:#97B0F8;border-width:1px;background-color:#D5DDF6;display:inline-block}.vis-item.vis-point.vis-selected,.vis-item.vis-selected{background-color:#FFF785}.vis-item.vis-selected{border-color:#FFC200;z-index:2}.vis-editable.vis-selected{cursor:move}.vis-item.vis-box{text-align:center;border-style:solid;border-radius:2px}.vis-item.vis-point{background:0 0}.vis-item.vis-dot{position:absolute;padding:0;border-width:4px;border-style:solid;border-radius:4px}.vis-item.vis-range{border-style:solid;border-radius:2px;box-sizing:border-box}.vis-item.vis-background{border:none;background-color:rgba(213,221,246,.4);box-sizing:border-box;padding:0;margin:0}.vis-item .vis-item-overflow{position:relative;width:100%;height:100%;padding:0;margin:0;overflow:hidden}.vis-item.vis-range .vis-item-content{position:relative;display:inline-block}.vis-item.vis-background .vis-item-content{position:absolute;display:inline-block}.vis-item.vis-line{padding:0;position:absolute;width:0;border-left-width:1px;border-left-style:solid}.vis-item .vis-item-content{white-space:nowrap;box-sizing:border-box;padding:5px}.vis-item .vis-delete{background:url(img/timeline/delete.png) center no-repeat;position:absolute;width:24px;height:24px;top:-4px;right:-24px;cursor:pointer}.vis-item.vis-range .vis-drag-left{position:absolute;width:24px;max-width:20%;min-width:2px;height:100%;top:0;left:-4px;cursor:w-resize}.vis-item.vis-range .vis-drag-right{position:absolute;width:24px;max-width:20%;min-width:2px;height:100%;top:0;right:-4px;cursor:e-resize}.vis-time-axis{position:relative;overflow:hidden}.vis-time-axis.vis-foreground{top:0;left:0;width:100%}.vis-time-axis.vis-background{position:absolute;top:0;left:0;width:100%;height:100%}.vis-time-axis .vis-text{position:absolute;color:#4d4d4d;padding:3px;overflow:hidden;box-sizing:border-box;white-space:nowrap}.vis-time-axis .vis-text.vis-measure{position:absolute;padding-left:0;padding-right:0;margin-left:0;margin-right:0;visibility:hidden}.vis-time-axis .vis-grid.vis-vertical{position:absolute;border-left:1px solid}.vis-time-axis .vis-grid.vis-minor{border-color:#e5e5e5}.vis-time-axis .vis-grid.vis-major{border-color:#bfbfbf}.vis-current-time{background-color:#FF7F6E;width:2px;z-index:1}.vis-custom-time{background-color:#6E94FF;width:2px;cursor:move;z-index:1}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-horizontal{position:absolute;width:100%;height:0;border-bottom:1px solid}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-minor{border-color:#e5e5e5}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-major{border-color:#bfbfbf}.vis-data-axis .vis-y-axis.vis-major{width:100%;position:absolute;color:#4d4d4d;white-space:nowrap}.vis-data-axis .vis-y-axis.vis-major.vis-measure{padding:0;margin:0;border:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-minor{position:absolute;width:100%;color:#bebebe;white-space:nowrap}.vis-data-axis .vis-y-axis.vis-minor.vis-measure{padding:0;margin:0;border:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-title{position:absolute;color:#4d4d4d;white-space:nowrap;bottom:20px;text-align:center}.vis-data-axis .vis-y-axis.vis-title.vis-measure{padding:0;margin:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-title.vis-left{bottom:0;-webkit-transform-origin:left top;-moz-transform-origin:left top;-ms-transform-origin:left top;-o-transform-origin:left top;transform-origin:left bottom;-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-ms-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg)}.vis-data-axis .vis-y-axis.vis-title.vis-right{bottom:0;-webkit-transform-origin:right bottom;-moz-transform-origin:right bottom;-ms-transform-origin:right bottom;-o-transform-origin:right bottom;transform-origin:right bottom;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.vis-legend{background-color:rgba(247,252,255,.65);padding:5px;border:1px solid #b3b3b3;box-shadow:2px 2px 10px rgba(154,154,154,.55)}.vis-legend-text{white-space:nowrap;display:inline-block}.vis-graph-group0{fill:#4f81bd;fill-opacity:0;stroke-width:2px;stroke:#4f81bd}.vis-graph-group1{fill:#f79646;fill-opacity:0;stroke-width:2px;stroke:#f79646}.vis-graph-group2{fill:#8c51cf;fill-opacity:0;stroke-width:2px;stroke:#8c51cf}.vis-graph-group3{fill:#75c841;fill-opacity:0;stroke-width:2px;stroke:#75c841}.vis-graph-group4{fill:#ff0100;fill-opacity:0;stroke-width:2px;stroke:#ff0100}.vis-graph-group5{fill:#37d8e6;fill-opacity:0;stroke-width:2px;stroke:#37d8e6}.vis-graph-group6{fill:#042662;fill-opacity:0;stroke-width:2px;stroke:#042662}.vis-graph-group7{fill:#00ff26;fill-opacity:0;stroke-width:2px;stroke:#00ff26}.vis-graph-group8{fill:#f0f;fill-opacity:0;stroke-width:2px;stroke:#f0f}.vis-graph-group9{fill:#8f3938;fill-opacity:0;stroke-width:2px;stroke:#8f3938}.vis-timeline .vis-fill{fill-opacity:.1;stroke:none}.vis-timeline .vis-bar{fill-opacity:.5;stroke-width:1px}.vis-timeline .vis-point{stroke-width:2px;fill-opacity:1}.vis-timeline .vis-legend-background{stroke-width:1px;fill-opacity:.9;fill:#fff;stroke:#c2c2c2}.vis-timeline .vis-outline{stroke-width:1px;fill-opacity:1;fill:#fff;stroke:#e5e5e5}.vis-timeline .vis-icon-fill{fill-opacity:.3;stroke:none}div.vis-network div.vis-manipulation{border-width:0;border-bottom:1px;border-style:solid;border-color:#d6d9d8;background:#fff;background:-moz-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#fff),color-stop(48%,#fcfcfc),color-stop(50%,#fafafa),color-stop(100%,#fcfcfc));background:-webkit-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-o-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-ms-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:linear-gradient(to bottom,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#fcfcfc', GradientType=0 );position:absolute;left:0;top:0;width:100%;height:30px}div.vis-network div.vis-edit-mode{position:absolute;left:0;top:15px;height:30px}div.vis-network div.vis-close{position:absolute;right:0;top:0;width:30px;height:30px;background-position:20px 3px;background-repeat:no-repeat;background-image:url(img/network/cross.png);cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-close:hover{opacity:.6}div.vis-network div.vis-edit-mode div.vis-button,div.vis-network div.vis-manipulation div.vis-button{position:relative;top:-7px;font-family:verdana;font-size:12px;-moz-border-radius:15px;border-radius:15px;background-position:0 0;height:24px;margin:0 0 0 10px;vertical-align:middle;cursor:pointer;padding:0 8px;user-select:none}div.vis-network div.vis-edit-mode div.vis-button,div.vis-network div.vis-manipulation div.vis-button,div.vis-network div.vis-navigation div.vis-button{display:inline-block;background-repeat:no-repeat;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none}div.vis-network div.vis-manipulation div.vis-button:hover{box-shadow:1px 1px 8px rgba(0,0,0,.2)}div.vis-network div.vis-manipulation div.vis-button:active{box-shadow:1px 1px 8px rgba(0,0,0,.5)}div.vis-network div.vis-manipulation div.vis-button.vis-back{background-image:url(img/network/backIcon.png)}div.vis-network div.vis-manipulation div.vis-button.vis-none:hover{box-shadow:1px 1px 8px transparent;cursor:default}div.vis-network div.vis-manipulation div.vis-button.vis-none:active{box-shadow:1px 1px 8px transparent}div.vis-network div.vis-manipulation div.vis-button.vis-none{padding:0}div.vis-network div.vis-manipulation div.notification{margin:2px;font-weight:700}div.vis-network div.vis-manipulation div.vis-button.vis-add{background-image:url(img/network/addNodeIcon.png)}div.vis-network div.vis-edit-mode div.vis-button.vis-edit,div.vis-network div.vis-manipulation div.vis-button.vis-edit{background-image:url(img/network/editIcon.png)}div.vis-network div.vis-edit-mode div.vis-button.vis-edit.vis-edit-mode{background-color:#fcfcfc;border:1px solid #ccc}div.vis-network div.vis-manipulation div.vis-button.vis-connect{background-image:url(img/network/connectIcon.png)}div.vis-network div.vis-manipulation div.vis-button.vis-delete{background-image:url(img/network/deleteIcon.png)}div.vis-network div.vis-edit-mode div.vis-label,div.vis-network div.vis-manipulation div.vis-label{margin:0 0 0 23px;line-height:25px}div.vis-network div.vis-manipulation div.vis-separator-line{display:inline-block;width:1px;height:20px;background-color:#bdbdbd;margin:5px 7px 0 15px}div.vis-network-tooltip{position:absolute;visibility:hidden;padding:5px;white-space:nowrap;font-family:verdana;font-size:14px;font-color:#000;background-color:#f5f4ed;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #808074;box-shadow:3px 3px 10px rgba(0,0,0,.2);pointer-events:none}div.vis-network div.vis-navigation div.vis-button{width:34px;height:34px;-moz-border-radius:17px;border-radius:17px;position:absolute;background-position:2px 2px;cursor:pointer;user-select:none}div.vis-network div.vis-navigation div.vis-button:hover{box-shadow:0 0 3px 3px rgba(56,207,21,.3)}div.vis-network div.vis-navigation div.vis-button:active{box-shadow:0 0 1px 3px rgba(56,207,21,.95)}div.vis-network div.vis-navigation div.vis-button.vis-up{background-image:url(img/network/upArrow.png);bottom:50px;left:55px}div.vis-network div.vis-navigation div.vis-button.vis-down{background-image:url(img/network/downArrow.png);bottom:10px;left:55px}div.vis-network div.vis-navigation div.vis-button.vis-left{background-image:url(img/network/leftArrow.png);bottom:10px;left:15px}div.vis-network div.vis-navigation div.vis-button.vis-right{background-image:url(img/network/rightArrow.png);bottom:10px;left:95px}div.vis-network div.vis-navigation div.vis-button.vis-zoomIn{background-image:url(img/network/plus.png);bottom:10px;right:15px}div.vis-network div.vis-navigation div.vis-button.vis-zoomOut{background-image:url(img/network/minus.png);bottom:10px;right:55px}div.vis-network div.vis-navigation div.vis-button.vis-zoomExtends{background-image:url(img/network/zoomExtends.png);bottom:50px;right:15px}div.vis-color-picker{position:absolute;margin-top:-140px;margin-left:30px;width:293px;height:425px;padding:10px;border-radius:15px;background-color:#fff;display:none;box-shadow:rgba(0,0,0,.5) 0 0 10px 0}div.vis-color-picker div.vis-arrow{position:absolute;top:147px;left:5px}div.vis-color-picker div.vis-arrow:after,div.vis-color-picker div.vis-arrow:before{right:100%;top:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.vis-color-picker div.vis-arrow:after{border-color:rgba(255,255,255,0);border-right-color:#fff;border-width:30px;margin-top:-30px}div.vis-color-picker div.vis-color{position:absolute;width:289px;height:289px;cursor:pointer}div.vis-color-picker div.vis-brightness{position:absolute;top:313px}div.vis-color-picker div.vis-opacity{position:absolute;top:350px}div.vis-color-picker div.vis-selector{position:absolute;top:137px;left:137px;width:15px;height:15px;border-radius:15px;border:1px solid #fff;background:#4c4c4c;background:-moz-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4c4c4c),color-stop(12%,#595959),color-stop(25%,#666),color-stop(39%,#474747),color-stop(50%,#2c2c2c),color-stop(51%,#000),color-stop(60%,#111),color-stop(76%,#2b2b2b),color-stop(91%,#1c1c1c),color-stop(100%,#131313));background:-webkit-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-o-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-ms-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:linear-gradient(to bottom,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313', GradientType=0 )}div.vis-color-picker div.vis-initial-color,div.vis-color-picker div.vis-new-color{position:absolute;vertical-align:middle;width:140px;height:20px;top:380px;font-size:10px;color:rgba(0,0,0,.4);line-height:20px}div.vis-color-picker div.vis-new-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;left:159px;text-align:right;padding-right:2px}div.vis-color-picker div.vis-initial-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;left:10px;text-align:left;padding-left:2px}div.vis-color-picker div.vis-label{position:absolute;width:300px;left:10px}div.vis-color-picker div.vis-label.vis-brightness{top:300px}div.vis-color-picker div.vis-label.vis-opacity{top:338px}div.vis-color-picker div.vis-button{position:absolute;width:68px;height:25px;border-radius:10px;vertical-align:middle;text-align:center;line-height:25px;top:410px;border:2px solid #d9d9d9;background-color:#f7f7f7;cursor:pointer}div.vis-color-picker div.vis-button.vis-cancel{left:5px}div.vis-color-picker div.vis-button.vis-load{left:82px}div.vis-color-picker div.vis-button.vis-apply{left:159px}div.vis-color-picker div.vis-button.vis-save{left:236px}div.vis-color-picker input.vis-range{width:290px;height:20px} \ No newline at end of file diff --git a/lib/network/modules/Clustering.js b/lib/network/modules/Clustering.js index 9c1c5889..0194e530 100644 --- a/lib/network/modules/Clustering.js +++ b/lib/network/modules/Clustering.js @@ -654,6 +654,8 @@ class ClusterEngine { if (containedEdges.hasOwnProperty(edgeId)) { let edge = containedEdges[edgeId]; edge.setOptions({physics: true, hidden: false}); + edge.hiddenByCluster = undefined; + delete edge.hiddenByCluster; } } diff --git a/test/networkTest.html b/test/networkTest.html index 9d9d6b67..2a7d4cde 100644 --- a/test/networkTest.html +++ b/test/networkTest.html @@ -26,53 +26,56 @@ var network2 = null; function draw() { - var nodes = []; - var edges = []; - nodes.push({ id: 1, label: 'Node1' }); - nodes.push({ id: 2, label: 'Node2' }); - edges.push({ from: 2, to: 1 }); + // create an array with nodes + var nodes = [ + {id: 1, label: 'Node 1'}, + {id: 2, label: 'Node 2'}, + {id: 3, label: 'Node 3'}, + {id: 4, label: 'Node 4'}, + {id: 5, label: 'Node 5'} + ]; + // create an array with edges + var edges = [ + {from: 1, to: 2}, + {from: 2, to: 3}, + {from: 3, to: 4}, + {from: 4, to: 5} + ]; + + // create a network + var container = document.getElementById('mynetwork'); var data = { nodes: nodes, edges: edges }; + var options = {layout:{randomSeed:8}}; + network = new vis.Network(container, data, options); - // create a network - var container = document.getElementById('mynetwork'); - var options = { - layout: { - hierarchical: { - direction: "UD" - } + setTimeout(function() { + var clusterOptionsByData = { + joinCondition:function(childOptions) { + return childOptions.id == 2 || childOptions.id == 3 || childOptions.id == 4; + }, + clusterNodeProperties: {id:'cid1', label:'cid1'} } - }; - network = new vis.Network(container, data, options); + network.cluster(clusterOptionsByData); + },100); - $('#divTreemapPopUp').modal('show'); + setTimeout(function() { + var itemId = 'cid1'; + network.openCluster([itemId]); + },300); -// -// var nodes2 = []; -// var edges2 = []; -// nodes2.push({ id: 1, label: 'Node1' }); -// nodes2.push({ id: 2, label: 'Node2' }); -// edges2.push({ from: 2, to: 1 }); -// -// var data2 = { -// nodes: nodes2, -// edges: edges2 -// }; -// -// // create a network -// var container2 = document.getElementById('mynetwork2'); -// var options2 = { -// layout: { -// hierarchical: { -// direction: "UD" -// } -// } -// }; -// network2 = new vis.Network(container2, data2, options2); -// setTimeout(function() {console.log('redraw');network.redraw()},1000) + setTimeout(function() { + var clusterOptionsByData = { + joinCondition:function(childOptions) { + return childOptions.id == 2 || childOptions.id == 3 || childOptions.id == 4; + }, + clusterNodeProperties: {id:'cid2', label:'cid2'} + } + network.cluster(clusterOptionsByData); + },1000); } @@ -80,15 +83,7 @@

Popup Example

- - -
+
\ No newline at end of file