Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

2 lines
51 KiB

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