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