text: dc={version:"0.6.0",_charts:[]},dc.registerChart=function(a){dc._charts.push(a)},dc.hasChart=function(a){return dc._charts.indexOf(a)>=0},dc._isDescendantNode=function(a,b){var c=b.parentNode;while(c!=null){if(c==a)return!0;c=c.parentNode}return!1},dc.getChartFor=function(a){for(var b=0;b<dc._charts.length;b++){var c=dc._charts[b];if(dc._isDescendantNode(c.root().node(),a))return c}return null},dc.deregisterAllCharts=function(){dc._charts=[]},dc.filterAll=function(){for(var a=0;a<dc._charts.length;++a)dc._charts[a].filterAll()},dc.renderAll=function(){for(var a=0;a<dc._charts.length;++a)dc._charts[a].render()},dc.redrawAll=function(){for(var a=0;a<dc._charts.length;++a)dc._charts[a].redraw()},dc.transition=function(a,b,c){if(b<=0)return a;var d=a.transition().duration(b);return c instanceof Function&&c(d),d},dc.units={},dc.units.integers=function(a,b){return new Array(Math.abs(b-a))},dc.round={},dc.round.floor=function(a){return Math.floor(a)},dc.override=function(a,b,c){var d=a[b];c._=d,a[b]=function(){return c(d)}},dc.dateFormat=d3.time.format("%m/%d/%Y"),dc.numberFormat=d3.format(",.0f"),dc.percentFormat=d3.format(",.2p"),dc.printers={},dc.printers.emptyValueLabel="(none)",dc.printers.value=function(a){return a==null||a==undefined||a===""?dc.printers.emptyValueLabel:a instanceof Date?dc.dateFormat(a):typeof a=="string"?a:typeof a=="number"?dc.numberFormat(a):""+a},dc.printers.filter=function(a){var b=dc.printers.value;if(a instanceof Array){if(a.length>=2)return"["+b(a[0])+" -> "+b(a[1])+"]";if(a.length>=1)return b(a[0])}return b(a)},dc.schema=function(){var a=20,b=[d3.time.format.iso,d3.time.format("%Y-%m-%d %H:%M:%S"),d3.time.format("%Y-%m-%d"),d3.time.format("%m-%d-%Y %H:%M:%S"),d3.time.format("%m-%d-%Y"),d3.time.format("%m-%d-%Y %H:%M:%S"),d3.time.format("%m/%d/%Y"),d3.time.format("%m/%d/%Y %H:%M:%S")],c=function(a){for(var c=0;c<b.length;c++){if(c==0&&a.length<12)continue;var d=b[c].parse(a);if(d!=null)return d}return null},d={day:1,hour:2,minute:3,second:4},e=function(a,b){a.date_granularity||(a.date_granularity="day");if(b==null)return;d[a.date_granularity]<4&&b.getSeconds()!=0?a.date_granularity="second":d[a.date_granularity]<3&&b.getMinutes()!=0?a.date_granularity="minute":d[a.date_granularity]<2&&b.getHours()!=0&&(a.date_granularity="hour")},f={};f.coerceData=function(a,b){var d={};for(var f in b.properties)if(b.properties[f].type=="date"){d[f]=b.properties[f];var g=b.properties[f];g.minimum!=null&&(g.minimum=c(g.minimum)),g.maximum!=null&&(g.maximum=c(g.maximum))}if(!d)return;for(var h=0;h<a.length;h++){var i=a[h];for(var j in i)d[j]&&(i[j]=c(i[j]),e(d[j],i[j]))}};var g=function(){return{required:!0,cardinality:0}},h=function(a,b,d){var e=null,f=typeof a,g=a,h=!1,i=a==null||a=="";if(!i)if(Object.prototype.toString.call(a)==="[object Array]")e="array";else if(f=="string"){var j=c(a);j!=null?(e="date",d&&(g=j,h=!0)):e="string"}else f=="number"?e="number":f=="integer"?e="integer":f=="boolean"?e="boolean":a.getMonth==="function"&&(e="date");return b!=null&&e!=b&&(i&&b=="date"?(e="date",g=null,h=!0):i?e=b:e=="number"&&b=="integer"?e="number":e=="integer"&&b=="number"?e="number":e=="date"&&b=="string"?e="string":e="mixed"),{type:e,coercedValue:g,wasCoerced:h}},i=function(a){var b=0;for(var c in a)a.hasOwnProperty(c)&&b++;return b};return f.getMetadata=function(b,c){var d={},f={};d.properties=f;for(var i=0;i<b.length;i++){var j=b[i];for(var k in j){var l=j[k],m=f[k];m==null&&(m=g(),f[k]=m);if(l==null)m.required=!1;else{var n=m.type,o=h(l,n,c);n==null?m.type=o.type:o.type!=n&&(m.type="mixed"),o.wasCoerced&&(l=o.coercedValue,j[k]=l)}m.values==null&&(m.values={}),m.values[l]===undefined&&(m.cardinality++,m.values[l]={value:l,count:0}),m.values[l].count++;if(m.type=="date"){e(m,l);if(m.minimum==null||m.minimum==""||l!=null&&l<m.minimum)m.minimum=l;if(m.maximum==null||m.maximum==""||l!=null&&l>m.maximum)m.maximum=l}else{if(m.minimum===undefined||l<m.minimum)m.minimum=l;if(m.maximum===undefined||l>m.maximum)m.maximum=l}}}for(var p in f){var m=f[p];if(m.cardinality>a)delete m.values;else{var q=null,r=null;for(var k in m.values){var l=m.values[k].count;if(l==null)continue;if(q==null||l<q)q=l;if(r==null||l>r)r=l}m.least_value_frequency=q,m.greatest_value_frequency=r}}return d},f}(),dc.chartStrategy=function(){function d(a){if(typeof a!="object")return a;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=d(a[c]));return b}var a={};a.PIE_THRESHOLD=5,a.PIE_LEAST_VALUE_FREQUENCY_MINIMUM=.05,a.ATTRIBUTION_PROPERTIES={channel:1,subchannel:2,source:3,campaign:4,subcampaign:5},a.EXCLUDED_PROPERTIES={coupon_ids:!0,website_id:!0},a.STRING_CARDINALITY_THRESHOLD=200,a.STRING_CARDINALITY_PCT_THRESHOLD=.9;var b="(none)";a.VALUE_ACCESSORS={standard:function(a){return function(c){var d=c[a];return d==null?b:d}},day:function(a){return function(b){return b[a]==null?null:d3.time.day(b[a])}},hour:function(a){return function(b){return b[a]!=null?b[a].getHours():null}},weekday:function(a){var c=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return function(d){return d[a]!=null?c[d[a].getDay()]:b}}};var c=function(a,b){var c=new Date(a.getTime());c.setHours(0),c.setMinutes(0),c.setSeconds(0),c.setMilliseconds(0);var d=new Date(b.getTime()+864e5);return d.setHours(0),d.setMinutes(0),d.setSeconds(0),d.setMilliseconds(0),[c,d]},e=function(b){return function(d,e){if(a.EXCLUDED_PROPERTIES[d])return null;if(e.type=="string"&&!a.ATTRIBUTION_PROPERTIES[d]&&(e.cardinality>a.STRING_CARDINALITY_THRESHOLD||e.cardinality/b.length>a.STRING_CARDINALITY_PCT_THRESHOLD))return null;var f;e.type=="date"||e.type!="string"&&e.type!="array"&&!a.ATTRIBUTION_PROPERTIES[d]&&e.cardinality>a.PIE_THRESHOLD?f="bar":e.cardinality>a.PIE_THRESHOLD||e.least_value_frequency/b.length<a.PIE_LEAST_VALUE_FREQUENCY_MINIMUM?f="leaderboard":f="pie";var g=null,h=null,i=null,j=null;if(e.treatment=="hour"&&e.type=="date")g=a.VALUE_ACCESSORS.hour(d),h=d3.scale.linear().domain([0,24]),j=dc.round.floor;else if(e.treatment=="weekday"&&e.type=="date")g=a.VALUE_ACCESSORS.weekday(d),f="pie";else if(e.type=="date")g=a.VALUE_ACCESSORS.day(d),h=d3.time.scale().domain(c(e.minimum,e.maximum)),i=d3.time.days,j=d3.time.day.round;else if(f=="bar"){g=a.VALUE_ACCESSORS.standard(d);var k=e.type=="integer"||e.type=="number"?+e.maximum+1:+e.maximum,l=e.type=="integer"||e.type=="number"?+e.minimum:e.minimum;h=d3.scale.linear().domain([l,k]),j=dc.round.floor}else g=a.VALUE_ACCESSORS.standard(d);return{field_name:d,type:f,value_accessor:g,domain:h,domainUnits:i,round:j,field_metadata:e}}};return a.getStrategy=function(a,b){var c={};if(!a.length||!b)return c;var f=e(a);for(var g in b.properties){var h=b.properties[g],i=f(g,h);if(!i)continue;c[g]=i;if(h.type=="date"){var j={hour:1,minute:1,second:1};if(j[h.date_granularity]){var k=d(h);k.treatment="hour";var l=f(g,k);l.field_name=g+"_hour",c[g+"_hour"]=l}var m=d(h);m.treatment="weekday";var n=f(g,m);n.field_name=g+"_weekday",c[g+"_weekday"]=n}}return c},a}(),dc.newCrossfilter=function(a,b,c){function f(a,b){return b.type==="array"?a.reduce(function(a,c){var d=b.value_accessor(c);for(var e=0;e<d.length;e++)a[d[e]]=(a[d[e]]||0)+1;return a},function(a,c){var d=b.value_accessor(c);for(var e=0;e<d.length;e++)a[d[e]]=(a[d[e]]||1)-1;return a},function(){return{}}):c.sum_field?a.reduceSum(c.sum_field):a.reduceCount()}var d=crossfilter(a),e={crossfilter:d,dimensions:{},groups:{},groupalls:{},info:{}};for(var g in b){var h=b[g],i=d.dimension(h.value_accessor),j=f(i.group(),h),k=f(i.groupAll(),h);e.dimensions[g]=i,e.groups[g]=j,e.groupalls[g]=k,e.info[g]=h}return e.topGroup=f(d.groupAll(),{}),e},dc.chartBuilder=function(){var a={defaultMargins:{top:10,right:50,bottom:30,left:40},defaultHeight:100,defaultWidth:900,defaultTransition:300,defaultPieSize:180,defaultPieRadius:80,defaultPieInnerRadius:20,defaultTableWidth:200,defaultTableHeight:300};return a.chartDivBuilder=function(a,b){var c=a.append("div").classed("title",!0).text(b.field_name);c.append("span").classed("filter",!0).style("display","none"),b.hierarchical&&c.append("span").classed("filter-pop",!0).attr("onclick","dc.getChartFor(this).popFilter();dc.redrawAll();return true;").style("display","none").text("back"),c.append("span").classed("reset",!0).attr("onclick","dc.getChartFor(this).filterAll();dc.redrawAll();return true;").style("display","none").text("reset")},a.build=function(b,c){var d={},e={},f=null,g="attribution";for(var h in c.info){if(!(h in dc.chartStrategy.ATTRIBUTION_PROPERTIES))continue;if(f&&c.info[h].type!=f)continue;f=c.info[h].type,e[h]=c.info[h]}if(f){var i=[];for(h in e)delete c.info[h],i.push(e[h]);i.sort(function(a,b){var c=dc.chartStrategy.ATTRIBUTION_PROPERTIES[a.field_name],d=dc.chartStrategy.ATTRIBUTION_PROPERTIES[b.field_name];return c<d?-1:c>d?1:0}),c.info[g]=i;var j=[],k=[],l=[];for(var m=0;m<i.length;m++){var n=i[m];j.push(c.dimensions[n.field_name]),k.push(c.groups[n.field_name]),l.push(c.groupalls[n.field_name]),delete c.dimensions[n.field_name],delete c.groups[n.field_name],delete c.groupalls[n.field_name]}c.dimensions[g]=j,c.groups[g]=k,c.groupalls[g]=l,c.info[g]=i[0],c.info[g].hierarchical=!0}var o=[];for(var h in c.info)o.push(h);o.sort(function(a,b){var d=c.info[a].type,e=c.info[b].type;return d<e?-1:d>e?1:0});var p=b.select("#charts");p.empty()&&(p=b.append("div").attr("id","charts").classed("charts",!0));for(var m=0;m<o.length;m++){var h=o[m],n=c.info[h],q=h+"-chart";if(b.select("#"+q).empty()){var r=p.append("div").attr("id",q).classed("chart",!0).classed(n.type+"-chart",!0);a.chartDivBuilder(r,n)}var s=null;if(n.type=="bar")s=dc.barChart("#"+q).width(a.defaultWidth).height(a.defaultHeight).transitionDuration(a.defaultTransition).margins(a.defaultMargins).dimension(c.dimensions[h]).group(c.groups[h]).groupAll(c.groupalls[h]).elasticY(!0).x(n.domain).round(n.round),n.domainUnits&&s.xUnits(n.domainUnits);else if(n.type=="pie"){var t=c.dimensions[h],u=c.groups[h],v=c.groupalls[h];s=dc.pieChart("#"+q,Array.isArray(t)).width(a.defaultPieSize).height(a.defaultPieSize).radius(a.defaultPieRadius).innerRadius(a.defaultPieInnerRadius).transitionDuration(a.defaultTransition).renderTitle(!0);if(Array.isArray(t))for(var w=0;w<t.length;w++)s.addDimensionAndGroup(t[w],u[w],v[w]);else s.dimension(t).group(u).groupAll(v)}else if(n.type=="leaderboard"){var t=c.dimensions[h],u=c.groups[h],v=c.groupalls[h];s=dc.leaderboardChart("#"+q,Array.isArray(t)).width(a.defaultTableWidth).height(a.defaultTableHeight).transitionDuration(a.defaultTransition).renderTitle(!0);if(Array.isArray(t))for(var w=0;w<t.length;w++)s.addDimensionAndGroup(t[w],u[w],v[w]);else s.dimension(t).group(u).groupAll(v)}d[q]=s}var x=d3.select("#reset-all");x.empty()&&(x=b.append("div").attr("id","reset-all")),x.classed("reset",!0).attr("onclick","dc.filterAll();dc.redrawAll();return true").text("Reset all");var y=d3.select("#data-count");return y.empty()&&(y=b.append("div").attr("id","data-count")),y.append("span").classed("filter-count",!0).text("-"),y.append("span").text(" ("),y.append("span").classed("filter-pct",!0).text("-"),y.append("span").text(") of "),y.append("span").classed("total-count",!0).text("-"),y.append("span").text(" items selected."),d["data-count"]=dc.dataCount(y).dimension(c.crossfilter).group(c.topGroup).groupAll(c.topGroup),d},a}(),dc.baseChart=function(a){var b,c,d,e,f,g,h=200,i=200,j=function(a){return a.key},k=function(a){return a.value},l=function(a){return dc.printers.value(a.key)},m=!1,n=function(b){return dc.printers.value(b.key)+": "+dc.printers.value(b.value)+" ("+dc.percentFormat(b.value/a.dimension().groupAll().value())+")"},o=!1,p=750,q=dc.printers.filter,r=dc.printers.value;return a.dimension=function(c){return arguments.length?(b=c,a.groupAll(c.groupAll()),a):b},a.group=function(b){return arguments.length?(c=b,a):c},a.groupAll=function(b){return arguments.length?(d=b,a):d},a.orderedGroup=function(){return a.group().order(function(a){return a.key})},a.filterAll=function(){return a.filter(null)},a.dataAreSet=function(){return a.dimension()!=undefined&&a.group()!=undefined},a.select=function(a){return f.select(a)},a.selectAll=function(a){return f.selectAll(a)},a.anchor=function(b){return arguments.length?(b instanceof Object&&b.anchor&&b.root?(e=b.anchor(),f=b.root()):b instanceof Object&&b.append&&b.classed?(e=b.node(),f=b):(e=b,f=d3.select(e)),dc.registerChart(a),a):e},a.root=function(b){return arguments.length?(f=b,a):f},a.width=function(b){return arguments.length?(h=b,a):h},a.height=function(b){return arguments.length?(i=b,a):i},a.svg=function(b){return arguments.length?(g=b,a):g},a.resetSvg=function(){return a.select("svg").remove(),a.generateSvg()},a.generateSvg=function(){return g=a.root().append("svg").attr("width",a.width()).attr("height",a.height()),g},a.valuePrinter=function(b){return arguments.length?(r=b,a):r},a.filterPrinter=function(b){return arguments.length?(q=b,a):q},a.filterText=function(){return a.filterPrinter()(a.filter())},a.turnOnControls=function(){a.select(".reset").style("display",null),a.select(".filter-pop").style("display",null),a.select(".filter").text(a.filterText()).style("display",null)},a.turnOffControls=function(){a.select(".reset").style("display","none"),a.select(".filter-pop").style("display","none"),a.select(".filter").style("display","none").text(a.filterText())},a.transitionDuration=function(b){return arguments.length?(p=b,a):p},a.filter=function(b){return a},a.render=function(){return a},a.redraw=function(){return a},a.keyRetriever=function(b){return arguments.length?(j=b,a):j},a.valueRetriever=function(b){return arguments.length?(k=b,a):k},a.label=function(b){return arguments.length?(l=b,m=!0,a):l},a.renderLabel=function(b){return arguments.length?(m=b,a):m},a.title=function(b){return arguments.length?(n=b,o=!0,a):n},a.renderTitle=function(b){return arguments.length?(o=b,a):o},a},dc.coordinateGridChart=function(a){function n(a){}function o(b){var c=l.extent();a.round()&&(c[0]=c.map(a.round())[0],c[1]=c.map(a.round())[1],d.select(".brush").call(l.extent(c))),c=l.extent(),a.filter(l.empty()?null:[c[0],c[1]]),dc.redrawAll()}function p(a){}var b=5;a=dc.baseChart(a);var c={top:10,right:50,bottom:30,left:20},d,e,f=d3.svg.axis(),g=dc.units.integers,h,i=d3.svg.axis(),j=!1,k,l=d3.svg.brush(),m;return a.generateG=function(){return d=a.svg().append("g").attr("transform","translate("+a.margins().left+","+a.margins().top+")"),d},a.g=function(b){return arguments.length?(d=b,a):d},a.margins=function(b){return arguments.length?(c=b,a):c},a.x=function(b){return arguments.length?(e=b,a):e},a.xAxis=function(b){return arguments.length?(f=b,a):f},a.renderXAxis=function(b){b.select("g.x").remove(),e.range([0,a.xAxisLength()]),f=f.scale(a.x()).orient("bottom"),b.append("g").attr("class","axis x").attr("transform","translate("+a.margins().left+","+a.xAxisY()+")").call(f)},a.xAxisY=function(){return a.height()-a.margins().bottom},a.xAxisLength=function(){return a.width()-a.margins().left-a.margins().right},a.xUnits=function(b){return arguments.length?(g=b,a):g},a.renderYAxis=function(c){c.select("g.y").remove();if(h==null||a.elasticY())h=d3.scale.linear(),h.domain([a.yAxisMin(),a.yAxisMax()]).rangeRound([a.yAxisHeight(),0]);h.range([a.yAxisHeight(),0]),i=i.scale(h).orient("left").ticks(b),c.append("g").attr("class","axis y").attr("transform","translate("+a.margins().left+","+a.margins().top+")").call(i)},a.y=function(b){return arguments.length?(h=b,a):h},a.yAxis=function(b){return arguments.length?(i=b,a):i},a.elasticY=function(b){return arguments.length?(j=b,a):j},a.yAxisMin=function(){var b=d3.min(a.group().all(),function(b){return a.valueRetriever()(b)});return b>0&&(b=0),b},a.yAxisMax=function(){return d3.max(a.group().all(),function(b){return b.key==null?0:a.valueRetriever()(b)})},a.yAxisHeight=function(){return a.height()-a.margins().top-a.margins().bottom},a.round=function(b){return arguments.length?(m=b,a):m},a._filter=function(b){return arguments.length?(k=b,a):k},a.filter=function(b){return arguments.length?(b?(k=b,a.brush().extent(b),a.dimension().filterRange(b),a.turnOnControls()):(k=null,a.brush().clear(),a.dimension().filterAll(),a.turnOffControls()),a):k},a.brush=function(b){return arguments.length?(l=b,a):l},a.renderBrush=function(b){l.on("brushstart",n).on("brush",o).on("brushend",p);var c=b.append("g").attr("class","brush").attr("transform","translate("+a.margins().left+",0)").call(l.x(a.x()));c.selectAll("rect").attr("height",a.xAxisY()),c.selectAll(".resize").append("path").attr("d",a.resizeHandlePath),k&&a.redrawBrush(b)},a.redrawBrush=function(b){a._filter()&&a.brush().empty()&&a.brush().extent(a._filter());var c=b.select("g.brush");c.call(a.brush().x(a.x())),c.selectAll("rect").attr("height",a.xAxisY()),a.fadeDeselectedArea()},a.fadeDeselectedArea=function(){},a.resizeHandlePath=function(b){var c=+(b=="e"),d=c?1:-1,e=a.xAxisY()/3;return"M"+.5*d+","+e+"A6,6 0 0 "+c+" "+6.5*d+","+(e+6)+"V"+(2*e-6)+"A6,6 0 0 "+c+" "+.5*d+","+2*e+"Z"+"M"+2.5*d+","+(e+8)+"V"+(2*e-8)+"M"+4.5*d+","+(e+8)+"V"+(2*e-8)},a.render=function(){return a.resetSvg(),a.dataAreSet()&&(a.generateG(),a.renderXAxis(a.g()),a.renderYAxis(a.g()),a.plotData(),a.renderBrush(a.g())),a},a.redraw=function(){return a.elasticY()&&a.renderYAxis(a.g()),a.plotData(),a.redrawBrush(a.g()),a},a.subRender=function(){return a.dataAreSet()&&a.plotData(),a},a},dc.colorChart=function(a){var b=d3.scale.category20c();return a.colors=function(c){return arguments.length?(c instanceof Array?b=d3.scale.ordinal().range(c):b=c,a):b},a},dc.singleSelectionChart=function(a,b){var c="selected",d="deselected";a.highlightSelected=function(a){d3.select(a).classed(c,!0),d3.select(a).classed(d,!1)},a.fadeDeselected=function(a){d3.select(a).classed(c,!1),d3.select(a).classed(d,!0)},a.resetHighlight=function(a){d3.select(a).classed(c,!1),d3.select(a).classed(d,!1)};if(!b){var e=null;a.hasFilter=function(){return e!=null},a.filter=function(b){return arguments.length?(e=b,a.dataAreSet()&&a.dimension().filter(e),b!=null?a.turnOnControls():a.turnOffControls(),a):e}}else{var f=[],g=[],h=[],i=[],j=function(){return i.length>0?i[i.length-1]:null};a.filterText=function(){var b=new Array;for(var c=0;c<i.length;c++)b.push(a.filterPrinter()(i[c]));return b.join(" >> ")},a.hasFilter=function(){return i.length==f.length},a.filter=function(b){return arguments.length?(b!=undefined?(a.dataAreSet()&&a.dimension().filter(b),i.length<f.length?i.push(b):i[i.length-1]=b):(a.dataAreSet()&&a.dimension().filter(b),i.length>0&&i.pop(),a.dataAreSet()&&a.dimension().filter(b)),i.length>0?a.turnOnControls():a.turnOffControls(),a):j()},a.popFilter=function(){return a.filter(null),a},a.filterAll=function(){while(i.length>0)a.filter(null)},a.dimension=function(){if(arguments.length)throw"Cannot call dimension() with argument, must call addDimensionAndGroup(d, g, ga)";return f.length==0?null:f[Math.min(i.length,f.length-1)]},a.group=function(){if(arguments.length)throw"Cannot call group() with argument, must call addDimensionAndGroup(d, g, ga)";return g.length==0?null:g[Math.min(i.length,g.length-1)]},a.groupAll=function(){if(arguments.length)throw"Cannot call groupAll() with argument, must call addDimensionAndGroup(d, g, ga)";return h.length==0?null:h[Math.min(i.length,h.length-1)]},a.addDimensionAndGroup=function(b,c,d){return f.push(b),g.push(c),h.push(d),a}}return a},dc.pieChart=function(a,b){function n(){return d3.layout.pie().value(function(a){return m.valueRetriever()(a)})}function o(a){dc.transition(l,m.transitionDuration()).attr("transform",function(b){b.innerRadius=m.innerRadius(),b.outerRadius=d;var c=a.centroid(b);return isNaN(c[0])||isNaN(c[1])?"translate(0,0)":"translate("+c+")"}).attr("text-anchor","middle").text(function(a){var b=a.data;return m.valueRetriever()(b)==0?"":m.label()(a)})}function p(){m.renderTitle()&&j.selectAll("title").text(function(a){return m.title()(a)})}function q(a){a.innerRadius=m.innerRadius();var b=this._current;r(b)&&(b={startAngle:0,endAngle:0});var c=d3.interpolate(b,a);return this._current=c(0),function(a){return g(c(a))}}function r(a){return a==null||isNaN(a.startAngle)||isNaN(a.endAngle)}function s(a){m.filter(m.keyRetriever()(a.data)),dc.redrawAll()}var c="pie-slice",d=0,e=0,f,g,h,i,j,k,l,m=dc.singleSelectionChart(dc.colorChart(dc.baseChart({})),b);return m.label(function(a){return m.valuePrinter()(m.keyRetriever()(a.data))}),m.renderLabel(!0),m.title(function(a){return m.valuePrinter()(a.data.key)+": "+m.valuePrinter()(a.data.value)+" ("+dc.percentFormat(a.data.value/m.groupAll().value())+")"}),m.transitionDuration(350),m.render=function(){return m.resetSvg(),m.dataAreSet()&&(f=m.svg().append("g").attr("transform","translate("+m.cx()+","+m.cy()+")"),h=n(),i=m.dimension(),g=m.buildArcs(),j=m.drawSlices(f,h,g),m.drawLabels(j,g),m.drawTitles(j,g),m.highlightFilter()),m},m.innerRadius=function(a){return arguments.length?(e=a,m):e},m.radius=function(a){return arguments.length?(d=a,m):d},m.cx=function(){return m.width()/2},m.cy=function(){return m.height()/2},m.buildArcs=function(){return d3.svg.arc().outerRadius(d).innerRadius(e)},m.drawSlices=function(a,b,d){return j=a.selectAll("g."+c).data(b(m.orderedGroup().top(Infinity))).enter().append("g").attr("class",function(a,b){return c+" "+b}),k=j.append("path").attr("fill",function(a,b){return m.colors()(b)}).attr("d",d),k.transition().duration(m.transitionDuration()).attrTween("d",q),k.on("click",s),j},m.drawLabels=function(a,b){m.renderLabel()&&(l=a.append("text"),o(b),l.on("click",s))},m.drawTitles=function(a,b){m.renderTitle()&&a.append("title").text(function(a){return m.title()(a)})},m.highlightFilter=function(){m.hasFilter()?m.selectAll("g."+c).select("path").each(function(a){m.isSelectedSlice(a)?m.highlightSelected(this):m.fadeDeselected(this)}):m.selectAll("g."+c).selectAll("path").each(function(a){m.resetHighlight(this)})},m.isSelectedSlice=function(a){return m.filter()==m.keyRetriever()(a.data)},m.redraw=function(){if(i!==m.dimension())return m.render();m.highlightFilter();var a=h(m.orderedGroup().top(Infinity));return k=k.data(a),l=l.data(a),dc.transition(k,m.transitionDuration(),function(a){a.attrTween("d",q)}),o(g),p(),m},m.anchor(a)},dc.barChart=function(a){function j(a){for(var b=0;b<a.length;++b){var c=a[b].all();h[b]=[];for(var d=0;d<c.length;++d){var e=c[d];b==0?h[b][d]=k()-o(e):h[b][d]=h[b-1][d]-o(e)}}}function k(){return i.margins().top+i.yAxisHeight()-d}function l(a){var c=i.xUnits()(i.x().domain()[0],i.x().domain()[1]).length+e,d=Math.floor(i.xAxisLength()/c);if(isNaN(d)||d<b)d=b;return d}function m(a,b,c,d){return a[f]=c,i.x()(i.keyRetriever()(b))+i.margins().left}function n(a,b,c){var d=a[f];return h[d][c]}function o(a){var b=i.yAxisHeight()-i.y()(i.valueRetriever()(a))-d;if(isNaN(b)||b<c)b=c;return b}function p(){var a=[];a.push(i.group());for(var b=0;b<i.stack().length;++b)a.push(i.stack()[b]);return a}var b=1,c=0,d=1,e=2,f="__group_index__",g=[],h=[],i=dc.coordinateGridChart({});return i.transitionDuration(500),i.plotData=function(){var a=p();j(a);for(var b=0;b<a.length;++b){var c=a[b],d=i.g().selectAll("rect.stack"+b).data(c.all());d.enter().append("rect").attr("class","bar stack"+b).attr("x",function(a,c){return m(this,a,b,c)}).attr("y",i.xAxisY()).attr("width",l),dc.transition(d,i.transitionDuration()).attr("y",function(a,b){return n(this,a,b)}).attr("height",o),dc.transition(d,i.transitionDuration()).attr("y",function(a,b){return n(this,a,b)}).attr("height",o),dc.transition(d.exit(),i.transitionDuration()).attr("y",i.xAxisY()).attr("height",0)}},i.fadeDeselectedArea=function(){var a=i.g().selectAll("rect.bar");if(!i.brush().empty()&&i.brush().extent()!=null){var b=i.brush().extent()[0],c=i.brush().extent()[1];a.classed("deselected",function(a){var d=i.keyRetriever()(a);return d<b||d>=c})}else a.classed("deselected",!1)},i.stack=function(a){return arguments.length?(g=a,i):g},i.yAxisMin=function(){var a=0,b=p();for(var c=0;c<b.length;++c){var d=b[c],e=d3.min(d.all(),function(a){return i.valueRetriever()(a)});e<a&&(a=e)}return a},i.yAxisMax=function(){var a=0,b=p();for(var c=0;c<b.length;++c){var d=b[c];a+=d3.max(d.all(),function(a){return a.key==null?0:i.valueRetriever()(a)})}return a},i.anchor(a)},dc.lineChart=function(a){var b=dc.coordinateGridChart({});return b.transitionDuration(500),b.plotData=function(){b.g().datum(b.group().all());var a=b.g().selectAll("path.line");a.empty()&&(a=b.g().append("path").attr("class","line"));var c=d3.svg.line().x(function(a){return b.x()(b.keyRetriever()(a))}).y(function(a){return b.y()(b.valueRetriever()(a))});a=a.attr("transform","translate("+b.margins().left+","+b.margins().top+")"),dc.transition(a,b.transitionDuration(),function(a){a.ease("linear")}).attr("d",c)},b.anchor(a)},dc.leaderboardChart=function(a,b){function d(){return d3.layout.pie().value(function(a){return c.valueRetriever()(a)})}function e(a){var b=[];for(var d=0;d<a.length;d++)c.valueRetriever()(a[d])>0&&b.push(a[d]);return b}function f(a){c.filter(c.keyRetriever()(a.data)),dc.redrawAll()}var c=dc.singleSelectionChart(dc.colorChart(dc.baseChart({})),b);return c.label(function(a){return c.valuePrinter()(c.keyRetriever()(a.data))}),c.renderLabel(!0),c.title(function(a){return c.valuePrinter()(a.data.key)+": "+c.valuePrinter()(a.data.value)}),c.transitionDuration(350),c.render=function(){c.selectAll("div.row-container").remove();if(c.dataAreSet()){dataPie=d();var a=c.root().append("div").attr("class","row-container"),b=c.groupAll().value(),g=a.selectAll("div.row").data(dataPie(e(c.group().top(Infinity)))).enter().append("div").attr("class","row"),h=[function(a){return a.data.key},function(a){return c.valuePrinter()(a.data.value)+" ("+dc.percentFormat(a.data.value/b)+")"}];for(var i=0;i<h.length;++i){var j=h[i];g.append("span").attr("class","column column-"+i+(h.length-i==1?" last-column":"")).text(function(a){return j(a)}).on("click",f)}}return c},c.redraw=function(){c.render()},c.anchor(a)},dc.dataCount=function(a){var b=dc.baseChart({}),c=null,d=b.groupAll;return b.groupAll=function(){var a=d.apply(undefined,arguments);return arguments.length>0&&(c=d().value()),a},b.render=function(){var a=b.group().value();return b.selectAll(".total-count").text(b.valuePrinter()(c)),b.selectAll(".filter-count").text(b.valuePrinter()(a)),b.selectAll(".filter-pct").text(c==null||c==0?"-":dc.percentFormat(a/c)),b},b.redraw=function(){return b.render()},b.anchor(a)},dc.dataTable=function(a){function h(){var a=b.root().selectAll("div.group").data(i(),function(a){return b.keyRetriever()(a)});return a.enter().append("div").attr("class","group").append("span").attr("class","label").text(function(a){return b.keyRetriever()(a)}),a.exit().remove(),a}function i(){g||(g=crossfilter.quicksort.by(e));var a=b.dimension().top(c);return d3.nest().key(b.group()).sortKeys(f).entries(g(a,0,a.length))}function j(a){var b=a.order().selectAll("div.row").data(function(a){return a.values}),c=b.enter().append("div").attr("class","row");for(var e=0;e<d.length;++e){var f=d[e];c.append("span").attr("class","column column-"+e+(d.length-e==1?" last-column":"")).text(function(a){return f(a)})}return b.exit().remove(),b}var b=dc.baseChart({}),c=25,d=[],e=function(a){return a},f=d3.ascending,g;return b.render=function(){return b.selectAll("div.row").remove(),j(h()),b},b.redraw=function(){return b.render()},b.size=function(a){return arguments.length?(c=a,b):c},b.columns=function(a){return arguments.length?(d=a,b):d},b.sortBy=function(a){return arguments.length?(e=a,b):e},b.order=function(a){return arguments.length?(f=a,b):f},b.anchor(a)},dc.bubbleChart=function(a,b){function j(a){var b=a.enter().append("g");b.attr("class",c).attr("transform",i).append("circle").attr("class",function(a,b){return d+" "+b}).on("click",s).attr("fill",function(a,b){return f.colors()(b)}).attr("r",0),dc.transition(a,f.transitionDuration()).attr("r",function(a){return v(a)}),l(b),o(b)}function l(a){f.renderLabel()&&a.append("text").attr("text-anchor","middle").attr("dy",".3em").on("click",s).text(k)}function m(a){f.renderLabel()&&a.selectAll("text").text(k)}function o(a){f.renderTitle()&&a.append("title").text(n)}function p(a){f.renderTitle()&&a.selectAll("title").text(n)}function q(a){dc.transition(a,f.transitionDuration()).attr("transform",i).selectAll("circle."+d).attr("r",function(a){return v(a)}),m(a),p(a)}function r(a){dc.transition(a.exit().selectAll("circle."+d),f.transitionDuration()).attr("r",0).remove()}function t(a){return f.x()(f.keyRetriever()(a))+f.margins().left}function u(a){return f.margins().top+f.y()(f.valueRetriever()(a))}function v(a){return f.r()(f.radiusValueRetriever()(a))}var c="node",d="bubble",e=10,f=dc.singleSelectionChart(dc.colorChart(dc.coordinateGridChart({})),b);f.renderLabel(!0),f.renderTitle(!1);var g=d3.scale.linear().domain([0,100]),h=function(a){return a.r};f.transitionDuration(750);var i=function(a){return"translate("+t(a)+","+u(a)+")"};f.plotData=function(){g.range([0,f.xAxisLength()/3]);var a=f.g().selectAll("g."+c).data(f.group().all());j(a),q(a),r(a),f.fadeDeselectedArea()};var k=function(a){return v(a)>e?f.label()(a):""},n=function(a){return f.title()(a)},s=function(a){f.filter(a.key),dc.redrawAll()};return f.renderBrush=function(a){},f.redrawBrush=function(a){f.fadeDeselectedArea()},f.fadeDeselectedArea=function(){var a=1,b=.1;f.hasFilter()?f.selectAll("g."+c).select("circle").each(function(a){f.isSelectedSlice(a)?f.highlightSelected(this):f.fadeDeselected(this)}):f.selectAll("g."+c).selectAll("circle").each(function(a){f.resetHighlight(this)})},f.isSelectedSlice=function(a){return f.filter()==a.key},f.r=function(a){return arguments.length?(g=a,f):g},f.radiusValueRetriever=function(a){return arguments.length?(h=a,f):h},f.anchor(a)},dc.compositeChart=function(a){var b="sub",c=dc.coordinateGridChart({}),d=[];return c.transitionDuration(500),dc.override(c,"generateG",function(a){for(var b=0;b<d.length;++b){var e=d[b];e.dimension()==null&&e.dimension(c.dimension()),e.group()==null&&e.group(c.group()),e.svg(c.svg()),e.height(c.height()),e.width(c.width()),e.margins(c.margins()),e.xUnits(c.xUnits()),e.transitionDuration(c.transitionDuration()),e.generateG(),e.g().attr("class","sub")}return a()}),c.plotData=function(){for(var a=0;a<d.length;++a){var b=d[a];b.x(c.x()),b.y(c.y()),b.xAxis(c.xAxis()),b.yAxis(c.yAxis()),b.plotData()}},c.fadeDeselectedArea=function(){for(var a=0;a<d.length;++a){var b=d[a];b.brush(c.brush()),b.fadeDeselectedArea()}},c.compose=function(a){return d=a,c},c.anchor(a)};