forked from dc-js/dc.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc.min.js
2 lines (2 loc) · 47.5 KB
/
dc.min.js
1
2
dc={version:"1.5.0",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},dc.chartRegistry=function(){function a(a){return a||(a=dc.constants.DEFAULT_CHART_GROUP),b[a]||(b[a]=[]),a}var b={};return this.has=function(a){for(var c in b)if(b[c].indexOf(a)>=0)return!0;return!1},this.register=function(c,d){d=a(d),b[d].push(c)},this.clear=function(){b={}},this.list=function(c){return c=a(c),b[c]},this}(),dc.registerChart=function(a,b){dc.chartRegistry.register(a,b)},dc.hasChart=function(a){return dc.chartRegistry.has(a)},dc.deregisterAllCharts=function(){dc.chartRegistry.clear()},dc.filterAll=function(a){for(var b=dc.chartRegistry.list(a),c=0;c<b.length;++c)b[c].filterAll()},dc.renderAll=function(a){for(var b=dc.chartRegistry.list(a),c=0;c<b.length;++c)b[c].render();null!==dc._renderlet&&dc._renderlet(a)},dc.redrawAll=function(a){for(var b=dc.chartRegistry.list(a),c=0;c<b.length;++c)b[c].redraw();null!==dc._renderlet&&dc._renderlet(a)},dc.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},dc.units={},dc.units.integers=function(a,b){return Math.abs(b-a)},dc.units.ordinal=function(a,b,c){return c},dc.units.fp={},dc.units.fp.precision=function(a){var b=function(a,c){return Math.ceil(Math.abs((c-a)/b.resolution))};return b.resolution=a,b},dc.round={},dc.round.floor=function(a){return Math.floor(a)},dc.round.ceil=function(a){return Math.ceil(a)},dc.round.round=function(a){return Math.round(a)},dc.override=function(a,b,c){var d=a[b];a["_"+b]=d,a[b]=c},dc.renderlet=function(a){return arguments.length?(dc._renderlet=a,dc):dc._renderlet},dc.instanceOfChart=function(a){return a instanceof Object&&a.__dc_flag__},dc.errors={},dc.errors.Exception=function(a){var b=void 0!==a?a:"Unexpected internal error";this.message=b,this.toString=function(){return b}},dc.errors.InvalidStateException=function(){dc.errors.Exception.apply(this,arguments)},dc.dateFormat=d3.time.format("%m/%d/%Y"),dc.printers={},dc.printers.filters=function(a){for(var b="",c=0;c<a.length;++c)c>0&&(b+=", "),b+=dc.printers.filter(a[c]);return b},dc.printers.filter=function(a){var b="";return a&&(a instanceof Array?a.length>=2?b="["+dc.utils.printSingleValue(a[0])+" -> "+dc.utils.printSingleValue(a[1])+"]":a.length>=1&&(b=dc.utils.printSingleValue(a[0])):b=dc.utils.printSingleValue(a)),b},dc.utils={},dc.utils.printSingleValue=function(a){var b=""+a;return a instanceof Date?b=dc.dateFormat(a):"string"==typeof a?b=a:"number"==typeof a&&(b=Math.round(a)),b},dc.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},dc.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},dc.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.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}},dc.utils.isNegligible=function(a){return void 0===a||a<dc.constants.NEGLIGIBLE_NUMBER&&a>-dc.constants.NEGLIGIBLE_NUMBER},dc.utils.groupMax=function(a,b){var c=d3.max(a.all(),function(a){return b(a)});return dc.utils.isNegligible(c)&&(c=0),c},dc.utils.groupMin=function(a,b){var c=d3.min(a.all(),function(a){return b(a)});return dc.utils.isNegligible(c)&&(c=0),c},dc.utils.nameToId=function(a){return a.toLowerCase().replace(/[\s]/g,"_").replace(/[\.']/g,"")},dc.utils.appendOrSelect=function(a,b){var c=a.select(b);return c.empty()&&(c=a.append(b)),c},dc.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},dc.utils.safeNumber=function(a){return isNaN(a)?0:a},dc.events={current:null},dc.events.trigger=function(a,b){return b?(dc.events.current=a,setTimeout(function(){a==dc.events.current&&a()},b),void 0):(a(),void 0)},dc.cumulative={},dc.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]}},dc.cumulative.Sum=function(){dc.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}},dc.cumulative.Sum.prototype=new dc.cumulative.Base,dc.cumulative.CountUnique=function(){function a(a){var b,c=0;for(b in a)a.hasOwnProperty(b)&&c++;return c}dc.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(b){return a(this.getValueByKey(b))},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}},dc.cumulative.CountUnique.prototype=new dc.cumulative.Base,dc.baseChart=function(a){function b(b){var c="default";return b?b==a.valueAccessor()?c:b:c}function c(b){B.splice(B.indexOf(b),1),f(),a.invokeFilteredListener(a,b)}function d(b){B.push(b),f(),a.invokeFilteredListener(a,b)}function e(){B=[],f(),a.invokeFilteredListener(a,null)}function f(){if(a.dataSet()&&void 0!==a.dimension().filter){var b=C(a.dimension(),B);B=b?b:B}}function g(){for(var b=0;b<x.length;++b)x[b](a)}a.__dc_flag__=!0;var h,i,j,k,l,m,n=200,o=200,p=function(a){return a.key},q=function(a){return a.value},r=function(a){return a.key},s=!1,t=function(a){return a.key+": "+a.value},u=!1,v=750,w=dc.printers.filters,x=[],y=dc.constants.DEFAULT_CHART_GROUP,z=function(){},A={preRender:z,postRender:z,preRedraw:z,postRedraw:z,filtered:z,zoomed:z},B=[],C=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};return a.width=function(b){return arguments.length?(n=b,a):n},a.height=function(b){return arguments.length?(o=b,a):o},a.dimension=function(b){return arguments.length?(h=b,a.expireCache(),a):h},a.group=function(b,c){return arguments.length?(i=b,a.expireCache(),"string"==typeof c&&a.setGroupName(i,c),a):i},a.setGroupName=function(a,c,d){a.__names__||(a.__names__={}),a.__names__[b(d)]=c},a.getGroupName=function(a,c){return a.__names__||(a.__names__={}),a.__names__[b(c)]},a.orderedGroup=function(){return i.order(function(a){return a.key})},a.filterAll=function(){return a.filter(null)},a.dataSet=function(){return void 0!==h&&void 0!==i},a.select=function(a){return k.select(a)},a.selectAll=function(a){return k?k.selectAll(a):null},a.anchor=function(b,c){return arguments.length?(dc.instanceOfChart(b)?(j=b.anchor(),k=b.root()):(j=b,k=d3.select(j),k.classed(dc.constants.CHART_CLASS,!0),dc.registerChart(a,c)),y=c,a):j},a.root=function(b){return arguments.length?(k=b,a):k},a.svg=function(b){return arguments.length?(l=b,a):l},a.resetSvg=function(){return a.select("svg").remove(),a.generateSvg()},a.generateSvg=function(){return l=a.root().append("svg").attr("width",a.width()).attr("height",a.height())},a.filterPrinter=function(b){return arguments.length?(w=b,a):w},a.turnOnControls=function(){return k&&(a.selectAll(".reset").style("display",null),a.selectAll(".filter").text(w(a.filters())).style("display",null)),a},a.turnOffControls=function(){return k&&(a.selectAll(".reset").style("display","none"),a.selectAll(".filter").style("display","none").text(a.filter())),a},a.transitionDuration=function(b){return arguments.length?(v=b,a):v},a.render=function(){if(A.preRender(a),void 0===h)throw new dc.errors.InvalidStateException("Mandatory attribute chart.dimension is missing on chart["+a.anchor()+"]");if(void 0===i)throw new dc.errors.InvalidStateException("Mandatory attribute chart.group is missing on chart["+a.anchor()+"]");var b=a.doRender();return m&&m.render(),a.activateRenderlets("postRender"),b},a.activateRenderlets=function(b){a.transitionDuration()>0&&l?l.transition().duration(a.transitionDuration()).each("end",function(){g(),b&&A[b](a)}):(g(),b&&A[b](a))},a.redraw=function(){A.preRedraw(a);var b=a.doRedraw();return a.activateRenderlets("postRedraw"),b},a.invokeFilteredListener=function(b,c){void 0!==c&&A.filtered(a,c)},a.invokeZoomedListener=function(){A.zoomed(a)},a.hasFilter=function(a){return arguments.length?B.indexOf(a)>=0:B.length>0},a.filter=function(b){return arguments.length?(null===b?e():a.hasFilter(b)?c(b):d(b),null!==k&&a.hasFilter()?a.turnOnControls():a.turnOffControls(),a):B.length>0?B[0]:null},a.filters=function(){return B},a.highlightSelected=function(a){d3.select(a).classed(dc.constants.SELECTED_CLASS,!0),d3.select(a).classed(dc.constants.DESELECTED_CLASS,!1)},a.fadeDeselected=function(a){d3.select(a).classed(dc.constants.SELECTED_CLASS,!1),d3.select(a).classed(dc.constants.DESELECTED_CLASS,!0)},a.resetHighlight=function(a){d3.select(a).classed(dc.constants.SELECTED_CLASS,!1),d3.select(a).classed(dc.constants.DESELECTED_CLASS,!1)},a.onClick=function(b){var c=a.keyAccessor()(b);dc.events.trigger(function(){a.filter(c),dc.redrawAll(a.chartGroup())})},a.filterHandler=function(b){return arguments.length?(C=b,a):C},a.doRender=function(){return a},a.doRedraw=function(){return a},a.legendables=function(){return[]},a.legendHighlight=function(){},a.legendReset=function(){},a.keyAccessor=function(b){return arguments.length?(p=b,a):p},a.valueAccessor=function(b){return arguments.length?(q=b,a):q},a.label=function(b){return arguments.length?(r=b,s=!0,a):r},a.renderLabel=function(b){return arguments.length?(s=b,a):s},a.title=function(b){return arguments.length?(t=b,u=!0,a):t},a.renderTitle=function(b){return arguments.length?(u=b,a):u},a.renderlet=function(b){return x.push(b),a},a.chartGroup=function(b){return arguments.length?(y=b,a):y},a.on=function(b,c){return A[b]=c,a},a.expireCache=function(){return a},a.legend=function(b){return arguments.length?(m=b,m.parent(a),a):m},a},dc.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},dc.coordinateGridChart=function(a){function b(b){a.elasticX()&&!a.isOrdinal()&&u.domain([a.xAxisMin(),a.xAxisMax()]),a.isOrdinal()?a.prepareOrdinalXAxis():u.range([0,a.xAxisLength()]),B=B.scale(a.x()).orient("bottom"),c(b)}function c(b){var c=b.selectAll("g."+q);if(L){c.empty()&&(c=b.insert("g",":first-child").attr("class",o+" "+q).attr("transform","translate("+a.yAxisX()+","+a.margins().top+")"));var d=B.tickValues()?B.tickValues():u.ticks(B.ticks()[0]),e=c.selectAll("line").data(d),f=e.enter().append("line").attr("x1",function(a){return u(a)}).attr("y1",a.xAxisY()-a.margins().top).attr("x2",function(a){return u(a)}).attr("y2",0).attr("opacity",0);dc.transition(f,a.transitionDuration()).attr("opacity",1),dc.transition(e,a.transitionDuration()).attr("x1",function(a){return u(a)}).attr("y1",a.xAxisY()-a.margins().top).attr("x2",function(a){return u(a)}).attr("y2",0),e.exit().remove()}else c.selectAll("line").remove()}function d(b){(void 0===w||a.elasticY())&&(w=d3.scale.linear(),w.domain([a.yAxisMin(),a.yAxisMax()]).rangeRound([a.yAxisHeight(),0])),w.range([a.yAxisHeight(),0]),F=F.scale(w).orient("left"),e(b)}function e(b){var c=b.selectAll("g."+p);if(K){var d=F.tickValues()?F.tickValues():w.ticks(F.ticks()[0]);c.empty()&&(c=b.insert("g",":first-child").attr("class",o+" "+p).attr("transform","translate("+a.yAxisX()+","+a.margins().top+")"));var e=c.selectAll("line").data(d),f=e.enter().append("line").attr("x1",1).attr("y1",function(a){return w(a)}).attr("x2",a.xAxisLength()).attr("y2",function(a){return w(a)}).attr("opacity",0);dc.transition(f,a.transitionDuration()).attr("opacity",1),dc.transition(e,a.transitionDuration()).attr("x1",1).attr("y1",function(a){return w(a)}).attr("x2",a.xAxisLength()).attr("y2",function(a){return w(a)}),e.exit().remove()}else c.selectAll("line").remove()}function f(){return a.xAxisY()-a.margins().top}function g(){}function h(){var b=a.extendBrush();a.redrawBrush(s),a.brushIsEmpty(b)?dc.events.trigger(function(){a.filter(null),dc.redrawAll(a.chartGroup())}):dc.events.trigger(function(){a.filter(null),a.filter([b[0],b[1]]),dc.redrawAll(a.chartGroup())},dc.constants.EVENT_DELAY)}function i(){}function j(){return a.anchor().replace("#","")+"-clip"}function k(){var b=dc.utils.appendOrSelect(r,"defs"),c=dc.utils.appendOrSelect(b,"clipPath").attr("id",j()),d=2*O;dc.utils.appendOrSelect(c,"rect").attr("width",a.xAxisLength()+d).attr("height",a.yAxisHeight()+d)}function l(){N&&a.root().call(d3.behavior.zoom().x(a.x()).scaleExtent([1,100]).on("zoom",function(){a.focus(a.x().domain()),a.invokeZoomedListener(a),m()}))}function m(){if(z){var b=a.x().domain(),c=z.xOriginalDomain(),d=[b[0]<c[0]?b[0]:c[0],b[1]>c[1]?b[1]:c[1]];z.focus(d),z.filter(null),z.filter(b),dc.events.trigger(function(){dc.redrawAll(a.chartGroup())})}}function n(a){return a instanceof Array&&a.length>1}var o="grid-line",p="horizontal",q="vertical";a=dc.colorChart(dc.marginable(dc.baseChart(a))),a.colors(d3.scale.category10());var r,s,t,u,v,w,x,y,z,A,B=d3.svg.axis(),C=dc.units.integers,D=0,E=!1,F=d3.svg.axis(),G=0,H=!1,I=d3.svg.brush(),J=!0,K=!1,L=!1,M=!1,N=!1,O=0;return a.title(function(a){return a.data.key+": "+a.data.value}),a.rescale=function(){y=void 0,a.xUnitCount()},a.rangeChart=function(b){return arguments.length?(z=b,z.focusChart(a),a):z},a.generateG=function(b){return r=void 0===b?a.svg():b,s=r.append("g"),t=s.append("g").attr("class","chart-body").attr("transform","translate("+a.margins().left+", "+a.margins().top+")").attr("clip-path","url(#"+j()+")"),s},a.g=function(b){return arguments.length?(s=b,a):s},a.mouseZoomable=function(b){return arguments.length?(N=b,a):N},a.chartBodyG=function(b){return arguments.length?(t=b,a):t},a.x=function(b){return arguments.length?(u=b,v=u.domain(),a):u},a.xOriginalDomain=function(){return v},a.xUnits=function(b){return arguments.length?(C=b,a):C},a.xAxis=function(b){return arguments.length?(B=b,a):B},a.elasticX=function(b){return arguments.length?(E=b,a):E},a.xAxisPadding=function(b){return arguments.length?(D=b,a):D},a.xUnitCount=function(){if(void 0===y){var b=a.xUnits()(a.x().domain()[0],a.x().domain()[1],a.x().domain());y=b instanceof Array?b.length:b}return y},a.isOrdinal=function(){return a.xUnits()===dc.units.ordinal},a.prepareOrdinalXAxis=function(b){b||(b=a.xUnitCount());for(var c=[],d=0,e=a.xAxisLength()/b,f=0;b>f;f++)c[f]=d,d+=e;u.range(c)},a.renderXAxis=function(b){var c=b.selectAll("g.x");c.empty()&&(c=b.append("g").attr("class","axis x").attr("transform","translate("+a.margins().left+","+a.xAxisY()+")")),dc.transition(c,a.transitionDuration()).call(B)},a.xAxisY=function(){return a.height()-a.margins().bottom},a.xAxisLength=function(){return a.effectiveWidth()},a.renderYAxis=function(b){var c=b.selectAll("g.y");c.empty()&&(c=b.append("g").attr("class","axis y").attr("transform","translate("+a.yAxisX()+","+a.margins().top+")")),dc.transition(c,a.transitionDuration()).call(F)},a.yAxisX=function(){return a.margins().left},a.y=function(b){return arguments.length?(w=b,a):w},a.yAxis=function(b){return arguments.length?(F=b,a):F},a.elasticY=function(b){return arguments.length?(H=b,a):H},a.renderHorizontalGridLines=function(b){return arguments.length?(K=b,a):K},a.renderVerticalGridLines=function(b){return arguments.length?(L=b,a):L},a.xAxisMin=function(){var b=d3.min(a.group().all(),function(b){return a.keyAccessor()(b)});return dc.utils.subtract(b,D)},a.xAxisMax=function(){var b=d3.max(a.group().all(),function(b){return a.keyAccessor()(b)});return dc.utils.add(b,D)},a.yAxisMin=function(){var b=d3.min(a.group().all(),function(b){return a.valueAccessor()(b)});return b=dc.utils.subtract(b,G)},a.yAxisMax=function(){var b=d3.max(a.group().all(),function(b){return a.valueAccessor()(b)});return b=dc.utils.add(b,G)},a.yAxisPadding=function(b){return arguments.length?(G=b,a):G},a.yAxisHeight=function(){return a.effectiveHeight()},a.round=function(b){return arguments.length?(x=b,a):x},dc.override(a,"filter",function(b){return arguments.length?(a._filter(b),b?a.brush().extent(b):a.brush().clear(),a):a._filter()}),a.brush=function(b){return arguments.length?(I=b,a):I},a.renderBrush=function(b){if(a.isOrdinal()&&(J=!1),J){I.on("brushstart",g).on("brush",h).on("brushend",i);var c=b.append("g").attr("class","brush").attr("transform","translate("+a.margins().left+","+a.margins().top+")").call(I.x(a.x()));c.selectAll("rect").attr("height",f()),c.selectAll(".resize").append("path").attr("d",a.resizeHandlePath),a.hasFilter()&&a.redrawBrush(b)}},a.extendBrush=function(){var b=I.extent();return a.round()&&(b[0]=b.map(a.round())[0],b[1]=b.map(a.round())[1],s.select(".brush").call(I.extent(b))),b},a.brushIsEmpty=function(a){return I.empty()||!a||a[1]<=a[0]},a.redrawBrush=function(b){if(J){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",f())}a.fadeDeselectedArea()},a.fadeDeselectedArea=function(){},a.resizeHandlePath=function(a){var b=+("e"==a),c=b?1:-1,d=f()/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)},a.clipPadding=function(b){return arguments.length?(O=b,a):O},a.doRender=function(){if(void 0===u)throw new dc.errors.InvalidStateException("Mandatory attribute chart.x is missing on chart["+a.anchor()+"]");return a.resetSvg(),a.dataSet()&&(a.generateG(),k(),b(a.g()),d(a.g()),a.plotData(),a.renderXAxis(a.g()),a.renderYAxis(a.g()),a.renderBrush(a.g()),l()),a},a.doRedraw=function(){return b(a.g()),d(a.g()),a.plotData(),a.elasticY()&&a.renderYAxis(a.g()),(a.elasticX()||M)&&a.renderXAxis(a.g()),a.redrawBrush(a.g()),a},a.subRender=function(){return a.dataSet()&&a.plotData(),a},a.brushOn=function(b){return arguments.length?(J=b,a):J},a.getDataWithinXDomain=function(b){var c=[];return a.isOrdinal()?c=b.all():b.all().forEach(function(b){var d=a.keyAccessor()(b);d>=a.x().domain()[0]&&d<=a.x().domain()[1]&&c.push(b)}),c},a.focus=function(b){M=!0,n(b)?a.x().domain(b):a.x().domain(a.xOriginalDomain()),a.rescale(),a.redraw(),n(b)||(M=!1)},a.refocused=function(){return M},a.focusChart=function(b){return arguments.length?(A=b,a.on("filtered",function(a){dc.events.trigger(function(){A.focus(a.filter()),A.filter(a.filter()),dc.redrawAll(a.chartGroup())})}),a):A},a},dc.colorChart=function(a){var b=d3.scale.category20c(),c=[0,b.range().length],d=function(d){var e=c[0],f=c[1];if(isNaN(d)&&(d=0),null===f)return b(d);var g=a.colors().range().length,h=(f-e)/g,i=Math.abs(Math.min(g-1,Math.round((d-e)/h)));return a.colors()(i)},e=function(a,b){return b};return a.colors=function(d){if(!arguments.length)return b;if(d instanceof Array){b=d3.scale.ordinal().range(d);for(var e=[],f=0;f<d.length;++f)e.push(f);b.domain(e)}else b=d;return c=[0,b.range().length],a},a.colorCalculator=function(b){return arguments.length?(d=b,a):d},a.getColor=function(a,b){return d(e(a,b))},a.colorAccessor=function(b){return arguments.length?(e=b,a):e},a.colorDomain=function(b){return arguments.length?(c=b,a):c},a},dc.stackableChart=function(a){function b(){var b=[];if(a.x()){var c=a.x().domain();a.stackLayers().forEach(function(a){a.points.forEach(function(a){a.x>=c[0]&&a.x<=c[1]&&b.push(a)})})}else a.stackLayers().forEach(function(a){b=b.concat(a.points)});return b}function c(b,c){return a.getKeyAccessorByIndex(b)(c)}function d(b,c){return a.getValueAccessorByIndex(b)(c)}function e(a,b){for(var e=0;e<a.length;++e){var f=a[e],g=c(b,f),h=d(b,f);j.setDataPoint(b,e,{data:f,x:g,y:h})}}var f,g,h,i,j=new dc.utils.GroupStack,k=d3.layout.stack().offset("zero").order("default").values(function(a){return a.points});return a.stack=function(b,c,d){return"string"==typeof c?a.setGroupName(b,c,d):"function"==typeof c&&(d=c),j.setDefaultAccessor(a.valueAccessor()),j.addGroup(b,d),a.expireCache(),a},a.expireCache=function(){return f=null,g=null,h=null,i=null,a},a.allGroups=function(){if(null===f){f=[],f.push(a.group());for(var b=0;b<j.size();++b)f.push(j.getGroupByIndex(b))}return f},a.allValueAccessors=function(){if(null===g){g=[],g.push(a.valueAccessor());for(var b=0;b<j.size();++b)g.push(j.getAccessorByIndex(b))}return g},a.getValueAccessorByIndex=function(b){return a.allValueAccessors()[b]},a.yAxisMin=function(){var c,d=b();return c=d3.min(d,function(a){return a.y+a.y0<a.y0?a.y+a.y0:a.y0}),c=dc.utils.subtract(c,a.yAxisPadding())},a.yAxisMax=function(){var c,d=b();return c=d3.max(d,function(a){return a.y+a.y0}),c=dc.utils.add(c,a.yAxisPadding())},a.allKeyAccessors=function(){if(null===h){h=[],h.push(a.keyAccessor());for(var b=0;b<j.size();++b)h.push(a.keyAccessor())}return h},a.getKeyAccessorByIndex=function(b){return a.allKeyAccessors()[b]},a.xAxisMin=function(){for(var b=null,c=a.allGroups(),d=0;d<c.length;++d){var e=c[d],f=dc.utils.groupMin(e,a.getKeyAccessorByIndex(d));(null===b||b>f)&&(b=f)}return dc.utils.subtract(b,a.xAxisPadding())},a.xAxisMax=function(){for(var b=null,c=a.allGroups(),d=0;d<c.length;++d){var e=c[d],f=dc.utils.groupMax(e,a.getKeyAccessorByIndex(d));(null===b||f>b)&&(b=f)}return dc.utils.add(b,a.xAxisPadding())},a.calculateDataPointMatrixForAll=function(){for(var b=a.allGroups(),c=0;c<b.length;++c){var d=b[c],f=d.all();e(f,c)}},a.getChartStack=function(){return j},dc.override(a,"valueAccessor",function(b){return arguments.length?(a.expireCache(),a._valueAccessor(b)):a._valueAccessor()}),dc.override(a,"keyAccessor",function(b){return arguments.length?(a.expireCache(),a._keyAccessor(b)):a._keyAccessor()}),a.stackLayout=function(b){return arguments.length?(k=b,a):k},a.stackLayers=function(b){return arguments.length?(i=b,void 0):(null===i&&(a.calculateDataPointMatrixForAll(),i=a.stackLayout()(j.toLayers())),i)},a.legendables=function(){var b=[];return f.forEach(function(c,d){b.push(dc.utils.createLegendable(a,c,d,a.getValueAccessorByIndex(d)))}),b},a},dc.abstractBubbleChart=function(a){var b=.3,c=10;a.BUBBLE_NODE_CLASS="node",a.BUBBLE_CLASS="bubble",a.MIN_RADIUS=10,a=dc.colorChart(a),a.renderLabel(!0),a.renderTitle(!1);var d=d3.scale.linear().domain([0,100]),e=function(a){return a.r};a.r=function(b){return arguments.length?(d=b,a):d},a.radiusValueAccessor=function(b){return arguments.length?(e=b,a):e},a.rMin=function(){var b=d3.min(a.group().all(),function(b){return a.radiusValueAccessor()(b)});return b},a.rMax=function(){var b=d3.max(a.group().all(),function(b){return a.radiusValueAccessor()(b)});return b},a.bubbleR=function(b){var c=a.radiusValueAccessor()(b),d=a.r()(c);return(isNaN(d)||0>=c)&&(d=0),d};var f=function(b){return a.label()(b)},g=function(b){return a.bubbleR(b)>c?1:0};a.doRenderLabel=function(b){if(a.renderLabel()){var c=b.select("text");c.empty()&&(c=b.append("text").attr("text-anchor","middle").attr("dy",".3em").on("click",a.onClick)),c.attr("opacity",0).text(f),dc.transition(c,a.transitionDuration()).attr("opacity",g)}},a.doUpdateLabels=function(b){if(a.renderLabel()){var c=b.selectAll("text").text(f);dc.transition(c,a.transitionDuration()).attr("opacity",g)}};var h=function(b){return a.title()(b)};return a.doRenderTitles=function(b){if(a.renderTitle()){var c=b.select("title");c.empty()&&b.append("title").text(h)}},a.doUpdateTitles=function(b){a.renderTitle()&&b.selectAll("title").text(h)},a.minRadiusWithLabel=function(b){return arguments.length?(c=b,a):c},a.maxBubbleRelativeSize=function(c){return arguments.length?(b=c,a):b},a.initBubbleColor=function(b,c){return this[dc.constants.NODE_INDEX_NAME]=c,a.getColor(b,c)},a.updateBubbleColor=function(b){return a.getColor(b,this[dc.constants.NODE_INDEX_NAME])},a.fadeDeselectedArea=function(){a.hasFilter()?a.selectAll("g."+a.BUBBLE_NODE_CLASS).each(function(b){a.isSelectedNode(b)?a.highlightSelected(this):a.fadeDeselected(this)}):a.selectAll("g."+a.BUBBLE_NODE_CLASS).each(function(){a.resetHighlight(this)})},a.isSelectedNode=function(b){return a.hasFilter(b.key)},a.onClick=function(b){var c=b.key;dc.events.trigger(function(){a.filter(c),dc.redrawAll(a.chartGroup())})},a},dc.pieChart=function(a,b){function c(){if(1/0==D)return C.orderedGroup().top(D);var a=C.group().top(D),b=d3.sum(a,C.valueAccessor()),c=C.group().all(),d=d3.sum(c,C.valueAccessor());return F(a,d-b),a}function d(){if(C.dataSet()){var a=p();w=w?w:d3.min([C.width(),C.height()])/2;var b=C.buildArcs(),d=a(c());if(x){var f=x.selectAll("g."+z).data(d);e(f,b,d),j(d,b),n(f),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(a,b){if(C.renderLabel()){var c=x.selectAll("text."+z).data(a);c.exit().remove();var d=c.enter().append("text").attr("class",function(a,b){return z+" _"+b}).on("click",u);dc.transition(d,C.transitionDuration()).attr("transform",function(a){a.innerRadius=C.innerRadius(),a.outerRadius=w;var c=b.centroid(a);return isNaN(c[0])||isNaN(c[1])?"translate(0,0)":"translate("+c+")"}).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(a,b){var c=x.selectAll("g."+z).data(a).select("path").attr("d",function(a,c){return v(a,c,b)});dc.transition(c,C.transitionDuration(),function(a){a.attrTween("d",s)}).attr("fill",function(a,b){return C.getColor(a,b)})}function l(a,b){if(C.renderLabel()){var c=x.selectAll("text."+z).data(a);dc.transition(c,C.transitionDuration()).attr("transform",function(a){a.innerRadius=C.innerRadius(),a.outerRadius=w;var c=b.centroid(a);return isNaN(c[0])||isNaN(c[1])?"translate(0,0)":"translate("+c+")"}).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=dc.colorChart(dc.baseChart({})),D=1/0,E="Others",F=function(a,b){a.push({key:E,value:b})};return 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.slicesCap=function(a){return arguments.length?(D=a,C):D},C.othersLabel=function(a){return arguments.length?(E=a,C):E},C.othersGrouper=function(a){return arguments.length?(F=a,C):F},C.anchor(a,b)},dc.barChart=function(a,b){function c(a){return dc.utils.safeNumber(Math.abs(k.y()(a.y+a.y0)-k.y()(a.y0)))}function d(a,b,d){var e=a.selectAll("rect.bar").data(b.points);e.enter().append("rect").attr("class","bar").attr("fill",function(){return k.colors()(d)}).append("title").text(k.title()),dc.transition(e,k.transitionDuration()).attr("x",function(a){var b=k.x()(a.x);return m&&(b-=h/2),dc.utils.safeNumber(b)}).attr("y",function(a){var b=k.y()(a.y+a.y0);return a.y<0&&(b-=c(a)),dc.utils.safeNumber(b)}).attr("width",h).attr("height",function(a){return c(a)}).select("title").text(k.title()),dc.transition(e.exit(),k.transitionDuration()).attr("height",0).remove()}function e(){if(void 0===h){var a=k.isOrdinal()?f()+1:f(),b=Math.floor((k.xAxisLength()-(a-1)*l)/a);(1/0==b||isNaN(b)||i>b)&&(b=i),h=b}}function f(){return void 0===g&&(g=k.xUnitCount()),g}var g,h,i=1,j=2,k=dc.stackableChart(dc.coordinateGridChart({})),l=j,m=!1;return dc.override(k,"rescale",function(){k._rescale(),g=void 0,h=void 0,f()}),k.plotData=function(){var a=k.chartBodyG().selectAll("g.stack").data(k.stackLayers());e(),a.enter().append("g").attr("class",function(a,b){return"stack _"+b}),a.each(function(a,b){var c=d3.select(this);d(c,a,b)}),k.stackLayers(null)},k.fadeDeselectedArea=function(){var a=k.chartBodyG().selectAll("rect.bar"),b=k.brush().extent();if(k.isOrdinal())k.hasFilter()?(a.classed(dc.constants.SELECTED_CLASS,function(a){return k.hasFilter(k.keyAccessor()(a.data))}),a.classed(dc.constants.DESELECTED_CLASS,function(a){return!k.hasFilter(k.keyAccessor()(a.data))})):(a.classed(dc.constants.SELECTED_CLASS,!1),a.classed(dc.constants.DESELECTED_CLASS,!1));else if(k.brushIsEmpty(b))a.classed(dc.constants.DESELECTED_CLASS,!1);else{var c=b[0],d=b[1];a.classed(dc.constants.DESELECTED_CLASS,function(a){var b=k.keyAccessor()(a.data);return c>b||b>=d})}},k.centerBar=function(a){return arguments.length?(m=a,k):m},k.gap=function(a){return arguments.length?(l=a,k):l},k.extendBrush=function(){var a=k.brush().extent();return k.round()&&!m&&(a[0]=a.map(k.round())[0],a[1]=a.map(k.round())[1],k.chartBodyG().select(".brush").call(k.brush().extent(a))),a
},dc.override(k,"prepareOrdinalXAxis",function(){return this._prepareOrdinalXAxis(k.xUnitCount()+1)}),k.legendHighlight=function(a){k.select(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!0),k.select(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!0)},k.legendReset=function(a){k.selectAll(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!1),k.selectAll(".chart-body").selectAll("rect.bar").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!1)},k.anchor(a,b)},dc.lineChart=function(a,b){function c(a,b){var c=d3.svg.line().x(function(a){return q.x()(a.x)}).y(function(a){return q.y()(a.y+a.y0)});a.append("path").attr("class","line").attr("stroke",function(a,b){return q.colors()(b)}).attr("fill",function(a,b){return q.colors()(b)}),dc.transition(b.select("path.line"),q.transitionDuration()).attr("d",function(a){return e(c(a.points))})}function d(a,b){if(r){var c=d3.svg.area().x(function(a){return q.x()(a.x)}).y(function(a){return q.y()(a.y+a.y0)}).y0(function(a){return q.y()(a.y0)});a.append("path").attr("class","area").attr("fill",function(a,b){return q.colors()(b)}).attr("d",function(a){return e(c(a.points))}),dc.transition(b.select("path.area"),q.transitionDuration()).attr("d",function(a){return e(c(a.points))})}}function e(a){return a.indexOf("NaN")>=0?"M0,0":a}function f(a){q.brushOn()||a.each(function(a,b){var c=d3.select(this),d=c.select("g."+m);d.empty()&&(d=c.append("g").attr("class",m)),g(d);var e=d.selectAll("circle."+n).data(d.datum().points);e.enter().append("circle").attr("class",n).attr("r",s).attr("fill",function(){return q.colors()(b)}).style("fill-opacity",1e-6).style("stroke-opacity",1e-6).on("mousemove",function(){var a=d3.select(this);h(a),i(a,d)}).on("mouseout",function(){var a=d3.select(this);j(a),k(d)}).append("title").text(q.title()),e.attr("cx",function(a){return dc.utils.safeNumber(q.x()(a.x))}).attr("cy",function(a){return dc.utils.safeNumber(q.y()(a.y+a.y0))}).select("title").text(q.title()),e.exit().remove()})}function g(a){var b=a.select("path."+o).empty()?a.append("path").attr("class",o):a.select("path."+o);b.style("display","none").attr("stroke-dasharray","5,5");var c=a.select("path."+p).empty()?a.append("path").attr("class",p):a.select("path."+p);c.style("display","none").attr("stroke-dasharray","5,5")}function h(a){return a.style("fill-opacity",.8),a.style("stroke-opacity",.8),a}function i(a,b){var c=a.attr("cx"),d=a.attr("cy");b.select("path."+o).style("display","").attr("d","M0 "+d+"L"+c+" "+d),b.select("path."+p).style("display","").attr("d","M"+c+" "+q.yAxisHeight()+"L"+c+" "+d)}function j(a){a.style("fill-opacity",1e-6).style("stroke-opacity",1e-6)}function k(a){a.select("path."+o).style("display","none"),a.select("path."+p).style("display","none")}var l=5,m="dc-tooltip",n="dot",o="yRef",p="xRef",q=dc.stackableChart(dc.coordinateGridChart({})),r=!1,s=l;return q.transitionDuration(500),q.plotData=function(){var a=q.chartBodyG().selectAll("g.stack").data(q.stackLayers()),b=a.enter().append("g").attr("class",function(a,b){return"stack _"+b});c(b,a),d(b,a),f(a),q.stackLayers(null)},q.renderArea=function(a){return arguments.length?(r=a,q):r},q.dotRadius=function(a){return arguments.length?(s=a,q):s},q.legendHighlight=function(a){q.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!0),q.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!0)},q.legendReset=function(a){q.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")==a.color}).classed("highlight",!1),q.selectAll(".chart-body").selectAll("path").filter(function(){return d3.select(this).attr("fill")!=a.color}).classed("fadeout",!1)},q.anchor(a,b)},dc.dataCount=function(a,b){var c=d3.format(",d"),d=dc.baseChart({});return d.doRender=function(){return d.selectAll(".total-count").text(c(d.dimension().size())),d.selectAll(".filter-count").text(c(d.group().value())),d},d.doRedraw=function(){return d.doRender()},d.anchor(a,b)},dc.dataTable=function(a,b){function c(){var a=k.root().selectAll("tbody").data(d(),function(a){return k.keyAccessor()(a)}),b=a.enter().append("tbody");return b.append("tr").attr("class",j).append("td").attr("class",g).attr("colspan",m.length).html(function(a){return k.keyAccessor()(a)}),a.exit().remove(),b}function d(){f||(f=crossfilter.quicksort.by(n));var a=k.dimension().top(l);return d3.nest().key(k.group()).sortKeys(o).sortValues(o).entries(f(a,0,a.length))}function e(a){for(var b=a.order().selectAll("tr."+h).data(function(a){return a.values}),c=b.enter().append("tr").attr("class",h),d=0;d<m.length;++d){var e=m[d];c.append("td").attr("class",i+" _"+d).html(function(a){return e(a)})}return b.exit().remove(),b}var f,g="dc-table-label",h="dc-table-row",i="dc-table-column",j="dc-table-group",k=dc.baseChart({}),l=25,m=[],n=function(a){return a},o=d3.ascending;return k.doRender=function(){return k.selectAll("tbody").remove(),e(c()),k},k.doRedraw=function(){return k.doRender()},k.size=function(a){return arguments.length?(l=a,k):l},k.columns=function(a){return arguments.length?(m=a,k):m},k.sortBy=function(a){return arguments.length?(n=a,k):n},k.order=function(a){return arguments.length?(o=a,k):o},k.anchor(a,b)},dc.bubbleChart=function(a,b){function c(a){var b=a.enter().append("g");b.attr("class",h.BUBBLE_NODE_CLASS).attr("transform",j).append("circle").attr("class",function(a,b){return h.BUBBLE_CLASS+" _"+b}).on("click",h.onClick).attr("fill",h.initBubbleColor).attr("r",0),dc.transition(a,h.transitionDuration()).attr("r",function(a){return h.bubbleR(a)}).attr("opacity",function(a){return h.bubbleR(a)>0?1:0}),h.doRenderLabel(b),h.doRenderTitles(b)}function d(a){dc.transition(a,h.transitionDuration()).attr("transform",j).selectAll("circle."+h.BUBBLE_CLASS).attr("fill",h.updateBubbleColor).attr("r",function(a){return h.bubbleR(a)}).attr("opacity",function(a){return h.bubbleR(a)>0?1:0}),h.doUpdateLabels(a),h.doUpdateTitles(a)}function e(a){a.exit().remove()}function f(a){var b=h.x()(h.keyAccessor()(a))+h.margins().left;return isNaN(b)&&(b=0),b}function g(a){var b=h.margins().top+h.y()(h.valueAccessor()(a));return isNaN(b)&&(b=0),b}var h=dc.abstractBubbleChart(dc.coordinateGridChart({})),i=!1;h.transitionDuration(750);var j=function(a){return"translate("+f(a)+","+g(a)+")"};return h.elasticRadius=function(a){return arguments.length?(i=a,h):i},h.plotData=function(){i&&h.r().domain([h.rMin(),h.rMax()]),h.r().range([h.MIN_RADIUS,h.xAxisLength()*h.maxBubbleRelativeSize()]);var a=h.chartBodyG().selectAll("g."+h.BUBBLE_NODE_CLASS).data(h.group().all());c(a),d(a),e(a),h.fadeDeselectedArea()},h.renderBrush=function(){},h.redrawBrush=function(){h.fadeDeselectedArea()},h.anchor(a,b)},dc.compositeChart=function(a,b){function c(a,b){a.generateG(i.g()),a.g().attr("class",h+" _"+b)}function d(){for(var a=[],b=0;b<j.length;++b)a.push(j[b].yAxisMin());return a}function e(){for(var a=[],b=0;b<j.length;++b)a.push(j[b].yAxisMax());return a}function f(){for(var a=[],b=0;b<j.length;++b)a.push(j[b].xAxisMin());return a}function g(){for(var a=[],b=0;b<j.length;++b)a.push(j[b].xAxisMax());return a}var h="sub",i=dc.coordinateGridChart({}),j=[];return i.transitionDuration(500),dc.override(i,"generateG",function(){for(var a=this._generateG(),b=0;b<j.length;++b){var d=j[b];c(d,b),void 0===d.dimension()&&d.dimension(i.dimension()),void 0===d.group()&&d.group(i.group()),d.chartGroup(i.chartGroup()),d.svg(i.svg()),d.xUnits(i.xUnits()),d.transitionDuration(i.transitionDuration()),d.brushOn(i.brushOn())}return a}),i.plotData=function(){for(var a=0;a<j.length;++a){var b=j[a];void 0===b.g()&&c(b,a),b.x(i.x()),b.y(i.y()),b.xAxis(i.xAxis()),b.yAxis(i.yAxis()),b.plotData(),b.activateRenderlets()}},i.fadeDeselectedArea=function(){for(var a=0;a<j.length;++a){var b=j[a];b.brush(i.brush()),b.fadeDeselectedArea()}},i.compose=function(a){j=a;for(var b=0;b<j.length;++b){var c=j[b];c.height(i.height()),c.width(i.width()),c.margins(i.margins())}return i},i.children=function(){return j},i.yAxisMin=function(){return d3.min(d())},i.yAxisMax=function(){return dc.utils.add(d3.max(e()),i.yAxisPadding())},i.xAxisMin=function(){return dc.utils.subtract(d3.min(f()),i.xAxisPadding())},i.xAxisMax=function(){return dc.utils.add(d3.max(g()),i.xAxisPadding())},i.legendables=function(){for(var a=[],b=0;b<j.length;++b){var c=j[b];c.allGroups().forEach(function(b,d){a.push(dc.utils.createLegendable(c,b,d,c.getValueAccessorByIndex(d)))})}return a},i.legendHighlight=function(a){for(var b=0;b<j.length;++b){var c=j[b];c.legendHighlight(a)}},i.legendReset=function(a){for(var b=0;b<j.length;++b){var c=j[b];c.legendReset(a)}},i.anchor(a,b)},dc.geoChoroplethChart=function(a,b){function c(a){var b=dc.utils.groupMax(n.group(),n.valueAccessor()),c=d();if(e(a)){var g=f(a);l(g,a,c,b),m(g,a,c)}}function d(){for(var a={},b=n.group().all(),c=0;c<b.length;++c)a[n.keyAccessor()(b[c])]=n.valueAccessor()(b[c]);return a}function e(a){return k(a).keyAccessor}function f(a){var b=n.svg().selectAll(g(a)).classed("selected",function(b){return h(a,b)}).classed("deselected",function(b){return i(a,b)}).attr("class",function(b){var c=k(a).name,d=dc.utils.nameToId(k(a).keyAccessor(b)),e=c+" "+d;return h(a,b)&&(e+=" selected"),i(a,b)&&(e+=" deselected"),e});return b}function g(a){return"g.layer"+a+" g."+k(a).name}function h(a,b){return n.hasFilter()&&n.hasFilter(j(a,b))}function i(a,b){return n.hasFilter()&&!n.hasFilter(j(a,b))}function j(a,b){return k(a).keyAccessor(b)}function k(a){return q[a]}function l(a,b,c){var d=a.select("path").attr("fill",function(){var a=d3.select(this).attr("fill");return a?a:"none"}).on("click",function(a){return n.onClick(a,b)});dc.transition(d,n.transitionDuration()).attr("fill",function(a,d){return n.getColor(c[k(b).keyAccessor(a)],d)})}function m(a,b,c){n.renderTitle()&&a.selectAll("title").text(function(a){var d=j(b,a),e=c[d];return n.title()({key:d,value:e})})}var n=dc.colorChart(dc.baseChart({}));n.colorAccessor(function(a){return a});var o,p=d3.geo.path(),q=[];return n.doRender=function(){n.resetSvg();for(var a=0;a<q.length;++a){var b=n.svg().append("g").attr("class","layer"+a),d=b.selectAll("g."+k(a).name).data(k(a).data).enter().append("g").attr("class",k(a).name);d.append("path").attr("fill","white").attr("d",p),d.append("title"),c(a)}o=!1},n.onClick=function(a,b){var c=k(b).keyAccessor(a);dc.events.trigger(function(){n.filter(c),dc.redrawAll(n.chartGroup())})},n.doRedraw=function(){for(var a=0;a<q.length;++a)c(a),o&&n.svg().selectAll("g."+k(a).name+" path").attr("d",p);o=!1},n.overlayGeoJson=function(a,b,c){for(var d=0;d<q.length;++d)if(q[d].name==b)return q[d].data=a,q[d].keyAccessor=c,n;return q.push({name:b,data:a,keyAccessor:c}),n},n.projection=function(a){return p.projection(a),o=!0,n},n.geoJsons=function(){return q},n.removeGeoJson=function(a){for(var b=[],c=0;c<q.length;++c){var d=q[c];d.name!=a&&b.push(d)}return q=b,n},n.anchor(a,b)},dc.bubbleOverlay=function(a,b){function c(){return h=l.select("g."+i),h.empty()&&(h=l.svg().append("g").attr("class",i)),h}function d(){var a=e();m.forEach(function(b){var c=f(b,a),d=c.select("circle."+k);d.empty()&&(d=c.append("circle").attr("class",k).attr("r",0).attr("fill",l.initBubbleColor).on("click",l.onClick)),dc.transition(d,l.transitionDuration()).attr("r",function(a){return l.bubbleR(a)}),l.doRenderLabel(c),l.doRenderTitles(c)})}function e(){var a={};return l.group().all().forEach(function(b){a[l.keyAccessor()(b)]=b}),a}function f(a,b){var c=j+" "+dc.utils.nameToId(a.name),d=h.select("g."+dc.utils.nameToId(a.name));return d.empty()&&(d=h.append("g").attr("class",c).attr("transform","translate("+a.x+","+a.y+")")),d.datum(b[a.name]),d}function g(){var a=e();m.forEach(function(b){var c=f(b,a),d=c.select("circle."+k);dc.transition(d,l.transitionDuration()).attr("r",function(a){return l.bubbleR(a)}).attr("fill",l.updateBubbleColor),l.doUpdateLabels(c),l.doUpdateTitles(c)})}var h,i="bubble-overlay",j="node",k="bubble",l=dc.abstractBubbleChart(dc.baseChart({})),m=[];return l.transitionDuration(750),l.radiusValueAccessor(function(a){return a.value}),l.point=function(a,b,c){return m.push({name:a,x:b,y:c}),l},l.doRender=function(){return h=c(),l.r().range([l.MIN_RADIUS,l.width()*l.maxBubbleRelativeSize()]),d(),l.fadeDeselectedArea(),l},l.doRedraw=function(){return g(),l.fadeDeselectedArea(),l},l.debug=function(a){if(a){var b=l.select("g."+dc.constants.DEBUG_GROUP_CLASS);b.empty()&&(b=l.svg().append("g").attr("class",dc.constants.DEBUG_GROUP_CLASS));var c=b.append("text").attr("x",10).attr("y",20);b.append("rect").attr("width",l.width()).attr("height",l.height()).on("mousemove",function(){var a=d3.mouse(b.node()),d=a[0]+", "+a[1];c.text(d)})}else l.selectAll(".debug").remove();return l},l.anchor(a,b),l},dc.rowChart=function(a,b){function c(){(!q||r)&&(q=d3.scale.linear().domain([0,d3.max(w.group().all(),w.valueAccessor())]).range([0,w.effectiveWidth()]),x.scale(q))}function d(){var a=p.select("g.axis");c(),a.empty()&&(a=p.append("g").attr("class","axis").attr("transform","translate(0, "+w.effectiveHeight()+")")),dc.transition(a,w.transitionDuration()).call(x)}function e(){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-w.effectiveHeight()})}function f(){d(),e();var a=p.selectAll("g."+v).data(w.group().all());g(a),h(a),i(a)}function g(a){var b=a.enter().append("g").attr("class",function(a,b){return v+" _"+b});b.append("rect").attr("width",0),k(b),l(a)}function h(a){a.exit().remove()}function i(a){var b=n();a=a.attr("transform",function(a,c){return"translate(0,"+((c+1)*u+c*b)+")"}).select("rect").attr("height",b).attr("fill",w.getColor).on("click",o).classed("deselected",function(a){return w.hasFilter()?!w.isSelectedRow(a):!1}).classed("selected",function(a){return w.hasFilter()?w.isSelectedRow(a):!1}),dc.transition(a,w.transitionDuration()).attr("width",function(a){return q(w.valueAccessor()(a))}),j(a)}function j(a){w.renderTitle()&&(a.selectAll("title").remove(),a.append("title").text(function(a){return w.title()(a)}))}function k(a){w.renderLabel()&&a.append("text").on("click",o)}function l(a){w.renderLabel()&&a.select("text").attr("x",s).attr("y",t).attr("class",function(a,b){return v+" _"+b}).text(function(a){return w.label()(a)})}function m(){return w.group().all().length}function n(){var a=m();return(w.effectiveHeight()-(a+1)*u)/a}function o(a){w.onClick(a)}var p,q,r,s=10,t=15,u=5,v="row",w=dc.marginable(dc.colorChart(dc.baseChart({}))),x=d3.svg.axis().orient("bottom");return w.doRender=function(){return w.resetSvg(),p=w.svg().append("g").attr("transform","translate("+w.margins().left+","+w.margins().top+")"),d(),e(),f(),w},w.title(function(a){return w.keyAccessor()(a)+": "+w.valueAccessor()(a)}),w.label(function(a){return w.keyAccessor()(a)}),w.x=function(a){return arguments.length?(q=a,w):q},w.doRedraw=function(){return f(),w},w.xAxis=function(){return x},w.gap=function(a){return arguments.length?(u=a,w):u},w.elasticX=function(a){return arguments.length?(r=a,w):r},w.labelOffsetX=function(a){return arguments.length?(s=a,w):s},w.labelOffsetY=function(a){return arguments.length?(t=a,w):t},w.isSelectedRow=function(a){return w.hasFilter(w.keyAccessor()(a))},w.anchor(a,b)},dc.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};