(function(O){function vd(){function t(e,g){e.attr("transform",function(e){return"translate("+(g(e)+fa)+", 0)"})}function y(e,g){e.attr("transform",function(e){return"translate(0,"+g(e)+")"})}function O(e){var g=e[0];e=e[e.length-1];return ga?a:0}),c=1;c+a||(b[d][c]+=+a)});return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}function nb(a){var b=ob(function(b){return R(b.id)===a}),c="y2"===a?Jd:Kd,d="y2"===a?Ld:Md,c=c?c:Gd(b),d=d?d:Hd(b),f=0.1*Math.abs(d-c),e=f,g=f,h="y2"===a?Nd:Od;h&&(c=Math.max(Math.abs(c),Math.abs(d)),d=c-h,c=h-c);"y"===a&&Ma&&(e=Ma.top?Ma.top:f, g=Ma.bottom?Ma.bottom:f);"y2"===a&&Na&&(e=Na.top?Na.top:f,g=Na.bottom?Na.bottom:f);ia(b,"bar")&&!zc(b)&&(g=c);return[c-g,d+e]}function Pd(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.x})})}function Qd(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function pb(a){var b=[Pd(a),Qd(a)];a=b[0];var b=b[1],c=ja?0:0.01*Math.abs(a-b);a=D?new Date(a.getTime()-c):a-c;b=D?new Date(b.getTime()+c):b+c;return[a,b]}function xa(a){return a[1]-a[0]}function Rd(a){for(var b= 0;ba?0:a}function Cc(a){return qa&&a===qa||ba&&Td(ba,a)}function Ud(a){return!Cc(a)}function Vd(a){Object.keys(a).forEach(function(b){ba[b]=a[b]})}function rb(a){var b;a&&(b=Oa[a.id],a.name=b?b:a.id);return a}function Dc(a){var b= a[0],c={},d=[],f,e;for(f=1;f b&&(c=a,b=a.values.length)}):c=a?k.data.targets[0]:null;return c}function Qa(a){a=y(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Hc(a){var b=Qa(),c;for(c=0;ca})}function Id(a){return Ic(a,function(a){return 0f&&(e-=c+30)),c=b[1]+15+dw[c].indexOf(f.id)))for(d=0;d=e;e+=p)g+=d(a[f-1],a[f],e,m)}return g}function ac(a){var b;tb=e.select(wa);if(tb.empty())O.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{tb.html(""); k.data.x={};k.data.targets=Pa(a);ua();Y();m.domain(e.extent(pb(k.data.targets)));z.domain(nb("y"));aa.domain(nb("y2"));U.domain(m.domain());ib.domain(z.domain());jb.domain(aa.domain());J.ticks(10>a.length?a.length:10);ya.ticks(ne).outerTickSize(0).tickFormat(bc);kb.ticks(oe).outerTickSize(0).tickFormat(pe);T=m.domain();K.scale(U);sa&&F.scale(m);n=e.select(wa).append("svg").attr("width",r+C+$).attr("height",s+q+M).on("mouseenter",qe).on("mouseleave",re);ub=n.append("defs");ub.append("clipPath").attr("id", cc).append("rect").attr("y",q).attr("width",r).attr("height",s-q);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-C).attr("y",-20).attr("width",W).attr("height",na);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-C+1).attr("y",q-1).attr("width",zb).attr("height",wd);l=n.append("g").attr("transform",L.main);G=Ca?n.append("g").attr("transform",L.context):null;Da=Ea?n.append("g").attr("transform",L.legend):null;V=e.select(wa).style("position","relative").append("div").style("position", "absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",h?"":"url(#xaxis-clip)").attr("transform",L.x).call(h?ya:J).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(se);l.append("g").attr("class","y axis").attr("clip-path",h?"url(#yaxis-clip)":"").call(h?J:ya).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(te);Cb&& l.append("g").attr("class","y2 axis").attr("transform",L.y2).call(kb);a=l.append("g").attr("clip-path",Wa).attr("class","grid");id&&a.append("g").attr("class","xgrids");dc&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(dc).enter().append("g").attr("class","xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",h?"":"rotate(-90)").attr("dx",h? 0:-q).attr("dy",-5).text(function(a){return a.text}));ue&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",h?0:-10).attr("x2",h?r:-10).attr("y1",h?-10:q).attr("y2",h?-10:s);jd&&a.append("g").attr("class","ygrids");ec&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(ec).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+ a["class"]}).attr("text-anchor","end").attr("transform",h?"rotate(-90)":"").attr("dx",h?0:-q).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Wa).attr("class","regions");l.append("g").attr("clip-path",Wa).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",sa?h?"ns-resize":"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines"); l.select(".chart").append("g").attr("class","chart-arcs").attr("transform",L.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(ve);if(sa)l.insert("rect",we?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",s).style("opacity",0).style("cursor",h?"ns-resize":"ew-resize").call(F).on("dblclick.zoom",null);null!==vb&&K.extent("function"!==typeof vb?vb:vb(pb()));Ca&&(G.append("g").attr("clip-path",Wa).attr("class","chart"),G.select(".chart").append("g").attr("class", "chart-bars"),G.select(".chart").append("g").attr("class","chart-lines"),G.append("g").attr("clip-path",Wa).attr("class","x brush").call(K).selectAll("rect").attr(h?"width":"height",h?Db:fb),G.append("g").attr("class","x axis").attr("transform",L.subx).attr("clip-path",h?"url(#yaxis-clip)":"").call(hb));Ea&&wb(k.data.targets);kd(k.data.targets);x({withTransform:!0,withUpdateXDomain:!0});if(xe){if(D&&"string"===typeof Fa){Fa=pa(Fa);for(a=0;aSb(c,a)?n.select(".event-rect").style("cursor","pointer"):n.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;E(k.data.targets)||(a=e.mouse(this),c=Sc(k.data.targets,a),100>Sb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){nd(this,c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){od(e.mouse(this))}).on("dragstart",function(){pd(e.mouse(this))}).on("dragend", function(){qd()})).call(F).on("dblclick.zoom",null)}function nd(a,b,c){var d=e.select(a),f=d.classed(ma),g=!1,h;"circle"===a.nodeName?(g=ad(a,1.5*Va),h=dd):"rect"===a.nodeName&&(g=bd(a),h=fd);if(ta||g)ka&&la(b)&&(d.classed(ma,!f),h(!f,d,b,c)),Be(b,d)}function od(a){var b,c,d,f,g,h,m;E(k.data.targets)||!ka||sa&&!F.altDomain||(b=ic[0],c=ic[1],d=a[0],a=a[1],f=Math.min(b,d),g=Math.max(b,d),h=ta?q:Math.min(c,a),m=ta?s:Math.max(c,a),l.select(".dragarea").attr("x",f).attr("y",h).attr("width",g-f).attr("height", m-h),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return la(a)}).each(function(a,b){var c=e.select(this),d=c.classed(ma),k=c.classed(jc),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=dd,l=f",c,d,e,g=bc?bc:function(a){return+a};for(c=0;c"+e+""+d+""}return b+""}),xe=g(["tooltip","init","show"],!1),Fa=g(["tooltip","init","x"],0),ld=g(["tooltip","init","position"],{top:"0px",left:"50px"}),cc=wa.replace("#","")+"-clip",Wa="url(#"+cc+")",D="timeseries"===ud,ja="categorized"===ud,Rb=!D&&(qa||ba),ic=null,Xa=!1,hc=!1,oa=Ea?40:0,N=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" "); return function(b){if(b in a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(Ke,Le),Dd=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}],[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[e.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[e.time.format("%I %p"),function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"), function(a){return a.getSeconds()}],[e.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)}}(),r,Db,s,fb,Ab,va,Ka,Eb,Fb,lb,uc,vc,Nb,Hb,Ib,Jb,Kb,Lb,Mb,m,z,aa,U,ib,jb,J,ya,kb,hb,yd=h?"left":"bottom",zd=h?cb?"top":"bottom":cb?"right":"left",Ad=h?eb?"bottom":"top":eb?"left":"right",Bd=h?"left":"bottom",L={main:function(){return"translate("+C+","+q+")"},context:function(){return"translate("+Ha+","+Ga+")"},legend:function(){return"translate("+ pc+","+oc+")"},y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+(h?0:fb)+")"},arc:function(){return"translate("+r/2+","+s/2+")"}},tc=40,sc=20;Nb=e.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var Ee=function(){var a=e.svg.line().x(h?function(a){return v(a.id)(a.value)}:za).y(h?za:function(a){return v(a.id)(a.value)});return function(b){var c=Xb(b.values),d;if(Ub(b))return Yc(b)? a.interpolate("cardinal"):a.interpolate("linear"),td[b.id]?me(c,m,v(b.id),td[b.id]):a(c);d=m(c[0].x);b=v(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Fe=function(){var a;a=h?e.svg.area().x0(function(a){return v(a.id)(0)}).x1(function(a){return v(a.id)(a.value)}).y(za):e.svg.area().x(za).y0(function(a){return v(a.id)(0)}).y1(function(a){return v(a.id)(a.value)});return function(b){var c=Xb(b.values),d;if(ia([b],"area")||ia([b],"area-spline"))return Yc(b)?a.interpolate("cardinal"):a.interpolate("linear"), a(c);d=m(c[0].x);b=v(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),xb=function(a,b){var c=a.__max__+1,d=1 b.classes.indexOf(a)})});return P};k.data.get=function(a){a=k.data.getAsTarget(a);return t(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=ob(function(b){return b.id===a});return 0