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
75 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-08
  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,o){if(!e[n]){if(!t[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(r)return r(n,!0);throw Error("Cannot find module '"+n+"'")}var a=e[n]={exports:{}};t[n][0].call(a.exports,function(e){var r=t[n][1][e];return i(r?r:e)},a,a.exports)}return e[n].exports}for(var r="function"==typeof require&&require,o=0;n.length>o;o++)i(n[o]);return i}({1:[function(e,n,i){function r(t){var e=this;this.options=t||{},this.data={},this.fieldId=this.options.fieldId||"id",this.fieldTypes={},this.options.fieldTypes&&w.forEach(this.options.fieldTypes,function(t,n){e.fieldTypes[n]="Date"==t||"ISODate"==t||"ASPDate"==t?"Date":t}),this.subscribers={},this.internalIds={}}function o(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=w.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=w.randomUUID(),this.components={},this.repaintTimer=void 0,this.reflowTimer=void 0}function c(){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 p(t,e,n){this.id=w.randomUUID(),this.parent=t,this.depends=e,this.options={},this.setOptions(n)}function u(t,e){this.id=w.randomUUID(),this.container=t,this.options={autoResize:!0},this.listeners={},this.setOptions(e)}function d(t,e,n){this.id=w.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=w.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.data=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.items={},this.queue={},this.stack=new o(this),this.conversion=null,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){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 r=S().hours(0).minutes(0).seconds(0).milliseconds(0);this.range=new s({start:r.clone().add("days",-3).valueOf(),end:r.clone().add("days",4).valueOf()}),this.range.subscribe(this.main,"move","horizontal"),this.range.subscribe(this.main,"zoom","horizontal"),this.range.on("rangechange",function(){var t=!0;i.controller.requestReflow(t)}),this.range.on("rangechanged",function(){var t=!0;i.controller.requestReflow(t)}),this.timeaxis=new d(this.main,[],{orientation:this.options.orientation,range:this.range}),this.t
  26. var c=w.getAbsoluteLeft(s),p=w.getPageX(t);o=(p-c)/h.factor+h.offset}else{a=e.component.height,h=i.conversion(a);var u=w.getAbsoluteTop(s),d=w.getPageY(t);o=(u+a-d-u)/h.factor+h.offset}}i.zoom(r,o)};r()}w.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,r=this.start-n*t,o=this.end-i*t;this.setRange(r,o)},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+")),r={id:w.randomUUID(),event:t,regexp:i,callback:"function"==typeof e?e:null,target:n};return this.subscriptions.push(r),r.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 r in t)t.hasOwnProperty(r)&&t[r]!==n[r]&&(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 r=this.subscriptions[i];r.regexp.test(t)&&r.callback&&r.callback(t,e,n)}},h.prototype.add=function(t){if(void 0==t.id)throw Error("Component has no field id");if(!(t instanceof c||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.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,r){r 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[r]=!0)}var e=!1;this.repaintTimer&&(clearTimeout(this.repaintTimer),this.repaintTimer=void 0);var n={};w.forEach(this.components,t),e&&this.reflow()},h.prototype.reflow=function(){function t(i,r){r 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[r]=!0)}var e=!1;this.reflowTimer&&(clearTimeout(this.reflowTimer),this.reflowTimer=void 0);var n={};w.forEach(this.components,t),e&&this.repaint()},c.prototype.setOptions=function(t){t&&(w.extend(this.options,t),this.controller&&(this.requestRepaint(),this.requestReflow()))},c.prototype.getContainer=function(){return null},c.prototype.getFrame=function(){return this.frame},c.prototype.repaint=function(){return!1},c.prototype.reflow=function(){return!1},c.prototype.requestRepaint=function(){if(!this.controller)throw Error("Cannot request a repaint: no controller configured");this.controller.requestRepaint()},c.prototype.requestReflow=function(){if(!this.controller)throw Error("Cannot request a reflow: no controller configured");this.controller.requestReflow()},p.prototype=new c,p.prototype.getContainer=function(){return this.frame},p.prototype.repaint=function(){var t=0,e=w.updateProperty,n=w.option.asSize,i=this.options,r=this.frame;if(r||(r=document.createElement("div"),r.className="panel",i.className&&("function"==typeof i.className?w.addClassName(r,i.className()+""):w.addClassName(r,i.className+"")),this.frame=r,t+=1),!r.parentNode){if(!this.parent)throw Error("Cannot repaint panel: no parent attached");var o=this.parent.getContainer();if(!o)throw Error("Cannot repaint panel: parent has no container element");o.appendChild(r),t+=1}return t+=e(r.style,"top",n(i.top,"0px")),t+=e(r.style,"left",n(i.left,"0px")),t+=e(r.style,"width",n(i.width,"100%")),t+=e(r.style,"height",n(i.height,"100%")),t>0},p.prototype.reflow=function(){var t=0,e=w.updateProperty,n=this.frame;return n?(t+=e(this,"top",n.offsetTop),t+=e(this,"left",n.offsetLeft),t+=e(this,"width",n.offsetWidth),t+=e(this,"height",n.offsetHeight)):t+=1,t>0},u.prototype=new p,u.prototype.setOptions=function(t){w.extend(this.options,t),this.options.autoResize?this._watch():this._unwatch()},u.protot
  27. break;case"MMM":case"MMMM":i=g(n._l).monthsParse(e),null!=i?r[1]=i:n._isValid=!1;break;case"D":case"DD":case"DDD":case"DDDD":null!=e&&(r[2]=~~e);break;case"YY":r[0]=~~e+(~~e>68?1900:2e3);break;case"YYYY":case"YYYYY":r[0]=~~e;break;case"a":case"A":n._isPm="pm"===(e+"").toLowerCase();break;case"H":case"HH":case"h":case"hh":r[3]=~~e;break;case"m":case"mm":r[4]=~~e;break;case"s":case"ss":r[5]=~~e;break;case"S":case"SS":case"SSS":r[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 T(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 E(t){var e,n,i=t._f.match(P),r=t._i;for(t._a=[],e=0;i.length>e;e++)n=(w(i[e]).exec(r)||[])[0],n&&(r=r.slice(r.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),T(t)}function M(t){for(var e,n,i,r,o=99;t._f.length;){if(e=c({},t),e._f=t._f.pop(),E(e),n=new a(e),n.isValid()){i=n;break}r=f(e._a,n.toArray()),o>r&&(o=r,i=n)}c(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"),E(t)}else t._d=new Date(n)}function D(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),T(t)):t._d=e instanceof Date?new Date(+e):new Date(e)}function L(t,e,n,i,r){return r.relativeTime(e||1,!!n,t,i)}function C(t,e,n){var i=j(Math.abs(t)/1e3),r=j(i/60),o=j(r/60),s=j(o/24),a=j(s/365),h=45>i&&["s",i]||1===r&&["m"]||45>r&&["mm",r]||1===o&&["h"]||22>o&&["hh",o]||1===s&&["d"]||25>=s&&["dd",s]||45>=s&&["M"]||345>s&&["MM",j(s/30)]||1===a&&["y"]||["yy",a];return h[2]=e,h[3]=t>0,h[4]=n,L.apply({},h)}function x(t,e,n){var i=n-e,r=n-t.day();return r>i&&(r-=7),i-7>r&&(r+=7),Math.ceil(k(t).add("d",r).dayOfYear()/7)}function A(t){var e=t._i,n=t._f;return null===e||""===e?null:("string"==typeof e&&(t._i=e=g().preparse(e)),k.isMoment(e)?(t=c({},e),t._d=new Date(+e._d)):n?l(n)?M(t):E(t):D(t),new a(t))}function O(t,e){k.fn[t]=k.fn[t+"s"]=function(t){var n=this._isUTC?"UTC":"";return null!=t?(this._d["set"+n+e](t),this):this._d["get"+n+e]()}}function N(t){k.duration.fn[t]=function(){return this._data[t]}}function Y(t,e){k.duration.fn["as"+t]=function(){return+this/e}}for(var k,H,I="2.0.0",j=Math.round,R={},U=n!==i&&n.exports,F=/^\/?Date\((\-?\d+)/i,P=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,z=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,W=/\d\d?/,q=/\d{1,3}/,V=/\d{3}/,B=/\d{1,4}/,Z=/[+\-]?\d{1,6}/,X=/[0-9]*[a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF]+\s*?[\u0600-\u06FF]+/i,K=/Z|[\+\-]\d\d:?\d\d/i,J=/T/i,$=/[\+\-]?\d+(\.\d{1,3})?/,Q=/^\s*\d{4}-\d\d-\d\d((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,G="YYYY-MM-DDTHH:mm:ssZ",te=[["HH:mm:ss.S",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],ee=/([\+\-]|\d\d)/gi,ne="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),ie={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},re={},oe="DDD w W M D d".split(" "),se="M D H h m s w W".split(" "),ae={M:function(){return this.month()+1},MMM:function(t){return this.lang().monthsShort(this,t)},MMMM:function(t){return this.lang().months(this,t)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(t){return this.lang().weekdaysMin(this,t)},ddd:function(t){return this.lang().weekdaysShort(this,t)},dddd:function(t){return this.lang().weekdays(this,t)},w:function(){return this.week()},W:function(){return th