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