(function(K){function yd(){function R(e,f){e.attr("transform",function(e){return"translate("+(f(e)+qa)+", 0)"})}function x(e,f){e.attr("transform",function(e){return"translate(0,"+f(e)+")"})}function y(e){var f=e[0];e=e[e.length-1];return fa?a:10}function sa(a){var b=!1;Qb(k.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function zb(){var a=e.svg.arc().outerRadius(Ka).innerRadius(Gb),b=function(b,d){var g;return d?a(b):(g=sa(b))?a(g):"M 0 0"};b.centroid= a.centroid;return b}function vc(a){var b=e.svg.arc().outerRadius(Fb*(a?a:1)).innerRadius(Gb);return function(a){return(a=sa(a))?b(a):"M 0 0"}}function Kd(a){a=sa(a);var b,c;b="";a&&(b=kb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*Ka+","+0.8*(b/c)*Ka+")");return b}function Ld(a){return Md(a,(a.endAngle-a.startAngle)/(2*Math.PI))}function Bc(a,b){var c=n.selectAll(".chart-arc"+ka(a)),d=n.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d", yc).transition().duration(100).attr("d",zc).each(function(a){Rb(a.data)});b||d.style("opacity",0.3)}function Sb(a){n.selectAll(".chart-arc"+ka(a)).selectAll("path").transition().duration(50).attr("d",kb);n.selectAll(".-arc").style("opacity",1)}function Nd(a){var b=Cc(a),c,d,g,H;if(0a?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 mb(a){var b=nb(function(b){return U(b.id)===a}),c="y2"===a?Qd:Rd,d="y2"===a?Sd:Td,c=c?c:Nd(b),d=d?d:Od(b), g=0.1*Math.abs(d-c),e=g,f=g,h="y2"===a?Ud:Vd;h&&(c=Math.max(Math.abs(c),Math.abs(d)),d=c-h,c=h-c);"y"===a&&Oa&&(e=z(Oa.top)?Oa.top:g,f=z(Oa.bottom)?Oa.bottom:g);"y2"===a&&Pa&&(e=z(Pa.top)?Pa.top:g,f=z(Pa.bottom)?Pa.bottom:g);ia(b,"bar")&&!Dc(b)&&(f=c);return[c-f,d+e]}function Wd(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.x})})}function Xd(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function ob(a){var b=[Wd(a),Xd(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 Ba(a){return a[1]-a[0]}function Yd(a){for(var b=0;ba?0:a}function Gc(a){return va&&a===va||ba&&$d(ba,a)}function ae(a){return!Gc(a)} function be(a){Object.keys(a).forEach(function(b){ba[b]=a[b]})}function qb(a){var b;a&&(b=Qa[a.id],a.name=b?b:a.id);return a}function Hc(a){var b=a[0],c={},d=[],g,e;for(g=1;gb&&(c=a,b=a.values.length)}):c=a?k.data.targets[0]:null;return c}function Sa(a){a=x(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Lc(a){var b=Sa(),c;for(c=0;ca})}function Pd(a){return Mc(a,function(a){return 0g&&(e-=c+30)),c=b[1]+15+dv[c].indexOf(g.id)))for(d=0;d=e;e+=p)f+=d(a[g-1],a[g],e,m)}return f}function dc(a){var b;sb=e.select(Aa);if(sb.empty())K.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); else{sb.html("");k.data.x={};k.data.targets=Ra(a);ya();tc();m.domain(e.extent(ob(k.data.targets)));A.domain(mb("y"));aa.domain(mb("y2"));W.domain(m.domain());ib.domain(A.domain());jb.domain(aa.domain());$=m.domain();I.scale(W);(la||ma)&&F.scale(m);n=e.select(Aa).append("svg").attr("width",r+C+Z).attr("height",t+q+M).on("mouseenter",ue).on("mouseleave",ve);tb=n.append("defs");tb.append("clipPath").attr("id",ec).append("rect").attr("y",q).attr("width",r).attr("height",t-q);tb.append("clipPath").attr("id", "xaxis-clip").append("rect").attr("x",-1-C).attr("y",-20).attr("width",ea).attr("height",Ab);tb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-C+1).attr("y",q-1).attr("width",zd).attr("height",Y);l=n.append("g").attr("transform",J.main);G=Fa?n.append("g").attr("transform",J.context):null;Ga=Ha?n.append("g").attr("transform",J.legend):null;X=e.select(Aa).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("+document.URL+"#xaxis-clip)").attr("transform",J.x).call(h?Ma:N).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(we);l.append("g").attr("class","y axis").attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").call(h?N:Ma).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(xe);Db&&l.append("g").attr("class","y2 axis").attr("transform", J.y2).call(Pb);a=l.append("g").attr("clip-path",Ya).attr("class","grid");ld&&a.append("g").attr("class","xgrids");fc&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fc).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})); ye&&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:t);md&&a.append("g").attr("class","ygrids");gc&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gc).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",Ya).attr("class","regions");l.append("g").attr("clip-path",Ya).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",la||ma?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", J.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(ze);if(la||ma)l.insert("rect",Ae?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",t).style("opacity",0).style("cursor",h?"ns-resize":"ew-resize").call(F).on("dblclick.zoom",null);null!==ub&&I.extent("function"!==typeof ub?ub:ub(ob()));Fa&&(G.append("g").attr("clip-path",Ya).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",Ya).attr("class","x brush").call(I).selectAll("rect").attr(h?"width":"height",h?Eb:gb),G.append("g").attr("class","x axis").attr("transform",J.subx).attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").call(hb));Ha&&vb(k.data.targets);nd(k.data.targets);w({withTransform:!0,withUpdateXDomain:!0});if(Be){if(D&&"string"===typeof Ia){Ia=ua(Ia);for(a=0;aVb(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=Wc(k.data.targets,a),100>Vb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){qd(this,c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){rd(e.mouse(this))}).on("dragstart",function(){sd(e.mouse(this))}).on("dragend",function(){td()})).call(F).on("dblclick.zoom", null)}function qd(a,b,c){var d=e.select(a),g=d.classed(pa),f=!1,h;"circle"===a.nodeName?(f=ed(a,1.5*Xa),h=hd):"rect"===a.nodeName&&(f=fd(a),h=jd);if(xa||f)na&&oa(b)&&(d.classed(pa,!g),h(!g,d,b,c)),Fe(b,d)}function rd(a){var b,c,d,g,f,h,m;E(k.data.targets)||!na||(la||ma)&&!F.altDomain||(b=kc[0],c=kc[1],d=a[0],a=a[1],g=Math.min(b,d),f=Math.max(b,d),h=xa?q:Math.min(c,a),m=xa?t:Math.max(c,a),l.select(".dragarea").attr("x",g).attr("y",h).attr("width",f-g).attr("height",m-h),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return oa(a)}).each(function(a, b){var c=e.select(this),d=c.classed(pa),k=c.classed(lc),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=hd,l=g"+d+""),h=a[e].name,f=b(a[e].value),d+=""+h+""+f+"");return d+ ""}),Be=f(["tooltip","init","show"],!1),Ia=f(["tooltip","init","x"],0),od=f(["tooltip","init","position"],{top:"0px",left:"50px"}),ec=Aa.replace("#","")+"-clip",Ya="url("+document.URL+"#"+ec+")",D="timeseries"===xd,ja="categorized"===xd,Ub=!D&&(va||ba),kc=null,Za=!1,jc=!1,ta=Ha?40:0,O=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]}}(Oe,Pe),Id=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,Eb,t,gb,Bb,za,Ka,Fb,Gb,kb,yc,zc,Qb,Ib,Jb,Kb,Lb,Mb,Nb,m,A,aa,W,ib,jb,N,Ma,Pb,hb,Ad=h?"left":"bottom",Cd=h?db?"top":"bottom":db?"right":"left",Ed=h?fb?"bottom":"top":fb?"left":"right",Bd=h?"left":"bottom",J={main:function(){return"translate("+C+","+q+")"},context:function(){return"translate("+sc+","+yb+")"},legend:function(){return"translate("+rc+","+qc+")"},y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"}, x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+(h?0:gb)+")"},arc:function(){return"translate("+r/2+","+t/2+")"}},xc=40,wc=20;Qb=e.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var Ie=function(){var a=e.svg.line().x(h?function(a){return s(a.id)(a.value)}:Ca).y(h?Ca:function(a){return s(a.id)(a.value)});return function(b){var c=$b(b.values),d;if(Xb(b))return bd(b)?a.interpolate("cardinal"):a.interpolate("linear"),wd[b.id]?te(c, m,s(b.id),wd[b.id]):a(c);d=m(c[0].x);b=s(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Je=function(){var a;a=h?e.svg.area().x0(function(a){return s(a.id)(0)}).x1(function(a){return s(a.id)(a.value)}).y(Ca):e.svg.area().x(Ca).y0(function(a){return s(a.id)(0)}).y1(function(a){return s(a.id)(a.value)});return function(b){var c=$b(b.values),d;if(ia([b],"area")||ia([b],"area-spline"))return bd(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=s(b.id)(c[0].value);return h? "M "+b+" "+d:"M "+d+" "+b}}(),wb=function(a,b){var c=a.__max__+1,d=1 b.classes.indexOf(a)})});return Q};k.data.get=function(a){a=k.data.getAsTarget(a);return y(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=nb(function(b){return b.id===a});return 0