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