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