text: var Plottable;!function(t){!function(t){function e(t,e,i){return Math.min(e,i)<=t&&t<=Math.max(e,i)}function i(t,e){return t.map(function(i,n){return t[n]+e[n]})}function n(t){return t.node().getBBox()}function r(t,e){var i=t.getPropertyValue(e);return null==i?0:parseFloat(i)}function o(t){var e=window.getComputedStyle(t);return r(e,"width")+r(e,"padding-left")+r(e,"padding-right")+r(e,"border-left-width")+r(e,"border-right-width")}function a(t){var e=window.getComputedStyle(t);return r(e,"height")+r(e,"padding-top")+r(e,"padding-bottom")+r(e,"border-top-width")+r(e,"border-bottom-width")}function s(e,i,n){var r=n.text();n.text(e);var o=t.getBBox(n),a=o.width;if(i>=a)return n.text(r),e;n.text(e+"...");var s=n.node(),l=s.getSubStringLength(s.textContent.length-3,3);if(l>i)return n.text(r),"";for(var h=e.length,c=1;h>c;c++){var u=s.getSubStringLength(0,c);if(u+l>i)return n.text(r),e.substr(0,c-1).trim()+"..."}}function l(e){var i=e.text();e.text("bqpdl");var n=t.getBBox(e).height;return e.text(i),n}function h(e,i){var n=e.text();e.text(i);var r=""===i?0:t.getBBox(e).width;return e.text(n),r}function c(e,i,n,r,o){"undefined"==typeof o&&(o=.7);var a=r.text(),l=r.node();r.text("-");var h=l.getSubStringLength(0,1);r.text(e);for(var c,u=t.getBBox(r),d=(u.width,u.height),p=Math.floor(n/d),f=e.length,y=[],_=i-h,g=o*_,m=0,x=1;f>x;x++){var b=l.getSubStringLength(m,x-m);if(b>g){var v=e.charAt(x);if(b>_){if(y.length+1>=p){c=e.substring(m,e.length).trim(),y.push(s(c,i,r));break}y.push(e.substring(m,x-1).trim()+"-"),m=x-1}else if(" "===v){if(y.length+1>=p){c=e.substring(m,e.length).trim(),y.push(s(c,i,r));break}y.push(e.substring(m,x+1).trim()),m=x+1}}}return f>m&&y.length<p&&y.push(e.substring(m,f).trim()),r.text(a),y}function u(t){var e=t.node().clientWidth;if(0===e){var i=t.attr("width");if(-1!==i.indexOf("%")){for(var n=t.node().parentNode;null!=n&&0===n.clientWidth;)n=n.parentNode;if(null==n)throw new Error("Could not compute width of element");e=n.clientWidth*parseFloat(i)/100}else e=parseFloat(i)}return e}function d(t){return"function"==typeof t?t:"string"==typeof t&&"#"!==t[0]?function(e){return e[t]}:function(){return t}}function p(t,e){var i=d(t);return function(t,n){return i(t,n,e.metadata())}}function f(t){var e={};return t.forEach(function(t){return e[t]=!0}),d3.keys(e)}function y(t,e){for(var i=[],n=0;e>n;n++)i[n]="function"==typeof t?t(n):t;return i}t.inRange=e,t.addArrays=i,t.getBBox=n,t.getElementWidth=o,t.getElementHeight=a,t.getTruncatedText=s,t.getTextHeight=l,t.getTextWidth=h,t.getWrappedText=c,t.getSVGPixelWidth=u,t.accessorize=d,t.applyAccessor=p,t.uniq=f;var _=function(){function t(){this.keyValuePairs=[]}return t.prototype.set=function(t,e){for(var i=0;i<this.keyValuePairs.length;i++)if(this.keyValuePairs[i][0]===t)return this.keyValuePairs[i][1]=e,!0;return this.keyValuePairs.push([t,e]),!1},t.prototype.get=function(t){for(var e=0;e<this.keyValuePairs.length;e++)if(this.keyValuePairs[e][0]===t)return this.keyValuePairs[e][1];return void 0},t.prototype.has=function(t){for(var e=0;e<this.keyValuePairs.length;e++)if(this.keyValuePairs[e][0]===t)return!0;return!1},t.prototype.values=function(){return this.keyValuePairs.map(function(t){return t[1]})},t.prototype.delete=function(t){for(var e=0;e<this.keyValuePairs.length;e++)if(this.keyValuePairs[e][0]===t)return this.keyValuePairs.splice(e,1),!0;return!1},t}();t.StrictEqualityAssociativeArray=_;var g=function(){function t(){this.counter={}}return t.prototype.setDefault=function(t){null==this.counter[t]&&(this.counter[t]=0)},t.prototype.increment=function(t){return this.setDefault(t),++this.counter[t]},t.prototype.decrement=function(t){return this.setDefault(t),--this.counter[t]},t.prototype.get=function(t){return this.setDefault(t),this.counter[t]},t}();t.IDCounter=g,t.createFilledArray=y}(t.Utils||(t.Utils={}));t.Utils}(Plottable||(Plottable={}));var Plottable;!function(t){!function(t){function e(t,e,i){for(var n=0,r=e.length;r>n;){var o=n+r>>>1,a=null==i?e[o]:i(e[o]);t>a?n=o+1:r=o}return n}t.sortedIndex=e}(t.OSUtils||(t.OSUtils={}));t.OSUtils}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(){function t(){this._plottableID=t.nextID++}return t.nextID=0,t}();t.PlottableObject=e}(Plottable||(Plottable={}));var __extends=this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);i.prototype=e.prototype,t.prototype=new i},Plottable;!function(t){var e=function(e){function i(){e.apply(this,arguments),this.listener2Callback=new t.Utils.StrictEqualityAssociativeArray}return __extends(i,e),i.prototype.registerListener=function(t,e){return this.listener2Callback.set(t,e),this},i.prototype._broadcast=function(){for(var t=this,e=[],i=0;i<arguments.length-0;i++)e[i]=arguments[i+0];return this.listener2Callback.values().forEach(function(i){return i(t,e)}),this},i.prototype.deregisterListener=function(t){var e=this.listener2Callback.delete(t);if(e)return this;throw new Error("Attempted to deregister listener, but listener not found")},i}(t.PlottableObject);t.Broadcaster=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(i,n){"undefined"==typeof i&&(i=[]),"undefined"==typeof n&&(n={}),e.call(this),this._data=i,this._metadata=n,this.accessor2cachedExtent=new t.Utils.StrictEqualityAssociativeArray}return __extends(i,e),i.prototype.data=function(e){return null==e?this._data:(this._data=e,this.accessor2cachedExtent=new t.Utils.StrictEqualityAssociativeArray,this._broadcast(),this)},i.prototype.metadata=function(e){return null==e?this._metadata:(this._metadata=e,this.accessor2cachedExtent=new t.Utils.StrictEqualityAssociativeArray,this._broadcast(),this)},i.prototype._getExtent=function(t){var e=this.accessor2cachedExtent.get(t);return void 0===e&&(e=this.computeExtent(t),this.accessor2cachedExtent.set(t,e)),e},i.prototype.computeExtent=function(e){var i=t.Utils.applyAccessor(e,this),n=this._data.map(i);return 0===n.length?void 0:"string"==typeof n[0]?t.Utils.uniq(n):d3.extent(n)},i}(t.Broadcaster);t.DataSource=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(){e.apply(this,arguments),this.interactionsToRegister=[],this.boxes=[],this.clipPathEnabled=!1,this.broadcastersCurrentlyListeningTo={},this.isTopLevelComponent=!1,this._xOffset=0,this._yOffset=0,this._xAlignProportion=0,this._yAlignProportion=0,this.cssClasses=["component"],this._isSetup=!1,this._isAnchored=!1}return __extends(i,e),i.prototype._anchor=function(t){return"svg"===t.node().nodeName&&(this.rootSVG=t,this.rootSVG.classed("plottable",!0),this.rootSVG.style("overflow","visible"),this.isTopLevelComponent=!0),null!=this.element?t.node().appendChild(this.element.node()):(this.element=t.append("g"),this._setup()),this._isAnchored=!0,this},i.prototype._setup=function(){var t=this;return this.cssClasses.forEach(function(e){t.element.classed(e,!0)}),this.cssClasses=null,this.backgroundContainer=this.element.append("g").classed("background-container",!0),this.content=this.element.append("g").classed("content",!0),this.foregroundContainer=this.element.append("g").classed("foreground-container",!0),this.boxContainer=this.element.append("g").classed("box-container",!0),this.clipPathEnabled&&this.generateClipPath(),this.addBox("bounding-box"),this.interactionsToRegister.forEach(function(e){return t.registerInteraction(e)}),this.interactionsToRegister=null,this._isSetup=!0,this},i.prototype._requestedSpace=function(){return{width:0,height:0,wantsWidth:!1,wantsHeight:!1}},i.prototype._computeLayout=function(e,i,n,r){var o=this;if(null==e||null==i||null==n||null==r){if(null==this.element)throw new Error("anchor must be called before computeLayout");if(!this.isTopLevelComponent)throw new Error("null arguments cannot be passed to _computeLayout() on a non-root node");e=0,i=0,null==this.rootSVG.attr("width")&&this.rootSVG.attr("width","100%"),null==this.rootSVG.attr("height")&&this.rootSVG.attr("height","100%");var a=this.rootSVG.node();n=t.Utils.getElementWidth(a),r=t.Utils.getElementHeight(a)}this.xOrigin=e,this.yOrigin=i;var s=this.xOrigin,l=this.yOrigin,h=this._requestedSpace(n,r);return s+=(n-h.width)*this._xAlignProportion,s+=this._xOffset,this.isFixedWidth()&&(n=Math.min(n,h.width)),l+=(r-h.height)*this._yAlignProportion,l+=this._yOffset,this.isFixedHeight()&&(r=Math.min(r,h.height)),this.availableWidth=n,this.availableHeight=r,this.element.attr("transform","translate("+s+","+l+")"),this.boxes.forEach(function(t){return t.attr("width",o.availableWidth).attr("height",o.availableHeight)}),this},i.prototype._render=function(){return this._isAnchored&&this._isSetup&&t.RenderController.registerToRender(this),this},i.prototype._scheduleComputeLayout=function(){return this._isAnchored&&this._isSetup&&t.RenderController.registerToComputeLayout(this),this},i.prototype._doRender=function(){return this},i.prototype._invalidateLayout=function(){this._isAnchored&&this._isSetup&&(this.isTopLevelComponent?this._scheduleComputeLayout():this._parent._invalidateLayout())},i.prototype.renderTo=function(t){if(null!=t){var e;e="function"==typeof t.node?t:d3.select(t),this._anchor(e)}return this._computeLayout()._render(),this},i.prototype.resize=function(t,e){return null!=this.element&&this._computeLayout(t,e)._render(),this},i.prototype.xAlign=function(t){if(t=t.toLowerCase(),"left"===t)this._xAlignProportion=0;else if("center"===t)this._xAlignProportion=.5;else{if("right"!==t)throw new Error("Unsupported alignment");this._xAlignProportion=1}return this._invalidateLayout(),this},i.prototype.yAlign=function(t){if(t=t.toLowerCase(),"top"===t)this._yAlignProportion=0;else if("center"===t)this._yAlignProportion=.5;else{if("bottom"!==t)throw new Error("Unsupported alignment");this._yAlignProportion=1}return this._invalidateLayout(),this},i.prototype.xOffset=function(t){return this._xOffset=t,this._invalidateLayout(),this},i.prototype.yOffset=function(t){return this._yOffset=t,this._invalidateLayout(),this},i.prototype.addBox=function(t,e){if(null==this.element)throw new Error("Adding boxes before anchoring is currently disallowed");var e=null==e?this.boxContainer:e,i=e.append("rect");return null!=t&&i.classed(t,!0),this.boxes.push(i),null!=this.availableWidth&&null!=this.availableHeight&&i.attr("width",this.availableWidth).attr("height",this.availableHeight),i},i.prototype.generateClipPath=function(){this.element.attr("clip-path","url(#clipPath"+this._plottableID+")");var t=this.boxContainer.append("clipPath").attr("id","clipPath"+this._plottableID);this.addBox("clip-rect",t)},i.prototype.registerInteraction=function(t){return null!=this.element?(null==this.hitBox&&(this.hitBox=this.addBox("hit-box"),this.hitBox.style("fill","#ffffff").style("opacity",0)),t._anchor(this.hitBox)):this.interactionsToRegister.push(t),this},i.prototype._registerToBroadcaster=function(t,e){t.registerListener(this,e),this.broadcastersCurrentlyListeningTo[t._plottableID]=t},i.prototype._deregisterFromBroadcaster=function(t){t.deregisterListener(this),delete this.broadcastersCurrentlyListeningTo[t._plottableID]},i.prototype.classed=function(t,e){if(null==e)return null==t?!1:null==this.element?-1!==this.cssClasses.indexOf(t):this.element.classed(t);if(null==t)return this;if(null==this.element){var i=this.cssClasses.indexOf(t);e&&-1===i?this.cssClasses.push(t):e||-1===i||this.cssClasses.splice(i,1)}else this.element.classed(t,e);return this},i.prototype.isFixedWidth=function(){return this._requestedSpace(-1,-1).wantsWidth},i.prototype.isFixedHeight=function(){return this._requestedSpace(-1,-1).wantsHeight},i.prototype.merge=function(e){var i;if(this._isSetup||this._isAnchored)throw new Error("Can't presently merge a component that's already been anchored");return t.ComponentGroup.prototype.isPrototypeOf(e)?(i=e,i._addComponent(this,!0),i):i=new t.ComponentGroup([this,e])},i.prototype.remove=function(){return this._isAnchored&&this.element.remove(),null!=this._parent&&this._parent._removeComponent(this),this._isAnchored=!1,this._parent=null,this},i}(t.PlottableObject);t.Component=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(){t.apply(this,arguments),this._components=[]}return __extends(e,t),e.prototype._anchor=function(e){var i=this;return t.prototype._anchor.call(this,e),this._components.forEach(function(t){return t._anchor(i.content)}),this},e.prototype._removeComponent=function(t){var e=this._components.indexOf(t);return e>=0&&(this._components.splice(e,1),this._invalidateLayout()),this},e.prototype._addComponent=function(t,e){return"undefined"==typeof e&&(e=!1),null==t?this:(e?this._components.unshift(t):this._components.push(t),t._parent=this,this._isAnchored&&t._anchor(this.content),this._invalidateLayout(),this)},e.prototype.components=function(){return this._components},e.prototype.empty=function(){return 0===this._components.length},e.prototype.removeAll=function(){return this._components.slice().forEach(function(t){return t.remove()}),this},e}(t.Component);t.ComponentContainer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){"undefined"==typeof e&&(e=[]);var i=this;t.call(this),this.classed("component-group",!0),e.forEach(function(t){return i._addComponent(t)})}return __extends(e,t),e.prototype._requestedSpace=function(t,e){var i=this._components.map(function(i){return i._requestedSpace(t,e)}),n=this.empty(),r=n?0:d3.max(i,function(t){return t.width}),o=n?0:d3.max(i,function(t){return t.height});return{width:Math.min(r,t),height:Math.min(o,e),wantsWidth:n?!1:i.map(function(t){return t.wantsWidth}).some(function(t){return t}),wantsHeight:n?!1:i.map(function(t){return t.wantsHeight}).some(function(t){return t})}},e.prototype.merge=function(t){return this._addComponent(t),this},e.prototype._computeLayout=function(e,i,n,r){var o=this;return t.prototype._computeLayout.call(this,e,i,n,r),this._components.forEach(function(t){t._computeLayout(0,0,o.availableWidth,o.availableHeight)}),this},e.prototype._doRender=function(){return t.prototype._doRender.call(this),this._components.forEach(function(t){return t._doRender()}),this},e.prototype.isFixedWidth=function(){return this._components.every(function(t){return t.isFixedWidth()})},e.prototype.isFixedHeight=function(){return this._components.every(function(t){return t.isFixedHeight()})},e}(t.ComponentContainer);t.ComponentGroup=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t){"undefined"==typeof t&&(t=[]);var i=this;e.call(this),this.rowPadding=0,this.colPadding=0,this.rows=[],this.rowWeights=[],this.colWeights=[],this.nRows=0,this.nCols=0,this.classed("table",!0),t.forEach(function(t,e){t.forEach(function(t,n){i.addComponent(e,n,t)})})}return __extends(i,e),i.prototype.addComponent=function(t,e,i){this.nRows=Math.max(t+1,this.nRows),this.nCols=Math.max(e+1,this.nCols),this.padTableToSize(this.nRows,this.nCols);var n=this.rows[t][e];if(null!=n)throw new Error("Table.addComponent cannot be called on a cell where a component already exists (for the moment)");return this.rows[t][e]=i,this._addComponent(i),this},i.prototype._removeComponent=function(){throw new Error("_removeComponent not yet implemented on Table")},i.prototype.iterateLayout=function(e,n){for(var r,o,a=d3.transpose(this.rows),s=e-this.colPadding*(this.nCols-1),l=n-this.rowPadding*(this.nRows-1),h=i.calcComponentWeights(this.rowWeights,this.rows,function(t){return null==t||t.isFixedHeight()}),c=i.calcComponentWeights(this.colWeights,a,function(t){return null==t||t.isFixedWidth()}),u=c.map(function(t){return 0===t?.5:t}),d=h.map(function(t){return 0===t?.5:t}),p=i.calcProportionalSpace(u,s),f=i.calcProportionalSpace(d,l),y=t.Utils.createFilledArray(0,this.nCols),_=t.Utils.createFilledArray(0,this.nRows),g=0;;){var m=t.Utils.addArrays(_,f),x=t.Utils.addArrays(y,p),b=this.determineGuarantees(x,m);y=b.guaranteedWidths,_=b.guaranteedHeights;var v=b.wantsWidthArr.some(function(t){return t}),S=b.wantsHeightArr.some(function(t){return t}),P=r,w=o;r=s-d3.sum(b.guaranteedWidths),o=l-d3.sum(b.guaranteedHeights);var A;A=v?b.wantsWidthArr.map(function(t){return t?1:0}):c;var C;C=S?b.wantsHeightArr.map(function(t){return t?1:0}):h,p=i.calcProportionalSpace(A,r),f=i.calcProportionalSpace(C,o),g++;var L=r>0&&v&&r!==P,E=o>0&&S&&o!==w;if(!L&&!E)break;if(g>5){console.log("More than 5 iterations in Table.iterateLayout; please report the circumstances");break}}return r=s-d3.sum(b.guaranteedWidths),o=l-d3.sum(b.guaranteedHeights),p=i.calcProportionalSpace(c,r),f=i.calcProportionalSpace(h,o),{colProportionalSpace:p,rowProportionalSpace:f,guaranteedWidths:b.guaranteedWidths,guaranteedHeights:b.guaranteedHeights,wantsWidth:v,wantsHeight:S}},i.prototype.determineGuarantees=function(e,i){var n=t.Utils.createFilledArray(0,this.nCols),r=t.Utils.createFilledArray(0,this.nRows),o=t.Utils.createFilledArray(!1,this.nCols),a=t.Utils.createFilledArray(!1,this.nRows);return this.rows.forEach(function(t,s){t.forEach(function(t,l){var h;if(h=null!=t?t._requestedSpace(e[l],i[s]):{width:0,height:0,wantsWidth:!1,wantsHeight:!1},h.width>e[l]||h.height>i[s])throw new Error("Invariant Violation: Component cannot request more space than is offered");n[l]=Math.max(n[l],h.width),r[s]=Math.max(r[s],h.height),o[l]=o[l]||h.wantsWidth,a[s]=a[s]||h.wantsHeight})}),{guaranteedWidths:n,guaranteedHeights:r,wantsWidthArr:o,wantsHeightArr:a}},i.prototype._requestedSpace=function(t,e){var i=this.iterateLayout(t,e);return{width:d3.sum(i.guaranteedWidths),height:d3.sum(i.guaranteedHeights),wantsWidth:i.wantsWidth,wantsHeight:i.wantsHeight}},i.prototype._computeLayout=function(i,n,r,o){var a=this;e.prototype._computeLayout.call(this,i,n,r,o);var s=this.iterateLayout(this.availableWidth,this.availableHeight),l=t.Utils.addArrays(s.rowProportionalSpace,s.guaranteedHeights),h=t.Utils.addArrays(s.colProportionalSpace,s.guaranteedWidths),c=0;return this.rows.forEach(function(t,e){var i=0;t.forEach(function(t,n){null!=t&&t._computeLayout(i,c,h[n],l[e]),i+=h[n]+a.colPadding}),c+=l[e]+a.rowPadding}),this},i.prototype._doRender=function(){return this.rows.forEach(function(t){t.forEach(function(t){null!=t&&t._doRender()})}),this},i.prototype.padding=function(t,e){return this.rowPadding=t,this.colPadding=e,this._invalidateLayout(),this},i.prototype.rowWeight=function(t,e){return this.rowWeights[t]=e,this._invalidateLayout(),this},i.prototype.colWeight=function(t,e){return this.colWeights[t]=e,this._invalidateLayout(),this},i.prototype.isFixedWidth=function(){var t=d3.transpose(this.rows);return i.fixedSpace(t,function(t){return null==t||t.isFixedWidth()})},i.prototype.isFixedHeight=function(){return i.fixedSpace(this.rows,function(t){return null==t||t.isFixedHeight()})},i.prototype.padTableToSize=function(t,e){for(var i=0;t>i;i++){void 0===this.rows[i]&&(this.rows[i]=[],this.rowWeights[i]=null);for(var n=0;e>n;n++)void 0===this.rows[i][n]&&(this.rows[i][n]=null)}for(n=0;e>n;n++)void 0===this.colWeights[n]&&(this.colWeights[n]=null)},i.calcComponentWeights=function(t,e,i){return t.map(function(t,n){if(null!=t)return t;var r=e[n].map(i),o=r.reduce(function(t,e){return t&&e});return o?0:1})},i.calcProportionalSpace=function(e,i){var n=d3.sum(e);return 0===n?t.Utils.createFilledArray(0,e.length):e.map(function(t){return i*t/n})},i.fixedSpace=function(t,e){var i=function(t){return t.reduce(function(t,e){return t&&e})},n=function(t){return i(t.map(e))};return i(t.map(n))},i}(t.ComponentContainer);t.Table=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(i){e.call(this),this._autoDomain=!0,this.rendererID2Perspective={},this.dataSourceReferenceCounter=new t.Utils.IDCounter,this._autoNice=!1,this._autoPad=!1,this._d3Scale=i}return __extends(i,e),i.prototype._getAllExtents=function(){var t=d3.values(this.rendererID2Perspective),e=t.map(function(t){var e=t.dataSource,i=t.accessor;return e._getExtent(i)}).filter(function(t){return null!=t});return e},i.prototype._getExtent=function(){return[]},i.prototype.autoDomain=function(){return this._setDomain(this._getExtent()),this},i.prototype._addPerspective=function(t,e,i){var n=this;null!=this.rendererID2Perspective[t]&&this._removePerspective(t),this.rendererID2Perspective[t]={dataSource:e,accessor:i};var r=e._plottableID;return 1===this.dataSourceReferenceCounter.increment(r)&&e.registerListener(this,function(){n._autoDomain&&n.autoDomain()}),this._autoDomain&&this.autoDomain(),this},i.prototype._removePerspective=function(t){var e=this.rendererID2Perspective[t].dataSource,i=e._plottableID;return 0===this.dataSourceReferenceCounter.decrement(i)&&e.deregisterListener(this),delete this.rendererID2Perspective[t],this._autoDomain&&this.autoDomain(),this},i.prototype.scale=function(t){return this._d3Scale(t)},i.prototype.domain=function(t){return null==t?this._d3Scale.domain():(this._autoDomain=!1,this._setDomain(t),this)},i.prototype._setDomain=function(t){this._d3Scale.domain(t),this._broadcast()},i.prototype.range=function(t){return null==t?this._d3Scale.range():(this._d3Scale.range(t),this)},i.prototype.copy=function(){return new i(this._d3Scale.copy())},i}(t.Broadcaster);t.Scale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(i){e.call(this),this._animate=!1,this._hasRendered=!1,this._projectors={},this._rerenderUpdateSelection=!1,this._requireRerender=!1,this.clipPathEnabled=!0,this.classed("renderer",!0);var n;n=null!=i?"function"==typeof i.data?i:n=new t.DataSource(i):new t.DataSource,this.dataSource(n)}return __extends(i,e),i.prototype.dataSource=function(t){var e=this;if(null==t)return this._dataSource;if(null==this._dataSource)return this._dataSource=t,this._registerToBroadcaster(this._dataSource,function(){return e._render()}),this;throw new Error("Can't set a new DataSource on the Renderer if it already has one.")},i.prototype.project=function(t,e,i){var n=this,r=this._plottableID+t,o=this._projectors[t],a=null!=o?o.scale:null;return null==i&&(i=a),null!=a&&(a._removePerspective(r),this._deregisterFromBroadcaster(a)),null!=i&&(i._addPerspective(r,this.dataSource(),e),this._registerToBroadcaster(i,function(){return n._render()})),this._projectors[t]={accessor:e,scale:i},this._requireRerender=!0,this._rerenderUpdateSelection=!0,this},i.prototype._generateAttrToProjector=function(){var e=this,i={};return d3.keys(this._projectors).forEach(function(n){var r=e._projectors[n],o=t.Utils.applyAccessor(r.accessor,e.dataSource()),a=r.scale,s=null==a?o:function(t,e){return a.scale(o(t,e))};i[n]=s}),i},i.prototype._doRender=function(){return null!=this.element&&(this._hasRendered=!0,this._paint(),this._requireRerender=!1,this._rerenderUpdateSelection=!1),this},i.prototype._paint=function(){},i.prototype._setup=function(){return e.prototype._setup.call(this),this.renderArea=this.content.append("g").classed("render-area",!0),this},i.prototype.animate=function(t){return null==t&&(t=!this._animate),this._animate=t,this},i.DEFAULT_COLOR_ACCESSOR=function(){return"#1f77b4"},i}(t.Component);t.Renderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(){function e(){}return e.registerToRender=function(i){return t.RenderController.enabled?(e.componentsNeedingRender[i._plottableID]=i,void e.requestFrame()):void i._doRender()},e.registerToComputeLayout=function(i){return t.RenderController.enabled?(e.componentsNeedingComputeLayout[i._plottableID]=i,e.componentsNeedingRender[i._plottableID]=i,void e.requestFrame()):void i._computeLayout()._render()},e.requestFrame=function(){e.animationRequested||(requestAnimationFrame(e.doRender),e.animationRequested=!0)},e.doRender=function(){var t=d3.values(e.componentsNeedingComputeLayout);t.forEach(function(t){return t._computeLayout()});var i=d3.values(e.componentsNeedingRender);i.forEach(function(t){return t._doRender()}),e.componentsNeedingComputeLayout={},e.componentsNeedingRender={},e.animationRequested=!1},e.componentsNeedingRender={},e.componentsNeedingComputeLayout={},e.animationRequested=!1,e.enabled=null==window.PlottableTestCode&&null!=window.requestAnimationFrame,e}();t.RenderController=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){t.call(this,e),this.lastRequestedTickCount=10}return __extends(e,t),e.prototype._getExtent=function(){var t=this._getAllExtents(),e=t.map(function(t){return t[0]}),i=t.map(function(t){return t[1]});return e.length>0?[d3.min(e),d3.max(i)]:[0,1]},e.prototype.autoDomain=function(){return t.prototype.autoDomain.call(this),this._autoPad&&this.padDomain(),this._autoNice&&this.nice(),this},e.prototype.invert=function(t){return this._d3Scale.invert(t)},e.prototype.copy=function(){return new e(this._d3Scale.copy())},e.prototype.domain=function(e){return t.prototype.domain.call(this,e)},e.prototype.interpolate=function(t){return null==t?this._d3Scale.interpolate():(this._d3Scale.interpolate(t),this)},e.prototype.rangeRound=function(t){return this._d3Scale.rangeRound(t),this},e.prototype.clamp=function(t){return null==t?this._d3Scale.clamp():(this._d3Scale.clamp(t),this)},e.prototype.nice=function(t){return this._d3Scale.nice(t),this._setDomain(this._d3Scale.domain()),this},e.prototype.ticks=function(t){return null!=t&&(this.lastRequestedTickCount=t),this._d3Scale.ticks(this.lastRequestedTickCount)},e.prototype.tickFormat=function(t,e){return this._d3Scale.tickFormat(t,e)},e.prototype.padDomain=function(t){"undefined"==typeof t&&(t=.05);var e=this.domain(),i=e[1]-e[0],n=[e[0]-t/2*i,e[1]+t/2*i];return 0===e[0]&&(n[0]=0),0===e[1]&&(n[1]=0),this._setDomain(n),this},e}(t.Scale);t.QuantitiveScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){t.call(this,null==e?d3.scale.linear():e)}return __extends(e,t),e.prototype.copy=function(){return new e(this._d3Scale.copy())},e}(t.QuantitiveScale);t.LinearScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){t.call(this,null==e?d3.scale.log():e)}return __extends(e,t),e.prototype.copy=function(){return new e(this._d3Scale.copy())},e}(t.QuantitiveScale);t.LogScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t){e.call(this,null==t?d3.scale.ordinal():t),this._range=[0,1],this._rangeType="points",this._innerPadding=.3,this._outerPadding=.5}return __extends(i,e),i.prototype._getExtent=function(){var e=this._getAllExtents(),i=[];return e.forEach(function(t){i=i.concat(t)}),t.Utils.uniq(i)},i.prototype.domain=function(t){return e.prototype.domain.call(this,t)},i.prototype._setDomain=function(t){e.prototype._setDomain.call(this,t),this.range(this.range())},i.prototype.range=function(t){return null==t?this._range:(this._range=t,"points"===this._rangeType?this._d3Scale.rangePoints(t,2*this._outerPadding):"bands"===this._rangeType&&this._d3Scale.rangeBands(t,this._innerPadding,this._outerPadding),this)},i.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},i.prototype.rangeType=function(t,e,i){if(null==t)return this._rangeType;if("points"!==t&&"bands"!==t)throw new Error("Unsupported range type: "+t);return this._rangeType=t,null!=e&&(this._outerPadding=e),null!=i&&(this._innerPadding=i),this},i}(t.Scale);t.OrdinalScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t){var i;switch(t){case"Category10":case"category10":case"10":i=d3.scale.category10();break;case"Category20":case"category20":case"20":i=d3.scale.category20();break;case"Category20b":case"category20b":case"20b":i=d3.scale.category20b();break;case"Category20c":case"category20c":case"20c":i=d3.scale.category20c();break;case null:case void 0:i=d3.scale.ordinal();break;default:throw new Error("Unsupported ColorScale type")}e.call(this,i)}return __extends(i,e),i.prototype._getExtent=function(){var e=this._getAllExtents(),i=[];return e.forEach(function(t){i=i.concat(t)}),t.Utils.uniq(i)},i}(t.Scale);t.ColorScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(){t.call(this,d3.time.scale())}return __extends(e,t),e}(t.QuantitiveScale);t.TimeScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(i,n){"undefined"==typeof i&&(i="reds"),"undefined"==typeof n&&(n="linear"),this._colorRange=this._resolveColorValues(i),this._scaleType=n,t.call(this,e.getD3InterpolatedScale(this._colorRange,this._scaleType))}return __extends(e,t),e.getD3InterpolatedScale=function(t,i){var n;switch(i){case"linear":n=d3.scale.linear();break;case"log":n=d3.scale.log();break;case"sqrt":n=d3.scale.sqrt();break;case"pow":n=d3.scale.pow()}if(null==n)throw new Error("unknown quantitive scale type "+i);return n.range([0,1]).interpolate(e.interpolateColors(t))},e.interpolateColors=function(t){if(t.length<2)throw new Error("Color scale arrays must have at least two elements.");return function(){return function(e){e=Math.max(0,Math.min(1,e));var i=e*(t.length-1),n=Math.floor(i),r=Math.ceil(i),o=i-n;return d3.interpolateLab(t[n],t[r])(o)}}},e.prototype.colorRange=function(t){return null==t?this._colorRange:(this._colorRange=this._resolveColorValues(t),void this._resetScale())},e.prototype.scaleType=function(t){return null==t?this._scaleType:(this._scaleType=t,void this._resetScale())},e.prototype._resetScale=function(){this._d3Scale=e.getD3InterpolatedScale(this._colorRange,this._scaleType),this._autoDomain&&this.autoDomain(),this._broadcast()},e.prototype._resolveColorValues=function(t){return t instanceof Array?t:null!=e.COLOR_SCALES[t]?e.COLOR_SCALES[t]:e.COLOR_SCALES.reds},e.COLOR_SCALES={reds:["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],blues:["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],posneg:["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"]},e}(t.QuantitiveScale);t.InterpolatedColorScale=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(){function t(t){var e=this;this.rescaleInProgress=!1,this.scales=t,this.scales.forEach(function(t){return t.registerListener(e,function(t){return e.rescale(t)})})}return t.prototype.rescale=function(t){if(!this.rescaleInProgress){this.rescaleInProgress=!0;var e=t.domain();this.scales.forEach(function(t){return t.domain(e)}),this.rescaleInProgress=!1}},t}();t.ScaleDomainCoordinator=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t,i){if("undefined"==typeof t&&(t=""),"undefined"==typeof i&&(i="horizontal"),e.call(this),this.classed("label",!0),this.setText(t),i=i.toLowerCase(),"horizontal"!==i&&"vertical-left"!==i&&"vertical-right"!==i)throw new Error(i+" is not a valid orientation for LabelComponent");this.orientation=i,this.xAlign("CENTER").yAlign("CENTER")}return __extends(i,e),i.prototype._requestedSpace=function(t,e){var i,n;return"horizontal"===this.orientation?(i=this.textLength,n=this.textHeight):(i=this.textHeight,n=this.textLength),{width:Math.min(i,t),height:Math.min(n,e),wantsWidth:i>t,wantsHeight:n>e}},i.prototype._setup=function(){return e.prototype._setup.call(this),this.textElement=this.content.append("text"),this.setText(this.text),this},i.prototype.setText=function(t){return this.text=t,null!=this.element&&(this.textElement.text(t),this.measureAndSetTextSize()),this._invalidateLayout(),this},i.prototype.measureAndSetTextSize=function(){var e=t.Utils.getBBox(this.textElement);this.textHeight=e.height,this.textLength=""===this.text?0:e.width},i.prototype.truncateTextAndRemeasure=function(e){var i=t.Utils.getTruncatedText(this.text,e,this.textElement);this.textElement.text(i),this.measureAndSetTextSize()},i.prototype._computeLayout=function(i,n,r,o){e.prototype._computeLayout.call(this,i,n,r,o),this.textElement.attr("dy",0);var a=t.Utils.getBBox(this.textElement);this.textElement.attr("dy",-a.y);var s=0,l=0;
  return"horizontal"===this.orientation?(this.truncateTextAndRemeasure(this.availableWidth),s=(this.availableWidth-this.textLength)*this._xAlignProportion):(this.truncateTextAndRemeasure(this.availableHeight),s=(this.availableHeight-this.textLength)*this._yAlignProportion,"vertical-right"===this.orientation?(this.textElement.attr("transform","rotate(90)"),l=-this.textHeight):(this.textElement.attr("transform","rotate(-90)"),s=-s-this.textLength)),this.textElement.attr("x",s),this.textElement.attr("y",l),this},i}(t.Component);t.Label=e;var i=function(t){function e(e,i){t.call(this,e,i),this.classed("title-label",!0)}return __extends(e,t),e}(e);t.TitleLabel=i;var n=function(t){function e(e,i){t.call(this,e,i),this.classed("axis-label",!0)}return __extends(e,t),e}(e);t.AxisLabel=n}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t){e.call(this),this.classed("legend",!0),this.scale(t),this.xAlign("RIGHT").yAlign("TOP"),this.xOffset(5).yOffset(5)}return __extends(i,e),i.prototype._setup=function(){return e.prototype._setup.call(this),this.legendBox=this.content.append("rect").classed("legend-box",!0),this},i.prototype.scale=function(t){var e=this;return null!=t?(null!=this.colorScale&&this._deregisterFromBroadcaster(this.colorScale),this.colorScale=t,this._registerToBroadcaster(this.colorScale,function(){return e._invalidateLayout()}),this):this.colorScale},i.prototype._computeLayout=function(t,i,n,r){e.prototype._computeLayout.call(this,t,i,n,r);var o=this.measureTextHeight(),a=this.colorScale.domain().length;return this.nRowsDrawn=Math.min(a,Math.floor(this.availableHeight/o)),this},i.prototype._requestedSpace=function(e,n){var r=this.measureTextHeight(),o=this.colorScale.domain().length,a=Math.min(o,Math.floor(n/r)),s=this.content.append("g").classed(i.SUBELEMENT_CLASS,!0),l=s.append("text"),h=d3.max(this.colorScale.domain(),function(e){return t.Utils.getTextWidth(l,e)});s.remove(),h=void 0===h?0:h;var c=h+r+i.MARGIN;return{width:Math.min(c,e),height:a*r,wantsWidth:c>e,wantsHeight:o>a}},i.prototype.measureTextHeight=function(){var e=this.content.append("g").classed(i.SUBELEMENT_CLASS,!0),n=t.Utils.getTextHeight(e.append("text"));return e.remove(),n},i.prototype._doRender=function(){e.prototype._doRender.call(this);var n=this.colorScale.domain().slice(0,this.nRowsDrawn),r=this.measureTextHeight(),o=this.availableWidth-r-i.MARGIN,a=r-2*i.MARGIN-2;this.content.selectAll("."+i.SUBELEMENT_CLASS).remove();var s=this.content.selectAll("."+i.SUBELEMENT_CLASS).data(n),l=s.enter().append("g").classed(i.SUBELEMENT_CLASS,!0).attr("transform",function(t,e){return"translate(0,"+e*r+")"});return l.append("circle").attr("cx",i.MARGIN+a/2).attr("cy",i.MARGIN+a/2).attr("r",a),l.append("text").attr("x",r).attr("y",i.MARGIN+r/2),s.selectAll("circle").attr("fill",this.colorScale._d3Scale),s.selectAll("text").text(function(e){return t.Utils.getTruncatedText(e,o,d3.select(this))}),this},i.SUBELEMENT_CLASS="legend-row",i.MARGIN=5,i}(t.Component);t.Legend=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){t.call(this,e),this.classed("xy-renderer",!0),this.project("x","x",i),this.project("y","y",n)}return __extends(e,t),e.prototype.project=function(e,i,n){return t.prototype.project.call(this,e,i,n),"x"===e&&(this._xAccessor=this._projectors.x.accessor,this.xScale=this._projectors.x.scale,this.xScale._autoNice=!0,this.xScale._autoPad=!0),"y"===e&&(this._yAccessor=this._projectors.y.accessor,this.yScale=this._projectors.y.scale,this.yScale._autoNice=!0,this.yScale._autoPad=!0),this},e.prototype._computeLayout=function(e,i,n,r){return this._hasRendered=!1,t.prototype._computeLayout.call(this,e,i,n,r),this.xScale.range([0,this.availableWidth]),this.yScale.range([this.availableHeight,0]),this},e.prototype.rescale=function(){null!=this.element&&this._hasRendered&&this._render()},e}(t.Renderer);t.XYRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n),this.classed("circle-renderer",!0),this.project("r",3),this.project("fill",function(){return"steelblue"})}return __extends(e,t),e.prototype.project=function(e,i,n){return e="cx"===e?"x":e,e="cy"===e?"y":e,t.prototype.project.call(this,e,i,n),this},e.prototype._paint=function(){t.prototype._paint.call(this);var e=this._generateAttrToProjector();e.cx=e.x,e.cy=e.y,delete e.x,delete e.y,this.dataSelection=this.renderArea.selectAll("circle").data(this._dataSource.data()),this.dataSelection.enter().append("circle"),this.dataSelection.attr(e),this.dataSelection.exit().remove()},e}(t.XYRenderer);t.CircleRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n),this.classed("line-renderer",!0),this.project("stroke",function(){return"steelblue"})}return __extends(e,t),e.prototype._setup=function(){return t.prototype._setup.call(this),this.path=this.renderArea.append("path").classed("line",!0),this},e.prototype._paint=function(){t.prototype._paint.call(this);var e=this._generateAttrToProjector();this.line=d3.svg.line().x(e.x).y(e.y),this.dataSelection=this.path.datum(this._dataSource.data()),delete e.x,delete e.y,this.path.attr("d",this.line).attr(e)},e}(t.XYRenderer);t.LineRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n),this.classed("rect-renderer",!0),this.project("width",4),this.project("height",4),this.project("fill",function(){return"steelblue"})}return __extends(e,t),e.prototype._paint=function(){t.prototype._paint.call(this);var e=this._generateAttrToProjector(),i=e.x,n=e.y,r=e.width,o=e.height;e.x=function(t,e){return i(t,e)-r(t,e)/2},e.y=function(t,e){return n(t,e)-o(t,e)/2},this.dataSelection=this.renderArea.selectAll("rect").data(this._dataSource.data()),this.dataSelection.enter().append("rect"),this.dataSelection.attr(e),this.dataSelection.exit().remove()},e}(t.XYRenderer);t.RectRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n,r){t.call(this,e,i,n),this.classed("grid-renderer",!0),this.xScale.rangeType("bands",0,0),this.yScale.rangeType("bands",0,0),this.colorScale=r,this.project("fill","value",r)}return __extends(e,t),e.prototype.project=function(e,i,n){return t.prototype.project.call(this,e,i,n),"fill"===e&&(this.colorScale=this._projectors.fill.scale),this},e.prototype._paint=function(){t.prototype._paint.call(this),this.dataSelection=this.renderArea.selectAll("rect").data(this._dataSource.data()),this.dataSelection.enter().append("rect");var e=this.xScale.rangeBand(),i=this.yScale.rangeBand(),n=this._generateAttrToProjector();n.width=function(){return e},n.height=function(){return i},this.dataSelection.attr(n),this.dataSelection.exit().remove()},e}(t.XYRenderer);t.GridRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n),this._baselineValue=0,this.classed("bar-renderer",!0),this.project("width",10)}return __extends(e,t),e.prototype.baseline=function(t){return this._baselineValue=t,null!=this.element&&this._render(),this},e.prototype.barAlignment=function(){return this},e.prototype.selectBar=function(t,e,i){"undefined"==typeof i&&(i=!0);var n=null;return this.dataSelection.each(function(){var i=this.getBBox();i.x<=t&&t<=i.x+i.width&&i.y<=e&&e<=i.y+i.height&&(n=d3.select(this))}),null!=n&&n.classed("selected",i),n},e.prototype.deselectAll=function(){return this.dataSelection.classed("selected",!1),this},e}(t.XYRenderer);t.AbstractBarRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t,i,n){e.call(this,t,i,n),this._barAlignment="left"}return __extends(i,e),i.prototype._paint=function(){e.prototype._paint.call(this);var i=this.yScale.scale(this._baselineValue),n=t.Utils.applyAccessor(this._xAccessor,this.dataSource());this.dataSelection=this.renderArea.selectAll("rect").data(this._dataSource.data(),n),this.dataSelection.enter().append("rect");var r=this._generateAttrToProjector(),o=r.x,a=r.width,s=this.xScale,l=null==s.rangeType?"points":s.rangeType();"points"===l?"center"===this._barAlignment?r.x=function(t,e){return o(t,e)-a(t,e)/2}:"right"===this._barAlignment&&(r.x=function(t,e){return o(t,e)-a(t,e)}):r.width=function(){return s.rangeBand()};var h=r.y;r.y=function(t,e){var n=h(t,e);return n>i?i:n};var c=function(t,e){return Math.abs(i-h(t,e))};r.height=c,null!=r.fill&&this.dataSelection.attr("fill",r.fill),null==this._baseline&&(this._baseline=this.renderArea.append("line").classed("baseline",!0));var u=this.dataSelection,d=this._baseline;this._animate&&(u=u.transition(),d=d.transition()),u.attr(r),this.dataSelection.exit().remove(),d.attr({x1:0,y1:i,x2:this.availableWidth,y2:i})},i.prototype.barAlignment=function(t){var e=t.toLowerCase();if("left"!==e&&"center"!==e&&"right"!==e)throw new Error("unsupported bar alignment");return this._barAlignment=e,null!=this.element&&this._render(),this},i}(t.AbstractBarRenderer);t.BarRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t,i,n){e.call(this,t,i,n),this._barAlignment="top"}return __extends(i,e),i.prototype._paint=function(){e.prototype._paint.call(this);var i=t.Utils.applyAccessor(this._yAccessor,this.dataSource());this.dataSelection=this.renderArea.selectAll("rect").data(this._dataSource.data(),i),this.dataSelection.enter().append("rect");var n=this._generateAttrToProjector(),r=n.y;n.height=n.width;var o=n.height,a=this.yScale,s=null==a.rangeType?"points":a.rangeType();"points"===s?"middle"===this._barAlignment?n.y=function(t,e){return r(t,e)-o(t,e)/2}:"bottom"===this._barAlignment&&(n.y=function(t,e){return r(t,e)-o(t,e)}):n.height=function(){return a.rangeBand()};var l=this.xScale.scale(this._baselineValue),h=n.x;n.x=function(t,e){var i=h(t,e);return i>l?l:i};var c=function(t,e){return Math.abs(l-h(t,e))};n.width=c,null!=n.fill&&this.dataSelection.attr("fill",n.fill),null==this._baseline&&(this._baseline=this.renderArea.append("line").classed("baseline",!0));var u=this.dataSelection,d=this._baseline;this._animate&&(u=u.transition(),d=d.transition()),u.attr(n),this.dataSelection.exit().remove(),d.attr({x1:l,y1:0,x2:l,y2:this.availableHeight})},i.prototype.barAlignment=function(t){var e=t.toLowerCase();if("top"!==e&&"middle"!==e&&"bottom"!==e)throw new Error("unsupported bar alignment");return this._barAlignment=e,null!=this.element&&this._render(),this},i}(t.AbstractBarRenderer);t.HorizontalBarRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(){function t(){}return t.initialize=function(){t.initialized||(d3.select(document).on("keydown",t.processEvent),t.initialized=!0)},t.addCallback=function(e,i){t.initialized||t.initialize(),null==t.callbacks[e]&&(t.callbacks[e]=[]),t.callbacks[e].push(i)},t.processEvent=function(){null!=t.callbacks[d3.event.keyCode]&&t.callbacks[d3.event.keyCode].forEach(function(t){t(d3.event)})},t.initialized=!1,t.callbacks=[],t}();t.KeyEventListener=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(){function t(t){this.componentToListenTo=t}return t.prototype._anchor=function(t){this.hitBox=t},t.prototype.registerWithComponent=function(){return this.componentToListenTo.registerInteraction(this),this},t}();t.Interaction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){t.call(this,e)}return __extends(e,t),e.prototype._anchor=function(e){var i=this;t.prototype._anchor.call(this,e),e.on("click",function(){var t=d3.mouse(e.node()),n=t[0],r=t[1];i._callback(n,r)})},e.prototype.callback=function(t){return this._callback=t,this},e}(t.Interaction);t.ClickInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){t.call(this,e)}return __extends(e,t),e.prototype._anchor=function(e){var i=this;t.prototype._anchor.call(this,e),e.on("mousemove",function(){var t=d3.mouse(e.node()),n=t[0],r=t[1];i.mousemove(n,r)})},e.prototype.mousemove=function(){},e}(t.Interaction);t.MousemoveInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(t,i){e.call(this,t),this.activated=!1,this.keyCode=i}return __extends(i,e),i.prototype._anchor=function(i){var n=this;e.prototype._anchor.call(this,i),i.on("mouseover",function(){n.activated=!0}),i.on("mouseout",function(){n.activated=!1}),t.KeyEventListener.addCallback(this.keyCode,function(){n.activated&&null!=n._callback&&n._callback()})},i.prototype.callback=function(t){return this._callback=t,this},i}(t.Interaction);t.KeyInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){var r=this;t.call(this,e),this.xScale=i,this.yScale=n,this.zoom=d3.behavior.zoom(),this.zoom.x(this.xScale._d3Scale),this.zoom.y(this.yScale._d3Scale),this.zoom.on("zoom",function(){return r.rerenderZoomed()})}return __extends(e,t),e.prototype.resetZoom=function(){var t=this;this.zoom=d3.behavior.zoom(),this.zoom.x(this.xScale._d3Scale),this.zoom.y(this.yScale._d3Scale),this.zoom.on("zoom",function(){return t.rerenderZoomed()}),this.zoom(this.hitBox)},e.prototype._anchor=function(e){t.prototype._anchor.call(this,e),this.zoom(e)},e.prototype.rerenderZoomed=function(){var t=this.xScale._d3Scale.domain(),e=this.yScale._d3Scale.domain();this.xScale.domain(t),this.yScale.domain(e)},e}(t.Interaction);t.PanZoomInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e){var i=this;t.call(this,e),this.dragInitialized=!1,this.origin=[0,0],this.location=[0,0],this.dragBehavior=d3.behavior.drag(),this.dragBehavior.on("dragstart",function(){return i._dragstart()}),this.dragBehavior.on("drag",function(){return i._drag()}),this.dragBehavior.on("dragend",function(){return i._dragend()})}return __extends(e,t),e.prototype.callback=function(t){return this.callbackToCall=t,this},e.prototype._dragstart=function(){var t=this.componentToListenTo.availableWidth,e=this.componentToListenTo.availableHeight,i=function(t,e){return function(i){return Math.min(Math.max(i,t),e)}};this.constrainX=i(0,t),this.constrainY=i(0,e)},e.prototype._drag=function(){this.dragInitialized||(this.origin=[d3.event.x,d3.event.y],this.dragInitialized=!0),this.location=[this.constrainX(d3.event.x),this.constrainY(d3.event.y)]},e.prototype._dragend=function(){this.dragInitialized&&(this.dragInitialized=!1,this._doDragend())},e.prototype._doDragend=function(){null!=this.callbackToCall&&this.callbackToCall([this.origin,this.location])},e.prototype._anchor=function(e){return t.prototype._anchor.call(this,e),e.call(this.dragBehavior),this},e}(t.Interaction);t.DragInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(){t.apply(this,arguments),this.boxIsDrawn=!1}return __extends(e,t),e.prototype._dragstart=function(){t.prototype._dragstart.call(this),null!=this.callbackToCall&&this.callbackToCall(null),this.clearBox()},e.prototype.clearBox=function(){return this.dragBox.attr("height",0).attr("width",0),this.boxIsDrawn=!1,this},e.prototype.setBox=function(t,e,i,n){var r=Math.abs(t-e),o=Math.abs(i-n),a=Math.min(t,e),s=Math.min(i,n);return this.dragBox.attr({x:a,y:s,width:r,height:o}),this.boxIsDrawn=r>0&&o>0,this},e.prototype._anchor=function(i){t.prototype._anchor.call(this,i);var n=e.CLASS_DRAG_BOX,r=this.componentToListenTo.backgroundContainer;return this.dragBox=r.append("rect").classed(n,!0).attr("x",0).attr("y",0),this},e.CLASS_DRAG_BOX="drag-box",e}(t.DragInteraction);t.DragBoxInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e.prototype._drag=function(){t.prototype._drag.call(this),this.setBox(this.origin[0],this.location[0])},e.prototype._doDragend=function(){if(null!=this.callbackToCall){var t=Math.min(this.origin[0],this.location[0]),e=Math.max(this.origin[0],this.location[0]),i={xMin:t,xMax:e};this.callbackToCall(i)}},e.prototype.setBox=function(e,i){return t.prototype.setBox.call(this,e,i,0,this.componentToListenTo.availableHeight),this},e}(t.DragBoxInteraction);t.XDragBoxInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e.prototype._drag=function(){t.prototype._drag.call(this),this.setBox(this.origin[0],this.location[0],this.origin[1],this.location[1])},e.prototype._doDragend=function(){if(null!=this.callbackToCall){var t=Math.min(this.origin[0],this.location[0]),e=Math.max(this.origin[0],this.location[0]),i=Math.min(this.origin[1],this.location[1]),n=Math.max(this.origin[1],this.location[1]),r={xMin:t,xMax:e,yMin:i,yMax:n};this.callbackToCall(r)}},e}(t.DragBoxInteraction);t.XYDragBoxInteraction=e}(Plottable||(Plottable={}));var Plottable;!function(t){function e(t,e,i){function n(n){return null==n?(a&&(e.domain(r),i.domain(o)),void(a=!a)):(a=!1,e.domain([e.invert(n.xMin),e.invert(n.xMax)]),i.domain([i.invert(n.yMax),i.invert(n.yMin)]),void t.clearBox())}var r=e.domain(),o=i.domain(),a=!1;t.callback(n)}t.setupDragBoxZoom=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(e){function i(){e.call(this),this.xTable=new t.Table,this.yTable=new t.Table,this.centerComponent=new t.ComponentGroup,this.xyTable=(new t.Table).addComponent(0,0,this.yTable).addComponent(1,1,this.xTable).addComponent(0,1,this.centerComponent),this.addComponent(1,0,this.xyTable)}return __extends(i,e),i.prototype.yAxis=function(t){if(null!=t){if(null!=this._yAxis)throw new Error("yAxis already assigned!");return this._yAxis=t,this.yTable.addComponent(0,1,this._yAxis),this}return this._yAxis},i.prototype.xAxis=function(t){if(null!=t){if(null!=this._xAxis)throw new Error("xAxis already assigned!");return this._xAxis=t,this.xTable.addComponent(0,0,this._xAxis),this}return this._xAxis},i.prototype.yLabel=function(e){if(null!=e){if(null!=this._yLabel){if("string"==typeof e)return this._yLabel.setText(e),this;throw new Error("yLabel already assigned!")}return"string"==typeof e&&(e=new t.AxisLabel(e,"vertical-left")),this._yLabel=e,this.yTable.addComponent(0,0,this._yLabel),this}return this._yLabel},i.prototype.xLabel=function(e){if(null!=e){if(null!=this._xLabel){if("string"==typeof e)return this._xLabel.setText(e),this;throw new Error("xLabel already assigned!")}return"string"==typeof e&&(e=new t.AxisLabel(e,"horizontal")),this._xLabel=e,this.xTable.addComponent(1,0,this._xLabel),this}return this._xLabel},i.prototype.titleLabel=function(e){if(null!=e){if(null!=this._titleLabel){if("string"==typeof e)return this._titleLabel.setText(e),this;throw new Error("titleLabel already assigned!")}return"string"==typeof e&&(e=new t.TitleLabel(e,"horizontal")),this._titleLabel=e,this.addComponent(0,0,this._titleLabel),this}return this._titleLabel},i.prototype.center=function(t){return this.centerComponent.merge(t),this},i}(t.Table);t.StandardChart=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){var r=this;if(t.call(this),this._showEndTickLabels=!1,this.tickPositioning="center",this._axisScale=e,i=i.toLowerCase(),this.d3Axis=d3.svg.axis().scale(e._d3Scale).orient(i),this.classed("axis",!0),null==n){var o=d3.format(".3s");n=function(t){return"number"==typeof t?Math.abs(t)<1?String(Math.round(1e3*t)/1e3):o(t):t}}this.tickFormat(n),this._registerToBroadcaster(this._axisScale,function(){return r.rescale()})}return __extends(e,t),e.prototype._setup=function(){return t.prototype._setup.call(this),this.axisElement=this.content.append("g").classed("axis",!0),this},e.prototype._doRender=function(){var t,e=this.d3Axis.scale().domain(),i=Math.abs(e[1]-e[0]),n=+d3.min(e),r=+d3.max(e),o=e[0]<e[1];if(t="number"==typeof e[0]?o?[n-i,r+i]:[r+i,n-i]:o?[new Date(n-i),new Date(r+i)]:[new Date(r+i),new Date(n-i)],null!=this._axisScale.ticks){var a=this._axisScale,s=10,l=a.ticks(s),h=a.domain(),c=h[1]-h[0],u=function(t){return Math.abs(t/c/s)<1e-4?0:t};l=l.map(u),this.d3Axis.tickValues(l)}return this.axisElement.call(this.d3Axis),this.axisElement.selectAll(".tick").select("text").style("visibility","visible"),this},e.prototype.showEndTickLabels=function(t){return null==t?this._showEndTickLabels:(this._showEndTickLabels=t,this)},e.prototype._hideCutOffTickLabels=function(){var t=this,e=(this.availableWidth,this.availableHeight,this.axisElement.selectAll(".tick").select("text")),i=this.element.select(".bounding-box")[0][0].getBoundingClientRect(),n=function(e){return i.left<=e.left&&i.top<=e.top&&e.right<=i.left+t.availableWidth&&e.bottom<=i.top+t.availableHeight};return e.each(function(){n(this.getBoundingClientRect())||d3.select(this).style("visibility","hidden")}),this},e.prototype._hideOverlappingTickLabels=function(){function t(t,e){return t.right<e.left?!1:t.left>e.right?!1:t.bottom<e.top?!1:t.top>e.bottom?!1:!0}var e,i=this.axisElement.selectAll(".tick").select("text");i.each(function(){var i=this.getBoundingClientRect();null!=e&&t(i,e)?d3.select(this).style("visibility","hidden"):(e=i,d3.select(this).style("visibility","visible"))})},e.prototype.rescale=function(){return null!=this.element?this._render():null},e.prototype.scale=function(t){return null==t?this._axisScale:(this._axisScale=t,this.d3Axis.scale(t._d3Scale),this)},e.prototype.tickLabelPosition=function(t){return null==t?this.tickPositioning:(this.tickPositioning=t,this)},e.prototype.orient=function(t){return null==t?this.d3Axis.orient():(this.d3Axis.orient(t),this)},e.prototype.ticks=function(){for(var t=[],e=0;e<arguments.length-0;e++)t[e]=arguments[e+0];return null==t||0===t.length?this.d3Axis.ticks():(this.d3Axis.ticks(t),this)},e.prototype.tickValues=function(){for(var t=[],e=0;e<arguments.length-0;e++)t[e]=arguments[e+0];return null==t?this.d3Axis.tickValues():(this.d3Axis.tickValues(t),this)},e.prototype.tickSize=function(t,e){return null!=t&&null!=e?(this.d3Axis.tickSize(t,e),this):null!=t?(this.d3Axis.tickSize(t),this):this.d3Axis.tickSize()},e.prototype.innerTickSize=function(t){return null==t?this.d3Axis.innerTickSize():(this.d3Axis.innerTickSize(t),this)},e.prototype.outerTickSize=function(t){return null==t?this.d3Axis.outerTickSize():(this.d3Axis.outerTickSize(t),this)},e.prototype.tickPadding=function(t){return null==t?this.d3Axis.tickPadding():(this.d3Axis.tickPadding(t),this)},e.prototype.tickFormat=function(t){return null==t?this.d3Axis.tickFormat():(this.d3Axis.tickFormat(t),this._invalidateLayout(),this)},e}(t.Component);t.Axis=e;var i=function(e){function i(t,i,n){"undefined"==typeof n&&(n=null),e.call(this,t,i,n),this._height=30;var i=i.toLowerCase();if("top"!==i&&"bottom"!==i)throw new Error(i+" is not a valid orientation for XAxis");this.tickLabelPosition("center")}return __extends(i,e),i.prototype.height=function(t){return this._height=t,this._invalidateLayout(),this},i.prototype._setup=function(){return e.prototype._setup.call(this),this.axisElement.classed("x-axis",!0),this},i.prototype._requestedSpace=function(t,e){return{width:0,height:Math.min(e,this._height),wantsWidth:!1,wantsHeight:e<this._height}},i.prototype.tickLabelPosition=function(t){if(null==t)return e.prototype.tickLabelPosition.call(this);var i=t.toLowerCase();if("left"===i||"center"===i||"right"===i)return"center"!==i&&this.tickSize(12),e.prototype.tickLabelPosition.call(this,i);throw new Error(t+" is not a valid tick label position for XAxis")},i.prototype._doRender=function(){var i=this;e.prototype._doRender.call(this),"top"===this.orient()&&this.axisElement.attr("transform","translate(0,"+this._height+")");var n=this.axisElement.selectAll("text");if(n[0].length>0)if("center"!==this.tickLabelPosition()&&(n.attr("y","0px"),"bottom"===this.orient()?n.attr("dy","1em"):n.attr("dy","-0.25em"),"right"===this.tickLabelPosition()?n.attr("dx","0.2em").style("text-anchor","start"):"left"===this.tickLabelPosition()&&n.attr("dx","-0.2em").style("text-anchor","end")),null!=this._axisScale.rangeType){var r=(this._axisScale.range(),this.availableWidth),o=Math.abs(parseFloat(d3.select(n[0][0]).attr("y"))),a=this.availableHeight-o;if(n[0].length>1){var s=n.data(),l=s.map(function(t){return i._axisScale.scale(t)});l.forEach(function(t,e){var i=Math.abs(l[e+1]-t);r=r>i?i:r})}r=.9*r,n.each(function(){var e=d3.select(this),i=e.text(),n=t.Utils.getWrappedText(i,r,a,e);if(1===n.length)e.text(t.Utils.getTruncatedText(i,r,e));else{e.text("");var o=e.selectAll("tspan").data(n);o.enter().append("tspan"),o.text(function(t){return t}).attr("x","0").attr("dy",function(t,i){return 0===i?e.attr("dy"):"1em"}).style("text-anchor",e.style("text-anchor"))}})}else this._hideOverlappingTickLabels();return this.showEndTickLabels()||this._hideCutOffTickLabels(),this},i}(e);t.XAxis=i;var n=function(e){function i(t,i,n){if("undefined"==typeof n&&(n=null),e.call(this,t,i,n),this._width=50,i=i.toLowerCase(),"left"!==i&&"right"!==i)throw new Error(i+" is not a valid orientation for YAxis");this.tickLabelPosition("middle")}return __extends(i,e),i.prototype._setup=function(){return e.prototype._setup.call(this),this.axisElement.classed("y-axis",!0),this},i.prototype.width=function(t){return this._width=t,this._invalidateLayout(),this},i.prototype._requestedSpace=function(t){return{width:Math.min(t,this._width),height:0,wantsWidth:t<this._width,wantsHeight:!1}},i.prototype.tickLabelPosition=function(t){if(null==t)return e.prototype.tickLabelPosition.call(this);var i=t.toLowerCase();if("top"===i||"middle"===i||"bottom"===i)return"middle"!==i&&this.tickSize(30),e.prototype.tickLabelPosition.call(this,i);throw new Error(t+" is not a valid tick label position for YAxis")},i.prototype._doRender=function(){var i=this;e.prototype._doRender.call(this),"left"===this.orient()&&this.axisElement.attr("transform","translate("+this._width+", 0)");var n=this.axisElement.selectAll("text");if(n[0].length>0)if("middle"!==this.tickLabelPosition()&&(n.attr("x","0px"),"left"===this.orient()?n.attr("dx","-0.25em"):n.attr("dx","0.25em"),"top"===this.tickLabelPosition()?n.attr("dy","-0.3em"):"bottom"===this.tickLabelPosition()&&n.attr("dy","1em")),null!=this._axisScale.rangeType){var r=(this._axisScale.range(),Math.abs(parseFloat(d3.select(n[0][0]).attr("x")))),o=this.availableWidth-r,a=this.availableHeight;if(n[0].length>1){var s=n.data(),l=s.map(function(t){return i._axisScale.scale(t)});l.forEach(function(t,e){var i=Math.abs(l[e+1]-t);a=a>i?i:a})}var h=this.tickLabelPosition();n.each(function(){var e=d3.select(this),i=e.text(),n=t.Utils.getWrappedText(i,o,a,e);if(1===n.length)e.text(t.Utils.getTruncatedText(i,o,e));else{var r=0;"top"===h?r=-(n.length-1):"middle"===h&&(r=-(n.length-1)/2),e.text("");var s=e.selectAll("tspan").data(n);s.enter().append("tspan"),s.text(function(t){return t}).attr({dy:e.attr("dy"),x:e.attr("x"),y:function(t,e){return r+e+"em"}}).style("text-anchor",e.style("text-anchor"))}})}else this._hideOverlappingTickLabels();return this.showEndTickLabels()||this._hideCutOffTickLabels(),this},i}(e);t.YAxis=n}(Plottable||(Plottable={}));var Plottable;!function(t){!function(t){function e(e,i,n){"undefined"==typeof i&&(i=t.ONE_DAY),"undefined"==typeof n&&(n="");var r=function(t){var r=Math.round((t.valueOf()-e)/i);return r.toString()+n};return r}t.ONE_DAY=864e5,t.generateRelativeDateFormatter=e}(t.AxisUtils||(t.AxisUtils={}));t.AxisUtils}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i){var n=this;t.call(this),this.classed("gridlines",!0),this.xScale=e,this.yScale=i,null!=this.xScale&&this._registerToBroadcaster(this.xScale,function(){return n.redrawXLines()}),null!=this.yScale&&this._registerToBroadcaster(this.yScale,function(){return n.redrawYLines()})}return __extends(e,t),e.prototype._setup=function(){return t.prototype._setup.call(this),this.xLinesContainer=this.content.append("g").classed("x-gridlines",!0),this.yLinesContainer=this.content.append("g").classed("y-gridlines",!0),this},e.prototype._doRender=function(){return t.prototype._doRender.call(this),this.redrawXLines(),this.redrawYLines(),this},e.prototype.redrawXLines=function(){var t=this;if(null!=this.xScale&&null!=this.element){var e=this.xScale.ticks(),i=function(e){return t.xScale.scale(e)},n=this.xLinesContainer.selectAll("line").data(e);n.enter().append("line"),n.attr("x1",i).attr("y1",0).attr("x2",i).attr("y2",this.availableHeight),n.exit().remove()}},e.prototype.redrawYLines=function(){var t=this;if(null!=this.yScale&&null!=this.element){var e=this.yScale.ticks(),i=function(e){return t.yScale.scale(e)},n=this.yLinesContainer.selectAll("line").data(e);n.enter().append("line"),n.attr("x1",0).attr("y1",i).attr("x2",this.availableWidth).attr("y2",i),n.exit().remove()}},e}(t.Component);t.Gridlines=e}(Plottable||(Plottable={}));var Plottable;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n),this.classed("area-renderer",!0),this.project("y0",0,n),this.project("fill",function(){return"steelblue"})}return __extends(e,t),e.prototype._setup=function(){return t.prototype._setup.call(this),this.path=this.renderArea.append("path").classed("area",!0),this},e.prototype._paint=function(){t.prototype._paint.call(this);var e=this._generateAttrToProjector();this.area=d3.svg.area().x(e.x).y0(e.y0).y1(e.y),this.dataSelection=this.path.datum(this._dataSource.data()),delete e.x,delete e.y0,delete e.y,this.path.attr("d",this.area).attr(e)},e}(t.XYRenderer);t.AreaRenderer=e}(Plottable||(Plottable={}));var Plottable;!function(){}(Plottable||(Plottable={}));