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