vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
80 KiB

11 years ago
11 years ago
11 years ago
  1. /**
  2. * vis.js
  3. * https://github.com/almende/vis
  4. *
  5. * A dynamic, browser-based visualization library.
  6. *
  7. * @version 0.0.8
  8. * @date 2013-05-10
  9. *
  10. * @license
  11. * Copyright (C) 2011-2013 Almende B.V, http://almende.com
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  14. * use this file except in compliance with the License. You may obtain a copy
  15. * of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  22. * License for the specific language governing permissions and limitations under
  23. * the License.
  24. */
  25. (function(t){if("function"==typeof bootstrap)bootstrap("vis",t);else if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeVis=t}else"undefined"!=typeof window?window.vis=t():global.vis=t()})(function(){var t;return function(t,e,n){function i(n,r){if(!e[n]){if(!t[n]){var s="function"==typeof require&&require;if(!r&&s)return s(n,!0);if(o)return o(n,!0);throw Error("Cannot find module '"+n+"'")}var a=e[n]={exports:{}};t[n][0].call(a.exports,function(e){var o=t[n][1][e];return i(o?o:e)},a,a.exports)}return e[n].exports}for(var o="function"==typeof require&&require,r=0;n.length>r;r++)i(n[r]);return i}({1:[function(e,n,i){function o(t){var e=this;this.options=t||{},this.data={},this.fieldId=this.options.fieldId||"id",this.fieldTypes={},this.options.fieldTypes&&b.forEach(this.options.fieldTypes,function(t,n){e.fieldTypes[n]="Date"==t||"ISODate"==t||"ASPDate"==t?"Date":t}),this.subscribers={},this.internalIds={}}function r(t,e){this.parent=t,this.options={order:function(t,e){if(t instanceof v){if(e instanceof v){var n=t.data.end-t.data.start,i=e.data.end-e.data.start;return n-i||t.data.start-e.data.start}return-1}return e instanceof v?1:t.data.start-e.data.start}},this.ordered=[],this.setOptions(e)}function s(t){this.id=b.randomUUID(),this.start=0,this.end=0,this.options={min:null,max:null,zoomMin:null,zoomMax:null},this.setOptions(t),this.listeners=[]}function a(){this.subscriptions=[]}function h(){this.id=b.randomUUID(),this.components={},this.repaintTimer=void 0,this.reflowTimer=void 0}function p(){this.id=null,this.parent=null,this.depends=null,this.controller=null,this.options=null,this.frame=null,this.top=0,this.left=0,this.width=0,this.height=0}function c(t,e,n){this.id=b.randomUUID(),this.parent=t,this.depends=e,this.options={},this.setOptions(n)}function u(t,e){this.id=b.randomUUID(),this.container=t,this.options={autoResize:!0},this.listeners={},this.setOptions(e)}function d(t,e,n){this.id=b.randomUUID(),this.parent=t,this.depends=e,this.dom={majorLines:[],majorTexts:[],minorLines:[],minorTexts:[],redundant:{majorLines:[],majorTexts:[],minorLines:[],minorTexts:[]}},this.props={range:{start:0,end:0,minimumStep:0},lineTop:0},this.options={orientation:"bottom",showMinorLabels:!0,showMajorLabels:!0},this.conversion=null,this.range=null,this.setOptions(n)}function l(t,e,n){this.id=b.randomUUID(),this.parent=t,this.depends=e,this.options={style:"box",align:"center",orientation:"bottom",margin:{axis:20,item:10},padding:5},this.dom={};var i=this;this.items=null,this.range=null,this.listeners={add:function(t,e){i._onAdd(e.items)},update:function(t,e){i._onUpdate(e.items)},remove:function(t,e){i._onRemove(e.items)}},this.contents={},this.queue={},this.stack=new r(this),this.conversion=null,n&&this.setOptions(n)}function f(t,e,n){this.parent=t,this.data=e,this.dom=null,this.options=n,this.selected=!1,this.visible=!1,this.top=0,this.left=0,this.width=0,this.height=0}function m(t,e,n){this.props={dot:{left:0,top:0,width:0,height:0},line:{top:0,left:0,width:0,height:0}},f.call(this,t,e,n)}function g(t,e,n){this.props={dot:{top:0,width:0,height:0},content:{height:0,marginLeft:0}},f.call(this,t,e,n)}function v(t,e,n){this.props={content:{left:0,width:0}},f.call(this,t,e,n)}function y(t,e,n){this.id=b.randomUUID(),this.parent=t,this.depends=e,this.options={},this.range=null,this.items=null,this.groups=null,this.contents={},this.queue={};var i=this;this.listeners={add:function(t,e){i._onAdd(e.items)},update:function(t,e){i._onUpdate(e.items)},remove:function(t,e){i._onRemove(e.items)}},n&&this.setOptions(n)}function S(t,e,n){var i=this;if(this.options={orientation:"bottom",zoomMin:10,zoomMax:31536e10,moveable:!0,zoomable:!0},this.controller=new h,!t)throw Error("No container element provided");this.main=new u(t,{autoResize:!1}),this.controller.add(this.main);var o=w().hours(0).minutes(0).seconds(0).milliseconds(0);this.range=new s({start:o.clone().add("days",-3).valueOf(),end:o.clone().add("days",4).valueOf()}),this.range.subs
  26. },s.prototype._onMouseWheel=function(t,e){t=t||window.event;var n=0;if(t.wheelDelta?n=t.wheelDelta/120:t.detail&&(n=-t.detail/3),n){var i=this,o=function(){var o=n/5,r=null,s=e.component.frame;if(s){var a,h;if("horizontal"==e.direction){a=e.component.width,h=i.conversion(a);var p=b.getAbsoluteLeft(s),c=b.getPageX(t);r=(c-p)/h.factor+h.offset}else{a=e.component.height,h=i.conversion(a);var u=b.getAbsoluteTop(s),d=b.getPageY(t);r=(u+a-d-u)/h.factor+h.offset}}i.zoom(o,r)};o()}b.preventDefault(t)},s.prototype.zoom=function(t,e){null==e&&(e=(this.start+this.end)/2),t>=1&&(t=.9),-1>=t&&(t=-.9),0>t&&(t/=1+t);var n=this.start-e,i=this.end-e,o=this.start-n*t,r=this.end-i*t;this.setRange(o,r)},s.prototype.move=function(t){var e=this.end-this.start,n=this.start+e*t,i=this.end+e*t;this.start=n,this.end=i},a.prototype.on=function(t,e,n){var i=t instanceof RegExp?t:RegExp(t.replace("*","\\w+")),o={id:b.randomUUID(),event:t,regexp:i,callback:"function"==typeof e?e:null,target:n};return this.subscriptions.push(o),o.id},a.prototype.off=function(t){for(var e=0;this.subscriptions.length>e;){var n=this.subscriptions[e],i=!0;if(t instanceof Object)for(var o in t)t.hasOwnProperty(o)&&t[o]!==n[o]&&(i=!1);else i=n.id==t;i?this.subscriptions.splice(e,1):e++}},a.prototype.emit=function(t,e,n){for(var i=0;this.subscriptions.length>i;i++){var o=this.subscriptions[i];o.regexp.test(t)&&o.callback&&o.callback(t,e,n)}},h.prototype.add=function(t){if(void 0==t.id)throw Error("Component has no field id");if(!(t instanceof p||t instanceof h))throw new TypeError("Component must be an instance of prototype Component or Controller");t.controller=this,this.components[t.id]=t},h.prototype.remove=function(t){var e;for(e in this.components)if(this.components.hasOwnProperty(e)&&(e==t||this.components[e]==t))break;e&&delete this.components[e]},h.prototype.requestReflow=function(t){if(t)this.reflow();else if(!this.reflowTimer){var e=this;this.reflowTimer=setTimeout(function(){e.reflowTimer=void 0,e.reflow()},0)}},h.prototype.requestRepaint=function(t){if(t)this.repaint();else if(!this.repaintTimer){var e=this;this.repaintTimer=setTimeout(function(){e.repaintTimer=void 0,e.repaint()},0)}},h.prototype.repaint=function(){function t(i,o){o in n||(i.depends&&i.depends.forEach(function(e){t(e,e.id)}),i.parent&&t(i.parent,i.parent.id),e=i.repaint()||e,n[o]=!0)}var e=!1;this.repaintTimer&&(clearTimeout(this.repaintTimer),this.repaintTimer=void 0);var n={};b.forEach(this.components,t),e&&this.reflow()},h.prototype.reflow=function(){function t(i,o){o in n||(i.depends&&i.depends.forEach(function(e){t(e,e.id)}),i.parent&&t(i.parent,i.parent.id),e=i.reflow()||e,n[o]=!0)}var e=!1;this.reflowTimer&&(clearTimeout(this.reflowTimer),this.reflowTimer=void 0);var n={};b.forEach(this.components,t),e&&this.repaint()},p.prototype.setOptions=function(t){t&&(b.extend(this.options,t),this.controller&&(this.requestRepaint(),this.requestReflow()))},p.prototype.getContainer=function(){return null},p.prototype.getFrame=function(){return this.frame},p.prototype.repaint=function(){return!1},p.prototype.reflow=function(){return!1},p.prototype.hide=function(){return this.frame&&this.frame.parentNode?(this.frame.parentNode.removeChild(this.frame),!0):!1},p.prototype.show=function(){return this.frame&&this.frame.parentNode?!1:this.repaint()},p.prototype.requestRepaint=function(){if(!this.controller)throw Error("Cannot request a repaint: no controller configured");this.controller.requestRepaint()},p.prototype.requestReflow=function(){if(!this.controller)throw Error("Cannot request a reflow: no controller configured");this.controller.requestReflow()},c.prototype=new p,c.prototype.getContainer=function(){return this.frame},c.prototype.repaint=function(){var t=0,e=b.updateProperty,n=b.option.asSize,i=this.options,o=this.frame;if(o||(o=document.createElement("div"),o.className="panel",i.className&&("function"==typeof i.className?b.addClassName(o,i.className()+""):b.addClassName(o,i.className+"")),this.frame=o,t+=1),!o.parentNode){if(!this.parent)throw Error("Cannot repaint panel: no parent attached");var
  27. },{moment:2}],2:[function(e,n){(function(){(function(i){function o(t,e){return function(n){return u(t.call(this,n),e)}}function r(t){return function(e){return this.lang().ordinal(t.call(this,e))}}function s(){}function a(t){p(this,t)}function h(t){var e=this._data={},n=t.years||t.year||t.y||0,i=t.months||t.month||t.M||0,o=t.weeks||t.week||t.w||0,r=t.days||t.day||t.d||0,s=t.hours||t.hour||t.h||0,a=t.minutes||t.minute||t.m||0,h=t.seconds||t.second||t.s||0,p=t.milliseconds||t.millisecond||t.ms||0;this._milliseconds=p+1e3*h+6e4*a+36e5*s,this._days=r+7*o,this._months=i+12*n,e.milliseconds=p%1e3,h+=c(p/1e3),e.seconds=h%60,a+=c(h/60),e.minutes=a%60,s+=c(a/60),e.hours=s%24,r+=c(s/24),r+=7*o,e.days=r%30,i+=c(r/30),e.months=i%12,n+=c(i/12),e.years=n}function p(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function c(t){return 0>t?Math.ceil(t):Math.floor(t)}function u(t,e){for(var n=t+"";e>n.length;)n="0"+n;return n}function d(t,e,n){var i,o=e._milliseconds,r=e._days,s=e._months;o&&t._d.setTime(+t+o*n),r&&t.date(t.date()+r*n),s&&(i=t.date(),t.date(1).month(t.month()+s*n).date(Math.min(i,t.daysInMonth())))}function l(t){return"[object Array]"===Object.prototype.toString.call(t)}function f(t,e){var n,i=Math.min(t.length,e.length),o=Math.abs(t.length-e.length),r=0;for(n=0;i>n;n++)~~t[n]!==~~e[n]&&r++;return r+o}function m(t,e){return e.abbr=t,R[t]||(R[t]=new s),R[t].set(e),R[t]}function g(t){return t?(!R[t]&&U&&e("./lang/"+t),R[t]):k.fn._lang}function v(t){return t.match(/\[.*\]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function y(t){var e,n,i=t.match(P);for(e=0,n=i.length;n>e;e++)i[e]=ae[i[e]]?ae[i[e]]:v(i[e]);return function(o){var r="";for(e=0;n>e;e++)r+="function"==typeof i[e].call?i[e].call(o,t):i[e];return r}}function S(t,e){function n(e){return t.lang().longDateFormat(e)||e}for(var i=5;i--&&z.test(e);)e=e.replace(z,n);return oe[e]||(oe[e]=y(e)),oe[e](t)}function w(t){switch(t){case"DDDD":return V;case"YYYY":return B;case"YYYYY":return Z;case"S":case"SS":case"SSS":case"DDD":return q;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return X;case"X":return J;case"Z":case"ZZ":return K;case"T":return G;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return W;default:return RegExp(t.replace("\\",""))}}function b(t,e,n){var i,o=n._a;switch(t){case"M":case"MM":o[1]=null==e?0:~~e-1;break;case"MMM":case"MMMM":i=g(n._l).monthsParse(e),null!=i?o[1]=i:n._isValid=!1;break;case"D":case"DD":case"DDD":case"DDDD":null!=e&&(o[2]=~~e);break;case"YY":o[0]=~~e+(~~e>68?1900:2e3);break;case"YYYY":case"YYYYY":o[0]=~~e;break;case"a":case"A":n._isPm="pm"===(e+"").toLowerCase();break;case"H":case"HH":case"h":case"hh":o[3]=~~e;break;case"m":case"mm":o[4]=~~e;break;case"s":case"ss":o[5]=~~e;break;case"S":case"SS":case"SSS":o[6]=~~(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,i=(e+"").match(ee),i&&i[1]&&(n._tzh=~~i[1]),i&&i[2]&&(n._tzm=~~i[2]),i&&"+"===i[0]&&(n._tzh=-n._tzh,n._tzm=-n._tzm)}null==e&&(n._isValid=!1)}function E(t){var e,n,i=[];if(!t._d){for(e=0;7>e;e++)t._a[e]=i[e]=null==t._a[e]?2===e?1:0:t._a[e];i[3]+=t._tzh||0,i[4]+=t._tzm||0,n=new Date(0),t._useUTC?(n.setUTCFullYear(i[0],i[1],i[2]),n.setUTCHours(i[3],i[4],i[5],i[6])):(n.setFullYear(i[0],i[1],i[2]),n.setHours(i[3],i[4],i[5],i[6])),t._d=n}}function T(t){var e,n,i=t._f.match(P),o=t._i;for(t._a=[],e=0;i.length>e;e++)n=(w(i[e]).exec(o)||[])[0],n&&(o=o.slice(o.indexOf(n)+n.length)),ae[i[e]]&&b(i[e],n,t);t._isPm&&12>t._a[3]&&(t._a[3]+=12),t._isPm===!1&&12===t._a[3]&&(t._a[3]=0),E(t)}function M(t){for(var e,n,i,o,r=99;t._f.length;){if(e=p({},t),e._f=t._f.pop(),T(e),n=new a(e),n.isValid()){i=n;break}o=f(e._a,n.toArray()),r>o&&(r=o,i=n)}p(t,i)}function _(t){var e,n=t._i;if(Q.exec(n)){for(t._f="YYYY-MM-DDT",e=0;4>e;e++)if(te[e][1].exec(n)){t._f+=te[e][0];break}K.exec(n)&&(t._f+=" Z"),T(t)}else t._d=new Date(n)}function C(t){var e=t._i,n=F.exec(e);e===i?t._d=new Date:n?t._d=new Date(+n[1]):"string"==typeof e?_(t):l(e)?(t._a=e.slice(0),E(t)):t.