diff --git a/c3.js b/c3.js index 0dc291d..c67fbf9 100644 --- a/c3.js +++ b/c3.js @@ -385,8 +385,8 @@ subYMax = __axis_rotated ? width2 : 1; // update scales x = getX(xMin, xMax, x ? x.domain() : undefined, function () { return xAxis.tickOffset(); }); - y = getY(yMin, yMax, y ? y.domain() : undefined); - y2 = getY(yMin, yMax, y2 ? y2.domain() : undefined); + y = getY(yMin, yMax); + y2 = getY(yMin, yMax); subX = getX(xMin, xMax, orgXDomain, function (d) { return d % 1 ? 0 : subXAxis.tickOffset(); }); subY = getY(subYMin, subYMax); subY2 = getY(subYMin, subYMax); @@ -689,7 +689,8 @@ yMax = axisId === 'y2' ? __axis_y2_max : __axis_y_max, yDomainMin = isValue(yMin) ? yMin : getYDomainMin(yTargets), yDomainMax = isValue(yMax) ? yMax : getYDomainMax(yTargets), - padding = Math.abs(yDomainMax - yDomainMin) * (hasDataLabel() && __axis_rotated ? 0.125 : 0.1), + domainLength = Math.abs(yDomainMax - yDomainMin), + padding = domainLength * 0.1, // TODO: should be an option padding_top = padding, padding_bottom = padding, center = axisId === 'y2' ? __axis_y2_center : __axis_y_center; if (center) { @@ -705,6 +706,13 @@ padding_top = isValue(__axis_y2_padding.top) ? __axis_y2_padding.top : padding; padding_bottom = isValue(__axis_y2_padding.bottom) ? __axis_y2_padding.bottom : padding; } + // add padding for data label + if (hasDataLabel() && __axis_rotated) { + var widths = getDataLabelWidth(yDomainMin, yDomainMax), diff = diffDomain(y.range()); + var ratio = [widths[0] / diff, widths[1] / diff]; + padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); + padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); + } // Bar chart with only positive values should be 0-based if (hasBarType(yTargets) && !hasNegativeValueInTargets(yTargets)) { padding_bottom = yDomainMin; @@ -1019,6 +1027,16 @@ } return false; } + function getDataLabelWidth(min, max) { + var widths = [], paddingCoef = 1.3; + d3.select('svg').selectAll('.dummy') + .data([min, max]) + .enter().append('text') + .text(function (d) { return d; }) + .each(function (d, i) { var box = this.getBBox(); widths[i] = box.width * paddingCoef; }) + .remove(); + return widths; + } function xx(d) { return d ? x(d.x) : null; diff --git a/c3.min.js b/c3.min.js index 23ece75..83e5125 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,2 +1,2 @@ -!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return p>=c||b%Math.ceil(c/p)===0}function f(a){return a0?a:320}function s(){return Nc(Sd.data.targets)?0:$d?$d:zf?1:u("y")}function t(){return Nc(Sd.data.targets)?0:_d?_d:xg?qe*(Df&&!mf?1.25:1):Df?Hf||mf?1:u("y2"):1}function u(){var a=T();return a.isInner?40:60}function v(){return+g.select(Xd).style("width").replace("px","")}function w(){return+g.select(Xd).style("height").replace("px","")}function x(){return je+2}function y(){return 80}function z(){return ge.left+20}function A(){return le+2}function B(){var a=mf?le:je,b=nb(),c=Kb();return c>1?a*b/(c-1):a}function C(){return hf?xg?150:ne:0}function D(){return hf?xg?oe:40:0}function E(){var a=S();return a.isInner?5:20}function F(){var a,b;ye=mf?1:0,ze=mf?le:je,Ae=mf?0:le,Be=mf?je:1,Ce=ye,De=ze,Ee=mf?0:me,Fe=mf?ke:1,Ge=H(ye,ze,Ge?Ge.domain():void 0,function(){return Me.tickOffset()}),He=I(Ae,Be,He?He.domain():void 0),Ie=I(Ae,Be,Ie?Ie.domain():void 0),Je=H(ye,ze,Mg,function(a){return a%1?0:Pe.tickOffset()}),Ke=I(Ee,Fe),Le=I(Ee,Fe),a=O(),b=P(),Me=L(Ge,sg,a,b),Pe=L(Je,vg,a,b),Ne=M(He,tg,Af,Cf),Oe=M(Ie,ug,If,Kf),G()}function G(){ue=cb(),ve=db(),we=db(.98)}function H(a,b,c,f){var h=(kg?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),lg){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function I(a,b){return g.scale.linear().range([a,b])}function J(a){return"y2"===N(a)?Ie:He}function K(a){return"y2"===N(a)?Le:Ke}function L(a,c,d,e){var f=(lg?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),lg?f.tickCentered(pf):f.tickOffset=function(){var a=mf?le:je;return a*nb()/Kb()/2},lg&&f.categories(of),f}function M(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function N(a){return a in We?We[a]:"y"}function O(){var a=kg?rg:lg?Tb:null;return qf&&("function"==typeof qf?a=qf:kg&&(a=function(a){return g.time.format(qf)(a)})),a}function P(){var a=Kb();return rf&&a>sf?sf:a}function Q(a){return"string"==typeof a?a:a?a.text:null}function R(a,b){var c=a&&"object"==typeof a&&a.position?a.position:b;return{isInner:c.indexOf("inner")>=0,isOuter:c.indexOf("outer")>=0,isLeft:c.indexOf("left")>=0,isCenter:c.indexOf("center")>=0,isRight:c.indexOf("right")>=0,isTop:c.indexOf("top")>=0,isMiddle:c.indexOf("middle")>=0,isBottom:c.indexOf("bottom")>=0}}function S(){return R(uf,"inner-right")}function T(){return R(yf,"inner-top")}function U(){return Q(uf)}function V(){return Q(yf)}function W(){var a=S();return a.isLeft?0:a.isCenter?je/2:je}function X(){var a=T();return a.isBottom?-le:a.isMiddle?-le/2:0}function Y(){var a=T();return a.isTop?"-0.5em":"0"}function Z(){var a=S();return a.isInner?"-0.5em":"3.5em"}function $(){var a=T(),b=0;return g.selectAll(".y.axis .tick text").each(function(){var a=this.getBBox();b0)for(f=Rb(a),b=0;ba?a:0}),c=1;c0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function lb(a){var b,c,d,e,f,h=Pb(a);if(Ve.length>0)for(f=Sb(a),b=0;b0?a:0}),c=1;c+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function mb(a){var b=Ob(function(b){return N(b.id)===a}),d="y2"===a?Ff:wf,e="y2"===a?Ef:vf,f=c(d)?d:kb(b),g=c(e)?e:lb(b),h=Math.abs(g-f)*(jc()&&mf?.125:.1),i=h,j=h,k="y2"===a?Gf:xf;if(k){var l=Math.max(Math.abs(f),Math.abs(g));g=l-k,f=k-l}return"y"===a&&Bf&&(i=c(Bf.top)?Bf.top:h,j=c(Bf.bottom)?Bf.bottom:h),"y2"===a&&Jf&&(i=c(Jf.top)?Jf.top:h,j=c(Jf.bottom)?Jf.bottom:h),Jc(b)&&!Rb(b)&&(j=f),[f-j,g+i]}function nb(a){return a?1:sb(Mg)/sb(Ge.domain())}function ob(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function pb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function qb(a,b){var c,d=b[0],e=b[1],f=Math.abs(d-e);return c=lg?0:Jc(a)?f/(Kb()-1)/2:.01*f}function rb(a){var b=[ob(a),pb(a)],c=b[0],d=b[1],e=qb(a,b),f=kg?new Date(c.getTime()-e):c-e,g=kg?new Date(d.getTime()+e):d+e;return[f,g]}function sb(a){return a[1]-a[0]}function tb(a){for(var b=0;bd?0:d}function yb(a){return Qe&&a===Qe||Re&&bd(Re,a)}function zb(a){return!yb(a)}function Ab(a){return Qe?Qe:Re?Re[a]:null}function Bb(a,b){return a in Sd.data.x&&Sd.data.x[a]&&Sd.data.x[a][b]?Sd.data.x[a][b]:b}function Cb(a){Object.keys(a).forEach(function(b){Re[b]=a[b]})}function Db(a){var b;return a&&(b=Ue[a.id],a.name=b?b:a.id),a}function Eb(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?b.map(function(a){return a[c]}):Sd.data.x[Object.keys(Sd.data.x)[0]]}),c=d.map(function(a){var c=Te(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=Ab(a);return e=kg?Zc(b[f]):mg?b[f]?+b[f]:Bb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),Xe&&Hc(Mb(c).filter(function(a){return!(a in Ye)}),Xe),c.forEach(function(a){ub(a.id_org,a)}),c)}function Hb(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Ib(a){return a>0&&Sd.data.targets[0].values[a-1]?Sd.data.targets[0].values[a-1].x:void 0}function Jb(a){return a1?Sd.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Sd.data.targets[0]:null,a}function Mb(a){return a=d(a)?Sd.data.targets:a,a.map(function(a){return a.id})}function Nb(a){var b,c=Mb();for(b=0;ba})}function Sb(a){return Qb(a,function(a){return a>0})}function Tb(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(pc(a,f))),a[g].x&&(e=e.concat(pc(a,g))),sc(e,b)):qc(a,b,f,g)}function rc(a,b){var c;return c=a.map(function(a){return qc(a.values,b)}),sc(c,b)}function sc(a,b){var c,d;return a.forEach(function(a){var e=cd(a,b);(c>e||!c)&&(c=e,d=a)}),d}function tc(){return $e&&"desc"===$e.toLowerCase()}function uc(){return $e&&"asc"===$e.toLowerCase()}function vc(a){var b=uc(),c=tc();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof $e&&a.sort($e),a}function wc(a,b){var d,e,f,g,h,i,j,k=a.filter(function(a){return a&&c(a.value)});bg&&0!==k.length&&(Kg.html(eg(a,O(),oc,qg)).style("visibility","hidden").style("display","block"),d=Kg.property("offsetWidth"),e=Kg.property("offsetHeight"),mf?(f=p(),g=f+b[0]+100,h=g+d,j=q()-t(),i=Ge(k[0].x)+20):(f=p(),g=f+s()+Ge(k[0].x)+20,h=g+d,j=f+q()-t(),i=b[1]+15),h>j&&(g-=d+60),i+e>r()&&(i-=e+30),Kg.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function xc(){Kg.style("display","none")}function yc(a){var b=a.filter(function(a){return a&&c(a.value)});bg&&(Kc(Sd.data.targets)||Nc(Sd.data.targets)||Hg.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(mf?"y1":"x1",kc).attr(mf?"y2":"x2",kc))}function zc(){Hg.select("line.xgrid-focus").style("visibility","hidden")}function Ac(a){return a.x||0===a.x?Ge(a.x):null}function Bc(a){return J(a.id)(a.value)}function Cc(){var a,b,c={},e=0;return Ob(Qc).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Gc(a,b){return b?2*a.tickOffset()*.6/b:0}function Hc(a,b){var c=d(a)?Mb():a;"string"==typeof c&&(c=[c]);for(var e=0;e=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function wd(b){var c,d,e,f,h;if(Lg=g.select(Xd),Lg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Lg.html(""),Sd.data.x={},Sd.data.targets=Gb(b),n(),F(),Ge.domain(g.extent(rb(Sd.data.targets))),He.domain(mb("y")),Ie.domain(mb("y2")),Je.domain(Ge.domain()),Ke.domain(He.domain()),Le.domain(Ie.domain()),Mg=Ge.domain(),Ag.scale(Je),ae&&Eg.scale(Ge),Fg=g.select(Xd).append("svg").attr("width",je+ge.left+ge.right).attr("height",le+ge.top+ge.bottom).on("mouseenter",de).on("mouseleave",ee),Gg=Fg.append("defs"),Gg.append("clipPath").attr("id",ig).append("rect").attr("width",je).attr("height",le),Gg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",x).attr("height",y),Gg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-ge.left+1).attr("width",z).attr("height",A),Hg=Fg.append("g").attr("transform",wg.main),Ig=ef?Fg.append("g").attr("transform",wg.context):null,Jg=hf?Fg.append("g").attr("transform",wg.legend):null,Kg=g.select(Xd).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Hg.append("g").attr("class","x axis").attr("clip-path",mf?"":"url("+document.URL+"#xaxis-clip)").attr("transform",wg.x).append("text").attr("class","-axis-x-label").attr("dy",Z).style("text-anchor",_).text(mf?V:U),Hg.append("g").attr("class","y axis").attr("clip-path",mf?"url("+document.URL+"#yaxis-clip)":"").append("text").attr("class","-axis-y-label").attr("transform","rotate(-90)").attr("dx",Y).style("text-anchor",ab).text(mf?U:V),Df&&Hg.append("g").attr("class","y2 axis").attr("transform",wg.y2),d=Hg.append("g").attr("clip-path",jg).attr("class","grid"),Lf&&d.append("g").attr("class","xgrids"),Nf&&(e=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Nf).enter().append("g").attr("class","xgrid-line"),e.append("line").attr("class",function(a){return""+a["class"]}),e.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",mf?"":"rotate(-90)").attr("dx",mf?0:-ge.top).attr("dy",-5).text(function(a){return a.text})),Tf&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",mf?0:-10).attr("x2",mf?je:-10).attr("y1",mf?-10:ge.top).attr("y2",mf?-10:le),Of&&d.append("g").attr("class","ygrids"),Pf&&(f=d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Pf).enter().append("g").attr("class","ygrid-line"),f.append("line").attr("class",function(a){return""+a["class"]}),f.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",mf?"rotate(-90)":"").attr("dx",mf?0:-ge.top).attr("dy",-5).text(function(a){return a.text})),Hg.append("g").attr("clip-path",jg).attr("class","regions"),Hg.append("g").attr("clip-path",jg).attr("class","chart"),c=Hg.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ae?mf?"ns-resize":"ew-resize":null),Hg.select(".chart").append("g").attr("class","chart-bars"),Hg.select(".chart").append("g").attr("class","chart-lines"),Hg.select(".chart").append("g").attr("class","chart-arcs").attr("transform",wg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(_f),Hg.select(".chart").append("g").attr("class","chart-texts"),ae&&Hg.insert("rect",ce?null:"g.grid").attr("class","zoom-rect").attr("width",je).attr("height",le).style("opacity",0).style("cursor",mf?"ns-resize":"ew-resize").call(Eg).on("dblclick.zoom",null),null!==tf&&Ag.extent("function"!=typeof tf?tf:tf(rb())),ef&&(Ig.append("g").attr("clip-path",jg).attr("class","chart"),Ig.select(".chart").append("g").attr("class","chart-bars"),Ig.select(".chart").append("g").attr("class","chart-lines"),Ig.append("g").attr("clip-path",jg).attr("class","x brush").call(Ag).selectAll("rect").attr(mf?"width":"height",mf?ke:me),Ig.append("g").attr("class","x axis").attr("transform",wg.subx).attr("clip-path",mf?"url("+document.URL+"#yaxis-clip)":"")),hf&&Nd(Sd.data.targets),Id(Sd.data.targets),Dd({withTransform:!0,withUpdateXDomain:!0}),fg){if(kg&&"string"==typeof gg){for(gg=Zc(gg),h=0;h0){d=[];for(var f in Ue)for(c=0;cf&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=id,o=c+e>f&&h>c&&j>d),o^n&&(l.classed(Wd,!n),l.classed(Vd,!m),k(!m,l,a,b))}))}function Bd(a){Nc(Sd.data.targets)||bf&&(ng=a,Hg.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),og=!0)}function Cd(){Nc(Sd.data.targets)||bf&&(Hg.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Hg.selectAll(".-shape").classed(Wd,!1),og=!1)}function Dd(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,C,D,E,F=Cc(),G=Nc(Sd.data.targets);if(a=e(a)?a:{},s=e(a.withY)?a.withY:!0,t=e(a.withSubchart)?a.withSubchart:!0,u=e(a.withTransition)?a.withTransition:!0,v=e(a.withTransform)?a.withTransform:!1,w=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,x=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,D=u?fe:0,E=e(a.durationForExit)?a.durationForExit:D,x&&(Ge.domain(g.extent(rb(Sd.data.targets))),Mg=Ge.domain(),ae&&Eg.scale(Ge).updateScaleExtent(),Je.domain(Ge.domain()),Ag.scale(Je)),w&&(Ge.domain(Ag.empty()?Mg:Ag.extent()),ae&&Eg.scale(Ge).updateScaleExtent()),He.domain(mb("y")),Ie.domain(mb("y2")),Hg.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(mf?Ne:Me),Hg.select(".y.axis").style("opacity",G?0:1).transition().duration(D).call(mf?Me:Ne),Hg.select(".y2.axis").style("opacity",G?0:1).transition().call(Oe),y=qd(F),A=rd(F,!0),C=rd(F,!1),Hg.select(".x.axis .-axis-x-label").attr("x",W),Hg.select(".y.axis .-axis-y-label").attr("x",X).attr("dy",$),Ke.domain(He.domain()),Le.domain(Ie.domain()),Kg.style("display","none"),Hg.select("line.xgrid-focus").style("visibility","hidden").attr("y2",le),Lf){if("year"===Mf){d=[];for(var H=rb(),I=H[0].getFullYear(),J=H[1].getFullYear(),K=I;J>=K;K++)d.push(new Date(K+"-01-01 00:00:00"))}else d=Ge.ticks(10);b=Hg.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",mf?0:function(a){return Ge(a)-Me.tickOffset()}).attr("x2",mf?je:function(a){return Ge(a)-Me.tickOffset()}).attr("y1",mf?function(a){return Ge(a)-Me.tickOffset()}:ge.top).attr("y2",mf?function(a){return Ge(a)-Me.tickOffset()}:le).style("opacity",function(){return+g.select(this).attr(mf?"y1":"x1")===(mf?le:0)?0:1}),b.exit().remove()}Nf&&(f=Hg.selectAll(".xgrid-lines"),f.selectAll("line").transition().duration(D).attr("x1",mf?0:lc).attr("x2",mf?je:lc).attr("y1",mf?lc:ge.top).attr("y2",mf?lc:le),f.selectAll("text").attr("x",mf?je:0).attr("y",lc)),s&&Of&&(h=Hg.select(".ygrids").selectAll(".ygrid").data(He.ticks(Qf)),h.enter().append("line").attr("class","ygrid"),h.attr("x1",mf?He:0).attr("x2",mf?He:je).attr("y1",mf?0:He).attr("y2",mf?le:He),h.exit().remove()),s&&Pf&&(i=Hg.select(".ygrid-lines"),i.selectAll("line").transition().duration(D).attr("x1",mf?mc:0).attr("x2",mf?mc:je).attr("y1",mf?0:mc).attr("y2",mf?le:mc),i.selectAll("text").attr("x",mf?0:je).attr("y",mc)),k=Hg.selectAll(".-bars").selectAll(".-bar").data(Vc),k.enter().append("path").attr("d",y).style("stroke","none").style("opacity",0).style("fill",function(a){return qg(a.id)}).attr("class",cc),k.style("opacity",fc).transition().duration(D).attr("d",y).style("opacity",1),k.exit().transition().duration(E).style("opacity",0).remove(),m=Hg.selectAll(".-texts").selectAll(".-text").data(Xc),m.enter().append("text").attr("class",Ub).attr("text-anchor",function(a){return mf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return oc(a.value) -}),m.style("fill-opacity",gc).transition().duration(D).attr("x",A).attr("y",C).style("fill-opacity",ic),m.exit().transition().duration(E).style("fill-opacity",0).remove(),Hg.selectAll(".-line").style("opacity",fc).transition().duration(D).attr("d",Bg).style("opacity",1),Hg.selectAll(".-area").style("opacity",0).transition().duration(D).attr("d",Cg).style("opacity",Ng),j=Hg.selectAll(".-circles").selectAll(".-circle").data(Wc),j.enter().append("circle").attr("class",bc).style("opacity",0).attr("r",Sf),j.style("opacity",fc).transition().duration(D).style("opacity",hc).attr("cx",mf?Bc:Ac).attr("cy",mf?Ac:Bc),j.exit().remove(),Hg.selectAll(".chart-arc").select(".-arc").attr("transform",v?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(D).attrTween("d",function(a){var b=bb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return eb(c(a),!0)}}).attr("transform",v?"scale(1)":"").style("opacity",1),Hg.selectAll(".chart-arc").select("text").attr("transform",fb).style("opacity",0).transition().duration(D).text(hb).style("opacity",function(a){return Uc(a.data)?1:0}),Hg.select(".chart-arcs-title").style("opacity",Mc(Sd.data.targets)?1:0),ef&&(null!==g.event&&"zoom"===g.event.type&&Ag.extent(Ge.orgDomain()).update(),t&&(Ig.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(Pe),Ag.empty()||Ag.extent(Ge.orgDomain()).update(),z=qd(F,!0),n=Ig.selectAll(".-bars").selectAll(".-bar").data(Vc),n.enter().append("path").attr("d",z).style("stroke","none").style("fill",function(a){return qg(a.id)}).attr("class",cc),n.style("opacity",fc).transition().duration(D).attr("d",z).style("opacity",1),n.exit().transition().duration(D).style("opacity",0).remove(),Ig.selectAll(".-line").style("opacity",fc).transition().duration(D).attr("d",Dg).style("opacity",1))),Hg.selectAll(".selected-circles").filter(function(a){return Qc(a)}).selectAll("circle").remove(),Hg.selectAll(".selected-circle").transition().duration(D).attr("cx",mf?Bc:Ac).attr("cy",mf?Ac:Bc),Re?(o=Hg.select(".event-rects").selectAll(".event-rect").data([0]),yd(o.enter()),o.attr("x",0).attr("y",0).attr("width",je).attr("height",le)):(mg?(r=function(a,b){var c=Ib(b),d=Jb(b);return(Ge(d?d:a.x+50)-Ge(c?c:a.x-50))/2},q=function(a,b){var c=Ib(b);return(Ge(a.x)+Ge(c?c:a.x-50))/2}):(r=B(),q=function(a){return Ge(a.x)-r/2}),p=Lb(),Hg.select(".event-rects").datum(p?p.values:[]),o=Hg.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),xd(o.enter()),o.attr("class",ec).attr("x",mf?0:q).attr("y",mf?q:0).attr("width",mf?je:r).attr("height",mf?r:le),o.exit().remove()),l=Hg.select(".regions").selectAll("rect.region").data(ag),l.enter().append("rect").style("fill-opacity",0),l.attr("class",dc).attr("x",mf?0:wb).attr("y",mf?wb:ge.top).attr("width",mf?je:xb).attr("height",mf?xb:le).transition().duration(D).style("fill-opacity",function(a){return c(a.opacity)?a.opacity:.1}),l.exit().transition().duration(D).style("fill-opacity",0).remove(),hf&&Nd(Sd.data.targets,{withTransition:u}),Mb().forEach(function(a){Og[a]=!0})}function Ed(){Dd({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Fd(){return"mousemove"===g.event.sourceEvent.type&&Eg.altDomain?(Ge.domain(Eg.altDomain),void Eg.scale(Ge).updateScaleExtent()):(lg&&Ge.orgDomain()[0]===Mg[0]&&Ge.domain([Mg[0]-1e-10,Ge.orgDomain()[1]]),Dd({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(pg=!0)))}function Gd(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Hd(a){var b,c;a=e(a)?a:{},b=e(a.withTransition)?a.withTransition:!1,c=e(a.withTransform)?a.withTransform:!1,n(),F(),Ag.scale(Je),ae&&Eg.scale(Ge),Fg.attr("width",ne).attr("height",oe),Fg.select("#"+ig).select("rect").attr("width",je).attr("height",le),Fg.select("#xaxis-clip").select("rect").attr("width",x),Fg.select(".zoom-rect").attr("width",je).attr("height",le),m(b),Dd({withTransition:b,withUpdateXDomain:!0,withTransform:c,durationForExit:0})}function Id(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=Hg.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none"),j.append("g").attr("class",Vb).style("fill",function(a){return qg(a.id)}),e=Hg.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none"),d.append("g").attr("class",Zb).style("fill",function(a){return qg(a.id)}).style("stroke","none").style("cursor",function(a){return df(a)?"pointer":null}),c=Hg.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none"),b.append("path").attr("class",Xb).style("opacity",0).style("stroke",function(a){return qg(a.id)}),b.append("path").attr("class",_b).style("opacity",function(){return Ng=+g.select(this).style("opacity"),0}).style("fill",function(a){return qg(a.id)}),b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id}),b.append("g").attr("class",Yb).style("fill",function(a){return qg(a.id)}).style("cursor",function(a){return df(a)?"pointer":null}),a.forEach(function(a){var b=Od(a.id);Hg.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=Hg.select(".chart-arcs").selectAll(".chart-arc").data(xe(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",$b).style("opacity",0).style("fill",function(a){return qg(a.data.id)}).style("cursor",function(a){return df(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){ib(a.data.id),Kd(a.data.id)}).on("mouseout",function(a){jb(a.data.id),Md()}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),ef&&(n=Ig.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),m.append("g").attr("class",Zb).style("fill",function(a){return qg(a.id)}),l=Ig.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),k.append("path").attr("class",Xb).style("opacity",0).style("stroke",function(a){return qg(a.id)})),hf&&Nd(a),Fg.selectAll(".target").transition().style("opacity",1)}function Jd(a,b){Sd.data.targets.forEach(function(b){for(var c=0;c=d&&(Object.keys(w).forEach(function(a){w[a]=h}),xg||(p=(qe-h*Object.keys(a).length)/2)),i>=e&&(Object.keys(x).forEach(function(a){x[a]=i}),xg&&(p=(pe-i*Object.keys(a).length)/2))):(v[c]=u,u+=j,p=(k-u)/2)}var i,j,k,l,m,n,o,p,q,r=Mb(a),s=4,t=30,u=0,v={},w={},x={};b=d(b)?{}:b,q=e(b.withTransition)?b.withTransition:!0,xg?(j=function(){return.2*qe},m=function(a,b){return p+f(a,b)}):(j=function(a,b){return p+c(a,b)},m=function(){return.2*pe}),k=function(a,b){return j(a,b)+14},n=function(a,b){return m(a,b)+9},l=function(a,b){return j(a,b)-4},o=function(a,b){return m(a,b)-7},i=Jg.selectAll(".legend-item").data(r).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){kf(a)}).on("mouseover",function(a){Kd(a),Sd.focus(a)}).on("mouseout",function(){Md(),Sd.revert()}),i.append("text").text(function(a){return e(Ue[a])?Ue[a]:a}).each(function(a){h(this,a)}).style("pointer-events","none").attr("x",xg?k:-200).attr("y",xg?-200:m),i.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",xg?l:-200).attr("y",xg?-200:o).attr("width",function(a){return w[a]}).attr("height",function(a){return x[a]}),i.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return qg(a)}).attr("x",xg?k:-200).attr("y",xg?-200:n).attr("width",10).attr("height",10),Jg.selectAll("text").data(r).each(function(a){h(this,a)}).transition().duration(q?250:0).attr("x",k).attr("y",n),Jg.selectAll("rect.legend-item-event").data(r).transition().duration(q?250:0).attr("x",l).attr("y",o),Jg.selectAll("rect.legend-item-tile").data(r).transition().duration(q?250:0).attr("x",j).attr("y",m)}function Od(a){return a?"-"+a.replace(/\./g,"\\."):""}function Pd(a){return".target"+Od(a)}function Qd(a){return Nb(a.id)}function Rd(a){return"data"in a&&Nb(a.data.id)}var Sd={data:{}},Td={},Ud="_expanded_",Vd="_selected_",Wd="_included_",Xd=i(["bindto"],"#chart"),Yd=i(["size","width"],null),Zd=i(["size","height"],null),$d=i(["padding","left"],null),_d=i(["padding","right"],null),ae=i(["zoom","enabled"],!1),be=i(["zoom","extent"],null),ce=i(["zoom","privileged"],!1),de=i(["onenter"],function(){}),ee=i(["onleave"],function(){}),fe=i(["transition","duration"],350);h("data","data is required in config");var ge,he,ie,je,ke,le,me,ne,oe,pe,qe,re,se,te,ue,ve,we,xe,ye,ze,Ae,Be,Ce,De,Ee,Fe,Ge,He,Ie,Je,Ke,Le,Me,Ne,Oe,Pe,Qe=i(["data","x"],null),Re=i(["data","xs"],null),Se=i(["data","x_format"],"%Y-%m-%d"),Te=i(["data","id_converter"],function(a){return a}),Ue=i(["data","names"],{}),Ve=i(["data","groups"],[]),We=i(["data","axes"],{}),Xe=i(["data","type"],null),Ye=i(["data","types"],{}),Ze=i(["data","labels"],{}),$e=i(["data","order"],null),_e=i(["data","regions"],{}),af=i(["data","colors"],{}),bf=i(["data","selection","enabled"],!1),cf=i(["data","selection","grouped"],!1),df=i(["data","selection","isselectable"],function(){return!0}),ef=i(["subchart","show"],!1),ff=ef?i(["subchart","size","height"],60):0,gf=i(["color","pattern"],null),hf=i(["legend","show"],!0),jf=i(["legend","position"],"bottom"),kf=i(["legend","item","onclick"],function(){}),lf=i(["legend","equally"],!1),mf=i(["axis","rotated"],!1),nf=i(["axis","x","type"],"indexed"),of=i(["axis","x","categories"],[]),pf=i(["axis","x","tick","centered"],!1),qf=i(["axis","x","tick","format"],null),rf=i(["axis","x","tick","culling"],"categorized"===nf?!1:!0),sf=i(["axis","x","tick","count"],10),tf=i(["axis","x","default"],null),uf=i(["axis","x","label"],null),vf=i(["axis","y","max"],null),wf=i(["axis","y","min"],null),xf=i(["axis","y","center"],null),yf=i(["axis","y","label"],null),zf=i(["axis","y","inner"],!1),Af=i(["axis","y","tick","format"],null),Bf=i(["axis","y","padding"],null),Cf=i(["axis","y","ticks"],10),Df=i(["axis","y2","show"],!1),Ef=i(["axis","y2","max"],null),Ff=i(["axis","y2","min"],null),Gf=i(["axis","y2","center"],null),Hf=i(["axis","y2","inner"],!1),If=i(["axis","y2","tick","format"],null),Jf=i(["axis","y2","padding"],null),Kf=i(["axis","y2","ticks"],10),Lf=i(["grid","x","show"],!1),Mf=i(["grid","x","type"],"tick"),Nf=i(["grid","x","lines"],null),Of=i(["grid","y","show"],!1),Pf=i(["grid","y","lines"],null),Qf=i(["grid","y","ticks"],10),Rf=i(["point","show"],!0),Sf=Rf?i(["point","r"],2.5):0,Tf=i(["point","focus","line","enabled"],!0),Uf=i(["point","focus","expand","enabled"],!0),Vf=i(["point","focus","expand","r"],Uf?4:Sf),Wf=i(["point","focus","select","r"],8),Xf=i(["point","onclick"],function(){}),Yf=i(["point","onselected"],function(){}),Zf=i(["point","onunselected"],function(){}),$f=i(["arc","label","format"],function(a,b){return(100*b).toFixed(1)+"%"}),_f=i(["arc","title"],""),ag=i(["regions"],[]),bg=i(["tooltip","show"],!0),cg=i(["tooltip","format","title"],null),dg=i(["tooltip","format","value"],null),eg=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=cg?cg:b,k=dg?dg:c;for(f=0;f"+g+""),i=a[f].name,h=k(a[f].value),e+=""+i+""+h+"");return e+""}),fg=i(["tooltip","init","show"],!1),gg=i(["tooltip","init","x"],0),hg=i(["tooltip","init","position"],{top:"0px",left:"50px"}),ig=Xd.replace("#","")+"-clip",jg="url("+document.URL+"#"+ig+")",kg="timeseries"===nf,lg="categorized"===nf,mg=!kg&&(Qe||Re),ng=null,og=!1,pg=!1,qg=Yc(af,gf),rg=function(){var a=[[g.time.format("%Y/%-m/%-d"),function(){return!0}],[g.time.format("%-m/%-d"),function(a){return a.getMonth()}],[g.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[g.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[g.time.format("%I %p"),function(a){return a.getHours()}],[g.time.format("%I:%M"),function(a){return a.getMinutes()}],[g.time.format(":%S"),function(a){return a.getSeconds()}],[g.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),sg=mf?"left":"bottom",tg=mf?zf?"top":"bottom":zf?"right":"left",ug=mf?Hf?"bottom":"top":Hf?"left":"right",vg=mf?"left":"bottom",wg={main:function(){return"translate("+ge.left+","+ge.top+")"},context:function(){return"translate("+he.left+","+he.top+")"},legend:function(){return"translate("+ie.left+","+ie.top+")"},y2:function(){return"translate("+(mf?0:je)+","+(mf?1:0)+")"},x:function(){return"translate(0,"+le+")"},subx:function(){return"translate(0,"+(mf?0:me)+")"},arc:function(){return"translate("+je/2+","+le/2+")"}},xg="right"===jf,yg=40,zg=20;xe=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Ag,Bg=function(){var a=g.svg.line().x(mf?function(a){return J(a.id)(a.value)}:kc).y(mf?kc:function(a){return J(a.id)(a.value)});return function(b){var c,d,e=jd(b.values);return Oc(b)?(a.interpolate(Pc(b)?"cardinal":"linear"),_e[b.id]?vd(e,Ge,J(b.id),_e[b.id]):a(e)):(c=Ge(e[0].x),d=J(b.id)(e[0].value),mf?"M "+d+" "+c:"M "+c+" "+d)}}(),Cg=function(){var a;return a=mf?g.svg.area().x0(function(a){return J(a.id)(0)}).x1(function(a){return J(a.id)(a.value)}).y(kc):g.svg.area().x(kc).y0(function(a){return J(a.id)(0)}).y1(function(a){return J(a.id)(a.value)}),function(b){var c,d,e=jd(b.values);return Ic([b],"area")||Ic([b],"area-spline")?(a.interpolate(Pc(b)?"cardinal":"linear"),a(e)):(c=Ge(e[0].x),d=J(b.id)(e[0].value),mf?"M "+d+" "+c:"M "+c+" "+d)}}(),Dg=function(){var a=g.svg.line().x(mf?function(a){return K(a.id)(a.value)}:nc).y(mf?nc:function(a){return K(a.id)(a.value)});return function(b){var c=jd(b.values);return Oc(b)?a(c):"M "+Je(c[0].x)+" "+K(b.id)(c[0].value)}}(),Eg=function(){};Ag=g.svg.brush().on("brush",Ed),Ag.update=function(){return Ig&&Ig.select(".x.brush").call(this),this},Ag.scale=function(a){return mf?this.y(a):this.x(a)},ae&&(Eg=g.behavior.zoom().on("zoomstart",function(){Eg.altDomain=g.event.sourceEvent.altKey?Ge.orgDomain():null}).on("zoom",ae?Fd:null),Eg.scale=function(a){return mf?this.y(a):this.x(a)},Eg.orgScaleExtent=function(){var a=be?be:[1,10];return[a[0],Math.max(Kb()/a[1],a[1])]},Eg.updateScaleExtent=function(){var a=sb(Ge.orgDomain())/sb(Mg),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Fg,Gg,Hg,Ig,Jg,Kg,Lg,Mg,Ng,Og={};if(Sd.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Fg.selectAll(Pd(a)),d=c.filter(Qd),e=c.filter(Rd);Sd.revert(),Sd.defocus(),b(d.classed("focused",!0)),b(e),Nc(Sd.data.targets)&&ib(a,!0),Kd(a)},Sd.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Fg.selectAll(Pd(a)),d=c.filter(Qd),e=c.filter(Rd);Sd.revert(),b(d.classed("focused",!1)),b(e),Nc(Sd.data.targets)&&jb(a),Ld(a)},Sd.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Fg.selectAll(Pd(a)),d=c.filter(Qd),e=c.filter(Rd);b(d.classed("focused",!1)),b(e),Nc(Sd.data.targets)&&jb(a),Md()},Sd.show=function(a){Fg.selectAll(Pd(a)).transition().style("opacity",1)},Sd.hide=function(a){Fg.selectAll(Pd(a)).transition().style("opacity",0)},Sd.unzoom=function(){Ag.clear().update(),Dd({withUpdateXDomain:!0})},Sd.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&Cb(a.xs),"categories"in a&&lg&&(of=a.categories,Me.categories(of)),"cacheIds"in a&&tb(a.cacheIds))return void Jd(vb(a.cacheIds),a.done);if("data"in a)Jd(Gb(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){Jd(Gb(c),a.done)});else if("rows"in a)Jd(Gb(Eb(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");Jd(Gb(Fb(a.columns)),a.done)}},Sd.unload=function(a){Sd.data.targets=Sd.data.targets.filter(function(b){return b.id!==a}),Fg.selectAll(Pd(a)).transition().style("opacity",0).remove(),hf&&(Fg.selectAll(".legend-item"+Od(a)).remove(),Nd(Sd.data.targets)),Sd.data.targets.length>0&&Dd({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},Sd.selected=function(a){var b=Od(a);return g.merge(Hg.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(Vd)}).map(function(a){return a.map(function(a){return a.__data__})}))},Sd.select=function(a,b,c){bf&&Hg.selectAll(".-shapes").selectAll(".-shape").each(function(f,h){var i="circle"===this.nodeName?dd:gd,j="circle"===this.nodeName?ed:hd;b.indexOf(h)>=0?df(f)&&(cf||d(a)||a.indexOf(f.id)>=0)&&i(g.select(this).classed(Vd,!0),f,h):e(c)&&c&&j(g.select(this).classed(Vd,!1),f,h)})},Sd.unselect=function(a,b){bf&&Hg.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?ed:hd;(d(b)||b.indexOf(e)>=0)&&df(c)&&(cf||d(a)||a.indexOf(c.id)>=0)&&f(g.select(this).classed(Vd,!1),c,e)})},Sd.toLine=function(a){Hc(a,"line"),Hd({withTransition:!0})},Sd.toSpline=function(a){Hc(a,"spline"),Hd({withTransition:!0})},Sd.toBar=function(a){Hc(a,"bar"),Hd({withTransition:!0})},Sd.toScatter=function(a){Hc(a,"scatter"),Hd({withTransition:!0})},Sd.toArea=function(a){Hc(a,"area"),Hd({withTransition:!0})},Sd.toAreaSpline=function(a){Hc(a,"area-spline"),Hd({withTransition:!0})},Sd.toPie=function(a){Hc(a,"pie"),Hd({withTransition:!0,withTransform:!0})},Sd.toDonut=function(a){Hc(a,"donut"),Hd({withTransition:!0,withTransform:!0})},Sd.groups=function(a){return d(a)?Ve:(Ve=a,Dd(),Ve)},Sd.regions=function(a){return d(a)?ag:(ag=a,Dd(),ag)},Sd.regions.add=function(a){return d(a)?ag:(ag=ag.concat(a),Dd(),ag)},Sd.regions.remove=function(a,b){var d=[].concat(a);return b=e(b)?b:{},d.forEach(function(a){var d=c(b.duration)?b.duration:0;Fg.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),ag=ag.filter(function(b){return b.classes.indexOf(a)<0})}),ag},Sd.data.get=function(a){var b=Sd.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Sd.data.getAsTarget=function(a){var b=Ob(function(b){return b.id===a});return b.length>0?b[0]:void 0},Sd.resize=function(a){Yd=a?a.width:null,Zd=a?a.height:null,Hd()},Sd.destroy=function(){Sd.data.targets=void 0,Sd.data.x={},Lg.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){wd(b)});else if("rows"in f.data)wd(Eb(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");wd(Fb(f.data.columns))}return Sd}}(window); \ No newline at end of file +!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return p>=c||b%Math.ceil(c/p)===0}function f(a){return a0?a:320}function s(){return Oc(Td.data.targets)?0:_d?_d:Af?1:u("y")}function t(){return Oc(Td.data.targets)?0:ae?ae:yg?re*(Ef&&!nf?1.25:1):Ef?If||nf?1:u("y2"):1}function u(){var a=T();return a.isInner?40:60}function v(){return+g.select(Yd).style("width").replace("px","")}function w(){return+g.select(Yd).style("height").replace("px","")}function x(){return ke+2}function y(){return 80}function z(){return he.left+20}function A(){return me+2}function B(){var a=nf?me:ke,b=nb(),c=Kb();return c>1?a*b/(c-1):a}function C(){return jf?yg?150:oe:0}function D(){return jf?yg?pe:40:0}function E(){var a=S();return a.isInner?5:20}function F(){var a,b;ze=nf?1:0,Ae=nf?me:ke,Be=nf?0:me,Ce=nf?ke:1,De=ze,Ee=Ae,Fe=nf?0:ne,Ge=nf?le:1,He=H(ze,Ae,He?He.domain():void 0,function(){return Ne.tickOffset()}),Ie=I(Be,Ce),Je=I(Be,Ce),Ke=H(ze,Ae,Ng,function(a){return a%1?0:Qe.tickOffset()}),Le=I(Fe,Ge),Me=I(Fe,Ge),a=O(),b=P(),Ne=L(He,tg,a,b),Qe=L(Ke,wg,a,b),Oe=M(Ie,ug,Bf,Df),Pe=M(Je,vg,Jf,Lf),G()}function G(){ve=cb(),we=db(),xe=db(.98)}function H(a,b,c,f){var h=(lg?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),mg){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function I(a,b){return g.scale.linear().range([a,b])}function J(a){return"y2"===N(a)?Je:Ie}function K(a){return"y2"===N(a)?Me:Le}function L(a,c,d,e){var f=(mg?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),mg?f.tickCentered(qf):f.tickOffset=function(){var a=nf?me:ke;return a*nb()/Kb()/2},mg&&f.categories(pf),f}function M(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function N(a){return a in Xe?Xe[a]:"y"}function O(){var a=lg?sg:mg?Tb:null;return rf&&("function"==typeof rf?a=rf:lg&&(a=function(a){return g.time.format(rf)(a)})),a}function P(){var a=Kb();return sf&&a>tf?tf:a}function Q(a){return"string"==typeof a?a:a?a.text:null}function R(a,b){var c=a&&"object"==typeof a&&a.position?a.position:b;return{isInner:c.indexOf("inner")>=0,isOuter:c.indexOf("outer")>=0,isLeft:c.indexOf("left")>=0,isCenter:c.indexOf("center")>=0,isRight:c.indexOf("right")>=0,isTop:c.indexOf("top")>=0,isMiddle:c.indexOf("middle")>=0,isBottom:c.indexOf("bottom")>=0}}function S(){return R(vf,"inner-right")}function T(){return R(zf,"inner-top")}function U(){return Q(vf)}function V(){return Q(zf)}function W(){var a=S();return a.isLeft?0:a.isCenter?ke/2:ke}function X(){var a=T();return a.isBottom?-me:a.isMiddle?-me/2:0}function Y(){var a=T();return a.isTop?"-0.5em":"0"}function Z(){var a=S();return a.isInner?"-0.5em":"3.5em"}function $(){var a=T(),b=0;return g.selectAll(".y.axis .tick text").each(function(){var a=this.getBBox();b0)for(f=Rb(a),b=0;ba?a:0}),c=1;c0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function lb(a){var b,c,d,e,f,h=Pb(a);if(We.length>0)for(f=Sb(a),b=0;b0?a:0}),c=1;c+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function mb(a){var b=Ob(function(b){return N(b.id)===a}),d="y2"===a?Gf:xf,e="y2"===a?Ff:wf,f=c(d)?d:kb(b),g=c(e)?e:lb(b),h=Math.abs(g-f),i=.1*h,j=i,k=i,l="y2"===a?Hf:yf;if(l){var m=Math.max(Math.abs(f),Math.abs(g));g=m-l,f=l-m}if("y"===a&&Cf&&(j=c(Cf.top)?Cf.top:i,k=c(Cf.bottom)?Cf.bottom:i),"y2"===a&&Kf&&(j=c(Kf.top)?Kf.top:i,k=c(Kf.bottom)?Kf.bottom:i),jc()&&nf){var n=kc(f,g),o=sb(Ie.range()),p=[n[0]/o,n[1]/o];j+=h*(p[1]/(1-p[0]-p[1])),k+=h*(p[0]/(1-p[0]-p[1]))}return Kc(b)&&!Rb(b)&&(k=f),[f-k,g+j]}function nb(a){return a?1:sb(Ng)/sb(He.domain())}function ob(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function pb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function qb(a,b){var c,d=b[0],e=b[1],f=Math.abs(d-e);return c=mg?0:Kc(a)?f/(Kb()-1)/2:.01*f}function rb(a){var b=[ob(a),pb(a)],c=b[0],d=b[1],e=qb(a,b),f=lg?new Date(c.getTime()-e):c-e,g=lg?new Date(d.getTime()+e):d+e;return[f,g]}function sb(a){return a[1]-a[0]}function tb(a){for(var b=0;bd?0:d}function yb(a){return Re&&a===Re||Se&&cd(Se,a)}function zb(a){return!yb(a)}function Ab(a){return Re?Re:Se?Se[a]:null}function Bb(a,b){return a in Td.data.x&&Td.data.x[a]&&Td.data.x[a][b]?Td.data.x[a][b]:b}function Cb(a){Object.keys(a).forEach(function(b){Se[b]=a[b]})}function Db(a){var b;return a&&(b=Ve[a.id],a.name=b?b:a.id),a}function Eb(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?b.map(function(a){return a[c]}):Td.data.x[Object.keys(Td.data.x)[0]]}),c=d.map(function(a){var c=Ue(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=Ab(a);return e=lg?$c(b[f]):ng?b[f]?+b[f]:Bb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),Ye&&Ic(Mb(c).filter(function(a){return!(a in Ze)}),Ye),c.forEach(function(a){ub(a.id_org,a)}),c)}function Hb(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Ib(a){return a>0&&Td.data.targets[0].values[a-1]?Td.data.targets[0].values[a-1].x:void 0}function Jb(a){return a1?Td.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Td.data.targets[0]:null,a}function Mb(a){return a=d(a)?Td.data.targets:a,a.map(function(a){return a.id})}function Nb(a){var b,c=Mb();for(b=0;ba})}function Sb(a){return Qb(a,function(a){return a>0})}function Tb(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(qc(a,f))),a[g].x&&(e=e.concat(qc(a,g))),tc(e,b)):rc(a,b,f,g)}function sc(a,b){var c;return c=a.map(function(a){return rc(a.values,b)}),tc(c,b)}function tc(a,b){var c,d;return a.forEach(function(a){var e=dd(a,b);(c>e||!c)&&(c=e,d=a)}),d}function uc(){return _e&&"desc"===_e.toLowerCase()}function vc(){return _e&&"asc"===_e.toLowerCase()}function wc(a){var b=vc(),c=uc();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof _e&&a.sort(_e),a}function xc(a,b){var d,e,f,g,h,i,j,k=a.filter(function(a){return a&&c(a.value)});cg&&0!==k.length&&(Lg.html(fg(a,O(),pc,rg)).style("visibility","hidden").style("display","block"),d=Lg.property("offsetWidth"),e=Lg.property("offsetHeight"),nf?(f=p(),g=f+b[0]+100,h=g+d,j=q()-t(),i=He(k[0].x)+20):(f=p(),g=f+s()+He(k[0].x)+20,h=g+d,j=f+q()-t(),i=b[1]+15),h>j&&(g-=d+60),i+e>r()&&(i-=e+30),Lg.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function yc(){Lg.style("display","none")}function zc(a){var b=a.filter(function(a){return a&&c(a.value)});cg&&(Lc(Td.data.targets)||Oc(Td.data.targets)||Ig.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(nf?"y1":"x1",lc).attr(nf?"y2":"x2",lc))}function Ac(){Ig.select("line.xgrid-focus").style("visibility","hidden")}function Bc(a){return a.x||0===a.x?He(a.x):null}function Cc(a){return J(a.id)(a.value)}function Dc(){var a,b,c={},e=0;return Ob(Rc).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Hc(a,b){return b?2*a.tickOffset()*.6/b:0}function Ic(a,b){var c=d(a)?Mb():a;"string"==typeof c&&(c=[c]);for(var e=0;e=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function xd(b){var c,d,e,f,h;if(Mg=g.select(Yd),Mg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Mg.html(""),Td.data.x={},Td.data.targets=Gb(b),n(),F(),He.domain(g.extent(rb(Td.data.targets))),Ie.domain(mb("y")),Je.domain(mb("y2")),Ke.domain(He.domain()),Le.domain(Ie.domain()),Me.domain(Je.domain()),Ng=He.domain(),Bg.scale(Ke),be&&Fg.scale(He),Gg=g.select(Yd).append("svg").attr("width",ke+he.left+he.right).attr("height",me+he.top+he.bottom).on("mouseenter",ee).on("mouseleave",fe),Hg=Gg.append("defs"),Hg.append("clipPath").attr("id",jg).append("rect").attr("width",ke).attr("height",me),Hg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",x).attr("height",y),Hg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-he.left+1).attr("width",z).attr("height",A),Ig=Gg.append("g").attr("transform",xg.main),Jg=ff?Gg.append("g").attr("transform",xg.context):null,Kg=jf?Gg.append("g").attr("transform",xg.legend):null,Lg=g.select(Yd).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Ig.append("g").attr("class","x axis").attr("clip-path",nf?"":"url("+document.URL+"#xaxis-clip)").attr("transform",xg.x).append("text").attr("class","-axis-x-label").attr("dy",Z).style("text-anchor",_).text(nf?V:U),Ig.append("g").attr("class","y axis").attr("clip-path",nf?"url("+document.URL+"#yaxis-clip)":"").append("text").attr("class","-axis-y-label").attr("transform","rotate(-90)").attr("dx",Y).style("text-anchor",ab).text(nf?U:V),Ef&&Ig.append("g").attr("class","y2 axis").attr("transform",xg.y2),d=Ig.append("g").attr("clip-path",kg).attr("class","grid"),Mf&&d.append("g").attr("class","xgrids"),Of&&(e=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Of).enter().append("g").attr("class","xgrid-line"),e.append("line").attr("class",function(a){return""+a["class"]}),e.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",nf?"":"rotate(-90)").attr("dx",nf?0:-he.top).attr("dy",-5).text(function(a){return a.text})),Uf&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",nf?0:-10).attr("x2",nf?ke:-10).attr("y1",nf?-10:he.top).attr("y2",nf?-10:me),Pf&&d.append("g").attr("class","ygrids"),Qf&&(f=d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Qf).enter().append("g").attr("class","ygrid-line"),f.append("line").attr("class",function(a){return""+a["class"]}),f.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",nf?"rotate(-90)":"").attr("dx",nf?0:-he.top).attr("dy",-5).text(function(a){return a.text})),Ig.append("g").attr("clip-path",kg).attr("class","regions"),Ig.append("g").attr("clip-path",kg).attr("class","chart"),c=Ig.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",be?nf?"ns-resize":"ew-resize":null),Ig.select(".chart").append("g").attr("class","chart-bars"),Ig.select(".chart").append("g").attr("class","chart-lines"),Ig.select(".chart").append("g").attr("class","chart-arcs").attr("transform",xg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(ag),Ig.select(".chart").append("g").attr("class","chart-texts"),be&&Ig.insert("rect",de?null:"g.grid").attr("class","zoom-rect").attr("width",ke).attr("height",me).style("opacity",0).style("cursor",nf?"ns-resize":"ew-resize").call(Fg).on("dblclick.zoom",null),null!==uf&&Bg.extent("function"!=typeof uf?uf:uf(rb())),ff&&(Jg.append("g").attr("clip-path",kg).attr("class","chart"),Jg.select(".chart").append("g").attr("class","chart-bars"),Jg.select(".chart").append("g").attr("class","chart-lines"),Jg.append("g").attr("clip-path",kg).attr("class","x brush").call(Bg).selectAll("rect").attr(nf?"width":"height",nf?le:ne),Jg.append("g").attr("class","x axis").attr("transform",xg.subx).attr("clip-path",nf?"url("+document.URL+"#yaxis-clip)":"")),jf&&Od(Td.data.targets),Jd(Td.data.targets),Ed({withTransform:!0,withUpdateXDomain:!0}),gg){if(lg&&"string"==typeof hg){for(hg=$c(hg),h=0;h0){d=[];for(var f in Ve)for(c=0;cf&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=jd,o=c+e>f&&h>c&&j>d),o^n&&(l.classed(Xd,!n),l.classed(Wd,!m),k(!m,l,a,b))}))}function Cd(a){Oc(Td.data.targets)||cf&&(og=a,Ig.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),pg=!0)}function Dd(){Oc(Td.data.targets)||cf&&(Ig.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Ig.selectAll(".-shape").classed(Xd,!1),pg=!1)}function Ed(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,C,D,E,F=Dc(),G=Oc(Td.data.targets);if(a=e(a)?a:{},s=e(a.withY)?a.withY:!0,t=e(a.withSubchart)?a.withSubchart:!0,u=e(a.withTransition)?a.withTransition:!0,v=e(a.withTransform)?a.withTransform:!1,w=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,x=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,D=u?ge:0,E=e(a.durationForExit)?a.durationForExit:D,x&&(He.domain(g.extent(rb(Td.data.targets))),Ng=He.domain(),be&&Fg.scale(He).updateScaleExtent(),Ke.domain(He.domain()),Bg.scale(Ke)),w&&(He.domain(Bg.empty()?Ng:Bg.extent()),be&&Fg.scale(He).updateScaleExtent()),Ie.domain(mb("y")),Je.domain(mb("y2")),Ig.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(nf?Oe:Ne),Ig.select(".y.axis").style("opacity",G?0:1).transition().duration(D).call(nf?Ne:Oe),Ig.select(".y2.axis").style("opacity",G?0:1).transition().call(Pe),y=rd(F),A=sd(F,!0),C=sd(F,!1),Ig.select(".x.axis .-axis-x-label").attr("x",W),Ig.select(".y.axis .-axis-y-label").attr("x",X).attr("dy",$),Le.domain(Ie.domain()),Me.domain(Je.domain()),Lg.style("display","none"),Ig.select("line.xgrid-focus").style("visibility","hidden").attr("y2",me),Mf){if("year"===Nf){d=[];for(var H=rb(),I=H[0].getFullYear(),J=H[1].getFullYear(),K=I;J>=K;K++)d.push(new Date(K+"-01-01 00:00:00"))}else d=He.ticks(10);b=Ig.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",nf?0:function(a){return He(a)-Ne.tickOffset()}).attr("x2",nf?ke:function(a){return He(a)-Ne.tickOffset()}).attr("y1",nf?function(a){return He(a)-Ne.tickOffset()}:he.top).attr("y2",nf?function(a){return He(a)-Ne.tickOffset()}:me).style("opacity",function(){return+g.select(this).attr(nf?"y1":"x1")===(nf?me:0)?0:1}),b.exit().remove()}Of&&(f=Ig.selectAll(".xgrid-lines"),f.selectAll("line").transition().duration(D).attr("x1",nf?0:mc).attr("x2",nf?ke:mc).attr("y1",nf?mc:he.top).attr("y2",nf?mc:me),f.selectAll("text").attr("x",nf?ke:0).attr("y",mc)),s&&Pf&&(h=Ig.select(".ygrids").selectAll(".ygrid").data(Ie.ticks(Rf)),h.enter().append("line").attr("class","ygrid"),h.attr("x1",nf?Ie:0).attr("x2",nf?Ie:ke).attr("y1",nf?0:Ie).attr("y2",nf?me:Ie),h.exit().remove()),s&&Qf&&(i=Ig.select(".ygrid-lines"),i.selectAll("line").transition().duration(D).attr("x1",nf?nc:0).attr("x2",nf?nc:ke).attr("y1",nf?0:nc).attr("y2",nf?me:nc),i.selectAll("text").attr("x",nf?0:ke).attr("y",nc)),k=Ig.selectAll(".-bars").selectAll(".-bar").data(Wc),k.enter().append("path").attr("d",y).style("stroke","none").style("opacity",0).style("fill",function(a){return rg(a.id)}).attr("class",cc),k.style("opacity",fc).transition().duration(D).attr("d",y).style("opacity",1),k.exit().transition().duration(E).style("opacity",0).remove(),m=Ig.selectAll(".-texts").selectAll(".-text").data(Yc),m.enter().append("text").attr("class",Ub).attr("text-anchor",function(a){return nf?a.value<0?"end":"start":"middle" +}).style("stroke","none").style("fill-opacity",0).text(function(a){return pc(a.value)}),m.style("fill-opacity",gc).transition().duration(D).attr("x",A).attr("y",C).style("fill-opacity",ic),m.exit().transition().duration(E).style("fill-opacity",0).remove(),Ig.selectAll(".-line").style("opacity",fc).transition().duration(D).attr("d",Cg).style("opacity",1),Ig.selectAll(".-area").style("opacity",0).transition().duration(D).attr("d",Dg).style("opacity",Og),j=Ig.selectAll(".-circles").selectAll(".-circle").data(Xc),j.enter().append("circle").attr("class",bc).style("opacity",0).attr("r",Tf),j.style("opacity",fc).transition().duration(D).style("opacity",hc).attr("cx",nf?Cc:Bc).attr("cy",nf?Bc:Cc),j.exit().remove(),Ig.selectAll(".chart-arc").select(".-arc").attr("transform",v?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(D).attrTween("d",function(a){var b=bb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return eb(c(a),!0)}}).attr("transform",v?"scale(1)":"").style("opacity",1),Ig.selectAll(".chart-arc").select("text").attr("transform",fb).style("opacity",0).transition().duration(D).text(hb).style("opacity",function(a){return Vc(a.data)?1:0}),Ig.select(".chart-arcs-title").style("opacity",Nc(Td.data.targets)?1:0),ff&&(null!==g.event&&"zoom"===g.event.type&&Bg.extent(He.orgDomain()).update(),t&&(Jg.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(Qe),Bg.empty()||Bg.extent(He.orgDomain()).update(),z=rd(F,!0),n=Jg.selectAll(".-bars").selectAll(".-bar").data(Wc),n.enter().append("path").attr("d",z).style("stroke","none").style("fill",function(a){return rg(a.id)}).attr("class",cc),n.style("opacity",fc).transition().duration(D).attr("d",z).style("opacity",1),n.exit().transition().duration(D).style("opacity",0).remove(),Jg.selectAll(".-line").style("opacity",fc).transition().duration(D).attr("d",Eg).style("opacity",1))),Ig.selectAll(".selected-circles").filter(function(a){return Rc(a)}).selectAll("circle").remove(),Ig.selectAll(".selected-circle").transition().duration(D).attr("cx",nf?Cc:Bc).attr("cy",nf?Bc:Cc),Se?(o=Ig.select(".event-rects").selectAll(".event-rect").data([0]),zd(o.enter()),o.attr("x",0).attr("y",0).attr("width",ke).attr("height",me)):(ng?(r=function(a,b){var c=Ib(b),d=Jb(b);return(He(d?d:a.x+50)-He(c?c:a.x-50))/2},q=function(a,b){var c=Ib(b);return(He(a.x)+He(c?c:a.x-50))/2}):(r=B(),q=function(a){return He(a.x)-r/2}),p=Lb(),Ig.select(".event-rects").datum(p?p.values:[]),o=Ig.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),yd(o.enter()),o.attr("class",ec).attr("x",nf?0:q).attr("y",nf?q:0).attr("width",nf?ke:r).attr("height",nf?r:me),o.exit().remove()),l=Ig.select(".regions").selectAll("rect.region").data(bg),l.enter().append("rect").style("fill-opacity",0),l.attr("class",dc).attr("x",nf?0:wb).attr("y",nf?wb:he.top).attr("width",nf?ke:xb).attr("height",nf?xb:me).transition().duration(D).style("fill-opacity",function(a){return c(a.opacity)?a.opacity:.1}),l.exit().transition().duration(D).style("fill-opacity",0).remove(),jf&&Od(Td.data.targets,{withTransition:u}),Mb().forEach(function(a){Pg[a]=!0})}function Fd(){Ed({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Gd(){return"mousemove"===g.event.sourceEvent.type&&Fg.altDomain?(He.domain(Fg.altDomain),void Fg.scale(He).updateScaleExtent()):(mg&&He.orgDomain()[0]===Ng[0]&&He.domain([Ng[0]-1e-10,He.orgDomain()[1]]),Ed({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(qg=!0)))}function Hd(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Id(a){var b,c;a=e(a)?a:{},b=e(a.withTransition)?a.withTransition:!1,c=e(a.withTransform)?a.withTransform:!1,n(),F(),Bg.scale(Ke),be&&Fg.scale(He),Gg.attr("width",oe).attr("height",pe),Gg.select("#"+jg).select("rect").attr("width",ke).attr("height",me),Gg.select("#xaxis-clip").select("rect").attr("width",x),Gg.select(".zoom-rect").attr("width",ke).attr("height",me),m(b),Ed({withTransition:b,withUpdateXDomain:!0,withTransform:c,durationForExit:0})}function Jd(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=Ig.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none"),j.append("g").attr("class",Vb).style("fill",function(a){return rg(a.id)}),e=Ig.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none"),d.append("g").attr("class",Zb).style("fill",function(a){return rg(a.id)}).style("stroke","none").style("cursor",function(a){return ef(a)?"pointer":null}),c=Ig.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none"),b.append("path").attr("class",Xb).style("opacity",0).style("stroke",function(a){return rg(a.id)}),b.append("path").attr("class",_b).style("opacity",function(){return Og=+g.select(this).style("opacity"),0}).style("fill",function(a){return rg(a.id)}),b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id}),b.append("g").attr("class",Yb).style("fill",function(a){return rg(a.id)}).style("cursor",function(a){return ef(a)?"pointer":null}),a.forEach(function(a){var b=Pd(a.id);Ig.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=Ig.select(".chart-arcs").selectAll(".chart-arc").data(ye(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",$b).style("opacity",0).style("fill",function(a){return rg(a.data.id)}).style("cursor",function(a){return ef(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){ib(a.data.id),Ld(a.data.id)}).on("mouseout",function(a){jb(a.data.id),Nd()}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),ff&&(n=Jg.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),m.append("g").attr("class",Zb).style("fill",function(a){return rg(a.id)}),l=Jg.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),k.append("path").attr("class",Xb).style("opacity",0).style("stroke",function(a){return rg(a.id)})),jf&&Od(a),Gg.selectAll(".target").transition().style("opacity",1)}function Kd(a,b){Td.data.targets.forEach(function(b){for(var c=0;c=d&&(Object.keys(w).forEach(function(a){w[a]=h}),yg||(p=(re-h*Object.keys(a).length)/2)),i>=e&&(Object.keys(x).forEach(function(a){x[a]=i}),yg&&(p=(qe-i*Object.keys(a).length)/2))):(v[c]=u,u+=j,p=(k-u)/2)}var i,j,k,l,m,n,o,p,q,r=Mb(a),s=4,t=30,u=0,v={},w={},x={};b=d(b)?{}:b,q=e(b.withTransition)?b.withTransition:!0,yg?(j=function(){return.2*re},m=function(a,b){return p+f(a,b)}):(j=function(a,b){return p+c(a,b)},m=function(){return.2*qe}),k=function(a,b){return j(a,b)+14},n=function(a,b){return m(a,b)+9},l=function(a,b){return j(a,b)-4},o=function(a,b){return m(a,b)-7},i=Kg.selectAll(".legend-item").data(r).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){lf(a)}).on("mouseover",function(a){Ld(a),Td.focus(a)}).on("mouseout",function(){Nd(),Td.revert()}),i.append("text").text(function(a){return e(Ve[a])?Ve[a]:a}).each(function(a){h(this,a)}).style("pointer-events","none").attr("x",yg?k:-200).attr("y",yg?-200:m),i.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",yg?l:-200).attr("y",yg?-200:o).attr("width",function(a){return w[a]}).attr("height",function(a){return x[a]}),i.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return rg(a)}).attr("x",yg?k:-200).attr("y",yg?-200:n).attr("width",10).attr("height",10),Kg.selectAll("text").data(r).each(function(a){h(this,a)}).transition().duration(q?250:0).attr("x",k).attr("y",n),Kg.selectAll("rect.legend-item-event").data(r).transition().duration(q?250:0).attr("x",l).attr("y",o),Kg.selectAll("rect.legend-item-tile").data(r).transition().duration(q?250:0).attr("x",j).attr("y",m)}function Pd(a){return a?"-"+a.replace(/\./g,"\\."):""}function Qd(a){return".target"+Pd(a)}function Rd(a){return Nb(a.id)}function Sd(a){return"data"in a&&Nb(a.data.id)}var Td={data:{}},Ud={},Vd="_expanded_",Wd="_selected_",Xd="_included_",Yd=i(["bindto"],"#chart"),Zd=i(["size","width"],null),$d=i(["size","height"],null),_d=i(["padding","left"],null),ae=i(["padding","right"],null),be=i(["zoom","enabled"],!1),ce=i(["zoom","extent"],null),de=i(["zoom","privileged"],!1),ee=i(["onenter"],function(){}),fe=i(["onleave"],function(){}),ge=i(["transition","duration"],350);h("data","data is required in config");var he,ie,je,ke,le,me,ne,oe,pe,qe,re,se,te,ue,ve,we,xe,ye,ze,Ae,Be,Ce,De,Ee,Fe,Ge,He,Ie,Je,Ke,Le,Me,Ne,Oe,Pe,Qe,Re=i(["data","x"],null),Se=i(["data","xs"],null),Te=i(["data","x_format"],"%Y-%m-%d"),Ue=i(["data","id_converter"],function(a){return a}),Ve=i(["data","names"],{}),We=i(["data","groups"],[]),Xe=i(["data","axes"],{}),Ye=i(["data","type"],null),Ze=i(["data","types"],{}),$e=i(["data","labels"],{}),_e=i(["data","order"],null),af=i(["data","regions"],{}),bf=i(["data","colors"],{}),cf=i(["data","selection","enabled"],!1),df=i(["data","selection","grouped"],!1),ef=i(["data","selection","isselectable"],function(){return!0}),ff=i(["subchart","show"],!1),gf=ff?i(["subchart","size","height"],60):0,hf=i(["color","pattern"],null),jf=i(["legend","show"],!0),kf=i(["legend","position"],"bottom"),lf=i(["legend","item","onclick"],function(){}),mf=i(["legend","equally"],!1),nf=i(["axis","rotated"],!1),of=i(["axis","x","type"],"indexed"),pf=i(["axis","x","categories"],[]),qf=i(["axis","x","tick","centered"],!1),rf=i(["axis","x","tick","format"],null),sf=i(["axis","x","tick","culling"],"categorized"===of?!1:!0),tf=i(["axis","x","tick","count"],10),uf=i(["axis","x","default"],null),vf=i(["axis","x","label"],null),wf=i(["axis","y","max"],null),xf=i(["axis","y","min"],null),yf=i(["axis","y","center"],null),zf=i(["axis","y","label"],null),Af=i(["axis","y","inner"],!1),Bf=i(["axis","y","tick","format"],null),Cf=i(["axis","y","padding"],null),Df=i(["axis","y","ticks"],10),Ef=i(["axis","y2","show"],!1),Ff=i(["axis","y2","max"],null),Gf=i(["axis","y2","min"],null),Hf=i(["axis","y2","center"],null),If=i(["axis","y2","inner"],!1),Jf=i(["axis","y2","tick","format"],null),Kf=i(["axis","y2","padding"],null),Lf=i(["axis","y2","ticks"],10),Mf=i(["grid","x","show"],!1),Nf=i(["grid","x","type"],"tick"),Of=i(["grid","x","lines"],null),Pf=i(["grid","y","show"],!1),Qf=i(["grid","y","lines"],null),Rf=i(["grid","y","ticks"],10),Sf=i(["point","show"],!0),Tf=Sf?i(["point","r"],2.5):0,Uf=i(["point","focus","line","enabled"],!0),Vf=i(["point","focus","expand","enabled"],!0),Wf=i(["point","focus","expand","r"],Vf?4:Tf),Xf=i(["point","focus","select","r"],8),Yf=i(["point","onclick"],function(){}),Zf=i(["point","onselected"],function(){}),$f=i(["point","onunselected"],function(){}),_f=i(["arc","label","format"],function(a,b){return(100*b).toFixed(1)+"%"}),ag=i(["arc","title"],""),bg=i(["regions"],[]),cg=i(["tooltip","show"],!0),dg=i(["tooltip","format","title"],null),eg=i(["tooltip","format","value"],null),fg=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=dg?dg:b,k=eg?eg:c;for(f=0;f"+g+""),i=a[f].name,h=k(a[f].value),e+=""+i+""+h+"");return e+""}),gg=i(["tooltip","init","show"],!1),hg=i(["tooltip","init","x"],0),ig=i(["tooltip","init","position"],{top:"0px",left:"50px"}),jg=Yd.replace("#","")+"-clip",kg="url("+document.URL+"#"+jg+")",lg="timeseries"===of,mg="categorized"===of,ng=!lg&&(Re||Se),og=null,pg=!1,qg=!1,rg=Zc(bf,hf),sg=function(){var a=[[g.time.format("%Y/%-m/%-d"),function(){return!0}],[g.time.format("%-m/%-d"),function(a){return a.getMonth()}],[g.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[g.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[g.time.format("%I %p"),function(a){return a.getHours()}],[g.time.format("%I:%M"),function(a){return a.getMinutes()}],[g.time.format(":%S"),function(a){return a.getSeconds()}],[g.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),tg=nf?"left":"bottom",ug=nf?Af?"top":"bottom":Af?"right":"left",vg=nf?If?"bottom":"top":If?"left":"right",wg=nf?"left":"bottom",xg={main:function(){return"translate("+he.left+","+he.top+")"},context:function(){return"translate("+ie.left+","+ie.top+")"},legend:function(){return"translate("+je.left+","+je.top+")"},y2:function(){return"translate("+(nf?0:ke)+","+(nf?1:0)+")"},x:function(){return"translate(0,"+me+")"},subx:function(){return"translate(0,"+(nf?0:ne)+")"},arc:function(){return"translate("+ke/2+","+me/2+")"}},yg="right"===kf,zg=40,Ag=20;ye=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Bg,Cg=function(){var a=g.svg.line().x(nf?function(a){return J(a.id)(a.value)}:lc).y(nf?lc:function(a){return J(a.id)(a.value)});return function(b){var c,d,e=kd(b.values);return Pc(b)?(a.interpolate(Qc(b)?"cardinal":"linear"),af[b.id]?wd(e,He,J(b.id),af[b.id]):a(e)):(c=He(e[0].x),d=J(b.id)(e[0].value),nf?"M "+d+" "+c:"M "+c+" "+d)}}(),Dg=function(){var a;return a=nf?g.svg.area().x0(function(a){return J(a.id)(0)}).x1(function(a){return J(a.id)(a.value)}).y(lc):g.svg.area().x(lc).y0(function(a){return J(a.id)(0)}).y1(function(a){return J(a.id)(a.value)}),function(b){var c,d,e=kd(b.values);return Jc([b],"area")||Jc([b],"area-spline")?(a.interpolate(Qc(b)?"cardinal":"linear"),a(e)):(c=He(e[0].x),d=J(b.id)(e[0].value),nf?"M "+d+" "+c:"M "+c+" "+d)}}(),Eg=function(){var a=g.svg.line().x(nf?function(a){return K(a.id)(a.value)}:oc).y(nf?oc:function(a){return K(a.id)(a.value)});return function(b){var c=kd(b.values);return Pc(b)?a(c):"M "+Ke(c[0].x)+" "+K(b.id)(c[0].value)}}(),Fg=function(){};Bg=g.svg.brush().on("brush",Fd),Bg.update=function(){return Jg&&Jg.select(".x.brush").call(this),this},Bg.scale=function(a){return nf?this.y(a):this.x(a)},be&&(Fg=g.behavior.zoom().on("zoomstart",function(){Fg.altDomain=g.event.sourceEvent.altKey?He.orgDomain():null}).on("zoom",be?Gd:null),Fg.scale=function(a){return nf?this.y(a):this.x(a)},Fg.orgScaleExtent=function(){var a=ce?ce:[1,10];return[a[0],Math.max(Kb()/a[1],a[1])]},Fg.updateScaleExtent=function(){var a=sb(He.orgDomain())/sb(Ng),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Gg,Hg,Ig,Jg,Kg,Lg,Mg,Ng,Og,Pg={};if(Td.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Gg.selectAll(Qd(a)),d=c.filter(Rd),e=c.filter(Sd);Td.revert(),Td.defocus(),b(d.classed("focused",!0)),b(e),Oc(Td.data.targets)&&ib(a,!0),Ld(a)},Td.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Gg.selectAll(Qd(a)),d=c.filter(Rd),e=c.filter(Sd);Td.revert(),b(d.classed("focused",!1)),b(e),Oc(Td.data.targets)&&jb(a),Md(a)},Td.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Gg.selectAll(Qd(a)),d=c.filter(Rd),e=c.filter(Sd);b(d.classed("focused",!1)),b(e),Oc(Td.data.targets)&&jb(a),Nd()},Td.show=function(a){Gg.selectAll(Qd(a)).transition().style("opacity",1)},Td.hide=function(a){Gg.selectAll(Qd(a)).transition().style("opacity",0)},Td.unzoom=function(){Bg.clear().update(),Ed({withUpdateXDomain:!0})},Td.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&Cb(a.xs),"categories"in a&&mg&&(pf=a.categories,Ne.categories(pf)),"cacheIds"in a&&tb(a.cacheIds))return void Kd(vb(a.cacheIds),a.done);if("data"in a)Kd(Gb(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){Kd(Gb(c),a.done)});else if("rows"in a)Kd(Gb(Eb(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");Kd(Gb(Fb(a.columns)),a.done)}},Td.unload=function(a){Td.data.targets=Td.data.targets.filter(function(b){return b.id!==a}),Gg.selectAll(Qd(a)).transition().style("opacity",0).remove(),jf&&(Gg.selectAll(".legend-item"+Pd(a)).remove(),Od(Td.data.targets)),Td.data.targets.length>0&&Ed({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},Td.selected=function(a){var b=Pd(a);return g.merge(Ig.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(Wd)}).map(function(a){return a.map(function(a){return a.__data__})}))},Td.select=function(a,b,c){cf&&Ig.selectAll(".-shapes").selectAll(".-shape").each(function(f,h){var i="circle"===this.nodeName?ed:hd,j="circle"===this.nodeName?fd:id;b.indexOf(h)>=0?ef(f)&&(df||d(a)||a.indexOf(f.id)>=0)&&i(g.select(this).classed(Wd,!0),f,h):e(c)&&c&&j(g.select(this).classed(Wd,!1),f,h)})},Td.unselect=function(a,b){cf&&Ig.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?fd:id;(d(b)||b.indexOf(e)>=0)&&ef(c)&&(df||d(a)||a.indexOf(c.id)>=0)&&f(g.select(this).classed(Wd,!1),c,e)})},Td.toLine=function(a){Ic(a,"line"),Id({withTransition:!0})},Td.toSpline=function(a){Ic(a,"spline"),Id({withTransition:!0})},Td.toBar=function(a){Ic(a,"bar"),Id({withTransition:!0})},Td.toScatter=function(a){Ic(a,"scatter"),Id({withTransition:!0})},Td.toArea=function(a){Ic(a,"area"),Id({withTransition:!0})},Td.toAreaSpline=function(a){Ic(a,"area-spline"),Id({withTransition:!0})},Td.toPie=function(a){Ic(a,"pie"),Id({withTransition:!0,withTransform:!0})},Td.toDonut=function(a){Ic(a,"donut"),Id({withTransition:!0,withTransform:!0})},Td.groups=function(a){return d(a)?We:(We=a,Ed(),We)},Td.regions=function(a){return d(a)?bg:(bg=a,Ed(),bg)},Td.regions.add=function(a){return d(a)?bg:(bg=bg.concat(a),Ed(),bg)},Td.regions.remove=function(a,b){var d=[].concat(a);return b=e(b)?b:{},d.forEach(function(a){var d=c(b.duration)?b.duration:0;Gg.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),bg=bg.filter(function(b){return b.classes.indexOf(a)<0})}),bg},Td.data.get=function(a){var b=Td.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Td.data.getAsTarget=function(a){var b=Ob(function(b){return b.id===a});return b.length>0?b[0]:void 0},Td.resize=function(a){Zd=a?a.width:null,$d=a?a.height:null,Id()},Td.destroy=function(){Td.data.targets=void 0,Td.data.x={},Mg.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){xd(b)});else if("rows"in f.data)xd(Eb(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");xd(Fb(f.data.columns))}return Td}}(window); \ No newline at end of file