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