|
|
- /**
- * vis.js
- * https://github.com/almende/vis
- *
- * A dynamic, browser-based visualization library.
- *
- * @version 0.0.5
- * @date 2013-04-24
- *
- * @license
- * Copyright (C) 2011-2013 Almende B.V, http://almende.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
- (function(){function t(t){var e=this;this.options=t||{},this.data={},this.fieldId=this.options.fieldId||"id",this.fieldTypes={},this.options.fieldTypes&&g.forEach(this.options.fieldTypes,function(t,n){e.fieldTypes[n]="Date"==t||"ISODate"==t||"ASPDate"==t?"Date":t}),this.subscribers={},this.internalIds={}}function e(t,e){this.parent=t,this.options={order:function(t,e){return e.width-t.width||t.left-e.left}},this.ordered=[],this.setOptions(e)}function n(t){this.id=g.randomUUID(),this.start=0,this.end=0,this.options={min:null,max:null,zoomMin:null,zoomMax:null},this.setOptions(t),this.listeners=[]}function i(){this.id=g.randomUUID(),this.components={},this.repaintTimer=void 0,this.reflowTimer=void 0}function o(){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 r(t,e,n){this.id=g.randomUUID(),this.parent=t,this.depends=e,this.options={},this.setOptions(n)}function s(t,e){this.id=g.randomUUID(),this.container=t,this.options={autoResize:!0},this.listeners={},this.setOptions(e)}function a(t,e,n){this.id=g.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 h(t,n,i){this.id=g.randomUUID(),this.parent=t,this.depends=n,this.options={style:"box",align:"center",orientation:"bottom",margin:{axis:20,item:10},padding:5},this.dom={};var o=this;this.data=null,this.range=null,this.listeners={add:function(t,e){o._onAdd(e.items)},update:function(t,e){o._onUpdate(e.items)},remove:function(t,e){o._onRemove(e.items)}},this.items={},this.queue={},this.stack=new e(this),this.conversion=null,this.setOptions(i)}function c(t,e,n){this.parent=t,this.data=e,this.selected=!1,this.visible=!0,this.dom=null,this.options=n}function p(t,e,n){this.props={dot:{left:0,top:0,width:0,height:0},line:{top:0,left:0,width:0,height:0}},c.call(this,t,e,n)}function u(t,e,n){this.props={dot:{top:0,width:0,height:0},content:{height:0,marginLeft:0}},c.call(this,t,e,n)}function d(t,e,n){this.props={content:{left:0,width:0}},c.call(this,t,e,n)}function l(t,e,o){var r=this;if(this.options={orientation:"bottom",zoomMin:10,zoomMax:31536e10,moveable:!0,zoomable:!0},this.controller=new i,!t)throw Error("No container element provided");this.main=new s(t,{autoResize:!1,height:function(){return r.timeaxis.height+r.itemset.height}}),this.controller.add(this.main);var c=moment().hours(0).minutes(0).seconds(0).milliseconds(0);this.range=new n({start:c.clone().add("days",-3).valueOf(),end:c.clone().add("days",4).valueOf()}),this.range.subscribe(this.main,"move","horizontal"),this.range.subscribe(this.main,"zoom","horizontal"),this.range.on("rangechange",function(){r.controller.requestReflow()}),this.range.on("rangechanged",function(){r.controller.requestReflow()}),this.timeaxis=new a(this.main,[],{orientation:this.options.orientation,range:this.range}),this.timeaxis.setRange(this.range),this.controller.add(this.timeaxis),this.itemset=new h(this.main,[this.timeaxis],{orientation:this.options.orientation}),this.itemset.setRange(this.range),this.controller.add(this.itemset),e&&this.setData(e),this.setOptions(o)}var f={component:{item:{}}};"undefined"!=typeof exports&&(exports=f),"undefined"!=typeof module&&(module.exports=f),"function"==typeof define&&define(function(){return f}),"undefined"!=typeof window&&(window.vis=f);var m=function(t){document.getElementsByTagName("script");var e=document.createElement("style");e.type="text/css",e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t)),document.getElementsByTagName("head")[0].appendChild(e)},g={};g.isNumber=function(t){return t instanceof Number||"number"==typeof t},g.isString=function(t){return t instanceof String||"string"==typeof t},g.isDate=function(t){if(t instanceof Date)return!
- },o.prototype.requestReflow=function(){if(!this.controller)throw Error("Cannot request a reflow: no controller configured");this.controller.requestReflow()},o.prototype.on=function(t,e){if(!this.parent)throw Error("Cannot attach event: no root panel found");this.parent.on(t,e)},f.component.Component=o,r.prototype=new o,r.prototype.getContainer=function(){return this.frame},r.prototype.repaint=function(){var t=0,e=g.updateProperty,n=g.option.asSize,i=this.options,o=this.frame;if(o||(o=document.createElement("div"),o.className="panel",i.className&&("function"==typeof i.className?g.addClassName(o,i.className()+""):g.addClassName(o,i.className+"")),this.frame=o,t+=1),!o.parentNode){if(!this.parent)throw Error("Cannot repaint panel: no parent attached");var r=this.parent.getContainer();if(!r)throw Error("Cannot repaint panel: parent has no container element");r.appendChild(o),t+=1}return t+=e(o.style,"top",n(i.top,"0px")),t+=e(o.style,"left",n(i.left,"0px")),t+=e(o.style,"width",n(i.width,"100%")),t+=e(o.style,"height",n(i.height,"100%")),t>0},r.prototype.reflow=function(){var t=0,e=g.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},f.component.Panel=r,s.prototype=new r,s.prototype.setOptions=function(t){g.extend(this.options,t),this.options.autoResize?this._watch():this._unwatch()},s.prototype.repaint=function(){var t=0,e=g.updateProperty,n=g.option.asSize,i=this.options,o=this.frame;if(o||(o=document.createElement("div"),o.className="graph panel",i.className&&g.addClassName(o,g.option.asString(i.className)),this.frame=o,t+=1),!o.parentNode){if(!this.container)throw Error("Cannot repaint root panel: no container attached");this.container.appendChild(o),t+=1}return t+=e(o.style,"top",n(i.top,"0px")),t+=e(o.style,"left",n(i.left,"0px")),t+=e(o.style,"width",n(i.width,"100%")),t+=e(o.style,"height",n(i.height,"100%")),this._updateEventEmitters(),t>0},s.prototype.reflow=function(){var t=0,e=g.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},s.prototype._watch=function(){var t=this;this._unwatch();var e=function(){return t.options.autoResize?(t.frame&&(t.frame.clientWidth!=t.width||t.frame.clientHeight!=t.height)&&t.requestReflow(),void 0):(t._unwatch(),void 0)};g.addEventListener(window,"resize",e),this.watchTimer=setInterval(e,1e3)},s.prototype._unwatch=function(){this.watchTimer&&(clearInterval(this.watchTimer),this.watchTimer=void 0)},s.prototype.on=function(t,e){var n=this.listeners[t];n||(n=[],this.listeners[t]=n),n.push(e),this._updateEventEmitters()},s.prototype._updateEventEmitters=function(){if(this.listeners){var t=this;g.forEach(this.listeners,function(e,n){if(t.emitters||(t.emitters={}),!(n in t.emitters)){var i=t.frame;if(i){var o=function(t){e.forEach(function(e){e(t)})};t.emitters[n]=o,g.addEventListener(i,n,o)}}})}},f.component.RootPanel=s,a.prototype=new o,a.prototype.setOptions=function(t){g.extend(this.options,t)},a.prototype.setRange=function(t){if(!(t instanceof n||t&&t.start&&t.end))throw new TypeError("Range must be an instance of Range, or an object containing start and end.");this.range=t},a.prototype.toTime=function(t){var e=this.conversion;return new Date(t/e.factor+e.offset)},a.prototype.toScreen=function(t){var e=this.conversion;return(t.valueOf()-e.offset)*e.factor},a.prototype.repaint=function(){var t=0,e=g.updateProperty,n=g.option.asSize,i=this.options,o=this.props,r=this.step,s=this.frame;if(s||(s=document.createElement("div"),this.frame=s,t+=1),s.className="axis "+i.orientation,!s.parentNode){if(!this.parent)throw Error("Cannot repaint time axis: no parent attached");var a=this.parent.getContainer();if(!a)throw Error("Cannot repaint time axis: parent has no container element");a.appendChild(s),t+=1}var h=s.parentNode;if(h){var c=s.nextSibling;h.removeChild(s);var p=i.orientation,u="bottom"==p&&this.props.parentHeight&&this.height?this.props.p
- },postformat:function(t){return t},week:function(t){return D(t,this._week.dow,this._week.doy)},_week:{dow:0,doy:6}},N=function(t,e,n){return L({_i:t,_f:e,_l:n,_isUTC:!1})},N.utc=function(t,e,n){return L({_useUTC:!0,_isUTC:!0,_l:n,_i:t,_f:e})},N.unix=function(t){return N(1e3*t)},N.duration=function(t,e){var n,i=N.isDuration(t),o="number"==typeof t,s=i?t._data:o?{}:t;return o&&(e?s[e]=t:s.milliseconds=t),n=new r(s),i&&t.hasOwnProperty("_lang")&&(n._lang=t._lang),n},N.version=Y,N.defaultFormat=J,N.lang=function(e,n){return e?(n?d(e,n):H[e]||l(e),N.duration.fn._lang=N.fn._lang=l(e),t):N.fn._lang._abbr},N.langData=function(t){return t&&t._lang&&t._lang._abbr&&(t=t._lang._abbr),l(t)},N.isMoment=function(t){return t instanceof o},N.isDuration=function(t){return t instanceof r},N.fn=o.prototype={clone:function(){return N(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 N.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?!u(this._a,(this._isUTC?N.utc(this._a):N(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=g(this,t||N.defaultFormat);return this.lang().postformat(e)},add:function(t,e){var n;return n="string"==typeof t?N.duration(+e,t):N.duration(t,e),c(this,n,1),this},subtract:function(t,e){var n;return n="string"==typeof t?N.duration(+e,t):N.duration(t,e),c(this,n,-1),this},diff:function(t,e,n){var i,o,r=this._isUTC?N(t).utc():N(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-N(this).startOf("month")-(r-N(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:a(o)},from:function(t,e){return N.duration(this.diff(t)).lang(this.lang()._abbr).humanize(!e)},fromNow:function(t){return this.from(N(),t)},calendar:function(){var t=this.diff(N().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()<N([this.year()]).zone()||this.zone()<N([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(e,n){return n=n!==t?n:"millisecond",+this.clone().startOf(n)>+N(e).startOf(n)},isBefore:function(e,n){return n=n!==t?n:"millisecond",+this.clone().startOf(n)<+N(e).startOf(n)},isSame:function(e,n){return n=n!==t?n:"millisecond",+this.clone().startOf(n)===+N(e).startOf(n)},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return N.utc([this.year(),this.month()+1,0]).date()},dayOfYear:function(t){var e=k((N(this).startOf("day")-N(this).startOf("year"))/864e5)+1;return null==t?e:this.add("d",t-e)},isoWeek:function(t){var e=D(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))},lang:function(e){return e===t?this._lang:(this._lang=l(e),this)}},O=0;G.length>O;O++)C(G[O].toLowerCase().replace(/s$/,""),G[O]);C("year","FullYear"),N
|