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
74 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.7
  8. * @date 2013-04-25
  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(t,e,n){var i={Controller:t("./controller"),DataSet:t("./dataset"),events:t("./events"),Range:t("./range"),Stack:t("./stack"),TimeStep:t("./timestep"),util:t("./util"),component:{item:{Item:"../../Item",ItemBox:"../../ItemBox",ItemPoint:"../../ItemPoint",ItemRange:"../../ItemRange"},Component:t("./component/component"),Panel:t("./component/panel"),RootPanel:t("./component/rootpanel"),ItemSet:t("./component/itemset"),TimeAxis:t("./component/timeaxis")},Timeline:t("./visualization/timeline")};e.exports=n=i},{"./controller":2,"./dataset":3,"./events":4,"./range":5,"./stack":6,"./timestep":7,"./util":8,"./component/component":9,"./component/panel":10,"./component/rootpanel":11,"./component/itemset":12,"./component/timeaxis":13,"./visualization/timeline":14}],8:[function(t,e,n){var i={};i.isNumber=function(t){return t instanceof Number||"number"==typeof t},i.isString=function(t){return t instanceof String||"string"==typeof t},i.isDate=function(t){if(t instanceof Date)return!0;if(i.isString(t)){var e=o.exec(t);if(e)return!0;if(!isNaN(Date.parse(t)))return!0}return!1},i.isDataTable=function(t){return"undefined"!=typeof google&&google.visualization&&google.visualization.DataTable&&t instanceof google.visualization.DataTable},i.randomUUID=function(){var t=function(){return Math.floor(65536*Math.random()).toString(16)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},i.extend=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},i.cast=function(t,e){if(void 0===t)return void 0;if(null===t)return null;if(!e)return t;if("function"==typeof e)return e(t);switch(e){case"boolean":case"Boolean":return Boolean(t);case"number":case"Number":return Number(t);case"string":case"String":return t+"";case"Date":if(i.isNumber(t))return new Date(t);if(t instanceof Date)return new Date(t.valueOf());if(i.isString(t)){var n=o.exec(t);return n?new Date(Number(n[1])):moment(t).toDate()}throw Error("Cannot cast object of type "+i.getType(t)+" to type Date");case"ISODate":if(t instanceof Date)return t.toISOString();if(i.isNumber(t)||i.isString(t))return moment(t).toDate().toISOString();throw Error("Cannot cast object of type "+i.getType(t)+" to type ISODate");case"ASPDate":if(t instanceof Date)return"/Date("+t.valueOf()+")/";if(i.isNumber(t)||i.isString(t))return"/Date("+moment(t).valueOf()+")/";throw Error("Cannot cast object of type "+i.getType(t)+" to type ASPDate");default:throw Error("Cannot cast object of type "+i.getType(t)+' to type "'+e+'"')}};var o=/^\/?Date\((\-?\d+)/i;if(i.getType=function(t){var e=typeof t;return"object"==e?null==t?"null":t instanceof Boolean?"Boolean":t instanceof Number?"Number":t instanceof String?"String":t instanceof Array?"Array":t instanceof Date?"Date":"Object":"number"==e?"Number":"boolean"==e?"Boolean":"string"==e?"String":e},i.getAbsoluteLeft=function(t){for(var e=document.documentElement,n=document.body,i=t.offsetLeft,o=t.offsetParent;null!=o&&o!=n&&o!=e;)i+=o.offsetLeft,i-=o.scrollLeft,o=o.offsetParent;return i},i.getAbsoluteTop=function(t){for(var e=document.documentElement,n=document.body,i=t.offsetTop,o=t.offsetParent;null!=o&&o!=n&&o!=e;)i+=o.offsetTop,i-=o.scrollTop,o=o.offsetParent;return i},i.getPageY=function(t){if("pageY"in t)return t.pageY;var e;e="targetTouches"in t&&t.targetTouches.length?t.targetTouches[0].clientY:t.clientY;var n=document.documentElement,i=docum
  26. },i.prototype._repaintStart=function(){var t=this.dom,e=t.redundant;e.majorLines=t.majorLines,e.majorTexts=t.majorTexts,e.minorLines=t.minorLines,e.minorTexts=t.minorTexts,t.majorLines=[],t.majorTexts=[],t.minorLines=[],t.minorTexts=[]},i.prototype._repaintEnd=function(){o.forEach(this.dom.redundant,function(t){for(;t.length;){var e=t.pop();e&&e.parentNode&&e.parentNode.removeChild(e)}})},i.prototype._repaintMinorText=function(t,e){var n=this.dom.redundant.minorTexts.shift();if(!n){var i=document.createTextNode("");n=document.createElement("div"),n.appendChild(i),n.className="text minor",this.frame.appendChild(n)}this.dom.minorTexts.push(n),n.childNodes[0].nodeValue=e,n.style.left=t+"px",n.style.top=this.props.minorLabelTop+"px"},i.prototype._repaintMajorText=function(t,e){var n=this.dom.redundant.majorTexts.shift();if(!n){var i=document.createTextNode(e);n=document.createElement("div"),n.className="text major",n.appendChild(i),this.frame.appendChild(n)}this.dom.majorTexts.push(n),n.childNodes[0].nodeValue=e,n.style.top=this.props.majorLabelTop+"px",n.style.left=t+"px"},i.prototype._repaintMinorLine=function(t){var e=this.dom.redundant.minorLines.shift();e||(e=document.createElement("div"),e.className="grid vertical minor",this.frame.appendChild(e)),this.dom.minorLines.push(e);var n=this.props;e.style.top=n.minorLineTop+"px",e.style.height=n.minorLineHeight+"px",e.style.left=t-n.minorLineWidth/2+"px"},i.prototype._repaintMajorLine=function(t){var e=this.dom.redundant.majorLines.shift();e||(e=document.createElement("DIV"),e.className="grid vertical major",this.frame.appendChild(e)),this.dom.majorLines.push(e);var n=this.props;e.style.top=n.majorLineTop+"px",e.style.left=t-n.majorLineWidth/2+"px",e.style.height=n.majorLineHeight+"px"},i.prototype._repaintLine=function(){var t=this.dom.line,e=this.frame,n=this.options;n.showMinorLabels||n.showMajorLabels?(t?(e.removeChild(t),e.appendChild(t)):(t=document.createElement("div"),t.className="grid horizontal major",e.appendChild(t),this.dom.line=t),t.style.top=this.props.lineTop+"px"):t&&axis.parentElement&&(e.removeChild(axis.line),delete this.dom.line)},i.prototype._repaintMeasureChars=function(){var t,e=this.dom;if(!e.characterMinor){t=document.createTextNode("0");var n=document.createElement("DIV");n.className="text minor measure",n.appendChild(t),this.frame.appendChild(n),e.measureCharMinor=n}if(!e.characterMajor){t=document.createTextNode("0");var i=document.createElement("DIV");i.className="text major measure",i.appendChild(t),this.frame.appendChild(i),e.measureCharMajor=i}},i.prototype.reflow=function(){var t=0,e=o.updateProperty,n=this.frame,i=this.range;if(!i)throw Error("Cannot repaint time axis: no range configured");if(n){t+=e(this,"top",n.offsetTop),t+=e(this,"left",n.offsetLeft);var s=this.props,a=this.options.showMinorLabels,h=this.options.showMajorLabels,c=this.dom.measureCharMinor,p=this.dom.measureCharMajor;c&&(s.minorCharHeight=c.clientHeight,s.minorCharWidth=c.clientWidth),p&&(s.majorCharHeight=p.clientHeight,s.majorCharWidth=p.clientWidth);var u=n.parentNode?n.parentNode.offsetHeight:0;switch(u!=s.parentHeight&&(s.parentHeight=u,t+=1),this.options.orientation){case"bottom":s.minorLabelHeight=a?s.minorCharHeight:0,s.majorLabelHeight=h?s.majorCharHeight:0,s.minorLabelTop=0,s.majorLabelTop=s.minorLabelTop+s.minorLabelHeight,s.minorLineTop=-this.top,s.minorLineHeight=Math.max(this.top+s.majorLabelHeight,0),s.minorLineWidth=1,s.majorLineTop=-this.top,s.majorLineHeight=Math.max(this.top+s.minorLabelHeight+s.majorLabelHeight,0),s.majorLineWidth=1,s.lineTop=0;break;case"top":s.minorLabelHeight=a?s.minorCharHeight:0,s.majorLabelHeight=h?s.majorCharHeight:0,s.majorLabelTop=0,s.minorLabelTop=s.majorLabelTop+s.majorLabelHeight,s.minorLineTop=s.minorLabelTop,s.minorLineHeight=Math.max(u-s.majorLabelHeight-this.top),s.minorLineWidth=1,s.majorLineTop=0,s.majorLineHeight=Math.max(u-this.top),s.majorLineWidth=1,s.lineTop=s.majorLabelHeight+s.minorLabelHeight;break;default:throw Error('Unkown orientation "'+this.options.orientation+'"')}var l=s.minorLabelHeight+s.majorLabel
  27. return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return x(t,this._week.dow,this._week.doy)},_week:{dow:0,doy:6}},k=function(t,e,n){return A({_i:t,_f:e,_l:n,_isUTC:!1})},k.utc=function(t,e,n){return A({_useUTC:!0,_isUTC:!0,_l:n,_i:t,_f:e})},k.unix=function(t){return k(1e3*t)},k.duration=function(t,e){var n,i=k.isDuration(t),o="number"==typeof t,r=i?t._data:o?{}:t;return o&&(e?r[e]=t:r.milliseconds=t),n=new h(r),i&&t.hasOwnProperty("_lang")&&(n._lang=t._lang),n},k.version=I,k.defaultFormat=G,k.lang=function(t,e){return t?(e?m(t,e):R[t]||g(t),k.duration.fn._lang=k.fn._lang=g(t),i):k.fn._lang._abbr},k.langData=function(t){return t&&t._lang&&t._lang._abbr&&(t=t._lang._abbr),g(t)},k.isMoment=function(t){return t instanceof a},k.isDuration=function(t){return t instanceof h},k.fn=a.prototype={clone:function(){return k(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._d},toJSON:function(){return k.utc(this).format("YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var t=this;return[t.year(),t.month(),t.date(),t.hours(),t.minutes(),t.seconds(),t.milliseconds()]},isValid:function(){return null==this._isValid&&(this._isValid=this._a?!f(this._a,(this._isUTC?k.utc(this._a):k(this._a)).toArray()):!isNaN(this._d.getTime())),!!this._isValid},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(t){var e=S(this,t||k.defaultFormat);return this.lang().postformat(e)},add:function(t,e){var n;return n="string"==typeof t?k.duration(+e,t):k.duration(t,e),l(this,n,1),this},subtract:function(t,e){var n;return n="string"==typeof t?k.duration(+e,t):k.duration(t,e),l(this,n,-1),this},diff:function(t,e,n){var i,o,r=this._isUTC?k(t).utc():k(t).local(),s=6e4*(this.zone()-r.zone());return e&&(e=e.replace(/s$/,"")),"year"===e||"month"===e?(i=432e5*(this.daysInMonth()+r.daysInMonth()),o=12*(this.year()-r.year())+(this.month()-r.month()),o+=(this-k(this).startOf("month")-(r-k(r).startOf("month")))/i,"year"===e&&(o/=12)):(i=this-r-s,o="second"===e?i/1e3:"minute"===e?i/6e4:"hour"===e?i/36e5:"day"===e?i/864e5:"week"===e?i/6048e5:i),n?o:p(o)},from:function(t,e){return k.duration(this.diff(t)).lang(this.lang()._abbr).humanize(!e)},fromNow:function(t){return this.from(k(),t)},calendar:function(){var t=this.diff(k().startOf("day"),"days",!0),e=-6>t?"sameElse":-1>t?"lastWeek":0>t?"lastDay":1>t?"sameDay":2>t?"nextDay":7>t?"nextWeek":"sameElse";return this.format(this.lang().calendar(e,this))},isLeapYear:function(){var t=this.year();return 0===t%4&&0!==t%100||0===t%400},isDST:function(){return this.zone()<k([this.year()]).zone()||this.zone()<k([this.year(),5]).zone()},day:function(t){var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null==t?e:this.add({d:t-e})},startOf:function(t){switch(t=t.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"week":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===t&&this.day(0),this},endOf:function(t){return this.startOf(t).add(t.replace(/s?$/,"s"),1).subtract("ms",1)},isAfter:function(t,e){return e=e!==i?e:"millisecond",+this.clone().startOf(e)>+k(t).startOf(e)},isBefore:function(t,e){return e=e!==i?e:"millisecond",+this.clone().startOf(e)<+k(t).startOf(e)},isSame:function(t,e){return e=e!==i?e:"millisecond",+this.clone().startOf(e)===+k(t).startOf(e)},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return k.utc([this.year(),this.month()+1,0]).date()},dayOfYear:function(t){var e=j((k(this).startOf("day")-k(this).startOf("year"))/864e5)+1;return null==t?e:this.add("d",t-e)},isoWeek:function(t){var e=x(this,1,4);return null==t?e:this.add("d",7*(t-e))},week:function(t){var e=this.lang().week(this);return null==t?e:this.add("d",7*(t-e))