forked from dc-js/dc.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dc.min.js
3 lines (3 loc) · 58.6 KB
/
dc.min.js
1
2
3
dc=function(){"use strict";var a={version:"1.7.0-dev",constants:{CHART_CLASS:"dc-chart",DEBUG_GROUP_CLASS:"debug",STACK_CLASS:"stack",DESELECTED_CLASS:"deselected",SELECTED_CLASS:"selected",NODE_INDEX_NAME:"__index__",GROUP_INDEX_NAME:"__group_index__",DEFAULT_CHART_GROUP:"__default_chart_group__",EVENT_DELAY:40,NEGLIGIBLE_NUMBER:1e-10},_renderlet:null};return a.chartRegistry=function(){function b(b){return b||(b=a.constants.DEFAULT_CHART_GROUP),c[b]||(c[b]=[]),b}var c={};return{has:function(a){for(var b in c)if(c[b].indexOf(a)>=0)return!0;return!1},register:function(a,d){d=b(d),c[d].push(a)},clear:function(a){a?delete c[a]:c={}},list:function(a){return a=b(a),c[a]}}}(),a.registerChart=function(b,c){a.chartRegistry.register(b,c)},a.hasChart=function(b){return a.chartRegistry.has(b)},a.deregisterAllCharts=function(b){a.chartRegistry.clear(b)},a.filterAll=function(b){for(var c=a.chartRegistry.list(b),d=0;d<c.length;++d)c[d].filterAll()},a.renderAll=function(b){for(var c=a.chartRegistry.list(b),d=0;d<c.length;++d)c[d].render();null!==a._renderlet&&a._renderlet(b)},a.redrawAll=function(b){for(var c=a.chartRegistry.list(b),d=0;d<c.length;++d)c[d].redraw();null!==a._renderlet&&a._renderlet(b)},a.transition=function(a,b,c){if(0>=b||void 0===b)return a;var d=a.transition().duration(b);return c instanceof Function&&c(d),d},a.units={},a.units.integers=function(a,b){return Math.abs(b-a)},a.units.ordinal=function(a,b,c){return c},a.units.fp={},a.units.fp.precision=function(b){var c=function(b,d){var e=Math.abs((d-b)/c.resolution);return a.utils.isNegligible(e-Math.floor(e))?Math.floor(e):Math.ceil(e)};return c.resolution=b,c},a.round={},a.round.floor=function(a){return Math.floor(a)},a.round.ceil=function(a){return Math.ceil(a)},a.round.round=function(a){return Math.round(a)},a.override=function(a,b,c){var d=a[b];a["_"+b]=d,a[b]=c},a.renderlet=function(b){return arguments.length?(a._renderlet=b,a):a._renderlet},a.instanceOfChart=function(a){return a instanceof Object&&a.__dc_flag__},a.errors={},a.errors.Exception=function(a){var b=a||"Unexpected internal error";this.message=b,this.toString=function(){return b}},a.errors.InvalidStateException=function(){a.errors.Exception.apply(this,arguments)},a.dateFormat=d3.time.format("%m/%d/%Y"),a.printers={},a.printers.filters=function(b){for(var c="",d=0;d<b.length;++d)d>0&&(c+=", "),c+=a.printers.filter(b[d]);return c},a.printers.filter=function(b){var c="";return b&&(b instanceof Array?b.length>=2?c="["+a.utils.printSingleValue(b[0])+" -> "+a.utils.printSingleValue(b[1])+"]":b.length>=1&&(c=a.utils.printSingleValue(b[0])):c=a.utils.printSingleValue(b)),c},a.utils={},a.utils.printSingleValue=function(b){var c=""+b;return b instanceof Date?c=a.dateFormat(b):"string"==typeof b?c=b:a.utils.isFloat(b)?c=a.utils.printSingleValue.fformat(b):a.utils.isInteger(b)&&(c=Math.round(b)),c},a.utils.printSingleValue.fformat=d3.format(".2f"),a.utils.add=function(a,b){if("string"==typeof b&&(b=b.replace("%","")),a instanceof Date){"string"==typeof b&&(b=+b);var c=new Date;return c.setTime(a.getTime()),c.setDate(a.getDate()+b),c}if("string"==typeof b){var d=+b/100;return a>0?a*(1+d):a*(1-d)}return a+b},a.utils.subtract=function(a,b){if("string"==typeof b&&(b=b.replace("%","")),a instanceof Date){"string"==typeof b&&(b=+b);var c=new Date;return c.setTime(a.getTime()),c.setDate(a.getDate()-b),c}if("string"==typeof b){var d=+b/100;return 0>a?a*(1+d):a*(1-d)}return a-b},a.utils.GroupStack=function(){function a(a){c[a]||(c[a]=[])}var b,c=[[]],d=[];this.setDataPoint=function(b,d,e){a(b),c[b][d]=e},this.getDataPoint=function(b,d){a(b);var e=c[b][d];return void 0===e&&(e=0),e},this.addGroup=function(a,c){return c||(c=b),d.push([a,c]),d.length-1},this.getGroupByIndex=function(a){return d[a][0]},this.getAccessorByIndex=function(a){return d[a][1]},this.size=function(){return d.length},this.clear=function(){c=[],d=[]},this.setDefaultAccessor=function(a){b=a},this.getDataLayers=function(){return c},this.clearDataLayers=function(){c=[[]]},this.toLayers=function(){for(var a=[],b=0;b<c.length;++b){for(var d={index:b,points:[]},e=c[b],f=0;f<e.length;++f)d.points.push(e[f]);a.push(d)}return a}},a.utils.isNumber=function(a){return a===+a},a.utils.isFloat=function(a){return a===+a&&a!==(0|a)},a.utils.isInteger=function(a){return a===+a&&a===(0|a)},a.utils.isNegligible=function(b){return void 0===b||b<a.constants.NEGLIGIBLE_NUMBER&&b>-a.constants.NEGLIGIBLE_NUMBER},a.utils.groupMax=function(b,c){var d=d3.max(b.all(),function(a){return c(a)});return a.utils.isNegligible(d)&&(d=0),d},a.utils.groupMin=function(b,c){var d=d3.min(b.all(),function(a){return c(a)});return a.utils.isNegligible(d)&&(d=0),d},a.utils.nameToId=function(a){return a.toLowerCase().replace(/[\s]/g,"_").replace(/[\.']/g,"")},a.utils.appendOrSelect=function(a,b){var c=a.select(b);return c.empty()&&(c=a.append(b)),c},a.utils.createLegendable=function(a,b,c,d){var e={name:a._getGroupName(b,d),data:b};return"function"==typeof a.colors&&(e.color=a.colors()(c)),e},a.utils.safeNumber=function(b){return a.utils.isNumber(+b)?+b:0},a.events={current:null},a.events.trigger=function(b,c){return c?(a.events.current=b,setTimeout(function(){b==a.events.current&&b()},c),void 0):(b(),void 0)},a.cumulative={},a.cumulative.Base=function(){this._keyIndex=[],this._map={},this.sanitizeKey=function(a){return a+=""},this.clear=function(){this._keyIndex=[],this._map={}},this.size=function(){return this._keyIndex.length},this.getValueByKey=function(a){a=this.sanitizeKey(a);var b=this._map[a];return b},this.setValueByKey=function(a,b){return a=this.sanitizeKey(a),this._map[a]=b},this.indexOfKey=function(a){return a=this.sanitizeKey(a),this._keyIndex.indexOf(a)},this.addToIndex=function(a){a=this.sanitizeKey(a),this._keyIndex.push(a)},this.getKeyByIndex=function(a){return this._keyIndex[a]}},a.cumulative.Sum=function(){a.cumulative.Base.apply(this,arguments),this.add=function(a,b){b||(b=0),void 0===this.getValueByKey(a)?(this.addToIndex(a),this.setValueByKey(a,b)):this.setValueByKey(a,this.getValueByKey(a)+b)},this.minus=function(a,b){this.setValueByKey(a,this.getValueByKey(a)-b)},this.cumulativeSum=function(a){var b=this.indexOfKey(a);if(0>b)return 0;for(var c=0,d=0;b>=d;++d){var e=this.getKeyByIndex(d);c+=this.getValueByKey(e)}return c}},a.cumulative.Sum.prototype=new a.cumulative.Base,a.cumulative.CountUnique=function(){function b(a){var b,c=0;for(b in a)a.hasOwnProperty(b)&&c++;return c}a.cumulative.Base.apply(this,arguments),this.add=function(a,b){void 0===this.getValueByKey(a)&&(this.setValueByKey(a,{}),this.addToIndex(a)),void 0!==b&&(void 0===this.getValueByKey(a)[b]&&(this.getValueByKey(a)[b]=0),this.getValueByKey(a)[b]+=1)},this.minus=function(a,b){this.getValueByKey(a)[b]-=1,this.getValueByKey(a)[b]<=0&&delete this.getValueByKey(a)[b]},this.count=function(a){return b(this.getValueByKey(a))},this.cumulativeCount=function(a){var b=this.indexOfKey(a);if(0>b)return 0;for(var c=0,d=0;b>=d;++d){var e=this.getKeyByIndex(d);c+=this.count(e)}return c}},a.cumulative.CountUnique.prototype=new a.cumulative.Base,a.baseChart=function(b){function c(a,b,c){var d=a.anchor(),e="__names__";c&&c!=a.valueAccessor()||(c="default"),b[e]||(b[e]={}),b[e][d]||(b[e][d]={a:[],n:[]});var f=b[e][d].a.indexOf(c);return-1==f&&(f=b[e][d].a.length,b[e][d].a[f]=c,b[e][d].n[f]={name:""}),b[e][d].n[f]}function d(){return o=b.root().append("svg").attr("width",b.width()).attr("height",b.height())}function e(c){if(!b[c]||!b[c]())throw new a.errors.InvalidStateException("Mandatory attribute chart."+c+" is missing on chart[#"+b.anchorName()+"]")}function f(a){G.splice(G.indexOf(a),1),i(),b._invokeFilteredListener(a)}function g(a){G.push(a),i(),b._invokeFilteredListener(a)}function h(){G=[],i(),b._invokeFilteredListener(null)}function i(){if(b.dataSet()&&void 0!==b.dimension().filter){var a=H(b.dimension(),G);G=a?a:G}}function j(){for(var a=0;a<B.length;++a)B[a](b)}b.__dc_flag__=!0;var k,l,m,n,o,p,q=200,r=200,s=function(a){return a.key},t=function(a){return a.value},u=function(a){return a.key},v=function(a){return a.key},w=!1,x=function(a){return a.key+": "+a.value},y=!1,z=750,A=a.printers.filters,B=[],C=["dimension","group"],D=a.constants.DEFAULT_CHART_GROUP,E=function(){},F={preRender:E,postRender:E,preRedraw:E,postRedraw:E,filtered:E,zoomed:E},G=[],H=function(a,b){return a.filter(null),0===b.length?a.filter(null):1===b.length?a.filter(b[0]):a.filterFunction(function(a){return b.indexOf(a)>=0}),b},I=function(){return l.all()};return b.width=function(a){return arguments.length?(q=a,b):q},b.height=function(a){return arguments.length?(r=a,b):r},b.dimension=function(a){return arguments.length?(k=a,b.expireCache(),b):k},b.data=function(a){return arguments.length?(I=d3.functor(a),b.expireCache(),b):I()},b.group=function(a,c){return arguments.length?(l=a,b.expireCache(),"string"==typeof c&&b._setGroupName(l,c),b):l},b._getGroupName=function(a,d){return c(b,a,d).name},b._setGroupName=function(a,d,e){c(b,a,e).name=d},b.ordering=function(a){return arguments.length?(u=a,b.expireCache(),b):u},b.computeOrderedGroups=function(a){var c=a?a:b.data().slice(0);if(c.length<2)return c;var d=crossfilter.quicksort.by(b.ordering());return d(c,0,c.length)},b.filterAll=function(){return b.filter(null)},b.dataSet=function(){return void 0!==k&&void 0!==l},b.select=function(a){return n.select(a)},b.selectAll=function(a){return n?n.selectAll(a):null},b.anchor=function(c,d){return arguments.length?(a.instanceOfChart(c)?(m=c.anchor(),n=c.root()):(m=c,n=d3.select(m),n.classed(a.constants.CHART_CLASS,!0),a.registerChart(b,d)),D=d,b):m},b.anchorName=function(){var a=b.anchor();return a&&a.id?a.id:a?a.replace("#",""):""},b.root=function(a){return arguments.length?(n=a,b):n},b.svg=function(a){return arguments.length?(o=a,b):o},b.resetSvg=function(){return b.select("svg").remove(),d()},b.filterPrinter=function(a){return arguments.length?(A=a,b):A},b.turnOnControls=function(){return n&&(b.selectAll(".reset").style("display",null),b.selectAll(".filter").text(A(b.filters())).style("display",null)),b},b.turnOffControls=function(){return n&&(b.selectAll(".reset").style("display","none"),b.selectAll(".filter").style("display","none").text(b.filter())),b},b.transitionDuration=function(a){return arguments.length?(z=a,b):z},b._mandatoryAttributes=function(a){return arguments.length?(C=a,b):C},b.render=function(){F.preRender(b),C.forEach(e);var a=b.doRender();return p&&p.render(),b.activateRenderlets("postRender"),a},b.activateRenderlets=function(a){b.transitionDuration()>0&&o?o.transition().duration(b.transitionDuration()).each("end",function(){j(),a&&F[a](b)}):(j(),a&&F[a](b))},b.redraw=function(){F.preRedraw(b);var a=b.doRedraw();return b.activateRenderlets("postRedraw"),a},b._invokeFilteredListener=function(a){void 0!==a&&F.filtered(b,a)},b._invokeZoomedListener=function(){F.zoomed(b)},b.hasFilter=function(a){return arguments.length?G.indexOf(a)>=0:G.length>0},b.filter=function(a){return arguments.length?(null===a?h():b.hasFilter(a)?f(a):g(a),null!==n&&b.hasFilter()?b.turnOnControls():b.turnOffControls(),b):G.length>0?G[0]:null},b.filters=function(){return G},b.highlightSelected=function(b){d3.select(b).classed(a.constants.SELECTED_CLASS,!0),d3.select(b).classed(a.constants.DESELECTED_CLASS,!1)},b.fadeDeselected=function(b){d3.select(b).classed(a.constants.SELECTED_CLASS,!1),d3.select(b).classed(a.constants.DESELECTED_CLASS,!0)},b.resetHighlight=function(b){d3.select(b).classed(a.constants.SELECTED_CLASS,!1),d3.select(b).classed(a.constants.DESELECTED_CLASS,!1)},b.onClick=function(c){var d=b.keyAccessor()(c);a.events.trigger(function(){b.filter(d),a.redrawAll(b.chartGroup())})},b.filterHandler=function(a){return arguments.length?(H=a,b):H},b.doRender=function(){return b},b.doRedraw=function(){return b},b.legendables=function(){return[]},b.legendHighlight=function(){},b.legendReset=function(){},b.keyAccessor=function(a){return arguments.length?(s=a,b):s},b.valueAccessor=function(a){return arguments.length?(t=a,b):t},b.label=function(a){return arguments.length?(v=a,w=!0,b):v},b.renderLabel=function(a){return arguments.length?(w=a,b):w},b.title=function(a){return arguments.length?(x=a,y=!0,b):x},b.renderTitle=function(a){return arguments.length?(y=a,b):y},b.renderlet=function(a){return B.push(a),b},b.chartGroup=function(a){return arguments.length?(D=a,b):D},b.expireCache=function(){return b},b.legend=function(a){return arguments.length?(p=a,p.parent(b),b):p},b.on=function(a,c){return F[a]=c,b},b},a.marginable=function(a){var b={top:10,right:50,bottom:30,left:30};return a.margins=function(c){return arguments.length?(b=c,a):b},a.effectiveWidth=function(){return a.width()-a.margins().left-a.margins().right},a.effectiveHeight=function(){return a.height()-a.margins().top-a.margins().bottom},a},a.coordinateGridChart=function(b){function c(a){b.elasticX()&&!b.isOrdinal()?v.domain([b.xAxisMin(),b.xAxisMax()]):b.isOrdinal()&&0===v.domain().length&&v.domain(b.computeOrderedGroups().map(function(a){return a.key})),b.isOrdinal()?b.prepareOrdinalXAxis():v.range([0,b.xAxisLength()]),E=E.scale(b.x()).orient("bottom"),d(a)}function d(c){var d=c.selectAll("g."+o);if(Q){d.empty()&&(d=c.insert("g",":first-child").attr("class",m+" "+o).attr("transform","translate("+b.yAxisX()+","+b.margins().top+")"));var e=E.tickValues()?E.tickValues():v.ticks(E.ticks()[0]),f=d.selectAll("line").data(e),g=f.enter().append("line").attr("x1",function(a){return v(a)}).attr("y1",b.xAxisY()-b.margins().top).attr("x2",function(a){return v(a)}).attr("y2",0).attr("opacity",0);a.transition(g,b.transitionDuration()).attr("opacity",1),a.transition(f,b.transitionDuration()).attr("x1",function(a){return v(a)}).attr("y1",b.xAxisY()-b.margins().top).attr("x2",function(a){return v(a)}).attr("y2",0),f.exit().remove()}else d.selectAll("line").remove()}function e(a){(void 0===y||b.elasticY())&&(y=d3.scale.linear(),y.domain([b.yAxisMin(),b.yAxisMax()]).rangeRound([b.yAxisHeight(),0])),y.range([b.yAxisHeight(),0]),J=J.scale(y).orient("left"),f(a)}function f(c){var d=c.selectAll("g."+n);if(P){var e=J.tickValues()?J.tickValues():y.ticks(J.ticks()[0]);d.empty()&&(d=c.insert("g",":first-child").attr("class",m+" "+n).attr("transform","translate("+b.yAxisX()+","+b.margins().top+")"));var f=d.selectAll("line").data(e),g=f.enter().append("line").attr("x1",1).attr("y1",function(a){return y(a)}).attr("x2",b.xAxisLength()).attr("y2",function(a){return y(a)}).attr("opacity",0);a.transition(g,b.transitionDuration()).attr("opacity",1),a.transition(f,b.transitionDuration()).attr("x1",1).attr("y1",function(a){return y(a)}).attr("x2",b.xAxisLength()).attr("y2",function(a){return y(a)}),f.exit().remove()}else d.selectAll("line").remove()}function g(){return b.xAxisY()-b.margins().top}function h(){return b.anchorName()+"-clip"}function i(){var c=a.utils.appendOrSelect(s,"defs"),d=a.utils.appendOrSelect(c,"clipPath").attr("id",h()),e=2*V;a.utils.appendOrSelect(d,"rect").attr("width",b.xAxisLength()+e).attr("height",b.yAxisHeight()+e)}function j(){U&&b.root().call(d3.behavior.zoom().x(b.x()).scaleExtent(S).on("zoom",function(){b.focus(b.x().domain()),b._invokeZoomedListener(),k()}))}function k(){if(C){var c=b.x().domain();if(T){var d=C.xOriginalDomain(),e=[c[0]<d[0]?c[0]:d[0],c[1]>d[1]?c[1]:d[1]];C.focus(e)}else C.focus(c);C.filter(null),C.filter(c),a.events.trigger(function(){a.redrawAll(b.chartGroup())})}}function l(a){return a instanceof Array&&a.length>1}var m="grid-line",n="horizontal",o="vertical",p="y-axis-label",q="x-axis-label",r=12;b=a.colorChart(a.marginable(a.baseChart(b))),b.colors(d3.scale.category10()),b._mandatoryAttributes().push("x");var s,t,u,v,w,x,y,z,A,B,C,D,E=d3.svg.axis(),F=a.units.integers,G=0,H=!1,I=0,J=d3.svg.axis(),K=0,L=!1,M=0,N=d3.svg.brush(),O=!0,P=!1,Q=!1,R=!1,S=[-10,100],T=!0,U=!1,V=0;return b.title(function(a){return a.data.key+": "+a.data.value}),b.rescale=function(){B=void 0,b.xUnitCount()},b.rangeChart=function(a){return arguments.length?(C=a,C.focusChart(b),b):C},b.zoomScale=function(a){return arguments.length?(S=a,b):S},b.zoomOutRestrict=function(a){return arguments.length?(T=a,b):T},b._generateG=function(a){return s=void 0===a?b.svg():a,t=s.append("g"),u=t.append("g").attr("class","chart-body").attr("transform","translate("+b.margins().left+", "+b.margins().top+")").attr("clip-path","url(#"+h()+")"),t},b.g=function(a){return arguments.length?(t=a,b):t},b.mouseZoomable=function(a){return arguments.length?(U=a,b):U},b.chartBodyG=function(a){return arguments.length?(u=a,b):u},b.x=function(a){return arguments.length?(v=a,w=v.domain(),b):v},b.xOriginalDomain=function(){return w},b.xUnits=function(a){return arguments.length?(F=a,b):F},b.xAxis=function(a){return arguments.length?(E=a,b):E},b.elasticX=function(a){return arguments.length?(H=a,b):H},b.xAxisPadding=function(a){return arguments.length?(G=a,b):G},b.xUnitCount=function(){if(void 0===B){var a=b.xUnits()(b.x().domain()[0],b.x().domain()[1],b.x().domain());B=a instanceof Array?a.length:a}return B},b.isOrdinal=function(){return b.xUnits()===a.units.ordinal},b.prepareOrdinalXAxis=function(a){a||(a=b.xUnitCount());for(var c=[],d=b.xAxisLength()/(a+1),e=d/2,f=0;a>f;f++)c[f]=e,e+=d;v.range(c)},b.renderXAxis=function(c){var d=c.selectAll("g.x");d.empty()&&(d=c.append("g").attr("class","axis x").attr("transform","translate("+b.margins().left+","+b.xAxisY()+")"));var e=c.selectAll("text."+q);e.empty()&&b.xAxisLabel()&&(e=c.append("text").attr("transform","translate("+b.xAxisLength()/2+","+(b.height()-I)+")").attr("class",q).attr("text-anchor","middle").text(b.xAxisLabel())),b.xAxisLabel()&&e.text()!=b.xAxisLabel()&&axisYLab.text(b.xAxisLabel()),a.transition(d,b.transitionDuration()).call(E)},b.xAxisY=function(){return b.height()-b.margins().bottom},b.xAxisLength=function(){return b.effectiveWidth()},b.xAxisLabel=function(a,c){return arguments.length?(x=a,b.margins().bottom-=I,I=void 0===c?r:c,b.margins().bottom+=I,b):x},b.renderYAxis=function(c){var d=c.selectAll("g.y");d.empty()&&(d=c.append("g").attr("class","axis y").attr("transform","translate("+b.yAxisX()+","+b.margins().top+")"));var e=c.selectAll("text."+p);e.empty()&&b.yAxisLabel()&&(e=c.append("text").attr("transform","translate("+M+","+b.yAxisHeight()/2+"),rotate(-90)").attr("class",p).attr("text-anchor","middle").text(b.yAxisLabel())),b.yAxisLabel()&&e.text()!=b.yAxisLabel()&&e.text(b.yAxisLabel()),a.transition(d,b.transitionDuration()).call(J)},b.yAxisX=function(){return b.margins().left},b.yAxisLabel=function(a,c){return arguments.length?(z=a,b.margins().left-=M,M=void 0===c?r:c,b.margins().left+=M,b):z},b.y=function(a){return arguments.length?(y=a,b):y},b.yAxis=function(a){return arguments.length?(J=a,b):J},b.elasticY=function(a){return arguments.length?(L=a,b):L},b.renderHorizontalGridLines=function(a){return arguments.length?(P=a,b):P},b.renderVerticalGridLines=function(a){return arguments.length?(Q=a,b):Q},b.xAxisMin=function(){var c=d3.min(b.data(),function(a){return b.keyAccessor()(a)});return a.utils.subtract(c,G)},b.xAxisMax=function(){var c=d3.max(b.data(),function(a){return b.keyAccessor()(a)});return a.utils.add(c,G)},b.yAxisMin=function(){var c=d3.min(b.data(),function(a){return b.valueAccessor()(a)});return c=a.utils.subtract(c,K)},b.yAxisMax=function(){var c=d3.max(b.data(),function(a){return b.valueAccessor()(a)});return c=a.utils.add(c,K)},b.yAxisPadding=function(a){return arguments.length?(K=a,b):K},b.yAxisHeight=function(){return b.effectiveHeight()},b.round=function(a){return arguments.length?(A=a,b):A},a.override(b,"filter",function(a){return arguments.length?(b._filter(a),a?b.brush().extent(a):b.brush().clear(),b):b._filter()}),b.brush=function(a){return arguments.length?(N=a,b):N},b.renderBrush=function(a){if(b.isOrdinal()&&(O=!1),O){N.on("brush",b._brushing);var c=a.append("g").attr("class","brush").attr("transform","translate("+b.margins().left+","+b.margins().top+")").call(N.x(b.x()));c.selectAll("rect").attr("height",g()),c.selectAll(".resize").append("path").attr("d",b.resizeHandlePath),b.hasFilter()&&b.redrawBrush(a)}},b.extendBrush=function(){var a=N.extent();return b.round()&&(a[0]=a.map(b.round())[0],a[1]=a.map(b.round())[1],t.select(".brush").call(N.extent(a))),a},b.brushIsEmpty=function(a){return N.empty()||!a||a[1]<=a[0]},b.brushHasNoLength=function(a){return a[0]instanceof Date&&a[1]instanceof Date?a[0].getTime()==a[1].getTime():a[0]==a[1]},b._brushing=function(){var c=b.extendBrush();b.redrawBrush(t),b.brushHasNoLength(c)||(b.brushIsEmpty(c)?a.events.trigger(function(){b.filter(null),a.redrawAll(b.chartGroup())}):a.events.trigger(function(){b.filter(null),b.filter([c[0],c[1]]),a.redrawAll(b.chartGroup())},a.constants.EVENT_DELAY))},b.redrawBrush=function(a){if(O){b.filter()&&b.brush().empty()&&b.brush().extent(b.filter());var c=a.select("g.brush");c.call(b.brush().x(b.x())),c.selectAll("rect").attr("height",g())}b.fadeDeselectedArea()},b.fadeDeselectedArea=function(){},b.resizeHandlePath=function(a){var b=+("e"==a),c=b?1:-1,d=g()/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"Z"+"M"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)},b.clipPadding=function(a){return arguments.length?(V=a,b):V},b.doRender=function(){return b.resetSvg(),b.dataSet()&&(b._generateG(),i(),c(b.g()),e(b.g()),b.plotData(),b.renderXAxis(b.g()),b.renderYAxis(b.g()),b.renderBrush(b.g()),j()),b},b.doRedraw=function(){return c(b.g()),e(b.g()),b.plotData(),b.elasticY()&&b.renderYAxis(b.g()),(b.elasticX()||R)&&b.renderXAxis(b.g()),b.redrawBrush(b.g()),b},b.subRender=function(){return b.dataSet()&&b.plotData(),b},b.brushOn=function(a){return arguments.length?(O=a,b):O},b.focus=function(a){R=!0,l(a)?b.x().domain(a):b.x().domain(b.xOriginalDomain()),b.rescale(),b.redraw(),l(a)||(R=!1)},b.refocused=function(){return R},b.focusChart=function(c){return arguments.length?(D=c,b.on("filtered",function(b){a.events.trigger(function(){D.focus(b.filter()),D.filter(b.filter()),a.redrawAll(b.chartGroup())})}),b):D},b},a.colorChart=function(b){var c=d3.scale.category20c(),d=[0,c.range().length],e=function(e){var f=d;"function"==typeof d&&(f=d.call(b));var g=f[0],h=f[1];if(isNaN(e)&&(e=0),!a.utils.isNumber(h))return c(e);var i=b.colors().range().length,j=(h-g)/i,k=Math.abs(Math.min(i-1,Math.round((e-g)/j)));return b.colors()(k)},f=function(a,b){return b};return b.colors=function(a){if(!arguments.length)return c;if(a instanceof Array){c=d3.scale.ordinal().range(a);for(var e=[],f=0;f<a.length;++f)e.push(f);c.domain(e)}else c=a;return d=[0,c.range().length],b},b.colorCalculator=function(a){return arguments.length?(e=a,b):e},b.getColor=function(a,b){return e(f(a,b))},b.colorAccessor=function(a){return arguments.length?(f=a,b):f},b.colorDomain=function(a){return arguments.length?(d=a,b):d},b},a.stackableChart=function(b){function c(){var a=[];if(b.x()){var c,d=b.x().domain();if(b.isOrdinal()){var e=d3.set(d);c=function(a){return e.has(a.x)}}else c=function(a){return a.x>=d[0]&&a.x<=d[d.length-1]};b.stackLayers().forEach(function(b){b.points.forEach(function(b){c(b)&&a.push(b)})})}else b.stackLayers().forEach(function(b){a=a.concat(b.points)});return a}function d(a,c){return b.getKeyAccessorByIndex(a)(c)}function e(a,c){return b.getValueAccessorByIndex(a)(c)}function f(a,b){for(var c=0;c<a.length;++c){var f=a[c],g=d(b,f),h=e(b,f);k.setDataPoint(b,c,{data:f,x:g,y:h,layer:b})}}var g,h,i,j,k=new a.utils.GroupStack,l=d3.layout.stack().offset("zero").order("default").values(function(a){return a.points});return b.stack=function(a,c,d){return arguments.length||k.clear(),"string"==typeof c?b._setGroupName(a,c,d):"function"==typeof c&&(d=c),k.setDefaultAccessor(b.valueAccessor()),k.addGroup(a,d),b.expireCache(),b},b.expireCache=function(){return g=null,h=null,i=null,j=null,b},b.allGroups=function(){if(null===g){g=[],g.push(b.group());for(var a=0;a<k.size();++a)g.push(k.getGroupByIndex(a))}return g},b.allValueAccessors=function(){if(null===h){h=[],h.push(b.valueAccessor());for(var a=0;a<k.size();++a)h.push(k.getAccessorByIndex(a))}return h},b.getValueAccessorByIndex=function(a){return b.allValueAccessors()[a]},b.yAxisMin=function(){var d,e=c();return d=d3.min(e,function(a){return a.y+a.y0<a.y0?a.y+a.y0:a.y0}),d=a.utils.subtract(d,b.yAxisPadding())},b.yAxisMax=function(){var d,e=c();return d=d3.max(e,function(a){return a.y+a.y0}),d=a.utils.add(d,b.yAxisPadding())},b.allKeyAccessors=function(){if(null===i){i=[],i.push(b.keyAccessor());for(var a=0;a<k.size();++a)i.push(b.keyAccessor())}return i},b.getKeyAccessorByIndex=function(a){return b.allKeyAccessors()[a]},b.xAxisMin=function(){for(var c=null,d=b.allGroups(),e=0;e<d.length;++e){var f=d[e],g=a.utils.groupMin(f,b.getKeyAccessorByIndex(e));(null===c||c>g)&&(c=g)}return a.utils.subtract(c,b.xAxisPadding())},b.xAxisMax=function(){for(var c=null,d=b.allGroups(),e=0;e<d.length;++e){var f=d[e],g=a.utils.groupMax(f,b.getKeyAccessorByIndex(e));(null===c||g>c)&&(c=g)}return a.utils.add(c,b.xAxisPadding())},b.calculateDataPointMatrixForAll=function(){k.clearDataLayers();for(var a=b.allGroups(),c=0;c<a.length;++c){var d=a[c],e=d.all();f(e,c)}},b.getChartStack=function(){return k},a.override(b,"valueAccessor",function(a){return arguments.length?(b.expireCache(),b._valueAccessor(a)):b._valueAccessor()}),a.override(b,"keyAccessor",function(a){return arguments.length?(b.expireCache(),b._keyAccessor(a)):b._keyAccessor()}),b.stackLayout=function(a){return arguments.length?(l=a,b):l},b.stackLayers=function(a){return arguments.length?(j=a,void 0):(null===j&&(b.calculateDataPointMatrixForAll(),j=b.stackLayout()(k.toLayers())),j)},b.colorAccessor(function(a){return a.layer||a.index}),b.legendables=function(){var c=[];return g.forEach(function(d,e){c.push(a.utils.createLegendable(b,d,e,b.getValueAccessorByIndex(e)))}),c},b},a.abstractBubbleChart=function(b){var c=.3,d=10;b.BUBBLE_NODE_CLASS="node",b.BUBBLE_CLASS="bubble",b.MIN_RADIUS=10,b=a.colorChart(b),b.renderLabel(!0),b.renderTitle(!1),b.data(function(){return b.group().top(1/0)});var e=d3.scale.linear().domain([0,100]),f=function(a){return a.r};b.r=function(a){return arguments.length?(e=a,b):e},b.radiusValueAccessor=function(a){return arguments.length?(f=a,b):f},b.rMin=function(){var a=d3.min(b.data(),function(a){return b.radiusValueAccessor()(a)});return a},b.rMax=function(){var a=d3.max(b.data(),function(a){return b.radiusValueAccessor()(a)});return a},b.bubbleR=function(a){var c=b.radiusValueAccessor()(a),d=b.r()(c);return(isNaN(d)||0>=c)&&(d=0),d};var g=function(a){return b.label()(a)},h=function(a){return b.bubbleR(a)>d?1:0};b.doRenderLabel=function(c){if(b.renderLabel()){var d=c.select("text");d.empty()&&(d=c.append("text").attr("text-anchor","middle").attr("dy",".3em").on("click",b.onClick)),d.attr("opacity",0).text(g),a.transition(d,b.transitionDuration()).attr("opacity",h)}},b.doUpdateLabels=function(c){if(b.renderLabel()){var d=c.selectAll("text").text(g);a.transition(d,b.transitionDuration()).attr("opacity",h)}};var i=function(a){return b.title()(a)};return b.doRenderTitles=function(a){if(b.renderTitle()){var c=a.select("title");c.empty()&&a.append("title").text(i)}},b.doUpdateTitles=function(a){b.renderTitle()&&a.selectAll("title").text(i)},b.minRadiusWithLabel=function(a){return arguments.length?(d=a,b):d},b.maxBubbleRelativeSize=function(a){return arguments.length?(c=a,b):c},b.initBubbleColor=function(c,d){return this[a.constants.NODE_INDEX_NAME]=d,b.getColor(c,d)},b.updateBubbleColor=function(c){return b.getColor(c,this[a.constants.NODE_INDEX_NAME])},b.fadeDeselectedArea=function(){b.hasFilter()?b.selectAll("g."+b.BUBBLE_NODE_CLASS).each(function(a){b.isSelectedNode(a)?b.highlightSelected(this):b.fadeDeselected(this)}):b.selectAll("g."+b.BUBBLE_NODE_CLASS).each(function(){b.resetHighlight(this)})},b.isSelectedNode=function(a){return b.hasFilter(a.key)},b.onClick=function(c){var d=c.key;a.events.trigger(function(){b.filter(d),a.redrawAll(b.chartGroup())})},b},a.pieChart=function(b,c){function d(){if(C.dataSet()){var a=p();w=w?w:d3.min([C.width(),C.height()])/2;var b=C.buildArcs(),c=a(C._assembleCappedData());if(x){var d=x.selectAll("g."+z).data(c);e(d,b,c),j(c,b),n(d),o()}}}function e(a,b,c){var d=f(a);g(d,b),h(d),i(c,b)}function f(a){var b=a.enter().append("g").attr("class",function(a,b){return z+" _"+b});return b}function g(a,b){var c=a.append("path").attr("fill",function(a,b){return C.getColor(a,b)}).on("click",u).attr("d",function(a,c){return v(a,c,b)});c.transition().duration(C.transitionDuration()).attrTween("d",s)}function h(a){C.renderTitle()&&a.append("title").text(function(a){return C.title()(a)})}function i(b,c){if(C.renderLabel()){var d=x.selectAll("text."+z).data(b);d.exit().remove();var e=d.enter().append("text").attr("class",function(a,b){return z+" _"+b}).on("click",u);a.transition(e,C.transitionDuration()).attr("transform",function(a){a.innerRadius=C.innerRadius(),a.outerRadius=w;var b=c.centroid(a);return isNaN(b[0])||isNaN(b[1])?"translate(0,0)":"translate("+b+")"}).attr("text-anchor","middle").text(function(a){var b=a.data;return r(b)||q(a)?"":C.label()(a)})}}function j(a,b){k(a,b),l(a,b),m(a)}function k(b,c){var d=x.selectAll("g."+z).data(b).select("path").attr("d",function(a,b){return v(a,b,c)});a.transition(d,C.transitionDuration(),function(a){a.attrTween("d",s)}).attr("fill",function(a,b){return C.getColor(a,b)})}function l(b,c){if(C.renderLabel()){var d=x.selectAll("text."+z).data(b);a.transition(d,C.transitionDuration()).attr("transform",function(a){a.innerRadius=C.innerRadius(),a.outerRadius=w;var b=c.centroid(a);return isNaN(b[0])||isNaN(b[1])?"translate(0,0)":"translate("+b+")"}).attr("text-anchor","middle").text(function(a){var b=a.data;return r(b)||q(a)?"":C.label()(a)})}}function m(a){C.renderTitle()&&x.selectAll("g."+z).data(a).select("title").text(function(a){return C.title()(a)})}function n(a){a.exit().remove()}function o(){C.hasFilter()?C.selectAll("g."+z).each(function(a){C.isSelectedSlice(a)?C.highlightSelected(this):C.fadeDeselected(this)}):C.selectAll("g."+z).each(function(){C.resetHighlight(this)})}function p(){return d3.layout.pie().sort(null).value(function(a){return C.valueAccessor()(a)})}function q(a){var b=a.endAngle-a.startAngle;return isNaN(b)||B>b}function r(a){return 0===C.valueAccessor()(a)}function s(a){a.innerRadius=C.innerRadius();var b=this._current;t(b)&&(b={startAngle:0,endAngle:0});var c=d3.interpolate(b,a);return this._current=c(0),function(a){return v(c(a),0,C.buildArcs())}}function t(a){return!a||isNaN(a.startAngle)||isNaN(a.endAngle)}function u(a){C.onClick(a.data)}function v(a,b,c){var d=c(a,b);return d.indexOf("NaN")>=0&&(d="M0,0"),d}var w,x,y=.5,z="pie-slice",A=0,B=y,C=a.capped(a.colorChart(a.baseChart({})));return C.slicesCap=C.cap,C.label(function(a){return C.keyAccessor()(a.data)}),C.renderLabel(!0),C.title(function(a){return C.keyAccessor()(a.data)+": "+C.valueAccessor()(a.data)}),C.transitionDuration(350),C.doRender=function(){return C.resetSvg(),x=C.svg().append("g").attr("transform","translate("+C.cx()+","+C.cy()+")"),d(),C},C.innerRadius=function(a){return arguments.length?(A=a,C):A},C.radius=function(a){return arguments.length?(w=a,C):w},C.cx=function(){return C.width()/2},C.cy=function(){return C.height()/2},C.buildArcs=function(){return d3.svg.arc().outerRadius(w).innerRadius(A)},C.isSelectedSlice=function(a){return C.hasFilter(C.keyAccessor()(a.data))},C.doRedraw=function(){return d(),C},C.minAngleForLabel=function(a){return arguments.length?(B=a,C):B},C.anchor(b,c)},a.barChart=function(b,c){function d(b){return a.utils.safeNumber(Math.abs(m.y()(b.y+b.y0)-m.y()(b.y0)))}function e(b,c){var e=b.selectAll("rect.bar").data(c.points);e.enter().append("rect").attr("class","bar").attr("fill",m.getColor).append("title").text(m.title()),m.isOrdinal()&&e.on("click",h),a.transition(e,m.transitionDuration()).attr("x",function(b){var c=m.x()(b.x);return(o||m.isOrdinal())&&(c-=j/2),a.utils.safeNumber(c)}).attr("y",function(b){var c=m.y()(b.y+b.y0);return b.y<0&&(c-=d(b)),a.utils.safeNumber(c)
}).attr("width",j).attr("height",function(a){return d(a)}).select("title").text(m.title()),a.transition(e.exit(),m.transitionDuration()).attr("height",0).remove()}function f(){if(void 0===j){var a=m.isOrdinal()?g()+1:g(),b=Math.floor((m.xAxisLength()-(a-1)*n)/a);(1/0==b||isNaN(b)||k>b)&&(b=k),j=b}}function g(){return void 0===i&&(i=m.xUnitCount()),i}function h(a){m.onClick(a.data)}var i,j,k=1,l=2,m=a.stackableChart(a.coordinateGridChart({})),n=l,o=!1;return a.override(m,"rescale",function(){m._rescale(),i=void 0,j=void 0,g()}),m.plotData=function(){var a=m.chartBodyG().selectAll("g.stack").data(m.stackLayers());f(),a.enter().append("g").attr("class",function(a,b){return"stack _"+b}),a.each(function(a,b){var c=d3.select(this);e(c,a,b)}),m.stackLayers(null)},m.fadeDeselectedArea=function(){var b=m.chartBodyG().selectAll("rect.bar"),c=m.brush().extent();if(m.isOrdinal())m.hasFilter()?(b.classed(a.constants.SELECTED_CLASS,function(a){return m.hasFilter(m.keyAccessor()(a.data))}),b.classed(a.constants.DESELECTED_CLASS,function(a){return!m.hasFilter(m.keyAccessor()(a.data))})):(b.classed(a.constants.SELECTED_CLASS,!1),b.classed(a.constants.DESELECTED_CLASS,!1));else if(m.brushIsEmpty(c))b.classed(a.constants.DESELECTED_CLASS,!1);else{var d=c[0],e=c[1];b.classed(a.constants.DESELECTED_CLASS,function(a){var b=m.keyAccessor()(a.data);return d>b||b>=e})}},m.centerBar=function(a){return arguments.length?(o=a,m):o},m.gap=function(a){return arguments.length?(n=a,m):n},m.extendBrush=function(){var a=m.brush().extent();return m.round()&&!o&&(a[0]=a.map(m.round())[0],a[1]=a.map(m.round())[1],m.chartBodyG().select(".brush").call(m.brush().extent(a))),a},m.legendHighlight=function(a){m.select(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!0),m.select(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!0)},m.legendReset=function(a){m.selectAll(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!1),m.selectAll(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!1)},m.anchor(b,c)},a.lineChart=function(b,c){function d(b,c){var d=d3.svg.line().x(function(a){return s.x()(a.x)}).y(function(a){return s.y()(a.y+a.y0)}).interpolate(v).tension(w);m&&d.defined(m),b.append("path").attr("class","line").attr("stroke",s.getColor).attr("fill",s.getColor),a.transition(c.select("path.line"),s.transitionDuration()).attr("d",function(a){return f(d(a.points))})}function e(b,c){if(t){var d=d3.svg.area().x(function(a){return s.x()(a.x)}).y(function(a){return s.y()(a.y+a.y0)}).y0(function(a){return s.y()(a.y0)}).interpolate(v).tension(w);m&&d.defined(m),b.append("path").attr("class","area").attr("fill",s.getColor).attr("d",function(a){return f(d(a.points))}),a.transition(c.select("path.area"),s.transitionDuration()).attr("d",function(a){return f(d(a.points))})}}function f(a){return!a||a.indexOf("NaN")>=0?"M0,0":a}function g(b,c){if(!s.brushOn()){var d=o+"-list",e=b.select("g."+d);e.empty()&&(e=b.append("g").attr("class",d)),c.each(function(b,c){var d=d3.select(this),f=d.datum().points,g=e.select("g."+o+"._"+c);g.empty()&&(g=e.append("g").attr("class",o+" _"+c)),h(g);var m=g.selectAll("circle."+p).data(f);m.enter().append("circle").attr("class",p).attr("r",u).attr("fill",s.getColor).style("fill-opacity",1e-6).style("stroke-opacity",1e-6).on("mousemove",function(){var a=d3.select(this);i(a),j(a,g)}).on("mouseout",function(){var a=d3.select(this);k(a),l(g)}).append("title").text(s.title()),m.attr("cx",function(b){return a.utils.safeNumber(s.x()(b.x))}).attr("cy",function(b){return a.utils.safeNumber(s.y()(b.y+b.y0))}).select("title").text(s.title()),m.exit().remove()})}}function h(a){var b=a.select("path."+q).empty()?a.append("path").attr("class",q):a.select("path."+q);b.style("display","none").attr("stroke-dasharray","5,5");var c=a.select("path."+r).empty()?a.append("path").attr("class",r):a.select("path."+r);c.style("display","none").attr("stroke-dasharray","5,5")}function i(a){return a.style("fill-opacity",.8),a.style("stroke-opacity",.8),a}function j(a,b){var c=a.attr("cx"),d=a.attr("cy");b.select("path."+q).style("display","").attr("d","M0 "+d+"L"+c+" "+d),b.select("path."+r).style("display","").attr("d","M"+c+" "+s.yAxisHeight()+"L"+c+" "+d)}function k(a){a.style("fill-opacity",1e-6).style("stroke-opacity",1e-6)}function l(a){a.select("path."+q).style("display","none"),a.select("path."+r).style("display","none")}var m,n=5,o="dc-tooltip",p="dot",q="yRef",r="xRef",s=a.stackableChart(a.coordinateGridChart({})),t=!1,u=n,v="linear",w=.7;return s.transitionDuration(500),s.plotData=function(){var a=s.chartBodyG(),b=a.selectAll("g.stack-list");b.empty()&&(b=a.append("g").attr("class","stack-list"));var c=b.selectAll("g.stack").data(s.stackLayers()),f=c.enter().append("g").attr("class",function(a,b){return"stack _"+b});d(f,c),e(f,c),g(a,c),s.stackLayers(null)},s.interpolate=function(a){return arguments.length?(v=a,s):v},s.tension=function(a){return arguments.length?(w=a,s):w},s.defined=function(a){return arguments.length?(m=a,s):m},s.renderArea=function(a){return arguments.length?(t=a,s):t},s.dotRadius=function(a){return arguments.length?(u=a,s):u},s.legendHighlight=function(a){s.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!0),s.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!0)},s.legendReset=function(a){s.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!1),s.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!1)},s.anchor(b,c)},a.dataCount=function(b,c){var d=d3.format(",d"),e=a.baseChart({});return e.doRender=function(){return e.selectAll(".total-count").text(d(e.dimension().size())),e.selectAll(".filter-count").text(d(e.group().value())),e},e.doRedraw=function(){return e.doRender()},e.anchor(b,c)},a.dataTable=function(b,c){function d(){var a=l.root().selectAll("tbody").data(e(),function(a){return l.keyAccessor()(a)}),b=a.enter().append("tbody");return b.append("tr").attr("class",k).append("td").attr("class",h).attr("colspan",n.length).html(function(a){return l.keyAccessor()(a)}),a.exit().remove(),b}function e(){g||(g=crossfilter.quicksort.by(o));var a=l.dimension().top(m);return d3.nest().key(l.group()).sortKeys(p).sortValues(p).entries(g(a,0,a.length))}function f(a){var b=a.order().selectAll("tr."+i).data(function(a){return a.values}),c=b.enter().append("tr").attr("class",i);return n.forEach(function(a,b){c.append("td").attr("class",j+" _"+b).html(a)}),b.exit().remove(),b}var g,h="dc-table-label",i="dc-table-row",j="dc-table-column",k="dc-table-group",l=a.baseChart({}),m=25,n=[],o=function(a){return a},p=d3.ascending;return l.doRender=function(){return l.selectAll("tbody").remove(),f(d()),l},l.doRedraw=function(){return l.doRender()},l.size=function(a){return arguments.length?(m=a,l):m},l.columns=function(a){return arguments.length?(n=a,l):n},l.sortBy=function(a){return arguments.length?(o=a,l):o},l.order=function(a){return arguments.length?(p=a,l):p},l.anchor(b,c)},a.bubbleChart=function(b,c){function d(b){var c=b.enter().append("g");c.attr("class",i.BUBBLE_NODE_CLASS).attr("transform",k).append("circle").attr("class",function(a,b){return i.BUBBLE_CLASS+" _"+b}).on("click",i.onClick).attr("fill",i.initBubbleColor).attr("r",0),a.transition(b,i.transitionDuration()).attr("r",function(a){return i.bubbleR(a)}).attr("opacity",function(a){return i.bubbleR(a)>0?1:0}),i.doRenderLabel(c),i.doRenderTitles(c)}function e(b){a.transition(b,i.transitionDuration()).attr("transform",k).selectAll("circle."+i.BUBBLE_CLASS).attr("fill",i.updateBubbleColor).attr("r",function(a){return i.bubbleR(a)}).attr("opacity",function(a){return i.bubbleR(a)>0?1:0}),i.doUpdateLabels(b),i.doUpdateTitles(b)}function f(a){a.exit().remove()}function g(a){var b=i.x()(i.keyAccessor()(a));return isNaN(b)&&(b=0),b}function h(a){var b=i.y()(i.valueAccessor()(a));return isNaN(b)&&(b=0),b}var i=a.abstractBubbleChart(a.coordinateGridChart({})),j=!1;i.transitionDuration(750);var k=function(a){return"translate("+g(a)+","+h(a)+")"};return i.elasticRadius=function(a){return arguments.length?(j=a,i):j},i.plotData=function(){j&&i.r().domain([i.rMin(),i.rMax()]),i.r().range([i.MIN_RADIUS,i.xAxisLength()*i.maxBubbleRelativeSize()]);var a=i.chartBodyG().selectAll("g."+i.BUBBLE_NODE_CLASS).data(i.data());d(a),e(a),f(a),i.fadeDeselectedArea()},i.renderBrush=function(){},i.redrawBrush=function(){i.fadeDeselectedArea()},i.anchor(b,c)},a.compositeChart=function(b,c){function d(a,b){a._generateG(j.g()),a.g().attr("class",i+" _"+b)}function e(){for(var a=[],b=0;b<k.length;++b)a.push(k[b].yAxisMin());return a}function f(){for(var a=[],b=0;b<k.length;++b)a.push(k[b].yAxisMax());return a}function g(){for(var a=[],b=0;b<k.length;++b)a.push(k[b].xAxisMin());return a}function h(){for(var a=[],b=0;b<k.length;++b)a.push(k[b].xAxisMax());return a}var i="sub",j=a.coordinateGridChart({}),k=[];return j.transitionDuration(500),j.group({}),a.override(j,"_generateG",function(){for(var a=this.__generateG(),b=0;b<k.length;++b){var c=k[b];d(c,b),void 0===c.dimension()&&c.dimension(j.dimension()),void 0===c.group()&&c.group(j.group()),c.chartGroup(j.chartGroup()),c.svg(j.svg()),c.xUnits(j.xUnits()),c.transitionDuration(j.transitionDuration()),c.brushOn(j.brushOn())}return a}),j.plotData=function(){for(var a=0;a<k.length;++a){var b=k[a];void 0===b.g()&&d(b,a),b.x(j.x()),b.y(j.y()),b.xAxis(j.xAxis()),b.yAxis(j.yAxis()),b.plotData(),b.activateRenderlets()}},j.fadeDeselectedArea=function(){for(var a=0;a<k.length;++a){var b=k[a];b.brush(j.brush()),b.fadeDeselectedArea()}},j.compose=function(a){k=a;for(var b=0;b<k.length;++b){var c=k[b];c.height(j.height()),c.width(j.width()),c.margins(j.margins())}return j},j.children=function(){return k},j.yAxisMin=function(){return d3.min(e())},j.yAxisMax=function(){return a.utils.add(d3.max(f()),j.yAxisPadding())},j.xAxisMin=function(){return a.utils.subtract(d3.min(g()),j.xAxisPadding())},j.xAxisMax=function(){return a.utils.add(d3.max(h()),j.xAxisPadding())},j.legendables=function(){var b=[];return k.forEach(function(c,d){var e=c.legendables();e.length>1?b.push.apply(b,e):b.push(a.utils.createLegendable(c,c.group(),d,c.valueAccessor()))}),b},j.legendHighlight=function(a){for(var b=0;b<k.length;++b){var c=k[b];c.legendHighlight(a)}},j.legendReset=function(a){for(var b=0;b<k.length;++b){var c=k[b];c.legendReset(a)}},j.anchor(b,c)},a.geoChoroplethChart=function(b,c){function d(a){var b=e();if(f(a)){var c=g(a);m(c,a,b),n(c,a,b)}}function e(){for(var a={},b=o.data(),c=0;c<b.length;++c)a[o.keyAccessor()(b[c])]=o.valueAccessor()(b[c]);return a}function f(a){return l(a).keyAccessor}function g(b){var c=o.svg().selectAll(h(b)).classed("selected",function(a){return i(b,a)}).classed("deselected",function(a){return j(b,a)}).attr("class",function(c){var d=l(b).name,e=a.utils.nameToId(l(b).keyAccessor(c)),f=d+" "+e;return i(b,c)&&(f+=" selected"),j(b,c)&&(f+=" deselected"),f});return c}function h(a){return"g.layer"+a+" g."+l(a).name}function i(a,b){return o.hasFilter()&&o.hasFilter(k(a,b))}function j(a,b){return o.hasFilter()&&!o.hasFilter(k(a,b))}function k(a,b){return l(a).keyAccessor(b)}function l(a){return r[a]}function m(b,c,d){var e=b.select("path").attr("fill",function(){var a=d3.select(this).attr("fill");return a?a:"none"}).on("click",function(a){return o.onClick(a,c)});a.transition(e,o.transitionDuration()).attr("fill",function(a,b){return o.getColor(d[l(c).keyAccessor(a)],b)})}function n(a,b,c){o.renderTitle()&&a.selectAll("title").text(function(a){var d=k(b,a),e=c[d];return o.title()({key:d,value:e})})}var o=a.colorChart(a.baseChart({}));o.colorAccessor(function(a){return a});var p,q=d3.geo.path(),r=[];return o.doRender=function(){o.resetSvg();for(var a=0;a<r.length;++a){var b=o.svg().append("g").attr("class","layer"+a),c=b.selectAll("g."+l(a).name).data(l(a).data).enter().append("g").attr("class",l(a).name);c.append("path").attr("fill","white").attr("d",q),c.append("title"),d(a)}p=!1},o.onClick=function(b,c){var d=l(c).keyAccessor(b);a.events.trigger(function(){o.filter(d),a.redrawAll(o.chartGroup())})},o.doRedraw=function(){for(var a=0;a<r.length;++a)d(a),p&&o.svg().selectAll("g."+l(a).name+" path").attr("d",q);p=!1},o.overlayGeoJson=function(a,b,c){for(var d=0;d<r.length;++d)if(r[d].name==b)return r[d].data=a,r[d].keyAccessor=c,o;return r.push({name:b,data:a,keyAccessor:c}),o},o.projection=function(a){return q.projection(a),p=!0,o},o.geoJsons=function(){return r},o.removeGeoJson=function(a){for(var b=[],c=0;c<r.length;++c){var d=r[c];d.name!=a&&b.push(d)}return r=b,o},o.anchor(b,c)},a.bubbleOverlay=function(b,c){function d(){return i=m.select("g."+j),i.empty()&&(i=m.svg().append("g").attr("class",j)),i}function e(){var b=f();n.forEach(function(c){var d=g(c,b),e=d.select("circle."+l);e.empty()&&(e=d.append("circle").attr("class",l).attr("r",0).attr("fill",m.initBubbleColor).on("click",m.onClick)),a.transition(e,m.transitionDuration()).attr("r",function(a){return m.bubbleR(a)}),m.doRenderLabel(d),m.doRenderTitles(d)})}function f(){var a={};return m.data().forEach(function(b){a[m.keyAccessor()(b)]=b}),a}function g(b,c){var d=k+" "+a.utils.nameToId(b.name),e=i.select("g."+a.utils.nameToId(b.name));return e.empty()&&(e=i.append("g").attr("class",d).attr("transform","translate("+b.x+","+b.y+")")),e.datum(c[b.name]),e}function h(){var b=f();n.forEach(function(c){var d=g(c,b),e=d.select("circle."+l);a.transition(e,m.transitionDuration()).attr("r",function(a){return m.bubbleR(a)}).attr("fill",m.updateBubbleColor),m.doUpdateLabels(d),m.doUpdateTitles(d)})}var i,j="bubble-overlay",k="node",l="bubble",m=a.abstractBubbleChart(a.baseChart({})),n=[];return m.transitionDuration(750),m.radiusValueAccessor(function(a){return a.value}),m.point=function(a,b,c){return n.push({name:a,x:b,y:c}),m},m.doRender=function(){return i=d(),m.r().range([m.MIN_RADIUS,m.width()*m.maxBubbleRelativeSize()]),e(),m.fadeDeselectedArea(),m},m.doRedraw=function(){return h(),m.fadeDeselectedArea(),m},m.debug=function(b){if(b){var c=m.select("g."+a.constants.DEBUG_GROUP_CLASS);c.empty()&&(c=m.svg().append("g").attr("class",a.constants.DEBUG_GROUP_CLASS));var d=c.append("text").attr("x",10).attr("y",20);c.append("rect").attr("width",m.width()).attr("height",m.height()).on("mousemove",function(){var a=d3.mouse(c.node()),b=a[0]+", "+a[1];d.text(b)})}else m.selectAll(".debug").remove();return m},m.anchor(b,c),m},a.rowChart=function(b,c){function d(){if(!q||r){var a=d3.extent(s,x.valueAccessor());a[0]>0&&(a[0]=0),q=d3.scale.linear().domain(a).range([0,x.effectiveWidth()]),y.scale(q)}}function e(){var b=p.select("g.axis");d(),b.empty()&&(b=p.append("g").attr("class","axis").attr("transform","translate(0, "+x.effectiveHeight()+")")),a.transition(b,x.transitionDuration()).call(y)}function f(){p.selectAll("g.tick").select("line.grid-line").remove(),p.selectAll("g.tick").append("line").attr("class","grid-line").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",function(){return-x.effectiveHeight()})}function g(){s=x._assembleCappedData(),e(),f();var a=p.selectAll("g."+w).data(s);h(a),i(a),j(a)}function h(a){var b=a.enter().append("g").attr("class",function(a,b){return w+" _"+b});b.append("rect").attr("width",0),l(b),m(a)}function i(a){a.exit().remove()}function j(b){var c=s.length,d=(x.effectiveHeight()-(c+1)*v)/c,e=b.attr("transform",function(a,b){return"translate(0,"+((b+1)*v+b*d)+")"}).select("rect").attr("height",d).attr("fill",x.getColor).on("click",n).classed("deselected",function(a){return x.hasFilter()?!x.isSelectedRow(a):!1}).classed("selected",function(a){return x.hasFilter()?x.isSelectedRow(a):!1});a.transition(e,x.transitionDuration()).attr("width",function(a){var b=q(0)==-1/0?q(1):q(0);return Math.abs(b-q(x.valueAccessor()(a)))}).attr("transform",o),k(b),m(b)}function k(a){x.renderTitle()&&(a.selectAll("title").remove(),a.append("title").text(function(a){return x.title()(a)}))}function l(a){x.renderLabel()&&a.append("text").on("click",n)}function m(b){if(x.renderLabel()){var c=b.select("text").attr("x",t).attr("y",u).on("click",n).attr("class",function(a,b){return w+" _"+b}).text(function(a){return x.label()(a)});a.transition(c,x.transitionDuration()).attr("transform",o)}}function n(a){x.onClick(a)}function o(a){var b=q(x.valueAccessor()(a)),c=q(0),d=b>c?c:b;return"translate("+d+",0)"}var p,q,r,s,t=10,u=15,v=5,w="row",x=a.capped(a.marginable(a.colorChart(a.baseChart({})))),y=d3.svg.axis().orient("bottom");return x.rowsCap=x.cap,x.doRender=function(){return x.resetSvg(),p=x.svg().append("g").attr("transform","translate("+x.margins().left+","+x.margins().top+")"),g(),x},x.title(function(a){return x.keyAccessor()(a)+": "+x.valueAccessor()(a)}),x.label(function(a){return x.keyAccessor()(a)}),x.x=function(a){return arguments.length?(q=a,x):q},x.doRedraw=function(){return g(),x},x.xAxis=function(){return y},x.gap=function(a){return arguments.length?(v=a,x):v},x.elasticX=function(a){return arguments.length?(r=a,x):r},x.labelOffsetX=function(a){return arguments.length?(t=a,x):t},x.labelOffsetY=function(a){return arguments.length?(u=a,x):u},x.isSelectedRow=function(a){return x.hasFilter(x.keyAccessor()(a))},x.anchor(b,c)},a.legend=function(){function a(){return i+h}var b,c,d=2,e={},f=0,g=0,h=12,i=5;return e.parent=function(a){return arguments.length?(b=a,e):b},e.render=function(){c=b.svg().append("g").attr("class","dc-legend").attr("transform","translate("+f+","+g+")");var e=c.selectAll("g.dc-legend-item").data(b.legendables()).enter().append("g").attr("class","dc-legend-item").attr("transform",function(b,c){return"translate(0,"+c*a()+")"}).on("mouseover",function(a){b.legendHighlight(a)}).on("mouseout",function(a){b.legendReset(a)});e.append("rect").attr("width",h).attr("height",h).attr("fill",function(a){return a.color}),e.append("text").text(function(a){return a.name}).attr("x",h+d).attr("y",function(){return h/2+(this.clientHeight?this.clientHeight:13)/2-2})},e.x=function(a){return arguments.length?(f=a,e):f},e.y=function(a){return arguments.length?(g=a,e):g},e.gap=function(a){return arguments.length?(i=a,e):i},e.itemHeight=function(a){return arguments.length?(h=a,e):h},e},a.capped=function(b){var c=1/0,d="Others",e=function(a){var c=d3.sum(a,b.valueAccessor()),e=b.data(),f=d3.sum(e,b.valueAccessor()),g=a.map(b.keyAccessor()),h=e.map(b.keyAccessor()),i=d3.set(g),j=h.filter(function(a){return!i.has(a)});f>c&&a.push({others:j,key:d,value:f-c})};return b._assembleCappedData=function(){if(1/0==c)return b.computeOrderedGroups();var a=b.group().top(c);return a=b.computeOrderedGroups(a),e&&e(a),a},b.cap=function(a){return arguments.length?(c=a,b):c},b.othersLabel=function(a){return arguments.length?(d=a,b):d},b.othersGrouper=function(a){return arguments.length?(e=a,b):e},a.override(b,"onClick",function(a){a.others&&a.others.forEach(function(a){b.filter(a)}),b._onClick(a)}),b},a.scatterPlot=function(b,c){var d=a.coordinateGridChart({});return d.plotData=function(){d.chartBodyG().selectAll("path.dc-symbol").data(d.data()).enter().append("path").attr("class","dc-symbol").attr("transform",function(a){return"translate("+d.x()(d.keyAccessor()(a))+","+d.y()(d.valueAccessor()(a))+")"}).attr("d",d3.svg.symbol())},d.anchor(b,c)},a.numberDisplay=function(b,c){var d="number-display",e=d3.format(".2s"),f=a.baseChart({});return f._mandatoryAttributes(["group"]),f.value=function(){return f.data()},f.data(function(){var a=f.group().all&&f.group().all()[0]||f.group().value();return f.valueAccessor()(a)}),f.transitionDuration(250),f.doRender=function(){var a=f.value(),b=f.selectAll("."+d);return b.empty()&&(b=b.data([0]).enter().append("span").attr("class",d)),b.transition().duration(f.transitionDuration()).ease("quad-out-in").tween("text",function(){var b=d3.interpolateNumber(this.lastValue||0,a);return this.lastValue=a,function(a){this.textContent=f.formatNumber()(b(a))}}),f},f.doRedraw=function(){return f.doRender()},f.formatNumber=function(a){return arguments.length?(e=a,f):e},f.anchor(b,c)},a.heatMap=function(b,c){function d(a,b,c){return!b||c[b-1]!=a}var e,f,g,h,i=function(a,b){return b},j=d3.scale.quantize().range(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),k=a.coordinateGridChart({});return k._mandatoryAttributes(["group"]),k.title(i),k.rows=function(a){if(arguments.length)return g=a,k;if(g)return g;var b=k.data().map(k.valueAccessor());return b.sort(d3.ascending),d3.scale.ordinal().domain(b.filter(d))},k.cols=function(a){if(arguments.length)return f=a,k;if(f)return f;var b=k.data().map(k.keyAccessor());return b.sort(d3.ascending),d3.scale.ordinal().domain(b.filter(d))},k.fill=function(a){return arguments.length?(h=a,k):h?h:j.domain(d3.extent(k.data(),i))},k.fillAccessor=function(a){return arguments.length?(i=a,k):i},k.doRender=function(){return k.resetSvg(),e=k.svg().append("g").attr("class","heatmap").attr("transform","translate("+k.margins().left+","+k.margins().top+")"),k.doRedraw()},k.doRedraw=function(){var b=k.rows(),c=k.cols(),d=k.fill(),f=b.domain().length,g=c.domain().length,h=Math.floor(k.effectiveWidth()/g),j=Math.floor(k.effectiveHeight()/f);c.rangeRoundBands([0,k.effectiveWidth()]),b.rangeRoundBands([k.effectiveHeight(),0]);var l=e.selectAll("g.box-group").data(k.data(),function(a,b){return k.keyAccessor()(a,b)+"\x00"+k.valueAccessor()(a,b)}),m=l.enter().append("g").attr("class","box-group");m.append("rect").attr("fill","white"),m.append("title").text(function(a){return k.title()(a)}),a.transition(l.select("rect"),k.transitionDuration()).attr("class","heat-box").attr("x",function(a,b){return c(k.keyAccessor()(a,b))}).attr("y",function(a,c){return b(k.valueAccessor()(a,c))}).attr("rx",.15*h).attr("ry",.15*j).attr("fill",function(a,b){return d(i(a,b))}).attr("width",h).attr("height",j),l.exit().remove();var n=e.selectAll("g.cols");n.empty()&&(n=e.append("g").attr("class","cols axis")),n.selectAll("text").data(c.domain()).enter().append("text").attr("x",function(a){return c(a)+h/2}).style("text-anchor","middle").attr("y",k.effectiveHeight()).attr("dy",12).text(function(a){return a});var o=e.selectAll("g.rows");o.empty()&&(o=e.append("g").attr("class","rows axis")),o.selectAll("text").data(b.domain()).enter().append("text").attr("y",function(a){return b(a)+j/2}).attr("dy",6).style("text-anchor","end").attr("x",0).attr("dx",-2).text(function(a){return a})},k.anchor(b,c)},function(){function a(a){return[0,a.length-1]}function b(a){return[d3.quantile(a,.25),d3.quantile(a,.5),d3.quantile(a,.75)]}d3.box=function(){function c(a){a.each(function(a,b){a=a.map(h).sort(d3.ascending);var c=d3.select(this),l=a.length,m=a[0],n=a[l-1],o=a.quartiles=j(a),p=i&&i.call(this,a,b),q=p&&p.map(function(b){return a[b]}),r=p?d3.range(0,p[0]).concat(d3.range(p[1]+1,l)):d3.range(l),s=d3.scale.linear().domain(g&&g.call(this,a,b)||[m,n]).range([e,0]),t=this.__chart__||d3.scale.linear().domain([0,1/0]).range(s.range());this.__chart__=s;var u=c.selectAll("line.center").data(q?[q]:[]);u.enter().insert("line","rect").attr("class","center").attr("x1",d/2).attr("y1",function(a){return t(a[0])}).attr("x2",d/2).attr("y2",function(a){return t(a[1])}).style("opacity",1e-6).transition().duration(f).style("opacity",1).attr("y1",function(a){return s(a[0])}).attr("y2",function(a){return s(a[1])}),u.transition().duration(f).style("opacity",1).attr("y1",function(a){return s(a[0])}).attr("y2",function(a){return s(a[1])}),u.exit().transition().duration(f).style("opacity",1e-6).attr("y1",function(a){return s(a[0])}).attr("y2",function(a){return s(a[1])}).remove();var v=c.selectAll("rect.box").data([o]);v.enter().append("rect").attr("class","box").attr("x",0).attr("y",function(a){return t(a[2])}).attr("width",d).attr("height",function(a){return t(a[0])-t(a[2])}).transition().duration(f).attr("y",function(a){return s(a[2])}).attr("height",function(a){return s(a[0])-s(a[2])}),v.transition().duration(f).attr("y",function(a){return s(a[2])}).attr("height",function(a){return s(a[0])-s(a[2])});var w=c.selectAll("line.median").data([o[1]]);w.enter().append("line").attr("class","median").attr("x1",0).attr("y1",t).attr("x2",d).attr("y2",t).transition().duration(f).attr("y1",s).attr("y2",s),w.transition().duration(f).attr("y1",s).attr("y2",s);var x=c.selectAll("line.whisker").data(q||[]);x.enter().insert("line","circle, text").attr("class","whisker").attr("x1",0).attr("y1",t).attr("x2",d).attr("y2",t).style("opacity",1e-6).transition().duration(f).attr("y1",s).attr("y2",s).style("opacity",1),x.transition().duration(f).attr("y1",s).attr("y2",s).style("opacity",1),x.exit().transition().duration(f).attr("y1",s).attr("y2",s).style("opacity",1e-6).remove();var y=c.selectAll("circle.outlier").data(r,Number);y.enter().insert("circle","text").attr("class","outlier").attr("r",5).attr("cx",d/2).attr("cy",function(b){return t(a[b])}).style("opacity",1e-6).transition().duration(f).attr("cy",function(b){return s(a[b])}).style("opacity",1),y.transition().duration(f).attr("cy",function(b){return s(a[b])}).style("opacity",1),y.exit().transition().duration(f).attr("cy",function(b){return s(a[b])}).style("opacity",1e-6).remove();var z=k||s.tickFormat(8),A=c.selectAll("text.box").data(o);A.enter().append("text").attr("class","box").attr("dy",".3em").attr("dx",function(a,b){return 1&b?6:-6}).attr("x",function(a,b){return 1&b?d:0}).attr("y",t).attr("text-anchor",function(a,b){return 1&b?"start":"end"}).text(z).transition().duration(f).attr("y",s),A.transition().duration(f).text(z).attr("y",s);var B=c.selectAll("text.whisker").data(q||[]);B.enter().append("text").attr("class","whisker").attr("dy",".3em").attr("dx",6).attr("x",d).attr("y",t).text(z).style("opacity",1e-6).transition().duration(f).attr("y",s).style("opacity",1),B.transition().duration(f).text(z).attr("y",s).style("opacity",1),B.exit().transition().duration(f).attr("y",s).style("opacity",1e-6).remove()}),d3.timer.flush()}var d=1,e=1,f=0,g=null,h=Number,i=a,j=b,k=null;return c.width=function(a){return arguments.length?(d=a,c):d},c.height=function(a){return arguments.length?(e=a,c):e},c.tickFormat=function(a){return arguments.length?(k=a,c):k},c.duration=function(a){return arguments.length?(f=a,c):f},c.domain=function(a){return arguments.length?(g=null==a?a:d3.functor(a),c):g},c.value=function(a){return arguments.length?(h=a,c):h},c.whiskers=function(a){return arguments.length?(i=a,c):i},c.quartiles=function(a){return arguments.length?(j=a,c):j},c}}(),a.boxPlot=function(b,c){function d(){return g.group().all().map(function(a){return a.map=function(){return g.valueAccessor()(a)},a})}function e(a){return function(b){for(var c=b.quartiles[0],d=b.quartiles[2],e=(d-c)*a,f=-1,g=b.length;b[++f]<c-e;);for(;b[--g]>d+e;);return[f,g]}}var f,g=a.coordinateGridChart({}),h=1.5,i=e,j=i(h),k=d3.box();return g.yAxisPadding(12),g.plotData=function(){f=.2*g.effectiveWidth()/(g.xUnitCount()+1),k.whiskers(j).width(f).height(g.effectiveHeight()).domain(g.y().domain());var a=Array.prototype.slice.call(g.x().domain(),0);g.chartBodyG().selectAll("g.box").data(d()).enter().append("g").attr("class","box").attr("transform",function(a,b){return"translate("+(g.x()(b)-f/2)+",0)"}).call(k),g.x().domain(a)},g.yAxisMin=function(){var b=d3.min(g.group().all(),function(a){return d3.min(g.valueAccessor()(a))});return b=a.utils.subtract(b,g.yAxisPadding())},g.yAxisMax=function(){var b=d3.max(g.group().all(),function(a){return d3.max(g.valueAccessor()(a))});return b=a.utils.add(b,g.yAxisPadding())},g.anchor(b,c)},a}();
//# sourceMappingURL=dc.min.js.map