-
Notifications
You must be signed in to change notification settings - Fork 0
/
segment-vis.min.js
1 lines (1 loc) · 8.35 KB
/
segment-vis.min.js
1
!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.segmentVis=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";function c(a){return"[object Function]"===Object.prototype.toString.call(a)}function d(a,b){return arguments.length<2&&(b=null),function(d,e){return c(b)&&(b=b()),1===arguments.length?d&&d[a]||b:void(d[a]=e)}}var e=a("get-set"),f=(a("extend"),{unitClass:{writable:!0},dname:{writable:!0},xBaseDomain:{writable:!0},yScale:{writable:!0},base:{writable:!0},g:{writable:!0},hdWidth:{writable:!0},on:{enumerable:!0,writable:!0},trigger:{writable:!0},init:{value:function(){return e(this)(["name","height","top","data","opacity","dataView","xDomain","xRange","yDomain","yRange","dStart","dDuration","dHeight","dY","dColor","dSortIndex","each"]),this.minWidth=1,this.selectable=!1,this.hdWidth=3,this.height(0),this.opacity(.7),this.dStart(d("start",0)),this.dDuration(d("duration",0)),this.dHeight(d("height",this.height)),this.dY(d("y",0)),this.dColor(d("color","#ccc")),this}},load:{enumerable:!0,configurable:!0,value:function(a){this.base=a,this.unitClass=this.name()+"-item"}},bind:{value:function(a){this.g=a,this.update()}},update:{enumerable:!0,value:function(a){a=a||this.data()||this.base.data(),this.data(a),this.zoomFactor=this.base.zoomFactor;var b=this.g.selectAll("."+this.unitClass).data(a,this.dSortIndex()),c=b.enter().append("g").attr("class",this.unitClass).attr("id",function(a){return a.id});c.append("rect").attr("class","seg").attr("fill-opacity",this.opacity()),c.append("line").attr("class","handle left").style("stroke-width",this.hdWidth).attr("stroke-opacity",0),c.append("line").attr("class","handle right").style("stroke-width",this.hdWidth).attr("stroke-opacity",0),b.exit().remove(),this.draw()}},xZoom:{enumerable:!0,value:function(){var a=this,b=this.base.xScale,c=b.domain()[0],d=b.domain()[1],e=[];this.data().forEach(function(b){var f=a.dStart()(b),g=a.dDuration()(b),h=f+g;(f>c&&d>h||c>f&&d>h&&h>c||f>c&&d>f&&h>d||h>d&&c>f)&&e.push(b)}),this.update()}},draw:{enumerable:!0,configurable:!0,value:function(a){a=a||this.g.selectAll("."+this.unitClass);var b=this,c=(this.g,.5*this.hdWidth),d=this.base,e=this.base.xScale,f=Math.max,g=this.dStart(),h=this.dDuration(),i=this.dY(),j=this.dColor(),k=this.dHeight(),l=function(a){return e(g(a))},m=function(a){return f(b.minWidth,e(g(a)+h(a))-e(g(a)))},n=function(a){return f(d.height()-b.yScale(k(a)),1)},o=function(a){return b.yScale(i(a))-n(a)},p=function(a){return e(g(a))+c},q=function(a){var d=e(g(a)+h(a))-e(g(a)),f=e(g(a)+h(a))-c;return d<b.minWidth?g(a)+2*(b.minWidth+b.hdWidth):f},r=function(a){return o(a)+n(a)},s=function(a){return j(a)},t=a.selectAll(".seg");t.attr("x",l).attr("y",o).attr("width",m).attr("height",n).attr("fill",s),this.each()&&t.each(this.each()),a.selectAll(".handle.left").attr("x1",p).attr("x2",p).attr("y1",o).attr("y2",r).attr("fill",s).style("stroke",s),a.selectAll(".handle.right").attr("x1",q).attr("x2",q).attr("y1",o).attr("y2",r).attr("fill",s).style("stroke",s)}}});b.exports=function(){var a=Object.create({},f);return a.init()}},{extend:3,"get-set":4}],2:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function d(a){return"function"==typeof a}function e(a){return"number"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(a){return void 0===a}b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!e(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],3:[function(a,b){var c,d=Object.prototype.hasOwnProperty,e=Object.prototype.toString,f=function(a){"use strict";if(!a||"[object Object]"!==e.call(a)||a.nodeType||a.setInterval)return!1;var b=d.call(a,"constructor"),f=a.constructor&&a.constructor.prototype&&d.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!b&&!f)return!1;var g;for(g in a);return g===c||d.call(a,g)};b.exports=function g(){"use strict";var a,b,d,e,h,i,j=arguments[0],k=1,l=arguments.length,m=!1;for("boolean"==typeof j?(m=j,j=arguments[1]||{},k=2):("object"!=typeof j&&"function"!=typeof j||j==c)&&(j={});l>k;++k)if(null!=(a=arguments[k]))for(b in a)d=j[b],e=a[b],j!==e&&(m&&e&&(f(e)||(h=Array.isArray(e)))?(h?(h=!1,i=d&&Array.isArray(d)?d:[]):i=d&&f(d)?d:{},j[b]=g(m,i,e)):e!==c&&(j[b]=e));return j}},{}],4:[function(a,b){"use strict";function c(a,b,c){var d="_"+b;c=c||!1,Object.defineProperty(a,d,{configurable:!0,writable:!0}),Object.defineProperty(a,b,{enumerable:!0,configurable:!0,value:function(e){return 0===arguments.length?a[d]:(a[d]=e,c&&(a.hasOwnProperty("on")||(a.on=f.on),a.hasOwnProperty("emit")||(a.trigger=f.emit),a.trigger(b+":changed",e)),a)}})}function d(a){return function(b,d){return Array.isArray(b)?b.forEach(function(b){c(a,b,d)}):c(a,b,d),c}}var e=a("events"),f=new e.EventEmitter;b.exports=d},{events:2}]},{},[1])(1)});