(function(O){function td(){function q(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?Hd:Id,d="y2"===a?Jd:Kd,c=c?c:Ed(b),d=d?d:Fd(b),f=0.1*Math.abs(d-c),e=f,g=f,h="y2"===a?Ld:Md;h&&(c=Math.max(Math.abs(c),Math.abs(d)),d=c-h,c=h-c);"y"===a&&La&&(e=La.top?La.top:f, g=La.bottom?La.bottom:f);"y2"===a&&Ma&&(e=Ma.top?Ma.top:f,g=Ma.bottom?Ma.bottom:f);ia(b,"bar")&&!yc(b)&&(g=c);return[c-g,d+e]}function Nd(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.x})})}function Od(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function pb(a){var b=[Nd(a),Od(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 Pd(a){for(var b= 0;ba?0:a}function Bc(a){return qa&&a===qa||ba&&Rd(ba,a)}function Sd(a){return!Bc(a)}function Td(a){Object.keys(a).forEach(function(b){ba[b]=a[b]})}function rb(a){var b;a&&(b=Na[a.id],a.name=b?b:a.id);return a}function Cc(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 Pa(a){a=y(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Gc(a){var b=Pa(),c;for(c=0;ca})}function Gd(a){return Hc(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 $b(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=Oa(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(le).outerTickSize(0).tickFormat(me);kb.ticks(ne).outerTickSize(0).tickFormat(oe);T=m.domain();K.scale(U);sa&&F.scale(m);n=e.select(wa).append("svg").attr("width",r+C+$).attr("height",s+t+M).on("mouseenter",pe).on("mouseleave",qe);ub=n.append("defs");ub.append("clipPath").attr("id",ac).append("rect").attr("y",t).attr("width", r).attr("height",s-t);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",t-1).attr("width",zb).attr("height",ud);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(re);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(se);Cb&&l.append("g").attr("class","y2 axis").attr("transform", L.y2).call(kb);a=l.append("g").attr("clip-path",Va).attr("class","grid");hd&&a.append("g").attr("class","xgrids");bc&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(bc).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:-t).attr("dy",-5).text(function(a){return a.text})); te&&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:t).attr("y2",h?-10:s);id&&a.append("g").attr("class","ygrids");cc&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(cc).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:-t).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Va).attr("class","regions");l.append("g").attr("clip-path",Va).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(ue);if(sa)l.insert("rect",ve?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",Va).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",Va).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);jd(k.data.targets);x({withTransform:!0,withUpdateXDomain:!0});if(we){if(D&&"string"===typeof Fa){Fa=pa(Fa);for(a=0;aRb(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=Rc(k.data.targets,a),100>Rb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){ld(this,c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){md(e.mouse(this))}).on("dragstart",function(){nd(e.mouse(this))}).on("dragend",function(){od()})).call(F).on("dblclick.zoom",null)}function ld(a,b,c){var d=e.select(a),f=d.classed(ma),g= !1,h;"circle"===a.nodeName?(g=$c(a,1.5*Ua),h=cd):"rect"===a.nodeName&&(g=ad(a),h=ed);if(ta||g)ka&&la(b)&&(d.classed(ma,!f),h(!f,d,b,c)),Be(b,d)}function md(a){var b,c,d,f,g,h,m;E(k.data.targets)||!ka||sa&&!F.altDomain||(b=gc[0],c=gc[1],d=a[0],a=a[1],f=Math.min(b,d),g=Math.max(b,d),h=ta?t: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(hc),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=cd,l=f",c,d,e;for(c=0;c"+e+""+d+"");return b+""}),we=g(["tooltip", "init","show"],!1),Fa=g(["tooltip","init","x"],0),kd=g(["tooltip","init","position"],{top:"0px",left:"50px"}),ac=wa.replace("#","")+"-clip",Va="url(#"+ac+")",D="timeseries"===sd,ja="categorized"===sd,Qb=!D&&(qa||ba),gc=null,Wa=!1,fc=!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),Bd=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,Ja,Eb,Fb,lb,tc,uc,Mb,Gb,Hb,Ib,Jb,Kb,Lb,m,z,aa,U,ib,jb,J,ya,kb,hb,wd=h?"left":"bottom",xd=h?cb?"top":"bottom":cb?"right":"left",yd=h?eb?"bottom":"top":eb?"left":"right",zd=h?"left":"bottom",L={main:function(){return"translate("+C+","+t+")"},context:function(){return"translate("+Ha+","+Ga+")"},legend:function(){return"translate("+nc+","+mc+")"},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+")"}},rc=40,qc=20;Mb=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=Wb(b.values),d;if(Tb(b))return Xc(b)?a.interpolate("cardinal"):a.interpolate("linear"),rd[b.id]?ke(c,m,v(b.id),rd[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=Wb(b.values),d;if(ia([b],"area")||ia([b],"area-spline"))return Xc(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=1b.classes.indexOf(a)})});return P};k.data.get=function(a){a=k.data.getAsTarget(a);return q(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