(function(T){function hd(){function p(d,e){d.attr("transform",function(d){return"translate("+(e(d)+da)+", 0)"})}function t(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function T(d){var e=d[0];d=d[d.length-1];return ea?0:a}function qc(a){return sa&&a===sa||aa&&Bd(aa,a)}function Cd(a){return!qc(a)}function lb(a){var b=Na[a.id];a.name=p(b)?b:a.id;return a}function rc(a){var b=a[0],c={},h=[],d,J;for(d=1;du[c].indexOf(d.id)))for(h=0;hb?a-b:0};return function(a){var d=b?W(a.id):H(a.id);return c(d(a.value))}}function Ra(a,b){var c=t(a)?mb():a;"string"===typeof c&&(c=[c]);for(var h=0;h=f;f+=u)k+=d(a[e-1],a[e],f,n)}return k}function Mb(a){var b,c;pb=d.select(ya);if(pb.empty())T.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); else{pb.html("");f.data.x={};f.data.targets=Oa(a);wa();Xb();m.domain(d.extent(yd()));x.domain(ib("y"));Y.domain(ib("y2"));fa.domain(m.domain());db.domain(x.domain());eb.domain(Y.domain());D.ticks(10>a.length?a.length:10);pa.ticks(Pd).outerTickSize(0).tickFormat(Qd);fb.ticks(Rd).outerTickSize(0).tickFormat(Sd);Z=m.domain();K.x(fa);ta&&E.x(m);Ta=d.select(ya).append("svg").attr("width",n+C+ea).attr("height",r+q+I).on("mouseenter",Td).on("mouseleave",Ud);qb=Ta.append("defs");qb.append("clipPath").attr("id", Nb).append("rect").attr("y",q).attr("width",n).attr("height",r-q);qb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-C).attr("y",-20).attr("width",V).attr("height",U);qb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-C+1).attr("y",q-1).attr("width",ma).attr("height",tb);k=Ta.append("g").attr("transform",F.main);y=za?Ta.append("g").attr("transform",F.context):null;Aa=Ba?Ta.append("g").attr("transform",F.legend):null;R=d.select(ya).style("position","relative").append("div").style("position", "absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",F.x).call(g?pa:D).append("text").attr("class","-axis-x-label").attr("x",n).attr("dy","-.5em").style("text-anchor","end").text(Vd);k.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?D:pa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Wd);dc&& k.append("g").attr("class","y2 axis").attr("transform",F.y2).call(fb);b=k.append("g").attr("clip-path",Ua).attr("class","grid");Uc&&b.append("g").attr("class","xgrids");Ob&&(c=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Ob).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g? 0:-q).attr("dy",-6).text(function(a){return a.text}));Xd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?n:-10).attr("y1",g?-10:q).attr("y2",g?-10:r);Vc&&b.append("g").attr("class","ygrids");Pb&&b.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Pb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ua).attr("class","regions");k.append("g").attr("clip-path", Ua).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ta?"ew-resize":null);aa?Yd(b):Zd(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");k.select(".chart").append("g").attr("class","chart-arcs").attr("transform",F.arc);if(ta)k.insert("rect",$d?null:"g.grid").attr("class","zoom-rect").attr("width",n).attr("height",r).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom", null);null!==rb&&K.extent("function"!==typeof rb?rb:rb(ga,qa));za&&(y.append("g").attr("clip-path",Ua).attr("class","chart"),y.select(".chart").append("g").attr("class","chart-bars"),y.select(".chart").append("g").attr("class","chart-lines"),y.append("g").attr("clip-path",Ua).attr("class","x brush").call(K).selectAll("rect").attr("height",oa),y.append("g").attr("class","x axis").attr("transform",F.subx).call(Ia));Ba&&sb(f.data.targets);Wc(f.data.targets);B({withTransition:!1,withUpdateXDomain:!0}); if(ae){if(z&&"string"===typeof Ca){Ca=ra(Ca);for(a=0;aFb(c,a)?d.select(".event-rect").style("cursor","pointer"):d.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;A(f.data.targets)||(a=d.mouse(this),c=Bc(f.data.targets,a),100>Fb(c,a)&&k.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){Yc(this, c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Zc(d.mouse(this))}).on("dragstart",function(){$c(d.mouse(this))}).on("dragend",function(){ad()})).call(E).on("dblclick.zoom",null)}function Yc(a,b,c){var e=d.select(a),f=e.classed(la),g=!1,k;"circle"===a.nodeName?(g=Lc(a,1.5*Sa),k=Oc):"rect"===a.nodeName&&(g=Mc(a),k=Qc);if(ua||g)ja&&ka(b)&&(e.classed(la,!f),k(!f,e,b,c)),ce(b,e)}function Zc(a){var b,c,e,g,m,v,l;A(f.data.targets)||!ja||ta&&!E.altDomain||(b=Tb[0],c=Tb[1],e=a[0], a=a[1],g=Math.min(b,e),m=Math.max(b,e),v=ua?q:Math.min(c,a),l=ua?r:Math.max(c,a),k.select(".dragarea").attr("x",g).attr("y",v).attr("width",m-g).attr("height",l-v),k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ka(a)}).each(function(a,b){var c=d.select(this),e=c.classed(la),h=c.classed(Ub),f,k,p,n;f=!1;"circle"===this.nodeName?(f=1*c.attr("cx"),k=1*c.attr("cy"),n=Oc,f=g",c,d,e;for(c=0;c"+e+""+d+"";return b+""}),ae=e(["tooltip","init","show"],!1),Ca=e(["tooltip","init","x"],0),Xc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Nb=ya.replace("#","")+"-clip",Ua="url(#"+Nb+")",z="timeseries"===gd,$="categorized"===gd,Eb=!z&&(sa||aa),Tb=null,Va=!1,Sb=!1,na=Ba?40:0,S=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]}}(ie,je),pd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"), function(a){return a.getSeconds()}],[d.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)}}(),$b,gc,bc,bb,fc,hc,n,r,oa,ub,xa,cb,xb,gb,lc,mc,Ab,jc,kc,yb,zb,m,x,Y,fa,db,eb,D,pa,fb,Ia,kd=g?"left":"bottom",ld=g?wb?"top":"bottom":wb?"right":"left",md=g?vb?"bottom":"top":vb?"left":"right",nd="bottom",F={main:function(){return"translate("+C+","+q+")"},context:function(){return"translate("+l+","+Da+")"},legend:function(){return"translate("+ Zb+","+Yb+")"},y2:function(){return"translate("+(g?0:n)+","+(g?10:0)+")"},x:function(){return"translate(0,"+r+")"},subx:function(){return"translate(0,"+oa+")"},arc:function(){return"translate("+n/2+","+r/2+")"}};Ab=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var ee=function(){var a=d.svg.line().x(g?function(a){return H(a.id)(a.value)}:ob).y(g?ob:function(a){return H(a.id)(a.value)});return function(b){var c=Rc(b.values),d;if(Gb(b))return"spline"=== N["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),fd[b.id]?Od(c,m,H(b.id),fd[b.id]):a(c);d=m(c[0].x);b=H(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),fe=function(){var a=d.svg.line().x(function(a){return fa(a.x)}).y(function(a){return W(a.id)(a.value)});return function(b){var c=Rc(b.values);return Gb(b)?a(c):"M "+fa(c[0].x)+" "+W(b.id)(c[0].value)}}(),K=d.svg.brush().on("brush",function(){B({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}), E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ta?ge:null);K.update=function(){y&&y.select(".x.brush").call(this);return this};E.orgScaleExtent=function(){var a=ed?ed:[1,10];return[a[0],Math.max(Pa()/a[1],a[1])]};E.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(Z[1]-Z[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Ta,qb,k,y,Aa,R,pb,ga=null,qa=null,Z;f.focus=function(a){var b=d.selectAll(Ya(a)), c=b.filter(Vb),b=b.filter(Wb);f.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);A(f.data.targets)&&Ga(a,!0)};f.defocus=function(a){var b=d.selectAll(Ya(a)),c=b.filter(Vb),b=b.filter(Wb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);A(f.data.targets)&&Ha(a)};f.revert=function(a){var b=d.selectAll(Ya(a)),c=b.filter(Vb),b=b.filter(Wb);c.classed("focused", !1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);A(f.data.targets)&&Ha(a)};f.show=function(a){d.selectAll(Ya(a)).transition().style("opacity",1)};f.hide=function(a){d.selectAll(Ya(a)).transition().style("opacity",0)};f.unzoom=function(){K.clear().update();B({withUpdateXDomain:!0})};f.load=function(a){t(a.done)&&(a.done=function(){});"categories"in a&&$&&(Ja=a.categories,D.categories(Ja));if("cacheIds"in a&&zd(a.cacheIds))Wa(Ad(a.cacheIds),a.done);else if("data"in a)Wa(Oa(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Wa(Oa(c),a.done)});else if("rows"in a)Wa(Oa(rc(a.rows)),a.done);else if("columns"in a)Wa(Oa(sc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};f.unload=function(a){f.data.targets=f.data.targets.filter(function(b){return b.id!==a});d.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(d.selectAll(".legend-item-"+a).remove(),sb(f.data.targets));0b.classes.indexOf(a)})});return O};f.data.get=function(a){a=f.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};f.data.getAsTarget=function(a){var b= jb(function(b){return b.id===a});return 0