function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=0)return!0;return!1},register:function(n,r){r=e(r),t[r].push(n)},deregister:function(n,r){r=e(r);for(var i=0;i=0||void 0!==e)&&(a=a.duration(e)),(r>=0||void 0!==r)&&(a=a.delay(r)),a},n.optionalTransition=function(t,e,r,i){return t?function(t){return n.transition(t,e,r,i)}:function(t){return t}},n.afterTransition=function(t,e){if(t.empty()||!t.duration)e.call(t);else{var n=0;t.each(function(){++n}).on("end",function(){--n||e.call(t)})}},n.units={},n.units.integers=function(t,e){return Math.abs(e-t)},n.units.ordinal=function(){throw new Error("dc.units.ordinal should not be called - it is a placeholder")},n.units.fp={},n.units.fp.precision=function(t){var e=function t(e,r){var i=Math.abs((r-e)/t.resolution);return n.utils.isNegligible(i-Math.floor(i))?Math.floor(i):Math.ceil(i)};return e.resolution=t,e},n.round={},n.round.floor=function(t){return Math.floor(t)},n.round.ceil=function(t){return Math.ceil(t)},n.round.round=function(t){return Math.round(t)},n.override=function(t,e,n){var r=t[e];t["_"+e]=r,t[e]=n},n.renderlet=function(t){return arguments.length?(n._renderlet=t,n):n._renderlet},n.instanceOfChart=function(t){return t instanceof Object&&t.__dcFlag__&&!0},n.errors={},n.errors.Exception=function(t){var e=t||"Unexpected internal error";this.message=e,this.toString=function(){return e},this.stack=(new Error).stack},n.errors.Exception.prototype=Object.create(Error.prototype),n.errors.Exception.prototype.constructor=n.errors.Exception,n.errors.InvalidStateException=function(){n.errors.Exception.apply(this,arguments)},n.errors.InvalidStateException.prototype=Object.create(n.errors.Exception.prototype),n.errors.InvalidStateException.prototype.constructor=n.errors.InvalidStateException,n.errors.BadArgumentException=function(){n.errors.Exception.apply(this,arguments)},n.errors.BadArgumentException.prototype=Object.create(n.errors.Exception.prototype),n.errors.BadArgumentException.prototype.constructor=n.errors.BadArgumentException,n.dateFormat=t.timeFormat("%m/%d/%Y"),n.printers={},n.printers.filters=function(t){for(var e="",r=0;r0&&(e+=", "),e+=n.printers.filter(t[r]);return e},n.printers.filter=function(t){var e="";return null!=t&&(t instanceof Array?t.length>=2?e="["+n.utils.printSingleValue(t[0])+" -> "+n.utils.printSingleValue(t[1])+"]":t.length>=1&&(e=n.utils.printSingleValue(t[0])):e=n.utils.printSingleValue(t)),e},n.pluck=function(t,e){return e?function(n,r){return e.call(n,n[t],r)}:function(e){return e[t]}},n.utils={},n.utils.printSingleValue=function(t){var e=""+t;return t instanceof Date?e=n.dateFormat(t):"string"==typeof t?e=t:n.utils.isFloat(t)?e=n.utils.printSingleValue.fformat(t):n.utils.isInteger(t)&&(e=Math.round(t)),e},n.utils.printSingleValue.fformat=t.format(".2f"),n.utils.toTimeFunc=function(t){return"time"+t.charAt(0).toUpperCase()+t.slice(1)},n.utils.add=function(e,r,i){if("string"==typeof r&&(r=r.replace("%","")),e instanceof Date)return"string"==typeof r&&(r=+r),"millis"===i?new Date(e.getTime()+r):("function"!=typeof(i=i||t.timeDay)&&(i=t[n.utils.toTimeFunc(i)]),i.offset(e,r));if("string"==typeof r){var a=+r/100;return e>0?e*(1+a):e*(1-a)}return e+r},n.utils.subtract=function(e,r,i){if("string"==typeof r&&(r=r.replace("%","")),e instanceof Date)return"string"==typeof r&&(r=+r),"millis"===i?new Date(e.getTime()-r):("function"!=typeof(i=i||t.timeDay)&&(i=t[n.utils.toTimeFunc(i)]),i.offset(e,-r));if("string"==typeof r){var a=+r/100;return e<0?e*(1+a):e*(1-a)}return e-r},n.utils.isNumber=function(t){return t===+t},n.utils.isFloat=function(t){return t===+t&&t!==(0|t)},n.utils.isInteger=function(t){return t===+t&&t===(0|t)},n.utils.isNegligible=function(t){return!n.utils.isNumber(t)||t-n.constants.NEGLIGIBLE_NUMBER},n.utils.clamp=function(t,e,n){return tn?n:t},n.utils.constant=function(t){return function(){return t}};var r,i,a,o,l,u=0;function c(t,e){for(var n=0;n=this[0]&&t=e[0][0]&&n=e[0][1]&&r=e.length))return!1;for(var n=0;np?e:p},y=m,v=200,x=function(t){var e=t&&t.getBoundingClientRect&&t.getBoundingClientRect().height;return e&&e>v?e:v},A=x,b=!1,w=n.pluck("key"),_=n.pluck("value"),k=n.pluck("key"),D=n.pluck("key"),L=!1,C=function(t){return r.keyAccessor()(t)+": "+r.valueAccessor()(t)},E=!0,O=!1,S=750,R=0,F=n.printers.filters,M=["dimension","group"],T=n.constants.DEFAULT_CHART_GROUP,B=t.dispatch("preRender","postRender","preRedraw","postRedraw","filtered","zoomed","renderlet","pretransition"),N=[],P=function(t,e){return 0===e.length?t.filter(null):1!==e.length||e[0].isFiltered?1===e.length&&"RangedFilter"===e[0].filterType?t.filterRange(e[0]):t.filterFunction(function(t){for(var n=0;n=t)return!0}return!1}):t.filterExact(e[0]),e},H=function(t){return t.all()};function G(){u&&(b?u.attr("viewBox")||u.attr("viewBox","0 0 "+r.width()+" "+r.height()):u.attr("width",r.width()).attr("height",r.height()))}function V(t){if(!r[t]||!r[t]())throw new n.errors.InvalidStateException("Mandatory attribute chart."+t+" is missing on chart[#"+r.anchorName()+"]")}r.height=function(t){return arguments.length?(A=t?"function"==typeof t?t:n.utils.constant(t):x,d=void 0,r):(n.utils.isNumber(d)||(d=A(l.node())),d)},r.width=function(t){return arguments.length?(y=t?"function"==typeof t?t:n.utils.constant(t):m,s=void 0,r):(n.utils.isNumber(s)||(s=y(l.node())),s)},r.minWidth=function(t){return arguments.length?(p=t,r):p},r.minHeight=function(t){return arguments.length?(v=t,r):v},r.useViewBoxResizing=function(t){return arguments.length?(b=t,r):b},r.dimension=function(t){return arguments.length?(i=t,r.expireCache(),r):i},r.data=function(t){return arguments.length?(H="function"==typeof t?t:n.utils.constant(t),r.expireCache(),r):H.call(r,a)},r.group=function(t,e){return arguments.length?(a=t,r._groupName=e,r.expireCache(),r):a},r.ordering=function(t){return arguments.length?(D=t,f=e.quicksort.by(D),r.expireCache(),r):D},r._computeOrderedGroups=function(t){var n=t.slice(0);return n.length<=1?n:(f||(f=e.quicksort.by(D)),f(n,0,n.length))},r.filterAll=function(){return r.filter(null)},r.select=function(t){return l.select(t)},r.selectAll=function(t){return l?l.selectAll(t):null},r.anchor=function(e,i){if(!arguments.length)return o;if(n.instanceOfChart(e))o=e.anchor(),l=e.root(),c=!0;else{if(!e)throw new n.errors.BadArgumentException("parent must be defined");o=e.select&&e.classed?e.node():e,(l=t.select(o)).classed(n.constants.CHART_CLASS,!0),n.registerChart(r,i),c=!1}return T=i,r},r.anchorName=function(){var t=r.anchor();return t&&t.id?t.id:t&&t.replace?t.replace("#",""):"dc-chart"+r.chartID()},r.root=function(t){return arguments.length?(l=t,r):l},r.svg=function(t){return arguments.length?(u=t,r):u},r.resetSvg=function(){return r.select("svg").remove(),u=r.root().append("svg"),G(),u},r.filterPrinter=function(t){return arguments.length?(F=t,r):F},r.controlsUseVisibility=function(t){return arguments.length?(O=t,r):O},r.turnOnControls=function(){if(l){var t=r.controlsUseVisibility()?"visibility":"display";r.selectAll(".reset").style(t,null),r.selectAll(".filter").text(F(r.filters())).style(t,null)}return r},r.turnOffControls=function(){if(l){var t=r.controlsUseVisibility()?"visibility":"display",e=r.controlsUseVisibility()?"hidden":"none";r.selectAll(".reset").style(t,e),r.selectAll(".filter").style(t,e).text(r.filter())}return r},r.transitionDuration=function(t){return arguments.length?(S=t,r):S},r.transitionDelay=function(t){return arguments.length?(R=t,r):R},r._mandatoryAttributes=function(t){return arguments.length?(M=t,r):M},r.render=function(){d=s=void 0,B.call("preRender",r,r),M&&M.forEach(V);var t=r._doRender();return h&&h.render(),r._activateRenderlets("postRender"),t},r._activateRenderlets=function(t){B.call("pretransition",r,r),r.transitionDuration()>0&&u?u.transition().duration(r.transitionDuration()).delay(r.transitionDelay()).on("end",function(){B.call("renderlet",r,r),t&&B.call(t,r,r)}):(B.call("renderlet",r,r),t&&B.call(t,r,r))},r.redraw=function(){G(),B.call("preRedraw",r,r);var t=r._doRedraw();return h&&h.render(),r._activateRenderlets("postRedraw"),t},r.commitHandler=function(t){return arguments.length?(g=t,r):g},r.redrawGroup=function(){return g?g(!1,function(t,e){t?console.log(t):n.redrawAll(r.chartGroup())}):n.redrawAll(r.chartGroup()),r},r.renderGroup=function(){return g?g(!1,function(t,e){t?console.log(t):n.renderAll(r.chartGroup())}):n.renderAll(r.chartGroup()),r},r._invokeFilteredListener=function(t){void 0!==t&&B.call("filtered",r,r,t)},r._invokeZoomedListener=function(){B.call("zoomed",r,r)};var U=function(t,e){return null==e?t.length>0:t.some(function(t){return e<=t&&e>=t})};r.hasFilterHandler=function(t){return arguments.length?(U=t,r):U},r.hasFilter=function(t){return U(N,t)};var z=function(t,e){for(var n=0;n=e){t.splice(n,1);break}return t};r.removeFilterHandler=function(t){return arguments.length?(z=t,r):z};var I=function(t,e){return t.push(e),t};r.addFilterHandler=function(t){return arguments.length?(I=t,r):I};var Y=function(t){return[]};return r.resetFilterHandler=function(t){return arguments.length?(Y=t,r):Y},r.replaceFilter=function(t){return N=Y(N),r.filter(t),r},r.filter=function(t){if(!arguments.length)return N.length>0?N[0]:null;var e=N;return t instanceof Array&&t[0]instanceof Array&&!t.isFiltered?t[0].forEach(function(t){e=U(e,t)?z(e,t):I(e,t)}):e=null===t?Y(e):U(e,t)?z(e,t):I(e,t),N=function(t){if(r.dimension()&&r.dimension().filter){var e=P(r.dimension(),t);e&&(t=e)}return t}(e),r._invokeFilteredListener(t),null!==l&&r.hasFilter()?r.turnOnControls():r.turnOffControls(),r},r.filters=function(){return N},r.highlightSelected=function(e){t.select(e).classed(n.constants.SELECTED_CLASS,!0),t.select(e).classed(n.constants.DESELECTED_CLASS,!1)},r.fadeDeselected=function(e){t.select(e).classed(n.constants.SELECTED_CLASS,!1),t.select(e).classed(n.constants.DESELECTED_CLASS,!0)},r.resetHighlight=function(e){t.select(e).classed(n.constants.SELECTED_CLASS,!1),t.select(e).classed(n.constants.DESELECTED_CLASS,!1)},r.onClick=function(t){var e=r.keyAccessor()(t);n.events.trigger(function(){r.filter(e),r.redrawGroup()})},r.filterHandler=function(t){return arguments.length?(P=t,r):P},r._doRender=function(){return r},r._doRedraw=function(){return r},r.legendables=function(){return[]},r.legendHighlight=function(){},r.legendReset=function(){},r.legendToggle=function(){},r.isLegendableHidden=function(){return!1},r.keyAccessor=function(t){return arguments.length?(w=t,r):w},r.valueAccessor=function(t){return arguments.length?(_=t,r):_},r.label=function(t,e){return arguments.length?(k=t,(void 0===e||e)&&(L=!0),r):k},r.renderLabel=function(t){return arguments.length?(L=t,r):L},r.title=function(t){return arguments.length?(C=t,r):C},r.renderTitle=function(t){return arguments.length?(E=t,r):E},r.renderlet=n.logger.deprecate(function(t){return r.on("renderlet."+n.utils.uniqueId(),t),r},'chart.renderlet has been deprecated. Please use chart.on("renderlet.", renderletFunction)'),r.chartGroup=function(t){return arguments.length?(c||n.deregisterChart(r,T),T=t,c||n.registerChart(r,T),r):T},r.expireCache=function(){return r},r.legend=function(t){return arguments.length?((h=t).parent(r),r):h},r.chartID=function(){return r.__dcFlag__},r.options=function(t){var e=["anchor","group","xAxisLabel","yAxisLabel","stack","title","point","getColor","overlayGeoJson"];for(var i in t)"function"==typeof r[i]?t[i]instanceof Array&&-1!==e.indexOf(i)?r[i].apply(r,t[i]):r[i].call(r,t[i]):n.logger.debug("Not a valid option setter name: "+i);return r},r.on=function(t,e){return B.on(t,e),r},r},n.marginMixin=function(t){var e={top:10,right:50,bottom:30,left:30};return t.margins=function(n){return arguments.length?(e=n,t):e},t.effectiveWidth=function(){return t.width()-t.margins().left-t.margins().right},t.effectiveHeight=function(){return t.height()-t.margins().top-t.margins().bottom},t},n.colorMixin=function(e){var r=t.scaleOrdinal(n.config.defaultColors()),i=!0,a=function(t){return e.keyAccessor()(t)};return e.colors=function(i){return arguments.length?(r=i instanceof Array?t.scaleQuantize().range(i):"function"==typeof i?i:n.utils.constant(i),e):r},e.ordinalColors=function(n){return e.colors(t.scaleOrdinal().range(n))},e.linearColors=function(n){return e.colors(t.scaleLinear().range(n).interpolate(t.interpolateHcl))},e.colorAccessor=function(t){return arguments.length?(a=t,i=!1,e):a},e.defaultColorAccessor=function(){return i},e.colorDomain=function(t){return arguments.length?(r.domain(t),e):r.domain()},e.calculateColorDomain=function(){var n=[t.min(e.data(),e.colorAccessor()),t.max(e.data(),e.colorAccessor())];return r.domain(n),e},e.getColor=function(t,e){return r(a.call(this,t,e))},e.colorCalculator=n.logger.deprecate(function(t){return arguments.length?(e.getColor=t,e):e.getColor},"colorMixin.colorCalculator has been deprecated. Please colorMixin.colors and colorMixin.colorAccessor instead"),e},n.coordinateGridMixin=function(e){var r,i,a,o,l,u,c="grid-line",s="vertical";(e=n.colorMixin(n.marginMixin(n.baseMixin(e)))).colors(t.scaleOrdinal(t.schemeCategory10)),e._mandatoryAttributes().push("x");var d,f,h,g,p,m,y,v,x,A=t.axisBottom(),b=n.units.integers,w=0,_=t.timeDay,k=!1,D=0,L=null,C=0,E=!1,O=0,S=t.brushX(),R=!0,F=!1,M=!1,T=!1,B=!1,N=[1,1/0],P=!0,H=t.zoom().on("zoom",function(){if(!t.event.sourceEvent)return;if(t.event.sourceEvent.type&&-1!==["start","zoom","end"].indexOf(t.event.sourceEvent.type))return;var n=t.event.transform.rescaleX(l).domain();e.focus(n,!1)}),G=t.zoom().on("zoom",null),V=!1,U=!1,z=0,I=.5,Y=0,j=!1;function X(r,i){e.isOrdinal()?(o.bandwidth||(n.logger.warn("For compatibility with d3v4+, dc.js d3.0 ordinal bar/line/bubble charts need d3.scaleBand() for the x scale, instead of d3.scaleOrdinal(). Replacing .x() with a d3.scaleBand with the same domain - make the same change in your code to avoid this warning!"),o=t.scaleBand().domain(o.domain())),(e.elasticX()||0===o.domain().length)&&o.domain(e._ordinalXDomain())):e.elasticX()&&o.domain([e.xAxisMin(),e.xAxisMax()]);var a=o.domain();!i&&n.utils.arraysEqual(f,a)||e.rescale(),f=a,e.isOrdinal()?o.range([0,e.xAxisLength()]).paddingInner(Y).paddingOuter(e._useOuterPadding()?I:0):o.range([0,e.xAxisLength()]),A=A.scale(e.x()),function(t){var r=t.select("g."+s);if(T){r.empty()&&(r=t.insert("g",":first-child").attr("class",c+" "+s).attr("transform","translate("+e.margins().left+","+e.margins().top+")"));var i=A.tickValues()?A.tickValues():"function"==typeof o.ticks?o.ticks.apply(o,A.tickArguments()):o.domain(),a=r.selectAll("line").data(i),l=a.enter().append("line").attr("x1",function(t){return o(t)}).attr("y1",e._xAxisY()-e.margins().top).attr("x2",function(t){return o(t)}).attr("y2",0).attr("opacity",0);n.transition(l,e.transitionDuration(),e.transitionDelay()).attr("opacity",1);var u=l.merge(a);n.transition(u,e.transitionDuration(),e.transitionDelay()).attr("x1",function(t){return o(t)}).attr("y1",e._xAxisY()-e.margins().top).attr("x2",function(t){return o(t)}).attr("y2",0),a.exit().remove()}else r.selectAll("line").remove()}(r)}function q(){return j?t.axisRight():t.axisLeft()}function W(){return e.anchorName().replace(/[ .#=\[\]"]/g,"-")+"-clip"}function K(){var t=n.utils.appendOrSelect(r,"defs"),i=W(),a=n.utils.appendOrSelect(t,"#"+i,"clipPath").attr("id",i),o=2*z;n.utils.appendOrSelect(a,"rect").attr("width",e.xAxisLength()+o).attr("height",e.yAxisHeight()+o).attr("transform","translate(-"+z+", -"+z+")")}function Q(t){e.isOrdinal()&&(R=!1),X(e.g(),t),e._prepareYAxis(e.g()),e.plotData(),(e.elasticX()||B||t)&&e.renderXAxis(e.g()),(e.elasticY()||B||t)&&e.renderYAxis(e.g()),t?e.renderBrush(e.g(),!1):e.redrawBrush(e.filter(),B),e.fadeDeselectedArea(e.filter()),B=!1}function Z(t,r){var i,a;(a=t)instanceof Array&&a.length>1?(e.x().domain(t),i=n.filters.RangedFilter(t[0],t[1])):(e.x().domain(u),i=null),e.replaceFilter(i),e.rescale(),e.redraw(),r||(v&&!tt(e.filter(),v.filter())&&n.events.trigger(function(){v.replaceFilter(i),v.redraw()}),e._invokeZoomedListener(),n.events.trigger(function(){e.redrawGroup()},n.constants.EVENT_DELAY))}function J(){var n,r,i,a,o;H&&H.transform(e.root(),(n=e.x().domain(),i=l,a=((r=u)[1]-r[0])/(n[1]-n[0]),o=-1*i(n[0]),t.zoomIdentity.scale(a).translate(o,0)))}function $(t,e){return t&&2===t.length&&e&&2===e.length?((t[0]>e[1]||t[1]e[0]?t[0]:e[0],t[1]=t[0]&&e.x<=t[t.length-1]}}()),t.values=e.evadeDomainFilter()?a:t.domainValues}var i=t.stack(),a=[],o={},l=!1,u=!1;function c(t){var e=a.map(n.pluck("name")).indexOf(t);return a[e]}function s(){var t=e.data().map(function(t){return t.domainValues});return Array.prototype.concat.apply([],t)}function d(t){return!t.hidden}return e.stack=function(t,n,r){if(!arguments.length)return a;arguments.length<=2&&(r=n);var i={group:t};return"string"==typeof n&&(i.name=n),"function"==typeof r&&(i.accessor=r),a.push(i),e},n.override(e,"group",function(t,n,r){return arguments.length?(a=[],o={},e.stack(t,n),r&&e.valueAccessor(r),e._group(t,n)):e._group()}),e.hidableStacks=function(t){return arguments.length?(l=t,e):l},e.hideStack=function(t){var n=c(t);return n&&(n.hidden=!0),e},e.showStack=function(t){var n=c(t);return n&&(n.hidden=!1),e},e.getValueAccessorByIndex=function(t){return a[t].accessor||e.valueAccessor()},e.yAxisMin=function(){var r=t.min(s(),function(t){return t.y<0?t.y+t.y0:t.y0});return n.utils.subtract(r,e.yAxisPadding())},e.yAxisMax=function(){var r=t.max(s(),function(t){return t.y>0?t.y+t.y0:t.y0});return n.utils.add(r,e.yAxisPadding())},e.xAxisMin=function(){var r=t.min(s(),n.pluck("x"));return n.utils.subtract(r,e.xAxisPadding(),e.xAxisPaddingUnit())},e.xAxisMax=function(){var r=t.max(s(),n.pluck("x"));return n.utils.add(r,e.xAxisPadding(),e.xAxisPaddingUnit())},n.override(e,"title",function(t,n){return t?"function"==typeof t?e._title(t):t===e._groupName&&"function"==typeof n?e._title(n):"function"!=typeof n?o[t]||e._title():(o[t]=n,e):e._title()}),e.stackLayout=function(t){return arguments.length?(i=t,e):i},e.evadeDomainFilter=function(t){return arguments.length?(u=t,e):u},e.data(function(){var t=a.filter(d);if(!t.length)return[];t.forEach(r);var n=t[0].values.map(function(e,n){var r={x:e.x};return t.forEach(function(t){r[t.name]=t.values[n].y}),r}),i=t.map(function(t){return t.name});return e.stackLayout().keys(i)(n).forEach(function(e,n){e.forEach(function(e,r){t[n].values[r].y0=e[0],t[n].values[r].y1=e[1]})}),t}),e._ordinalXDomain=function(){var t=s().map(n.pluck("data"));return e._computeOrderedGroups(t).map(e.keyAccessor())},e.colorAccessor(function(t){return this.layer||this.name||t.name||t.layer}),e.legendables=function(){return a.map(function(t,n){return{chart:e,name:t.name,hidden:t.hidden||!1,color:e.getColor.call(t,t.values,n)}})},e.isLegendableHidden=function(t){var e=c(t.name);return!!e&&e.hidden},e.legendToggle=function(t){l&&(e.isLegendableHidden(t)?e.showStack(t.name):e.hideStack(t.name),e.renderGroup())},e},n.capMixin=function(e){var r=1/0,i=!0,a="Others";e.ordering(function(t){return-t.value});var o=function(n,r){var i=t.sum(r,e.valueAccessor()),a=r.map(e.keyAccessor());return i>0?n.concat([{others:a,key:e.othersLabel(),value:i}]):n};return e.cappedKeyAccessor=function(t,n){return t.others?t.key:e.keyAccessor()(t,n)},e.cappedValueAccessor=function(t,n){return t.others?t.value:e.valueAccessor()(t,n)},e.data(function(t){if(r===1/0)return e._computeOrderedGroups(t.all());var n,a=t.all();if(a=e._computeOrderedGroups(a),r)if(i)n=a.slice(r),a=a.slice(0,r);else{var l=Math.max(0,a.length-r);n=a.slice(0,l),a=a.slice(l)}return o?o(a,n):a}),e.cap=function(t){return arguments.length?(r=t,e):r},e.takeFront=function(t){return arguments.length?(i=t,e):i},e.othersLabel=function(t){return arguments.length?(a=t,e):a},e.othersGrouper=function(t){return arguments.length?(o=t,e):o},n.override(e,"onClick",function(t){t.others&&e.filter([t.others]),e._onClick(t)}),e},n.bubbleMixin=function(e){var r=.3,i=10,a=!1,o=!1;e.BUBBLE_NODE_CLASS="node",e.BUBBLE_CLASS="bubble",e.MIN_RADIUS=10,(e=n.colorMixin(e)).renderLabel(!0),e.data(function(n){var r=n.all();if(a){var i=e.radiusValueAccessor();r.sort(function(e,n){return t.descending(i(e),i(n))})}return r});var l=t.scaleLinear().domain([0,100]),u=function(t){return t.r};e.r=function(t){return arguments.length?(l=t,e):l},e.elasticRadius=function(t){return arguments.length?(o=t,e):o},e.calculateRadiusDomain=function(){o&&e.r().domain([e.rMin(),e.rMax()])},e.radiusValueAccessor=function(t){return arguments.length?(u=t,e):u},e.rMin=function(){return t.min(e.data(),function(t){return e.radiusValueAccessor()(t)})},e.rMax=function(){return t.max(e.data(),function(t){return e.radiusValueAccessor()(t)})},e.bubbleR=function(t){var n=e.radiusValueAccessor()(t),r=e.r()(n);return(isNaN(r)||n<=0)&&(r=0),r};var c=function(t){return e.label()(t)},s=function(t){return e.bubbleR(t)>i},d=function(t){return s(t)?1:0},f=function(t){return s(t)?"all":"none"};e._doRenderLabel=function(t){if(e.renderLabel()){var r=t.select("text");r.empty()&&(r=t.append("text").attr("text-anchor","middle").attr("dy",".3em").on("click",e.onClick)),r.attr("opacity",0).attr("pointer-events",f).text(c),n.transition(r,e.transitionDuration(),e.transitionDelay()).attr("opacity",d)}},e.doUpdateLabels=function(t){if(e.renderLabel()){var r=t.select("text").attr("pointer-events",f).text(c);n.transition(r,e.transitionDuration(),e.transitionDelay()).attr("opacity",d)}};var h=function(t){return e.title()(t)};return e._doRenderTitles=function(t){e.renderTitle()&&(t.select("title").empty()&&t.append("title").text(h))},e.doUpdateTitles=function(t){e.renderTitle()&&t.select("title").text(h)},e.sortBubbleSize=function(t){return arguments.length?(a=t,e):a},e.minRadius=function(t){return arguments.length?(e.MIN_RADIUS=t,e):e.MIN_RADIUS},e.minRadiusWithLabel=function(t){return arguments.length?(i=t,e):i},e.maxBubbleRelativeSize=function(t){return arguments.length?(r=t,e):r},e.fadeDeselectedArea=function(t){e.hasFilter()?e.selectAll("g."+e.BUBBLE_NODE_CLASS).each(function(t){e.isSelectedNode(t)?e.highlightSelected(this):e.fadeDeselected(this)}):e.selectAll("g."+e.BUBBLE_NODE_CLASS).each(function(){e.resetHighlight(this)})},e.isSelectedNode=function(t){return e.hasFilter(t.key)},e.onClick=function(t){var r=t.key;n.events.trigger(function(){e.filter(r),e.redrawGroup()})},e},n.pieChart=function(e,r){var i,a,o,l,u,c,s="pie-slice",d="pie-label",f="pie-slice-group",h="pie-label-group",g="empty-chart",p="empty",m=0,y=0,v=.5,x=!1,A=n.capMixin(n.colorMixin(n.baseMixin({})));function b(){var e=t.min([A.width(),A.height()])/2;i=a&&a=0&&(r="M0,0"),r}function R(e,n){A.selectAll("g.pie-slice").each(function(r){e.name===r.data.key&&t.select(this).classed("highlight",n)})}return A.colorAccessor(A.cappedKeyAccessor),A.title(function(t){return A.cappedKeyAccessor(t)+": "+A.cappedValueAccessor(t)}),A.slicesCap=A.cap,A.label(A.cappedKeyAccessor),A.renderLabel(!0),A.transitionDuration(350),A.transitionDelay(0),A._doRender=function(){return A.resetSvg(),(o=A.svg().append("g").attr("transform","translate("+A.cx()+","+A.cy()+")")).append("g").attr("class",f),o.append("g").attr("class",h),b(),A},A._applyLabelText=function(t){t.text(function(t){return!function(t){return 0===A.cappedValueAccessor(t)}(t.data)&&!function(t){var e=t.endAngle-t.startAngle;return isNaN(e)||e=0;o--){var l=i[o];n.utils.arraysIdentical(l,e)&&(a=!0),g.filter(i[o])}n.events.trigger(function(){a||g.filter(r),g.redrawGroup()})}function w(t,e){a.attr("class")!==s&&b(t)}function _(t,e,n){var r=n(t,e);return r.indexOf("NaN")>=0&&(r="M0,0"),r}function k(e,n){g.selectAll("g.pie-slice").each(function(r){e.name===r.key&&t.select(this).classed("highlight",n)})}return g.colorAccessor(g.cappedKeyAccessor),g.title(function(t){return g.cappedKeyAccessor(t)+": "+g.cappedValueAccessor(t)}),g.label(g.cappedKeyAccessor),g.renderLabel(!0),g.transitionDuration(350),g.filterHandler(function(t,e){return 0===e.length?t.filter(null):t.filterFunction(function(t){for(var n=0;n=i})}},l.centerBar=function(t){return arguments.length?(c=t,l):c},n.override(l,"onClick",function(t){l._onClick(t.data)}),l.barPadding=function(t){return arguments.length?(l._rangeBandPadding(t),u=void 0,l):l._rangeBandPadding()},l._useOuterPadding=function(){return void 0===u},l.outerPadding=l._outerRangeBandPadding,l.gap=function(t){return arguments.length?(u=t,l):u},l.extendBrush=function(t){return t&&l.round()&&(!c||s)&&(t[0]=l.round()(t[0]),t[1]=l.round()(t[1])),t},l.alwaysUseRounding=function(t){return arguments.length?(s=t,l):s},l.legendHighlight=function(t){l.isLegendableHidden(t)||l.g().selectAll("rect.bar").classed("highlight",p(t.color)).classed("fadeout",p(t.color,!0))},l.legendReset=function(){l.g().selectAll("rect.bar").classed("highlight",!1).classed("fadeout",!1)},n.override(l,"xAxisMax",function(){var t=this._xAxisMax();"resolution"in l.xUnits()&&(t+=l.xUnits().resolution);return t}),l.anchor(e,r)},n.lineChart=function(e,r){var i,a,o="dc-tooltip",l="dot",u="yRef",c="xRef",s=3,d=n.stackMixin(n.coordinateGridMixin({})),f=!1,h=5,g=null,p=1e-6,m=1e-6,y=null,v=null,x=null,A=!0;function b(t,e){return d.getColor.call(t,t.values,e)}function w(){var e=null;if(y)return y;"function"==typeof v?e=v:e={linear:t.curveLinear,"linear-closed":t.curveLinearClosed,step:t.curveStep,"step-before":t.curveStepBefore,"step-after":t.curveStepAfter,basis:t.curveBasis,"basis-open":t.curveBasisOpen,"basis-closed":t.curveBasisClosed,bundle:t.curveBundle,cardinal:t.curveCardinal,"cardinal-open":t.curveCardinalOpen,"cardinal-closed":t.curveCardinalClosed,monotone:t.curveMonotoneX}[v];return e||(e=t.curveLinear),null!==x&&("function"!=typeof e.tension?n.logger.warn("tension was specified but the curve/interpolate does not support it."):e=e.tension(x)),e}function _(t){return!t||t.indexOf("NaN")>=0?"M0,0":t}function k(){return g||h}function D(t,e){d.renderTitle()&&(t.select("title").remove(),t.append("title").text(n.pluck("data",d.title(e.name))))}function L(e,n,r){return function(){var i=t.select(this),a=i.attr("stroke")===e&&i.attr("stroke-dasharray")===(n instanceof Array?n.join(","):null)||i.attr("fill")===e;return r?!a:a}}return d.transitionDuration(500),d.transitionDelay(0),d._rangeBandPadding(1),d.plotData=function(){var e=d.chartBodyG(),r=e.select("g.stack-list");r.empty()&&(r=e.append("g").attr("class","stack-list"));var g=r.selectAll("g.stack").data(d.data()),y=g.enter().append("g").attr("class",function(t,e){return"stack _"+e});g=y.merge(g),function(e,r){var o=t.line().x(function(t){return d.x()(t.x)}).y(function(t){return d.y()(t.y+t.y0)}).curve(w());i&&o.defined(i);var l=e.append("path").attr("class","line").attr("stroke",b);a&&l.attr("stroke-dasharray",a);n.transition(r.select("path.line"),d.transitionDuration(),d.transitionDelay()).attr("stroke",b).attr("d",function(t){return _(o(t.values))})}(y,g),function(e,r){if(f){var a=t.area().x(function(t){return d.x()(t.x)}).y1(function(t){return d.y()(t.y+t.y0)}).y0(function(t){return d.y()(t.y0)}).curve(w());i&&a.defined(i),e.append("path").attr("class","area").attr("fill",b).attr("d",function(t){return _(a(t.values))}),n.transition(r.select("path.area"),d.transitionDuration(),d.transitionDelay()).attr("fill",b).attr("d",function(t){return _(a(t.values))})}}(y,g),function(e,r){if("always"===d.xyTipsOn()||!d.brushOn()&&!d.parentBrushOn()&&d.xyTipsOn()){var a=o+"-list",s=e.select("g."+a);s.empty()&&(s=e.append("g").attr("class",a)),r.each(function(e,r){var a=e.values;i&&(a=a.filter(i));var f=s.select("g."+o+"._"+r);f.empty()&&(f=s.append("g").attr("class",o+" _"+r)),function(t){(t.select("path."+u).empty()?t.append("path").attr("class",u):t.select("path."+u)).style("display","none").attr("stroke-dasharray","5,5"),(t.select("path."+c).empty()?t.append("path").attr("class",c):t.select("path."+c)).style("display","none").attr("stroke-dasharray","5,5")}(f);var g=f.selectAll("circle."+l).data(a,n.pluck("x")),y=g.enter().append("circle").attr("class",l).attr("cx",function(t){return n.utils.safeNumber(d.x()(t.x))}).attr("cy",function(t){return n.utils.safeNumber(d.y()(t.y+t.y0))}).attr("r",k()).style("fill-opacity",p).style("stroke-opacity",m).attr("fill",d.getColor).on("mousemove",function(){var e=t.select(this);!function(t){t.style("fill-opacity",.8),t.style("stroke-opacity",.8),t.attr("r",h)}(e),function(t,e){var n=t.attr("cx"),r=t.attr("cy"),i="M"+(d._yAxisX()-d.margins().left)+" "+r+"L"+n+" "+r,a="M"+n+" "+d.yAxisHeight()+"L"+n+" "+r;e.select("path."+u).style("display","").attr("d",i),e.select("path."+c).style("display","").attr("d",a)}(e,f)}).on("mouseout",function(){var e=t.select(this);!function(t){t.style("fill-opacity",p).style("stroke-opacity",m).attr("r",k())}(e),function(t){t.select("path."+u).style("display","none"),t.select("path."+c).style("display","none")}(f)}).merge(g);y.call(D,e),n.transition(y,d.transitionDuration()).attr("cx",function(t){return n.utils.safeNumber(d.x()(t.x))}).attr("cy",function(t){return n.utils.safeNumber(d.y()(t.y+t.y0))}).attr("fill",d.getColor),g.exit().remove()})}}(e,g),d.renderLabel()&&function(e){e.each(function(e,r){var i=t.select(this),a=i.selectAll("text.lineLabel").data(e.values,n.pluck("x")),o=a.enter().append("text").attr("class","lineLabel").attr("text-anchor","middle").merge(a);n.transition(o,d.transitionDuration()).attr("x",function(t){return n.utils.safeNumber(d.x()(t.x))}).attr("y",function(t){var e=d.y()(t.y+t.y0)-s;return n.utils.safeNumber(e)}).text(function(t){return d.label()(t)}),n.transition(a.exit(),d.transitionDuration()).attr("height",0).remove()})}(g)},d.curve=function(t){return arguments.length?(y=t,d):y},d.interpolate=n.logger.deprecate(function(t){return arguments.length?(v=t,d):v},"dc.lineChart.interpolate has been deprecated since version 3.0 use dc.lineChart.curve instead"),d.tension=n.logger.deprecate(function(t){return arguments.length?(x=t,d):x},"dc.lineChart.tension has been deprecated since version 3.0 use dc.lineChart.curve instead"),d.defined=function(t){return arguments.length?(i=t,d):i},d.dashStyle=function(t){return arguments.length?(a=t,d):a},d.renderArea=function(t){return arguments.length?(f=t,d):f},d.label(function(t){return n.utils.printSingleValue(t.y0+t.y)},!1),d.xyTipsOn=function(t){return arguments.length?(A=t,d):A},d.dotRadius=function(t){return arguments.length?(h=t,d):h},d.renderDataPoints=function(t){return arguments.length?(t?(p=t.fillOpacity||.8,m=t.strokeOpacity||.8,g=t.radius||2):(p=1e-6,m=1e-6,g=null),d):{fillOpacity:p,strokeOpacity:m,radius:g}},d.legendHighlight=function(t){d.isLegendableHidden(t)||d.g().selectAll("path.line, path.area").classed("highlight",L(t.color,t.dashstyle)).classed("fadeout",L(t.color,t.dashstyle,!0))},d.legendReset=function(){d.g().selectAll("path.line, path.area").classed("highlight",!1).classed("fadeout",!1)},n.override(d,"legendables",function(){var t=d._legendables();return a?t.map(function(t){return t.dashstyle=a,t}):t}),d.anchor(e,r)},n.dataCount=function(e,r){var i=t.format(",d"),a=n.baseMixin({}),o={some:"",all:""};return a.html=function(t){return arguments.length?(t.all&&(o.all=t.all),t.some&&(o.some=t.some),a):o},a.formatNumber=function(t){return arguments.length?(i=t,a):i},a._doRender=function(){var t=a.dimension().size(),e=a.group().value(),n=i(t),r=i(e);return t===e&&""!==o.all?a.root().html(o.all.replace("%total-count",n).replace("%filter-count",r)):""!==o.some?a.root().html(o.some.replace("%total-count",n).replace("%filter-count",r)):(a.selectAll(".total-count").text(n),a.selectAll(".filter-count").text(r)),a},a._doRedraw=function(){return a._doRender()},a.anchor(e,r)},n.dataTable=function(e,r){var i,a="dc-table-label",o="dc-table-row",l="dc-table-column",u="dc-table-group",c="dc-table-head",s=n.baseMixin({}),d=25,f=[],h=function(t){return t},g=t.ascending,p=0,m=!0;return s._doRender=function(){var e,n,r;return s.selectAll("tbody").remove(),e=function(){var e=!0;if(f.forEach(function(t){e&="function"==typeof t}),!e){var n=s.selectAll("thead").data([0]);n.exit().remove();var r=(n=n.enter().append("thead").merge(n)).selectAll("tr").data([0]);r.exit().remove();var o=(r=r.enter().append("tr").merge(r)).selectAll("th").data(f);o.exit().remove(),o.enter().append("th").merge(o).attr("class",c).html(function(t){return s._doColumnHeaderFormat(t)})}var l=s.root().selectAll("tbody").data(function(){var e;e=g===t.ascending?s.dimension().bottom(d):s.dimension().top(d);return t.nest().key(s.group()).sortKeys(g).entries(e.sort(function(t,e){return g(h(t),h(e))}).slice(p,i))}(),function(t){return s.keyAccessor()(t)}),y=l.enter().append("tbody");!0===m&&y.append("tr").attr("class",u).append("td").attr("class",a).attr("colspan",f.length).html(function(t){return s.keyAccessor()(t)});return l.exit().remove(),y}(),n=e.order().selectAll("tr."+o).data(function(t){return t.values}),r=n.enter().append("tr").attr("class",o),f.forEach(function(t,e){r.append("td").attr("class",l+" _"+e).html(function(e){return s._doColumnValueFormat(t,e)})}),n.exit().remove(),s},s._doColumnValueFormat=function(t,e){return"function"==typeof t?t(e):"string"==typeof t?e[t]:t.format(e)},s._doColumnHeaderFormat=function(t){return"function"==typeof t?s._doColumnHeaderFnToString(t):"string"==typeof t?s._doColumnHeaderCapitalize(t):String(t.label)},s._doColumnHeaderCapitalize=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},s._doColumnHeaderFnToString=function(t){var e=String(t),n=e.indexOf("return ");if(n>=0){var r=e.lastIndexOf(";");if(r>=0)(e=e.substring(n+7,r)).indexOf("numberFormat")>=0&&(e=e.replace("numberFormat",""))}return e},s._doRedraw=function(){return s._doRender()},s.size=function(t){return arguments.length?(d=t,s):d},s.beginSlice=function(t){return arguments.length?(p=t,s):p},s.endSlice=function(t){return arguments.length?(i=t,s):i},s.columns=function(t){return arguments.length?(f=t,s):f},s.sortBy=function(t){return arguments.length?(h=t,s):h},s.order=function(t){return arguments.length?(g=t,s):g},s.showGroups=function(t){return arguments.length?(m=t,s):m},s.anchor(e,r)},n.dataGrid=function(e,r){var i,a="dc-grid-item",o="dc-grid-top",l=n.baseMixin({}),u=999,c=function(t){return"you need to provide an html() handling param: "+JSON.stringify(t)},s=function(t){return t},d=t.ascending,f=0,h=function(t){return"

"+l.keyAccessor()(t)+"

"};return l._doRender=function(){var e,n;return l.selectAll("div."+o).remove(),e=function(){var e=l.root().selectAll("div."+o).data((r=l.dimension().top(u),t.nest().key(l.group()).sortKeys(d).entries(r.sort(function(t,e){return d(s(t),s(e))}).slice(f,i))),function(t){return l.keyAccessor()(t)}),n=e.enter().append("div").attr("class",o);var r;h&&n.html(function(t){return h(t)});return e.exit().remove(),n}(),(n=e.order().selectAll("div."+a).data(function(t){return t.values})).exit().remove(),n=n.enter().append("div").attr("class",a).html(function(t){return c(t)}).merge(n),l},l._doRedraw=function(){return l._doRender()},l.beginSlice=function(t){return arguments.length?(f=t,l):f},l.endSlice=function(t){return arguments.length?(i=t,l):i},l.size=function(t){return arguments.length?(u=t,l):u},l.html=function(t){return arguments.length?(c=t,l):c},l.htmlGroup=function(t){return arguments.length?(h=t,l):h},l.sortBy=function(t){return arguments.length?(s=t,l):s},l.order=function(t){return arguments.length?(d=t,l):d},l.anchor(e,r)},n.bubbleChart=function(t,e){var r=n.bubbleMixin(n.coordinateGridMixin({}));r.transitionDuration(750),r.transitionDelay(0);var i=function(t){return"translate("+function(t){var e=r.x()(r.keyAccessor()(t));!isNaN(e)&&isFinite(e)||(e=0);return e}(t)+","+function(t){var e=r.y()(r.valueAccessor()(t));!isNaN(e)&&isFinite(e)||(e=0);return e}(t)+")"};return r.plotData=function(){r.calculateRadiusDomain(),r.r().range([r.MIN_RADIUS,r.xAxisLength()*r.maxBubbleRelativeSize()]);var t=r.data(),e=r.chartBodyG().selectAll("g."+r.BUBBLE_NODE_CLASS).data(t,function(t){return t.key});r.sortBubbleSize()&&e.order(),function(t){n.transition(t,r.transitionDuration(),r.transitionDelay()).attr("transform",i).select("circle."+r.BUBBLE_CLASS).attr("fill",r.getColor).attr("r",function(t){return r.bubbleR(t)}).attr("opacity",function(t){return r.bubbleR(t)>0?1:0}),r.doUpdateLabels(t),r.doUpdateTitles(t)}(e=function(t){var e=t.enter().append("g");return e.attr("class",r.BUBBLE_NODE_CLASS).attr("transform",i).append("circle").attr("class",function(t,e){return r.BUBBLE_CLASS+" _"+e}).on("click",r.onClick).attr("fill",r.getColor).attr("r",0),t=e.merge(t),n.transition(t,r.transitionDuration(),r.transitionDelay()).select("circle."+r.BUBBLE_CLASS).attr("r",function(t){return r.bubbleR(t)}).attr("opacity",function(t){return r.bubbleR(t)>0?1:0}),r._doRenderLabel(e),r._doRenderTitles(e),t}(e)),function(t){t.exit().remove()}(e),r.fadeDeselectedArea(r.filter())},r.renderBrush=function(){},r.redrawBrush=function(t,e){r.fadeDeselectedArea(t)},r.anchor(t,e)},n.compositeChart=function(e,r){var i,a="sub",o=n.coordinateGridMixin({}),l=[],u={},c=!1,s=!0,d=!1,f=t.axisRight(),h=0,g=12,p=!1;function m(t,e){t._generateG(o.g()),t.g().attr("class",a+" _"+e)}function y(){return l.filter(function(t){return!t.useRightYAxis()})}function v(){return l.filter(function(t){return t.useRightYAxis()})}function x(t){return t.map(function(t){return t.yAxisMin()})}function A(t){return t.map(function(t){return t.yAxisMax()})}return o._mandatoryAttributes([]),o.transitionDuration(500),o.transitionDelay(0),n.override(o,"_generateG",function(){for(var t=this.__generateG(),e=0;e0&&!p?o._renderHorizontalGridLinesForAxis(o.g(),o.y(),o.yAxis()):v().length>0&&o._renderHorizontalGridLinesForAxis(o.g(),i,f)},o.renderYAxis=function(){0!==y().length&&(o.renderYAxisAt("y",o.yAxis(),o.margins().left),o.renderYAxisLabel("y",o.yAxisLabel(),-90)),0!==v().length&&(o.renderYAxisAt("yr",o.rightYAxis(),o.width()-o.margins().right),o.renderYAxisLabel("yr",o.rightYAxisLabel(),90,o.width()-g))},o.plotData=function(){for(var t=0;t0&&(e[0]=0),e[1]<0&&(e[1]=0),a=t.scaleLinear().domain(e).range([0,v.effectiveWidth()])}x.scale(a)}(),e.empty()&&(e=i.append("g").attr("class","axis")),e.attr("transform","translate(0, "+v.effectiveHeight()+")"),n.transition(e,v.transitionDuration(),v.transitionDelay()).call(x)}function b(){l=v.data(),A(),i.selectAll("g.tick").select("line.grid-line").remove(),i.selectAll("g.tick").append("line").attr("class","grid-line").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",function(){return-v.effectiveHeight()});var t=i.selectAll("g."+p).data(l);!function(t){t.exit().remove()}(t),function(t){var e,r=l.length;e=g||(v.effectiveHeight()-(r+1)*h)/r;s||(c=e/2);var i=t.attr("transform",function(t,n){return"translate(0,"+((n+1)*h+n*e)+")"}).select("rect").attr("height",e).attr("fill",v.getColor).on("click",_).classed("deselected",function(t){return!!v.hasFilter()&&!D(t)}).classed("selected",function(t){return!!v.hasFilter()&&D(t)});n.transition(i,v.transitionDuration(),v.transitionDelay()).attr("width",function(t){return Math.abs(w()-a(v.valueAccessor()(t)))}).attr("transform",k),function(t){v.renderTitle()&&(t.select("title").remove(),t.append("title").text(v.title()))}(t),function(t){if(v.renderLabel()){var e=t.select("text").attr("x",u).attr("y",c).attr("dy",d).on("click",_).attr("class",function(t,e){return p+" _"+e}).text(function(t){return v.label()(t)});n.transition(e,v.transitionDuration(),v.transitionDelay()).attr("transform",k)}if(v.renderTitleLabel()){var r=t.select("."+m).attr("x",v.effectiveWidth()-f).attr("y",c).attr("dy",d).attr("text-anchor","end").on("click",_).attr("class",function(t,e){return m+" _"+e}).text(function(t){return v.title()(t)});n.transition(r,v.transitionDuration(),v.transitionDelay()).attr("transform",k)}}(t)}(t=function(t){var e=t.enter().append("g").attr("class",function(t,e){return p+" _"+e});return e.append("rect").attr("width",0),function(t){v.renderLabel()&&t.append("text").on("click",_),v.renderTitleLabel()&&t.append("text").attr("class",m).on("click",_)}(e),e}(t).merge(t))}function w(){var t=a(0);return t===-1/0||t!=t?a(1):t}function _(t){v.onClick(t)}function k(t){var e=a(v.cappedValueAccessor(t)),n=w();return"translate("+(e>n?n:e)+",0)"}function D(t){return v.hasFilter(v.cappedKeyAccessor(t))}return v.rowsCap=v.cap,v._doRender=function(){return v.resetSvg(),i=v.svg().append("g").attr("transform","translate("+v.margins().left+","+v.margins().top+")"),b(),v},v.title(function(t){return v.cappedKeyAccessor(t)+": "+v.cappedValueAccessor(t)}),v.label(v.cappedKeyAccessor),v.x=function(t){return arguments.length?(a=t,v):a},v.renderTitleLabel=function(t){return arguments.length?(y=t,v):y},v._doRedraw=function(){return b(),v},v.xAxis=function(t){return arguments.length?(x=t,this):x},v.fixedBarHeight=function(t){return arguments.length?(g=t,v):g},v.gap=function(t){return arguments.length?(h=t,v):h},v.elasticX=function(t){return arguments.length?(o=t,v):o},v.labelOffsetX=function(t){return arguments.length?(u=t,v):u},v.labelOffsetY=function(t){return arguments.length?(c=t,s=!0,v):c},v.titleLabelOffsetX=function(t){return arguments.length?(f=t,v):f},v.anchor(e,r)},n.legend=function(){var t,e,r,i={},a=0,o=0,l=12,u=5,c=!1,s=560,d=70,f=!1,h=n.pluck("name");function g(){return u+l}return i.parent=function(e){return arguments.length?(t=e,i):t},i.render=function(){t.svg().select("g.dc-legend").remove(),r=t.svg().append("g").attr("class","dc-legend").attr("transform","translate("+a+","+o+")");var i=t.legendables();void 0!==e&&(i=i.slice(0,e));var p=r.selectAll("g.dc-legend-item").data(i).enter().append("g").attr("class","dc-legend-item").on("mouseover",function(e){t.legendHighlight(e)}).on("mouseout",function(e){t.legendReset(e)}).on("click",function(t){t.chart.legendToggle(t)});r.selectAll("g.dc-legend-item").classed("fadeout",function(t){return t.chart.isLegendableHidden(t)}),i.some(n.pluck("dashstyle"))?p.append("line").attr("x1",0).attr("y1",l/2).attr("x2",l).attr("y2",l/2).attr("stroke-width",2).attr("stroke-dasharray",n.pluck("dashstyle")).attr("stroke",n.pluck("color")):p.append("rect").attr("width",l).attr("height",l).attr("fill",function(t){return t?t.color:"blue"}),p.append("text").text(h).attr("x",l+2).attr("y",function(){return l/2+(this.clientHeight?this.clientHeight:13)/2-2});var m=0,y=0;p.attr("transform",function(t,e){if(c){var n=!0===f?this.getBBox().width+u:d;m+n>s&&m>0&&(++y,m=0);var r="translate("+m+","+y*g()+")";return m+=n,r}return"translate(0,"+e*g()+")"})},i.x=function(t){return arguments.length?(a=t,i):a},i.y=function(t){return arguments.length?(o=t,i):o},i.gap=function(t){return arguments.length?(u=t,i):u},i.itemHeight=function(t){return arguments.length?(l=t,i):l},i.horizontal=function(t){return arguments.length?(c=t,i):c},i.legendWidth=function(t){return arguments.length?(s=t,i):s},i.itemWidth=function(t){return arguments.length?(d=t,i):d},i.autoItemWidth=function(t){return arguments.length?(f=t,i):f},i.legendText=function(t){return arguments.length?(h=t,i):h},i.maxItems=function(t){return arguments.length?(e=n.utils.isNumber(t)?t:void 0,i):e},i},n.htmlLegend=function(){var e,r,i,a,o={},l=n.pluck("name"),u=!1,c=!1;return o.parent=function(t){return arguments.length?(e=t,o):e},o.render=function(){var t=u?"dc-legend-item-horizontal":"dc-legend-item-vertical";r.select("div.dc-html-legend").remove();var o=r.append("div").attr("class","dc-html-legend");o.attr("style","max-width:"+r.nodes()[0].style.width);var s=e.legendables(),d=e.filters();void 0!==i&&(s=s.slice(0,i));var f=a||t,h=o.selectAll("div."+f).data(s).enter().append("div").classed(f,!0).on("mouseover",e.legendHighlight).on("mouseout",e.legendReset).on("click",e.legendToggle);c&&h.classed(n.constants.SELECTED_CLASS,function(t){return-1!==d.indexOf(t.name)}),h.append("span").attr("class","dc-legend-item-color").style("background-color",n.pluck("color")),h.append("span").attr("class","dc-legend-item-label").attr("title",l).text(l)},o.container=function(e){return arguments.length?(r=t.select(e),o):r},o.legendItemClass=function(t){return arguments.length?(a=t,o):a},o.highlightSelected=function(t){return arguments.length?(c=t,o):c},o.horizontal=function(t){return arguments.length?(u=t,o):u},o.legendText=function(t){return arguments.length?(l=t,o):l},o.maxItems=function(t){return arguments.length?(i=n.utils.isNumber(t)?t:void 0,o):i},o},n.scatterPlot=function(e,r){var i=n.coordinateGridMixin({}),a=t.symbol(),o=function(t){return t.value},l=i.keyAccessor();i.keyAccessor(function(t){return l(t)[0]}),i.valueAccessor(function(t){return l(t)[1]}),i.colorAccessor(function(){return i._groupName}),i.title(function(t){return i.keyAccessor()(t)+","+i.valueAccessor()(t)+": "+i.existenceAccessor()(t)});var u=function(t){return"translate("+i.x()(i.keyAccessor()(t))+","+i.y()(i.valueAccessor()(t))+")"},c=7,s=5,d=3,f=null,h=1,g=0,p=0,m=1,y=null,v=[];function x(t,e){return o(t)?v[e]?Math.pow(s,2):Math.pow(d,2):Math.pow(g,2)}function A(t,e){i.renderTitle()&&(t.selectAll("title").remove(),t.append("title").text(function(t){return i.title()(t)}))}function b(e,r){var o=i.chartBodyG().selectAll(".chart-body path.symbol").filter(function(){return e(t.select(this))}),l=a.size();a.size(Math.pow(r,2)),n.transition(o,i.transitionDuration(),i.transitionDelay()).attr("d",a),a.size(l)}return i.brush(t.brush()),a.size(x),n.override(i,"_filter",function(t){return arguments.length?i.__filter(n.filters.RangedTwoDimensionalFilter(t)):i.__filter()}),i.plotData=function(){var t=i.chartBodyG().selectAll("path.symbol").data(i.data());(t=t.enter().append("path").attr("class","symbol").attr("opacity",0).attr("fill",i.getColor).attr("transform",u).merge(t)).call(A,i.data()),t.each(function(t,e){v[e]=!i.filter()||i.filter().isFiltered([i.keyAccessor()(t),i.valueAccessor()(t)])}),n.transition(t,i.transitionDuration(),i.transitionDelay()).attr("opacity",function(t,e){return o(t)?v[e]?m:i.excludedOpacity():p}).attr("fill",function(t,e){return y&&!o(t)?y:i.excludedColor()&&!v[e]?i.excludedColor():i.getColor(t)}).attr("transform",u).attr("d",a),n.transition(t.exit(),i.transitionDuration(),i.transitionDelay()).attr("opacity",0).remove()},i.existenceAccessor=function(t){return arguments.length?(o=t,this):o},i.symbol=function(t){return arguments.length?(a.type(t),i):a.type()},i.customSymbol=function(t){return arguments.length?((a=t).size(x),i):a},i.symbolSize=function(t){return arguments.length?(s=t,i):s},i.highlightedSize=function(t){return arguments.length?(c=t,i):c},i.excludedSize=function(t){return arguments.length?(d=t,i):d},i.excludedColor=function(t){return arguments.length?(f=t,i):f},i.excludedOpacity=function(t){return arguments.length?(h=t,i):h},i.hiddenSize=i.emptySize=function(t){return arguments.length?(g=t,i):g},i.emptyColor=function(t){return arguments.length?(y=t,i):y},i.emptyOpacity=function(t){return arguments.length?(p=t,i):p},i.nonemptyOpacity=function(t){return arguments.length?(m=t,i):p},i.legendables=function(){return[{chart:i,name:i._groupName,color:i.getColor()}]},i.legendHighlight=function(e){b(function(t){return t.attr("fill")===e.color},c),i.chartBodyG().selectAll(".chart-body path.symbol").filter(function(){return t.select(this).attr("fill")!==e.color}).classed("fadeout",!0)},i.legendReset=function(e){b(function(t){return t.attr("fill")===e.color},s),i.chartBodyG().selectAll(".chart-body path.symbol").filter(function(){return t.select(this).attr("fill")!==e.color}).classed("fadeout",!1)},i.createBrushHandlePaths=function(){},i.extendBrush=function(t){return i.round()&&(t[0]=t[0].map(i.round()),t[1]=t[1].map(i.round())),t},i.brushIsEmpty=function(t){return!t||t[0][0]>=t[1][0]||t[0][1]>=t[1][1]},i._brushing=function(){if(t.event.sourceEvent&&(!t.event.sourceEvent.type||-1===["start","brush","end"].indexOf(t.event.sourceEvent.type))){var e=t.event.selection,r=i.brushIsEmpty(e);e&&(e=e.map(function(t){return t.map(function(t,e){return(0===e?i.x():i.y()).invert(t)})}),e=i.extendBrush(e),r=r&&i.brushIsEmpty(e)),i.redrawBrush(e,!1);var a=r?null:n.filters.RangedTwoDimensionalFilter(e);n.events.trigger(function(){i.replaceFilter(a),i.redrawGroup()},n.constants.EVENT_DELAY)}},i.redrawBrush=function(t,e){var r=i.brush(),a=i.gBrush();i.brushOn()&&a&&(i.resizing()&&i.setBrushExtents(e),t?(t=t.map(function(t){return t.map(function(t,e){return(0===e?i.x():i.y())(t)})}),n.optionalTransition(e,i.transitionDuration(),i.transitionDelay())(a).call(r.move,t)):a.call(r.move,t));i.fadeDeselectedArea(t)},i.setBrushY=function(t){t.call(i.brush().y(i.y()))},i.anchor(e,r)},n.numberDisplay=function(e,r){var i,a=t.format(".2s"),o=n.baseMixin({}),l={one:"",some:"",none:""};return o._mandatoryAttributes(["group"]),o.ordering(function(t){return t.value}),o.html=function(t){return arguments.length?(t.none?l.none=t.none:t.one?l.none=t.one:t.some&&(l.none=t.some),t.one?l.one=t.one:t.some&&(l.one=t.some),t.some?l.some=t.some:t.one&&(l.some=t.one),o):l},o.value=function(){return o.data()},o.data(function(t){var e=t.value?t.value():function(t){if(!t.length)return null;var e=o._computeOrderedGroups(t);return e[e.length-1]}(t.all());return o.valueAccessor()(e)}),o.transitionDuration(250),o.transitionDelay(0),o._doRender=function(){var e=o.value(),n=o.selectAll(".number-display");n.empty()&&(n=n.data([0]).enter().append("span").attr("class","number-display").merge(n)),n.transition().duration(o.transitionDuration()).delay(o.transitionDelay()).ease(t.easeQuad).tween("text",function(){var n=isFinite(i)?i:0,r=t.interpolateNumber(n||0,e);i=e;var a=this;return function(t){var n=null,i=o.formatNumber()(r(t));0===e&&""!==l.none?n=l.none:1===e&&""!==l.one?n=l.one:""!==l.some&&(n=l.some),a.innerHTML=n?n.replace("%number",i):i}})},o._doRedraw=function(){return o._doRender()},o.formatNumber=function(t){return arguments.length?(a=t,o):a},o.anchor(e,r)},n.heatMap=function(e,r){var i,a,o,l=t.ascending,u=t.ascending,c=t.scaleBand(),s=t.scaleBand(),d=6.75,f=6.75,h=n.colorMixin(n.marginMixin(n.baseMixin({})));h._mandatoryAttributes(["group"]),h.title(h.colorAccessor());var g=function(t){return t},p=function(t){return t};h.colsLabel=function(t){return arguments.length?(g=t,h):g},h.rowsLabel=function(t){return arguments.length?(p=t,h):p};var m=function(t){x(0,t)},y=function(t){x(1,t)},v=function(t){var e=t.key;n.events.trigger(function(){h.filter(e),h.redrawGroup()})};function x(t,e){var r=h.selectAll(".box-group").filter(function(n){return n.key[t]===e}),i=r.filter(function(t){return!h.hasFilter(t.key)});n.events.trigger(function(){var t=(i.empty()?r:i).data().map(function(t){return n.filters.TwoDimensionalFilter(t.key)});h._filter([t]),h.redrawGroup()})}return n.override(h,"filter",function(t){return arguments.length?h._filter(n.filters.TwoDimensionalFilter(t)):h._filter()}),h.rows=function(t){return arguments.length?(o=t,h):o},h.rowOrdering=function(t){return arguments.length?(u=t,h):u},h.cols=function(t){return arguments.length?(a=t,h):a},h.colOrdering=function(t){return arguments.length?(l=t,h):l},h._doRender=function(){return h.resetSvg(),i=h.svg().append("g").attr("class","heatmap").attr("transform","translate("+h.margins().left+","+h.margins().top+")"),h._doRedraw()},h._doRedraw=function(){var t=h.data(),e=h.rows()||t.map(h.valueAccessor()),r=h.cols()||t.map(h.keyAccessor());u&&(e=e.sort(u)),l&&(r=r.sort(l)),e=s.domain(e),r=c.domain(r);var a=e.domain().length,o=r.domain().length,g=Math.floor(h.effectiveWidth()/o),p=Math.floor(h.effectiveHeight()/a);r.rangeRound([0,h.effectiveWidth()]),e.rangeRound([h.effectiveHeight(),0]);var m=i.selectAll("g.box-group").data(h.data(),function(t,e){return h.keyAccessor()(t,e)+"\0"+h.valueAccessor()(t,e)});m.exit().remove();var y=m.enter().append("g").attr("class","box-group");y.append("rect").attr("class","heat-box").attr("fill","white").attr("x",function(t,e){return r(h.keyAccessor()(t,e))}).attr("y",function(t,n){return e(h.valueAccessor()(t,n))}).on("click",h.boxOnClick()),h.renderTitle()&&(y.append("title"),m.select("title").text(h.title())),m=y.merge(m),n.transition(m.select("rect"),h.transitionDuration(),h.transitionDelay()).attr("x",function(t,e){return r(h.keyAccessor()(t,e))}).attr("y",function(t,n){return e(h.valueAccessor()(t,n))}).attr("rx",d).attr("ry",f).attr("fill",h.getColor).attr("width",g).attr("height",p);var v=i.select("g.cols");v.empty()&&(v=i.append("g").attr("class","cols axis"));var x=v.selectAll("text").data(r.domain());x.exit().remove(),x=x.enter().append("text").attr("x",function(t){return r(t)+g/2}).style("text-anchor","middle").attr("y",h.effectiveHeight()).attr("dy",12).on("click",h.xAxisOnClick()).text(h.colsLabel()).merge(x),n.transition(x,h.transitionDuration(),h.transitionDelay()).text(h.colsLabel()).attr("x",function(t){return r(t)+g/2}).attr("y",h.effectiveHeight());var A=i.select("g.rows");A.empty()&&(A=i.append("g").attr("class","rows axis"));var b=A.selectAll("text").data(e.domain());return b.exit().remove(),b=b.enter().append("text").style("text-anchor","end").attr("x",0).attr("dx",-2).attr("y",function(t){return e(t)+p/2}).attr("dy",6).on("click",h.yAxisOnClick()).text(h.rowsLabel()).merge(b),n.transition(b,h.transitionDuration(),h.transitionDelay()).text(h.rowsLabel()).attr("y",function(t){return e(t)+p/2}),h.hasFilter()?h.selectAll("g.box-group").each(function(t){h.isSelectedNode(t)?h.highlightSelected(this):h.fadeDeselected(this)}):h.selectAll("g.box-group").each(function(){h.resetHighlight(this)}),h},h.boxOnClick=function(t){return arguments.length?(v=t,h):v},h.xAxisOnClick=function(t){return arguments.length?(m=t,h):m},h.yAxisOnClick=function(t){return arguments.length?(y=t,h):y},h.xBorderRadius=function(t){return arguments.length?(d=t,h):d},h.yBorderRadius=function(t){return arguments.length?(f=t,h):f},h.isSelectedNode=function(t){return h.hasFilter(t.key)},h.anchor(e,r)},function(){function e(t){return[0,t.length-1]}function r(e){return[t.quantile(e,.25),t.quantile(e,.5),t.quantile(e,.75)]}t.box=function(){var i=1,a=1,o=0,l=0,u=null,c=Number,s=e,d=r,f=null;function h(e){e.each(function(e,n){e=e.map(c).sort(t.ascending);var r=t.select(this),h=e.length,g=e[0],p=e[h-1],m=e.quartiles=d(e),y=s&&s.call(this,e,n),v=y&&y.map(function(t){return e[t]}),x=y?t.range(0,y[0]).concat(t.range(y[1]+1,h)):t.range(h),A=t.scaleLinear().domain(u&&u.call(this,e,n)||[g,p]).range([a,0]),b=this.__chart__||t.scaleLinear().domain([0,1/0]).range(A.range());this.__chart__=A;var w=r.selectAll("line.center").data(v?[v]:[]);w.enter().insert("line","rect").attr("class","center").attr("x1",i/2).attr("y1",function(t){return b(t[0])}).attr("x2",i/2).attr("y2",function(t){return b(t[1])}).style("opacity",1e-6).transition().duration(o).delay(l).style("opacity",1).attr("y1",function(t){return A(t[0])}).attr("y2",function(t){return A(t[1])}),w.transition().duration(o).delay(l).style("opacity",1).attr("x1",i/2).attr("x2",i/2).attr("y1",function(t){return A(t[0])}).attr("y2",function(t){return A(t[1])}),w.exit().transition().duration(o).delay(l).style("opacity",1e-6).attr("y1",function(t){return A(t[0])}).attr("y2",function(t){return A(t[1])}).remove();var _=r.selectAll("rect.box").data([m]);_.enter().append("rect").attr("class","box").attr("x",0).attr("y",function(t){return b(t[2])}).attr("width",i).attr("height",function(t){return b(t[0])-b(t[2])}).transition().duration(o).delay(l).attr("y",function(t){return A(t[2])}).attr("height",function(t){return A(t[0])-A(t[2])}),_.transition().duration(o).delay(l).attr("width",i).attr("y",function(t){return A(t[2])}).attr("height",function(t){return A(t[0])-A(t[2])});var k=r.selectAll("line.median").data([m[1]]);k.enter().append("line").attr("class","median").attr("x1",0).attr("y1",b).attr("x2",i).attr("y2",b).transition().duration(o).delay(l).attr("y1",A).attr("y2",A),k.transition().duration(o).delay(l).attr("x1",0).attr("x2",i).attr("y1",A).attr("y2",A);var D=r.selectAll("line.whisker").data(v||[]);D.enter().insert("line","circle, text").attr("class","whisker").attr("x1",0).attr("y1",b).attr("x2",i).attr("y2",b).style("opacity",1e-6).transition().duration(o).delay(l).attr("y1",A).attr("y2",A).style("opacity",1),D.transition().duration(o).delay(l).attr("x1",0).attr("x2",i).attr("y1",A).attr("y2",A).style("opacity",1),D.exit().transition().duration(o).delay(l).attr("y1",A).attr("y2",A).style("opacity",1e-6).remove();var L=r.selectAll("circle.outlier").data(x,Number);L.enter().insert("circle","text").attr("class","outlier").attr("r",5).attr("cx",i/2).attr("cy",function(t){return b(e[t])}).style("opacity",1e-6).transition().duration(o).delay(l).attr("cy",function(t){return A(e[t])}).style("opacity",1),L.transition().duration(o).delay(l).attr("cx",i/2).attr("cy",function(t){return A(e[t])}).style("opacity",1),L.exit().transition().duration(o).delay(l).attr("cy",function(t){return A(e[t])}).style("opacity",1e-6).remove();var C=f||A.tickFormat(8),E=r.selectAll("text.box").data(m);E.enter().append("text").attr("class","box").attr("dy",".3em").attr("dx",function(t,e){return 1&e?6:-6}).attr("x",function(t,e){return 1&e?i:0}).attr("y",b).attr("text-anchor",function(t,e){return 1&e?"start":"end"}).text(C).transition().duration(o).delay(l).attr("y",A),E.transition().duration(o).delay(l).text(C).attr("x",function(t,e){return 1&e?i:0}).attr("y",A);var O=r.selectAll("text.whisker").data(v||[]);O.enter().append("text").attr("class","whisker").attr("dy",".3em").attr("dx",6).attr("x",i).attr("y",b).text(C).style("opacity",1e-6).transition().duration(o).delay(l).attr("y",A).style("opacity",1),O.transition().duration(o).delay(l).text(C).attr("x",i).attr("y",A).style("opacity",1),O.exit().transition().duration(o).delay(l).attr("y",A).style("opacity",1e-6).remove()}),t.timerFlush()}return h.width=function(t){return arguments.length?(i=t,h):i},h.height=function(t){return arguments.length?(a=t,h):a},h.tickFormat=function(t){return arguments.length?(f=t,h):f},h.duration=function(t){return arguments.length?(o=t,h):o},h.domain=function(t){return arguments.length?(u=null===t?t:"function"==typeof t?t:n.utils.constant(t),h):u},h.value=function(t){return arguments.length?(c=t,h):c},h.whiskers=function(t){return arguments.length?(s=t,h):s},h.quartiles=function(t){return arguments.length?(d=t,h):d},h}}(),n.boxPlot=function(e,r){var i=n.coordinateGridMixin({});var a=function(t){return function(e){var n=e.quartiles[0],r=e.quartiles[2],i=(r-n)*t,a=-1,o=e.length;do{++a}while(e[a]r+i);return[a,o]}}(1.5),o=t.box(),l=null,u=function(t,e){return i.isOrdinal()?i.x().bandwidth():t/(1+i.boxPadding())/e};i.yAxisPadding(12),i.x(t.scaleBand()),i.xUnits(n.units.ordinal),i.data(function(t){return t.all().map(function(t){return t.map=function(e){return e.call(t,t)},t}).filter(function(t){return 0!==i.valueAccessor()(t).length})}),i.boxPadding=i._rangeBandPadding,i.boxPadding(.8),i.outerPadding=i._outerRangeBandPadding,i.outerPadding(.5),i.boxWidth=function(t){return arguments.length?(u="function"==typeof t?t:n.utils.constant(t),i):u};var c=function(t,e){return"translate("+i.x()(i.keyAccessor()(t,e))+", 0)"};return i._preprocessData=function(){i.elasticX()&&i.x().domain([])},i.plotData=function(){var e=u(i.effectiveWidth(),i.xUnitCount());o.whiskers(a).width(e).height(i.effectiveHeight()).value(i.valueAccessor()).domain(i.y().domain()).duration(i.transitionDuration()).tickFormat(l);var r=i.chartBodyG().selectAll("g.box").data(i.data(),i.keyAccessor());!function(e){n.transition(e,i.transitionDuration(),i.transitionDelay()).attr("transform",c).call(o).each(function(){t.select(this).select("rect.box").attr("fill",i.getColor)})}(function(t){var e=t.enter().append("g");return e.attr("class","box").attr("transform",c).call(o).on("click",function(t){i.filter(i.keyAccessor()(t)),i.redrawGroup()}),e.merge(t)}(r)),function(t){t.exit().remove().call(o)}(r),i.fadeDeselectedArea(i.filter())},i.fadeDeselectedArea=function(t){if(i.hasFilter())if(i.isOrdinal())i.g().selectAll("g.box").each(function(t){i.isSelectedNode(t)?i.highlightSelected(this):i.fadeDeselected(this)});else{if(!i.brushOn()&&!i.parentBrushOn())return;var e=t[0],n=t[1],r=i.keyAccessor();i.g().selectAll("g.box").each(function(t){var a=r(t);a=n?i.fadeDeselected(this):i.highlightSelected(this)})}else i.g().selectAll("g.box").each(function(){i.resetHighlight(this)})},i.isSelectedNode=function(t){return i.hasFilter(i.keyAccessor()(t))},i.yAxisMin=function(){var e=t.min(i.data(),function(e){return t.min(i.valueAccessor()(e))});return n.utils.subtract(e,i.yAxisPadding())},i.yAxisMax=function(){var e=t.max(i.data(),function(e){return t.max(i.valueAccessor()(e))});return n.utils.add(e,i.yAxisPadding())},i.tickFormat=function(t){return arguments.length?(l=t,i):l},i.anchor(e,r)},n.selectMenu=function(e,r){var i,a="dc-select-option",o=n.baseMixin({}),l="Select all",u=!1,c=null,s=null,d=function(t,e){return o.keyAccessor()(t)>o.keyAccessor()(e)?1:o.keyAccessor()(e)>o.keyAccessor()(t)?-1:0},f=function(t){return o.valueAccessor()(t)>0};o.data(function(t){return t.all().filter(f)}),o._doRender=function(){return o.select("select").remove(),(i=o.root().append("select").classed("dc-select-menu",!0)).append("option").text(l).attr("value",""),o._doRedraw(),o};var h=window.navigator.userAgent;function g(e,n){var r,i=t.event.target;i.selectedOptions?r=Array.prototype.slice.call(i.selectedOptions).map(function(t){return t.value}):r=[].slice.call(t.event.target.options).filter(function(t){return t.selected}).map(function(t){return t.value});1===r.length&&""===r[0]?r=c||null:u||1!==r.length||(r=r[0]),o.onChange(r)}return h.indexOf("Trident/")>0&&-1===h.indexOf("MSIE")&&(o.redraw=o.render),o._doRedraw=function(){var t;return function(){u?i.attr("multiple",!0):i.attr("multiple",null);null!==s?i.attr("size",s):i.attr("size",null)}(),(t=i.selectAll("option."+a).data(o.data(),function(t){return o.keyAccessor()(t)})).exit().remove(),t.enter().append("option").classed(a,!0).attr("value",function(t){return o.keyAccessor()(t)}).merge(t).text(o.title()),i.selectAll("option."+a).sort(d),i.on("change",g),o.hasFilter()&&u?i.selectAll("option").property("selected",function(t){return void 0!==t&&o.filters().indexOf(String(o.keyAccessor()(t)))>=0}):o.hasFilter()?i.property("value",o.filter()):i.property("value",""),o},o.onChange=function(t){t&&u?o.replaceFilter([t]):t?o.replaceFilter(t):o.filterAll(),n.events.trigger(function(){o.redrawGroup()})},o.order=function(t){return arguments.length?(d=t,o):d},o.promptText=function(t){return arguments.length?(l=t,o):l},o.filterDisplayed=function(t){return arguments.length?(f=t,o):f},o.multiple=function(t){return arguments.length?(u=t,o):u},o.promptValue=function(t){return arguments.length?(c=t,o):c},o.numberVisible=function(t){return arguments.length?(s=t,o):s},o.size=n.logger.deprecate(o.numberVisible,"selectMenu.size is ambiguous - use numberVisible instead"),o.anchor(e,r)},n.textFilterWidget=function(t,e){var r=n.baseMixin({}),i=function(t){return t.toLowerCase()},a=function(t){return t=i(t),function(e){return-1!==i(e).indexOf(t)}},o="search";return r.group(function(){throw"the group function on textFilterWidget should never be called, please report the issue"}),r._doRender=function(){return r.select("input").remove(),r.root().append("input").classed("dc-text-filter-input",!0).on("input",function(){r.dimension().filterFunction(a(this.value)),n.events.trigger(function(){n.redrawAll()},n.constants.EVENT_DELAY)}),r._doRedraw(),r},r._doRedraw=function(){return r.root().selectAll("input").attr("placeholder",o),r},r.normalize=function(t){return arguments.length?(i=t,r):i},r.placeHolder=function(t){return arguments.length?(o=t,r):o},r.filterFunctionFactory=function(t){return arguments.length?(a=t,r):a},r.anchor(t,e)},n.cboxMenu=function(e,r){var i,a="dc-cbox-item",o=n.baseMixin({}),l="Select all",u=!1,c="radio",s=null,d=Math.floor(1e5*Math.random())+1,f=function(t,e){return o.keyAccessor()(t)>o.keyAccessor()(e)?1:o.keyAccessor()(e)>o.keyAccessor()(t)?-1:0},h=function(t){return o.valueAccessor()(t)>0};function g(e,n){var r;t.select(t.event.target).datum()?(r=t.select(this).selectAll("input").filter(function(t){if(t)return this.checked}).nodes().map(function(t){return t.value}),u||1!==r.length||(r=r[0])):r=s||null,o.onChange(r)}return o.data(function(t){return t.all().filter(h)}),o._doRender=function(){return o._doRedraw()},o._doRedraw=function(){return o.select("ul").remove(),i=o.root().append("ul").classed("dc-cbox-group",!0),function(){var t=i.selectAll("li."+a).data(o.data(),function(t){return o.keyAccessor()(t)});if(t.exit().remove(),(t=t.enter().append("li").classed(a,!0).merge(t)).append("input").attr("type",c).attr("value",function(t){return o.keyAccessor()(t)}).attr("name","domain_"+d).attr("id",function(t,e){return"input_"+d+"_"+e}),t.append("label").attr("for",function(t,e){return"input_"+d+"_"+e}).text(o.title()),u)i.append("li").append("input").attr("type","reset").text(l).on("click",g);else{var e=i.append("li");e.append("input").attr("type",c).attr("value",s).attr("name","domain_"+d).attr("id",function(t,e){return"input_"+d+"_all"}).property("checked",!0),e.append("label").attr("for",function(t,e){return"input_"+d+"_all"}).text(l)}i.selectAll("li."+a).sort(f),i.on("change",g)}(),o.hasFilter()&&u?i.selectAll("input").property("checked",function(t){return t&&o.filters().indexOf(String(o.keyAccessor()(t)))>=0||!1}):o.hasFilter()&&i.selectAll("input").property("checked",function(t){return!!t&&o.keyAccessor()(t)===o.filter()}),o},o.onChange=function(t){t&&u?o.replaceFilter([t]):t?o.replaceFilter(t):o.filterAll(),n.events.trigger(function(){o.redrawGroup()})},o.order=function(t){return arguments.length?(f=t,o):f},o.promptText=function(t){return arguments.length?(l=t,o):l},o.filterDisplayed=function(t){return arguments.length?(h=t,o):h},o.multiple=function(t){return arguments.length?(c=(u=t)?"checkbox":"radio",o):u},o.promptValue=function(t){return arguments.length?(s=t,o):s},o.anchor(e,r)},n.abstractBubbleChart=n.bubbleMixin,n.baseChart=n.baseMixin,n.capped=n.capMixin,n.colorChart=n.colorMixin,n.coordinateGridChart=n.coordinateGridMixin,n.marginable=n.marginMixin,n.stackableChart=n.stackMixin,n.d3=t,n.crossfilter=e,n}if("function"==typeof define&&define.amd)define(["d3","crossfilter2"],t);else if("object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports){var e=require("d3"),n=require("crossfilter2");"function"!=typeof n&&(n=n.crossfilter),module.exports=t(e,n)}else this.dc=t(d3,crossfilter)}();var PODLOVE=PODLOVE||{};PODLOVE.Analytics=PODLOVE.Analytics||{},dc.config.defaultColors(d3.schemeAccent),PODLOVE.Analytics.decimalRound=function(t,e){var n=Math.pow(10,e);return t*=n,t=Math.round(t),t/=n},PODLOVE.Analytics.formatThousands=function(t){return t<1e3?t:PODLOVE.Analytics.decimalRound(t/1e3,1)+"k"},PODLOVE.Analytics.hourFormat=function(t){var e=0,n=0,r=[];return t>48&&(e=(t-t%24)/24,t%=24),e>13&&(n=(e-e%7)/7,e%=7),n&&r.push(PODLOVE.Analytics.decimalRound(n,1)+"w"),e&&r.push(PODLOVE.Analytics.decimalRound(e,1)+"d"),t&&r.push(PODLOVE.Analytics.decimalRound(t,1)+"h"),0===r.length&&(r=["0h"]),r.join(" ")},PODLOVE.Analytics.addPercentageLabels=function(t,e){var n=t.data(),r=t.filters();n.forEach(function(n,i){var a=t.select("g.row._"+i),o=t.select("g.row._"+i+" text"),l="";a.select(".subLabel").size()||a.append("text").attr("class","subLabel").attr("text-anchor","end").attr("x",-10).attr("y",o.attr("y")),r.length>0&&-1===$.inArray(n.key,r)?a.select(".subLabel").style({display:"none"}):a.select(".subLabel").style({display:"inherit"}),e>0&&(l=Math.round(n.value/e*100)+"%"),a.select(".subLabel").text(l)})},Number.isNaN=Number.isNaN||function(t){return t!=t},jQuery(document).ready(function(t){var e,n,r,i,a=d3.timeFormat("%Y-%m-%d %H:%M %Z"),o=jQuery("#episode-performance-chart").data("episode"),l=t("#episode-performance-chart").closest(".inside").width(),u={min:null,max:null},c=function(t,e){return t.downloads+=e.downloads,t.asset_id=e.asset_id,t.date=t.date&&t.date0&&-1===t.inArray(n.key,r)?a.select(".subLabel").style({display:"none"}):a.select(".subLabel").style({display:"inherit"}),p.value().downloads>0&&(l=Math.round(n.value.downloads/p.value().downloads*100)+"%"),a.select(".subLabel").text(l)})},y=function(t,e){t.select(".reset").on("click",function(e,n){d3.event.preventDefault(),t.filterAll(),dc.redrawAll()})},v=function(t){return Math.floor(t.hoursSinceRelease/f)},x=h.dimension(v),A=g.dimension(v),b=h.dimension(function(t){return t.asset_id}),w=h.dimension(function(t){return t.client}),_=h.dimension(function(t){return t.system}),k=h.dimension(function(t){return t.source}),D=h.dimension(function(t){return t.context}),L=h.dimension(function(t){return t.geo}),C=x.group().reduce(c,s,d),E=A.group().reduce(c,s,d),O=x.group().reduce(c,s,d).all().reduce(function(t,e){return e.key+=1,e.value.cum=!0,t.length&&(e.value.downloads+=t.slice(-1)[0].value.downloads),t.push(e),t},[]);O.unshift({key:0,value:{date:0,downloads:0,cum:!0}});var S={all:function(){return O}},R=b.group().reduce(c,s,d),F=w.group().reduce(c,s,d).order(function(t){return t.downloads}),M=_.group().reduce(c,s,d).order(function(t){return t.downloads}),T=k.group().reduce(c,s,d),B=D.group().reduce(c,s,d),N=L.group().reduce(c,s,d),P=dc.compositeChart("#episode-performance-chart"),H=dc.barChart(P).dimension(x).group(C,"Current Episode").renderTitle(!0).valueAccessor(function(t){return t.value.downloads}).gap(1).colors("#69B3FF"),G=dc.barChart(P).dimension(x).group(E,"Average Episode").renderTitle(!0).colors("#224BA6").valueAccessor(function(t){return t.value.downloads}).barPadding(2),V=dc.lineChart(P).dimension(x).group(S,"Cumulative").colors("#CCC").useRightYAxis(!0).valueAccessor(function(t){return t.value.downloads}).renderDataPoints({}).renderArea(!0),U=C.all().reduce(function(t,e){return Math.max(t,e.key)},0),z=dc.barChart("#episode-range-chart").width(l).height(80).dimension(x).group(C).x(d3.scaleLinear().domain([0,U])).valueAccessor(function(t){return t.value.downloads}).colors("#69B3FF").yAxisLabel(" ");window.rangeChart=z,P.width(l).x(d3.scaleLinear().domain([0,1/0])).legend(dc.legend().x(l-160).y(20).itemHeight(13).gap(5)).elasticX(!1).brushOn(!1).transitionDuration(0).yAxisLabel("Downloads").xAxisLabel("Hours since release").rangeChart(z).title(function(t){return[t.value.date?a(t.value.date):"Average Episode",t.value.cum?t.key*f+"h after release":t.key*f+"h – "+(t.key+1)*f+"h after release","Downloads: "+t.value.downloads].join("\n")}).compose([V,H,G]).rightYAxisLabel("Cumulative Downloads");var I=dc.rowChart("#episode-asset-chart").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(b).group(R).valueAccessor(function(t){return t.value?t.value.downloads:0}).ordering(function(t){return-t.value.downloads}).label(function(t){return assetNames[t.key]}).title(function(t){return t.value.downloads}).colors("#69B3FF").on("preRedraw",m).on("renderlet",y),Y=dc.rowChart("#episode-client-chart").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(w).group(F).valueAccessor(function(t){return t.value.downloads}).ordering(function(t){return-t.value.downloads}).othersGrouper(function(t){return t}).cap(10).label(function(t){return t.key}).colors("#69B3FF").on("preRedraw",m).on("renderlet",y),j=dc.rowChart("#episode-system-chart").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(_).group(M).valueAccessor(function(t){return t.value.downloads}).ordering(function(t){return-t.value.downloads}).othersGrouper(function(t){return t}).cap(10).label(function(t){return t.key}).colors("#69B3FF").on("preRedraw",m).on("renderlet",y),X=dc.rowChart("#episode-source-chart").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(k).group(T).valueAccessor(function(t){return t.value.downloads}).ordering(function(t){return-t.value.downloads}).label(function(t){return t.key}).colors("#69B3FF").on("preRedraw",m).on("renderlet",y),q=dc.rowChart("#episode-context-chart").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(D).group(B).valueAccessor(function(t){return t.value.downloads}).ordering(function(t){return-t.value.downloads}).label(function(t){return t.value.source+"/"+t.key}).colors("#69B3FF").on("preRedraw",m).on("renderlet",y),W=dc.rowChart("#episode-geo-chart").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).cap(10).dimension(L).group(N).valueAccessor(function(t){return t.value.downloads}).ordering(function(t){return-t.value.downloads}).othersGrouper(function(t){return t}).colors("#69B3FF").on("preRedraw",m).on("renderlet",y);z.yAxis().ticks([2]),z.xAxis().tickFormat(function(t){return PODLOVE.Analytics.hourFormat(t*f)}),P.xAxis().tickFormat(function(t){return PODLOVE.Analytics.hourFormat(t*f)}),z.yAxis().tickFormat(PODLOVE.Analytics.formatThousands),P.yAxis().tickFormat(PODLOVE.Analytics.formatThousands),P.rightYAxis().tickFormat(PODLOVE.Analytics.formatThousands),I.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),Y.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),j.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),X.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),q.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),W.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),r=function(){P.elasticY(!0).compose([V,H,G]),P.render()},i=function(){P.elasticY(!0).compose([V,H]),P.render()},[P,z,I,Y,j,X,q,W].forEach(function(t){t.render()});var K=function(t,e){dc.filterAll(),z.filter(dc.filters.RangedFilter(t/f,e/f)),dc.redrawAll()};window.filterHours=K,u.min||u.max||(u.min=0,u.max=168,t("#chart-zoom-selection .button:eq(1)").addClass("active")),t("#chart-zoom-selection .button").on("click",function(e){var n=parseInt(t(this).data("hours"),10);e.preventDefault(),t(this).hasClass("disabled")||(t(this).siblings().removeClass("active"),t(this).addClass("active"),0===n?(u.min=0,u.max=z.xUnitCount()*f):u.max=u.min+n,K(u.min,u.max))}),o.rendered&&o.rendered instanceof Function&&o.rendered()}t("#chart-grouping-selection").on("click","a",function(r){var i,a=parseInt(t(this).data("hours"),10),l=parseInt(t("#chart-zoom-selection .button.active").data("hours"),10);t(this).siblings().removeClass("active"),t(this).addClass("active"),t("#chart-zoom-selection a.button").each(function(){var e=parseInt(t(this).data("hours"),10);0!==e&&e=a}).first().click():t("#chart-zoom-selection a.button.active:first").click()}},e?f(i):t.when(t.ajax(ajaxurl+"?action=podlove-analytics-episode-downloads-per-hour&episode="+o),t.ajax(ajaxurl+"?action=podlove-analytics-episode-average-downloads-per-hour")).done(function(t,r){e=d3.csvParse(t[0],function(t){return{date:new Date(1e3*+t.date),downloads:+t.downloads,hoursSinceRelease:+t.hours_since_release,asset_id:+t.asset_id,client:t.client?t.client:"Unknown",system:t.system?t.system:"Unknown",source:t.source?t.source:"Unknown",context:t.context?t.context:"Unknown",geo:t.geo?t.geo:"Unknown"}}),n=d3.csvParse(r[0],function(t){return{hoursSinceRelease:+t.hoursSinceRelease,downloads:+t.downloads}}),f(i)}),r.preventDefault()}),t("#chart-grouping-selection a:eq(3)").click(),t("input[name='podlove_analytics_tiles']").each(function(){var e=t(this).attr("checked"),n=t(this).val(),r=t(".chart-wrapper[data-tile-id='"+n+"']");e||r.hide()}).on("click",function(){var e=t(this).attr("checked"),n=t(this).val(),r=t(".chart-wrapper[data-tile-id='"+n+"']");t.ajax({url:ajaxurl,data:{action:"podlove-analytics-settings-tiles-update",tile_id:n,checked:e}}),e?r.show():r.hide()});var h=function e(){void 0===i?window.setTimeout(e,500):t("#average-episode").attr("checked")?r():i()};t("#average-episode").each(h).on("click",function(){!function(){t.ajax({url:ajaxurl,data:{action:"podlove-analytics-settings-avg-update",checked:t(this).attr("checked")}})}(),h()})}),jQuery(document).ready(function(t){var e,n,r=function(t,e){return t.downloads+=e.downloads,t.episode_id=e.episode_id,t.date=e.date,t},i=function(t,e){return t.downloads-=e.downloads,t},a=function(){return{downloads:0,episode_id:0,date:0}};function o(){var n=t("#total-chart").closest(".wrap").width(),o=crossfilter(e),l=o.groupAll().reduce(r,i,a).value().downloads,u=o.dimension(function(t){return d3.timeDay(t.date)}),c=o.dimension(function(t){return t.episode_id}).group().reduce(function(t,e){return t.downloads+=e.downloads,t.episode_id=e.episode_id,t},null,function(){return{downloads:0,episode_id:0}}).all().reduce(function(t,e){return e.value.downloads>.04*l&&t.push(e),t},[]),s=_.pluck(c,"key"),d=u.group().reduce(function(t,e){return _.contains(s,e.episode_id)?t:r(t,e)},function(t,e){return _.contains(s,e.episode_id)?t:i(t,e)},a),f=function(t,e){return t.group().reduce(function(t,n){return n.episode_id==e?r(t,n):t},function(t,n){return n.episode_id==e?i(t,n):t},a)},h=[];for(var g in s)h[s[g]]=f(u,s[g]);var p,m=d3.timeFormat("%Y-%m-%d"),y=dc.barChart("#total-chart").width(n).height(200).dimension(u).group(d,"Other Episodes").x(d3.scaleTime().domain([(p=28,new Date((new Date).setDate((new Date).getDate()-p))),new Date])).xUnits(d3.timeDays).brushOn(!1).renderTitle(!0).elasticY(!0).yAxisLabel("Downloads").valueAccessor(function(t){return t.value.downloads}).title(function(t){return[m(t.key),"Downloads: "+t.value.downloads].join("\n")}).renderHorizontalGridLines(!0);if(n>650){var v=n-300;jQuery("#total-chart").height("200px"),y.height(200),y.legend(dc.legend().horizontal(!1).x(v).y(10).autoItemWidth(!0)),y.margins().bottom=30,y.margins().right=305}else{v=n-300;var x=50+13*c.length,A=240+x+30;console.log({chartHeight:240,legendHeight:x,padding:30,totalHeight:A}),jQuery("#total-chart").height(A),y.height(A),y.legend(dc.legend().horizontal(!1).x(30).y(270).autoItemWidth(!0)),y.margins().bottom=x+30}for(var g in h)y.stack(h[g],podlove_episode_names[g]);y.yAxis().tickFormat(PODLOVE.Analytics.formatThousands),y.xAxis().tickFormat(d3.timeFormat("%d %b")),n<550?y.xAxis().ticks(d3.timeDay,5):n<635?y.xAxis().ticks(d3.timeDay,4):n<780?y.xAxis().ticks(d3.timeDay,3):y.xAxis().ticks(d3.timeDay,2),y.render()}function l(t,e,n,r,i){return dc.lineChart(t).dimension(e).group(n,r).colors(i).defined(function(t){return null!=t.y})}function u(t){return function(e,n){return null===n[t]&&null===e?null:e+=n[t]}}function c(t){return function(e,n){return null===n[t]&&null===e?null:e-=n[t]}}function s(t){return null}function d(){var e=t("#total-abo-chart").closest(".wrap").width(),r=crossfilter(n).dimension(function(t){return t.number}),i=r.group().reduceSum(function(t){return t.downloads}),a=r.group().reduce(u("q1"),c("q1"),s),o=r.group().reduce(u("d1"),c("d1"),s),d=r.group().reduce(u("w1"),c("w1"),s),f=dc.compositeChart("#total-abo-chart"),h=function(t,e,n,r){return dc.barChart(t).dimension(e).colors("#cccccc").centerBar(!0).group(n,r)}(f,r,i,"Total"),g=l(f,r,a,"1q","#aa0000"),p=l(f,r,d,"1w","#8b008b"),m=l(f,r,o,"1d","#3a539b");f.width(e).x(d3.scaleBand().domain(r)).xUnits(dc.units.ordinal).elasticX(!0).brushOn(!1).yAxisLabel("Downloads").group(i)._rangeBandPadding(1).title(function(t){return[n[t.key].title,"Downloads: "+t.value].join("\n")}).renderHorizontalGridLines(!0).compose([h,m,p,g]);if(e>650){var y=e-300;jQuery("#total-abo-chart").height("200px"),f.height(200),f.legend(dc.legend().horizontal(!1).x(y).y(10).autoItemWidth(!0)),f.margins().bottom=30,f.margins().right=305}else{y=e-300;jQuery("#total-abo-chart").height("370px"),f.height(370),f.legend(dc.legend().horizontal(!1).x(30).y(170).autoItemWidth(!0)),f.margins().bottom=230}f.render()}function f(t){return t?+t:null}t("#total-chart").length&&(e?(o(),t(window).on("resize",o)):t.when(t.ajax(ajaxurl+"?action=podlove-analytics-total-downloads-per-day")).done(function(n){e=d3.csvParse(n,function(t){return{date:new Date(1e3*+t.date),downloads:+t.downloads,episode_id:+t.episode_id}}),o(),t(window).on("resize",o)})),t("#total-abo-chart").length&&(n?(d(),t(window).on("resize",d)):t.when(t.ajax(ajaxurl+"?action=podlove-analytics-csv-episodes-table")).done(function(e){var r=0;n=d3.csvParse(e,function(t){return{number:r++,title:t.title,downloads:+t.downloads,d1:f(t["1d"]),d2:f(t["2d"]),w1:f(t["1w"]),q1:f(t["1q"])}}),d(),t(window).on("resize",d)}));var h=[{id:"#analytics-chart-global-assets",action:"podlove-analytics-global-assets",mapper:function(t){return{downloads:+t.downloads,asset:t.asset?t.asset:"Unknown"}},renderer:function(t){var e=crossfilter(t),n=e.dimension(function(t){return t.asset}),r=n.group().reduceSum(function(t){return t.downloads}),i=e.groupAll().reduceSum(function(t){return t.downloads}).value(),a=dc.rowChart("#analytics-chart-global-assets").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(n).group(r).valueAccessor(function(t){return t.value?t.value:0}).ordering(function(t){return-t.value}).colors("#69B3FF").on("renderlet",function(t){return PODLOVE.Analytics.addPercentageLabels(t,i)});a.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),a.render()}},{id:"#analytics-chart-global-clients",action:"podlove-analytics-global-clients",mapper:function(t){return{downloads:+t.downloads,client_name:t.client_name?t.client_name:"Unknown"}},renderer:function(t){var e=crossfilter(t),n=e.dimension(function(t){return t.client_name}),r=n.group().reduceSum(function(t){return t.downloads}),i=e.groupAll().reduceSum(function(t){return t.downloads}).value(),a=dc.rowChart("#analytics-chart-global-clients").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(n).group(r).valueAccessor(function(t){return t.value?t.value:0}).ordering(function(t){return-t.value}).othersGrouper(function(t){return t}).colors("#69B3FF").cap(10).on("renderlet",function(t){return PODLOVE.Analytics.addPercentageLabels(t,i)});a.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),a.render()}},{id:"#analytics-chart-global-systems",action:"podlove-analytics-global-systems",mapper:function(t){return{downloads:+t.downloads,os_name:t.os_name?t.os_name:"Unknown"}},renderer:function(t){var e=crossfilter(t),n=e.dimension(function(t){return t.os_name}),r=n.group().reduceSum(function(t){return t.downloads}),i=e.groupAll().reduceSum(function(t){return t.downloads}).value(),a=dc.rowChart("#analytics-chart-global-systems").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(n).group(r).valueAccessor(function(t){return t.value?t.value:0}).ordering(function(t){return-t.value}).othersGrouper(function(t){return t}).colors("#69B3FF").cap(10).on("renderlet",function(t){return PODLOVE.Analytics.addPercentageLabels(t,i)});a.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),a.render()}},{id:"#analytics-chart-global-sources",action:"podlove-analytics-global-sources",mapper:function(t){return{downloads:+t.downloads,source:t.source?t.source:"Unknown"}},renderer:function(t){var e=crossfilter(t),n=e.dimension(function(t){return t.source}),r=n.group().reduceSum(function(t){return t.downloads}),i=e.groupAll().reduceSum(function(t){return t.downloads}).value(),a=dc.rowChart("#analytics-chart-global-sources").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(n).group(r).valueAccessor(function(t){return t.value?t.value:0}).ordering(function(t){return-t.value}).othersGrouper(function(t){return t}).colors("#69B3FF").on("renderlet",function(t){return PODLOVE.Analytics.addPercentageLabels(t,i)});a.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),a.render()}},{id:"#analytics-global-top-episodes",action:"podlove-analytics-global-top-episodes",mapper:function(t){return{downloads:+t.downloads,title:t.title?t.title:"Unknown"}},renderer:function(t){var e=crossfilter(t),n=e.dimension(function(t){return t.title}),r=n.group().reduceSum(function(t){return t.downloads}),i=e.groupAll().reduceSum(function(t){return t.downloads}).value(),a=dc.rowChart("#analytics-global-top-episodes").margins({top:0,left:40,right:10,bottom:25}).elasticX(!0).dimension(n).group(r).valueAccessor(function(t){return t.value?t.value:0}).ordering(function(t){return-t.value}).othersGrouper(function(t){return t}).colors("#69B3FF").cap(10).on("renderlet",function(t){return PODLOVE.Analytics.addPercentageLabels(t,i)});a.xAxis().tickFormat(PODLOVE.Analytics.formatThousands),a.render()}}],g=function(e){var n,r;e&&e.length?(n=e[0],r=e[1]):(n=new Date(0),r=new Date),function(e,n){var r=t("#analytics-global-downloads"),i=t("#analytics-global-downloads-value"),a=t(".chart-loading",r);a.show(),i.hide(),t.when(t.ajax(ajaxurl+"?action=podlove-analytics-global-total-downloads&date_from="+e.toDateString()+"&date_to="+n.toDateString())).done(function(t){a.hide(),i.html(t),i.show(),r.show()}).fail(function(){a.hide()})}(n,r),function(e,n){var r=t("#analytics-global-shows"),i=t(".chart-loading",r),a=t(".chart-failed",r),o=t(".chart-nodata",r),l=t(".chart-content",r);r.length&&(i.show(),a.hide(),o.hide(),l.hide(),t.when(t.ajax(ajaxurl+"?action=podlove-analytics-global-total-downloads-by-show&date_from="+e.toDateString()+"&date_to="+n.toDateString())).done(function(t){i.hide(),console.log(t),l.html(t),l.show()}).fail(function(){i.hide(),a.show()}))}(n,r),h.forEach(function(e){var i=t(e.id+" .chart-loading"),a=t(e.id+" .chart-failed"),o=t(e.id+" .chart-nodata");t(e.id).each(function(){i.show(),a.hide(),o.hide(),t.when(t.ajax(ajaxurl+"?action="+e.action+"&date_from="+n.toISOString()+"&date_to="+r.toISOString())).done(function(t){var n=d3.csvParse(t,e.mapper);i.hide(),n.length||o.show(),(0,e.renderer)(n)}).fail(function(){i.hide(),a.show()})})})};window.analyticsApp.$on("setChartRange",function(t){g(t)})});