mirror of https://github.com/masayuki0812/c3.git
Masayuki Tanaka
11 years ago
2 changed files with 111 additions and 94 deletions
@ -1,80 +1,81 @@
|
||||
(function(T){function hd(){function p(d,e){d.attr("transform",function(d){return"translate("+(e(d)+da)+", 0)"})}function t(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function T(d){var e=d[0];d=d[d.length-1];return e<d?[e,d]:[d,e]}function Da(d){for(var e=[],p=Math.ceil(d[0]);p<d[1];p++)e.push(p);0<e.length&&0<e[0]&&e.unshift(e[0]-(e[1]-e[0]));return e}function Ea(d){d=d<U.length?U[d]:d;return V?V(d):d}function l(l){l.each(function(){var l=d.select(this),ma=Da(q.domain()), |
||||
L=l.selectAll(".tick.major").data(ma,String),G=L.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),H=d.transition(L.exit()).style("opacity",1E-6).remove(),W=d.transition(L).style("opacity",1),P,Q=q.rangeExtent?q.rangeExtent():T(q.range()),l=l.selectAll(".domain").data([0]);l.enter().append("path").attr("class","domain");var l=d.transition(l),M=q.copy(),V=this.__chart__||M;this.__chart__=M;G.append("line");G.append("text");var U=G.select("line"),Fa=W.select("line"),va=L.select("text"), |
||||
$a=G.select("text"),Ga=W.select("text");da=(M(1)-M(0))/2;L=wa?0:da;switch(ea){case "bottom":P=p;U.attr("y2",I);$a.attr("y",Math.max(I,0)+e);Fa.attr("x1",L).attr("x2",L).attr("y2",I);Ga.attr("x",0).attr("y",Math.max(I,0)+e);va.attr("dy",".71em").style("text-anchor","middle");va.text(function(d){return ma.length<X||0===d%Math.ceil(ma.length/X)?Ea(d):""});l.attr("d","M"+Q[0]+","+C+"V0H"+Q[1]+"V"+C);break;case "left":P=t,U.attr("x2",-I),$a.attr("x",-(Math.max(I,0)+e)),Fa.attr("x2",-I).attr("y2",0),Ga.attr("x", |
||||
-(Math.max(I,0)+e)).attr("y",da),va.attr("dy",".32em").style("text-anchor","end"),va.text(function(d){return ma.length<X||0===d%Math.ceil(ma.length/X)?Ea(d):""}),l.attr("d","M"+-C+","+Q[0]+"H0V"+Q[1]+"H"+-C)}if(q.ticks)G.call(P,V),W.call(P,M),H.call(P,M);else{var Ha=M.rangeBand()/2,H=function(d){return M(d)+Ha};G.call(P,H);W.call(P,H)}})}var q=d.scale.linear(),ea="bottom",I=6,C=6,e=3,wa=!1,X=10,da=0,V=null,U=[];l.scale=function(d){if(!arguments.length)return q;q=d;return l};l.orient=function(d){if(!arguments.length)return ea; |
||||
ea=d in{top:1,right:1,bottom:1,left:1}?d+"":"bottom";return l};l.categories=function(d){if(!arguments.length)return U;U=d;return l};l.tickCentered=function(d){if(!arguments.length)return wa;wa=d;return l};l.tickTextNum=function(d){if(!arguments.length)return X;X=d;return l};l.tickFormat=function(d){if(!arguments.length)return V;V=d;return l};l.tickOffset=function(){return da};l.ticks=function(){};return l}function t(d){return"undefined"===typeof d}function p(d){return"undefined"!==typeof d}var tb= |
||||
T.c3={},d=T.d3;tb.generate=function(ca){var Yb,Zb,Da,Ea,l,q,ea,I,C;function e(a,b){for(var c=ca,h=0;h<a.length;h++){if(!(a[h]in c))return b;c=c[a[h]]}return c}function wa(){ub=null===ab?da():ab;xa=X();$b=20+ac+na;bc=cc?cc:dc?vb||g?1:40:20;bb=ec?ec:wb?1:40;fc=xa-ac-na;gc=20+na;hc=xa-na;q=0;ea=bc;I=$b;C=bb;Da=fc;Ea=gc;l=bb;Yb=hc;Zb=bb;n=ub-C-ea;r=xa-q-I;oa=xa-Da-Ea;xb=r/2;cb=0.95*xb}function X(){var a=null===ic?+d.select(ya).style("height").replace("px",""):ic;return 0<a?a:320}function da(){return+d.select(ya).style("width").replace("px", |
||||
"")}function V(){return n+2+C+ea}function U(){return 40}function ma(){return C+20}function tb(){return r-q+42}function Xb(){jc=g?10:0;kc=g?r:n;yb=g?0:r;zb=g?n:1;m=L(jc,kc,p(m)?m.domain():void 0,function(){return D.tickOffset()});x=G(yb,zb,p(x)?x.domain():void 0);Y=G(yb,zb,p(Y)?Y.domain():void 0);fa=L(0,n,p(Z)?Z:void 0,function(a){return 0===a%1?Ia.tickOffset():0});db=G(oa,10);eb=G(oa,10);D=P(m,kd);pa=d.svg.axis().scale(x).orient(ld);fb=d.svg.axis().scale(Y).orient(md);Ia=P(fa,nd);gb=id();lc=Fa(); |
||||
mc=Fa(0.98)}function L(a,b,c,h){var s=(z?d.time.scale():d.scale.linear()).range([a,b]);s.orgDomain=function(){return s.domain()};p(c)&&s.domain(c);t(h)&&(h=function(){return 0});if($){var J=s,e,s=function(a){return J(a)+h(a)};for(e in J)s[e]=J[e];s.orgDomain=function(){return J.domain()};s.domain=function(a){if(!arguments.length)return a=J.domain(),[a[0],a[1]+1];J.domain(a);return s}}return s}function G(a,b){return d.scale.linear().range([a,b])}function H(a){return"y2"===Q(a)?Y:x}function W(a){return"y2"=== |
||||
Q(a)?eb:db}function P(a,b){var c=($?hd():d.svg.axis()).scale(a).orient(b);c.tickFormat(M());$?c.categories(Ja).tickCentered(od):c.tickOffset=function(){return 0};return c}function Q(a){return a in nc?nc[a]:"y"}function M(){var a=z?pd:$?qd:function(a){return a};hb&&(a="function"===typeof hb?hb:z?function(a){return d.time.format(hb)(a)}:a);return a}function Za(a){var b=!1;Ab(f.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function id(){var a=d.svg.arc().outerRadius(cb).innerRadius(0), |
||||
b=function(b,h){var s;return h?a(b):(s=Za(b))?a(s):"M 0 0"};b.centroid=a.centroid;return b}function Fa(a){var b=d.svg.arc().outerRadius(xb*(a?a:1)).innerRadius(0);return function(a){return(a=Za(a))?b(a):"M 0 0"}}function va(a){a=Za(a);var b,c;b="";a&&(b=gb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*cb+","+0.8*(b/c)*cb+")");return b}function $a(a){return(100*(a.endAngle-a.startAngle)/(2*Math.PI)).toFixed(1)+"%"}function Ga(a,b){var c=d.selectAll(".chart-arc.target"+(a? |
||||
"-"+a:"")),h=d.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",lc).transition().duration(100).attr("d",mc);b||h.style("opacity",0.3)}function Ha(a){d.selectAll(".chart-arc.target"+(a?"-"+a:"")).selectAll("path").transition().duration(50).attr("d",gb);d.selectAll(".-arc").style("opacity",1)}function jd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.value})})}function rd(a){var b={},c,h;a.forEach(function(a){b[a.id]= |
||||
[];a.values.forEach(function(c){b[a.id].push(c.value)})});for(c=0;c<u.length;c++)for(h=1;h<u[c].length;h++)Ka(u[c][h])&&(t(b[u[c][h]])||b[u[c][h]].forEach(function(a,d){Q(u[c][h])===Q(u[c][0])&&(b[u[c][0]][d]+=1*a)}));return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function ib(a){var b=jb(function(b){return Q(b.id)===a}),c="y2"===a?sd:td,h="y2"===a?ud:vd,c=null!==c?c:jd(b),h=null!==h?h:rd(b),s=0.1*Math.abs(h-c),d=s,e=s,g="y2"===a?wd:xd;null!==g&&(c=Math.max(Math.abs(c),Math.abs(h)), |
||||
h=c-g,c=g-c);"y"===a&&null!==La&&(d=p(La.top)?La.top:s,e=p(La.bottom)?La.bottom:s);"y2"===a&&null!==Ma&&(d=p(Ma.top)?Ma.top:s,e=p(Ma.bottom)?Ma.bottom:s);return[Bb(b,"bar")?0:c-e,h+d]}function Cb(a){var b;a?(a=m.domain(),b=K.extent()):(a=Z,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function yd(){var a=$?0:0.01*Math.abs(ga-qa),b=z?new Date(ga.getTime()-a):ga-a,a=z?new Date(qa.getTime()+a):qa+a;return[b,a]}function zd(a){for(var b=0;b<a.length;b++)if(!(a[b]in kb))return!1;return!0}function Ad(a){for(var b= |
||||
[],c=0;c<a.length;c++)a[c]in kb&&b.push(oc(kb[a[c]]));return b}function Db(a){return"start"in a?m(z?ra(a.start):a.start):0}function pc(a){var b=Db(a);a=("end"in a?m(z?ra(a.end):a.end):n)-b;return 0>a?0:a}function qc(a){return sa&&a===sa||aa&&Bd(aa,a)}function Cd(a){return!qc(a)}function lb(a){var b=Na[a.id];a.name=p(b)?b:a.id;return a}function rc(a){var b=a[0],c={},h=[],d,J;for(d=1;d<a.length;d++){c={};for(J=0;J<a[d].length;J++)c[b[J]]=a[d][J];h.push(c)}return h}function sc(a){var b=[],c,h,d;for(c= |
||||
0;c<a.length;c++)for(d=a[c][0],h=1;h<a[c].length;h++)t(b[h-1])&&(b[h-1]={}),b[h-1][d]=a[c][h];return b}function Oa(a){var b=d.keys(a[0]).filter(Cd),c=d.keys(a[0]).filter(qc);if(z&&0===c.length)return T.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];Eb&&b.forEach(function(b){var d=sa?sa:aa?aa[b]:null;0<=c.indexOf(d)&&(f.data.x[b]=a.map(function(a){return a[d]}))});b=b.map(function(b){var c=Dd(b);return{id:c,id_org:b,values:a.map(function(a,d){var e;e=sa?sa:aa?aa[b]: |
||||
null;e=z?ra(a[e]):Eb?a[e]?a[e]:b in f.data.x&&f.data.x[d]?f.data.x[d]:d:d;if(e<ga||null===ga)ga=e;qa<e&&(qa=e);a.x=e;return{x:e,value:null===a[b]||isNaN(a[b])?null:+a[b],id:c}})}});b.forEach(function(a){var b;a.values=a.values.sort(function(a,b){return(a.x||0===a.x?a.x:Infinity)-(b.x||0===b.x?b.x:Infinity)});b=0;a.values.forEach(function(a){a.index=b++})});b.forEach(function(a){kb[a.id_org]=oc(a)});return b}function oc(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 Pa(){return d.max(f.data.targets,function(a){return a.values.length})}function mb(a){a=t(a)?f.data.targets:a;return a.map(function(a){return a.id})}function tc(a){var b=mb(),c;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1}function jb(a){return p(a)?f.data.targets.filter(a):f.data.targets}function qd(a){return a<Ja.length?Ja[a]:a}function nb(a){return"-shapes -shapes-"+a.id}function uc(a){return nb(a)+" -line -line-"+a.id}function Ed(a){return nb(a)+" -circles -circles-"+ |
||||
a.id}function vc(a){return nb(a)+" -bars -bars-"+a.id}function Fd(a){return nb(a.data)+" -arc -arc-"+a.data.id}function Gd(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function wc(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function Hd(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function ob(a){return m(a.x)}function Qa(a){return m(z?ra(a.value):a.value)}function xc(a){return x(a.value)}function yc(a,b){var c,h=a[b].x,d=[];for(c=b-1;0<=c&&h===a[c].x;c--)d.push(a[c]); |
||||
for(c=b;c<a.length&&h===a[c].x;c++)d.push(a[c]);return d}function zc(a,b,c,h){c=c?c:0;h=h?h:a.length-1;var d=Math.floor((h-c)/2)+c;0<m(a[d].x)-b[0]?h=d:c=d;return 1===h-c?(d=[],a[c].x&&(d=d.concat(yc(a,c))),a[h].x&&(d=d.concat(yc(a,h))),Ac(d,b)):zc(a,b,c,h)}function Bc(a,b){var c;c=a.map(function(a){return zc(a.values,b)});return Ac(c,b)}function Ac(a,b){var c,h;a.forEach(function(a){var d=Fb(a,b);if(d<c||!c)c=d,h=a});return h}function Cc(a,b){R.html(Dc(a)).style("visibility","hidden").style("display", |
||||
"block");var c=R.property("offsetWidth"),h=R.property("offsetHeight");R.style("top",(b[1]+15+h<X()?b[1]+15:b[1]-h)+"px").style("left",g?b[0]:m(a[0].x)+60+c<(null===ab?da():ab)?m(a[0].x)+60+"px":m(a[0].x)-c+30+"px").style("visibility","visible")}function Ec(a){Bb(f.data.targets,"scatter")||A(f.data.targets)||k.selectAll("line.xgrid-focus").style("visibility","visible").data([a]).attr(g?"y1":"x1",ob).attr(g?"y2":"x2",ob)}function Fc(){k.select("line.xgrid-focus").style("visibility","hidden")}function ha(a){return a.x|| |
||||
0===a.x?m(a.x):null}function ia(a){return H(a.id)(a.value)}function Id(){var a={},b=0,c,h;jb(Ka).forEach(function(d){for(c=0;c<u.length;c++)if(!(0>u[c].indexOf(d.id)))for(h=0;h<u[c].length;h++)if(u[c][h]in a){a[d.id]=a[u[c][h]];break}t(a[d.id])&&(a[d.id]=b++)});a.__max__=b-1;return a}function Gc(a,b,c,h){var d=h?fa:m;return b?function(h){var e=h.id in c?c[h.id]:0;return h.x||0===h.x?d(h.x)-a*(b/2-e):0}:function(){return 0}}function Hc(a,b,c,h){var d=Object.keys(b);return function(e,g){var f=0,k=h? |
||||
W(e.id):H(e.id);jb(Ka).forEach(function(c){c.id!==e.id&&b[c.id]===b[e.id]&&d.indexOf(c.id)<d.indexOf(e.id)&&(f+=a(c.values[g]))});return c?f:k(e.value)-f}}function Ic(a,b){var c=null===a?function(a){return a}:function(b){return a>b?a-b:0};return function(a){var d=b?W(a.id):H(a.id);return c(d(a.value))}}function Ra(a,b){var c=t(a)?mb():a;"string"===typeof c&&(c=[c]);for(var h=0;h<c.length;h++)N[c[h]]=b}function Bb(a,b){var c=!1;a.forEach(function(a){N[a.id]===b&&(c=!0);a.id in N||"line"!==b||(c=!0)}); |
||||
return c}function A(a){return Bb(a,"pie")}function Gb(a){a="string"===typeof a?a:a.id;return!(a in N)||"line"===N[a]||"spline"===N[a]}function Ka(a){return"bar"===N["string"===typeof a?a:a.id]}function Jc(a){return"pie"===N["string"===typeof a?a:a.id]}function Kc(a){return Ka(a)?a.values:[]}function Jd(a){var b;(b=Gb(a))||(b="scatter"===N["string"===typeof a?a:a.id]);return b?a.values:[]}function ra(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+Hb+". Maybe 'x' of this data is not defined. See data.x or data.xs option."); |
||||
b=d.time.format(Hb).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+Hb);return b}function Lc(a,b){var c=d.mouse(a),h=d.select(a),e=1*h.attr("cx"),h=1*h.attr("cy");return Math.sqrt(Math.pow(e-c[0],2)+Math.pow(h-c[1],2))<b}function Mc(a){var b=d.mouse(a),c=d.select(a);a=1*c.attr("x");var h=1*c.attr("y"),c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&h-10<b[1]}function Kd(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function Bd(a,b){var c=!1; |
||||
Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)});return c}function Fb(a,b){return Math.pow(m(a.x)-b[0],2)+Math.pow(x(a.value)-b[1],2)}function Nc(a,b,c){Ld(a,b);k.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",g?ia:ha).attr("cy",g?ha:ia).attr("stroke",function(){return S(b.id)}).attr("r",1.4*Sa).transition().duration(100).attr("r",Sa)}function Ib(a,b,c){Md(a,b); |
||||
k.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",0).remove()}function Oc(a,b,c,d){a?Nc(b,c,d):Ib(b,c,d)}function Nd(){}function Pc(){}function Qc(a,b,c,d){}function Rc(a){return a.filter(function(a){return null!==a.value})}function Jb(a,b){return(b?k.selectAll(".-circles-"+b):k).selectAll(".-circle"+(a||0===a?"-"+a:""))}function Kb(a){Jb(a).filter(function(){return d.select(this).classed(ba)}).classed(ba,!1).attr("r",Lb)}function Sc(a){return k.selectAll(".-bar"+ |
||||
(a||0===a?"-"+a:""))}function Od(a,b,c,d){var e,f,k="M",m,l,n,Tc,r,q=[];if(p(d))for(e=0;e<d.length;e++)q[e]={},t(d[e].start)?q[e].start=a[0].x:q[e].start=z?ra(d[e].start):d[e].start,t(d[e].end)?q[e].end=a[a.length-1].x:q[e].end=z?ra(d[e].end):d[e].end;Tc=g?function(a){return c(a.value)}:function(a){return b(a.x)};r=g?function(a){return b(a.x)}:function(a){return c(a.value)};d=z?function(a,d,h,e){var f=a.x.getTime();a=d.x-a.x;d=new Date(f+a*(h+e));return"M"+b(new Date(f+a*h))+" "+c(l(h))+" "+b(d)+ |
||||
" "+c(l(h+e))}:function(a,d,h,e){return"M"+b(m(h))+" "+c(l(h))+" "+b(m(h+e))+" "+c(l(h+e))};for(e=0;e<a.length;e++)if(t(q)||!Kd(a[e].x,q))k+=" "+Tc(a[e])+" "+r(a[e]);else{m=L(a[e-1].x,a[e].x);l=G(a[e-1].value,a[e].value);f=b(a[e].x)-b(a[e-1].x);n=c(a[e].value)-c(a[e-1].value);f=Math.sqrt(Math.pow(f,2)+Math.pow(n,2));n=2/f;var u=2*n;for(f=n;1>=f;f+=u)k+=d(a[e-1],a[e],f,n)}return k}function Mb(a){var b,c;pb=d.select(ya);if(pb.empty())T.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); |
||||
else{pb.html("");f.data.x={};f.data.targets=Oa(a);wa();Xb();m.domain(d.extent(yd()));x.domain(ib("y"));Y.domain(ib("y2"));fa.domain(m.domain());db.domain(x.domain());eb.domain(Y.domain());D.ticks(10>a.length?a.length:10);pa.ticks(Pd).outerTickSize(0).tickFormat(Qd);fb.ticks(Rd).outerTickSize(0).tickFormat(Sd);Z=m.domain();K.x(fa);ta&&E.x(m);Ta=d.select(ya).append("svg").attr("width",n+C+ea).attr("height",r+q+I).on("mouseenter",Td).on("mouseleave",Ud);qb=Ta.append("defs");qb.append("clipPath").attr("id", |
||||
Nb).append("rect").attr("y",q).attr("width",n).attr("height",r-q);qb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-C).attr("y",-20).attr("width",V).attr("height",U);qb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-C+1).attr("y",q-1).attr("width",ma).attr("height",tb);k=Ta.append("g").attr("transform",F.main);y=za?Ta.append("g").attr("transform",F.context):null;Aa=Ba?Ta.append("g").attr("transform",F.legend):null;R=d.select(ya).style("position","relative").append("div").style("position", |
||||
"absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",F.x).call(g?pa:D).append("text").attr("class","-axis-x-label").attr("x",n).attr("dy","-.5em").style("text-anchor","end").text(Vd);k.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?D:pa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Wd);dc&& |
||||
k.append("g").attr("class","y2 axis").attr("transform",F.y2).call(fb);b=k.append("g").attr("clip-path",Ua).attr("class","grid");Uc&&b.append("g").attr("class","xgrids");Ob&&(c=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Ob).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g? |
||||
0:-q).attr("dy",-6).text(function(a){return a.text}));Xd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?n:-10).attr("y1",g?-10:q).attr("y2",g?-10:r);Vc&&b.append("g").attr("class","ygrids");Pb&&b.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Pb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ua).attr("class","regions");k.append("g").attr("clip-path", |
||||
Ua).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ta?"ew-resize":null);aa?Yd(b):Zd(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");k.select(".chart").append("g").attr("class","chart-arcs").attr("transform",F.arc);if(ta)k.insert("rect",$d?null:"g.grid").attr("class","zoom-rect").attr("width",n).attr("height",r).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom", |
||||
null);null!==rb&&K.extent("function"!==typeof rb?rb:rb(ga,qa));za&&(y.append("g").attr("clip-path",Ua).attr("class","chart"),y.select(".chart").append("g").attr("class","chart-bars"),y.select(".chart").append("g").attr("class","chart-lines"),y.append("g").attr("clip-path",Ua).attr("class","x brush").call(K).selectAll("rect").attr("height",oa),y.append("g").attr("class","x axis").attr("transform",F.subx).call(Ia));Ba&&sb(f.data.targets);Wc(f.data.targets);B({withTransition:!1,withUpdateXDomain:!0}); |
||||
if(ae){if(z&&"string"===typeof Ca){Ca=ra(Ca);for(a=0;a<f.data.targets[0].values.length&&0!==f.data.targets[0].values[a].x-Ca;a++);Ca=a}R.html(Dc(f.data.targets.map(function(a){return lb(a.values[Ca])})));R.style("top",Xc.top).style("left",Xc.left).style("display","block")}null==T.onresize&&(T.onresize=be)}}function Zd(a,b){a.selectAll(".event-rects").data(b).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",ja&&ua?"pointer":null).on("mouseover",function(a, |
||||
b){if(!Va&&!A(f.data.targets)){var d=f.data.targets.map(function(a){return lb(a.values[b])}),e,g;if(0<Object.keys(Na).length){g=[];for(var k in Na)for(e=0;e<d.length;e++)if(d[e].id===k){g.push(d[e]);d.shift(e);break}d=g.concat(d)}Qb&&Jb(b,void 0).classed(ba,!0).attr("r",Rb);Sc(b).classed(ba,!1);Ec(d[0])}}).on("mouseout",function(a,b){A(f.data.targets)||(Fc(),R.style("display","none"),Kb(b),Sc(void 0).classed(ba,!1))}).on("mousemove",function(a,b){var e;Va||A(f.data.targets)||(e=f.data.targets.map(function(a){return lb(a.values[b])}), |
||||
Cc(e,d.mouse(this)),ja&&(ua||k.selectAll(".-shape-"+b).filter(function(a){return ka(a)}).each(function(){var a=d.select(this).classed(ba,!0);"circle"===this.nodeName&&a.attr("r",Rb);d.select(".event-rect-"+b).style("cursor",null)}).filter(function(){var a=d.select(this);if("circle"===this.nodeName)return Lc(this,Sa);if("rect"===this.nodeName)return Mc(this,a.attr("x"),a.attr("y"))}).each(function(){var a=d.select(this);a.classed(ba)||(a.classed(ba,!0),"circle"===this.nodeName&&a.attr("r",Sa));d.select(".event-rect-"+ |
||||
b).style("cursor","pointer")})))}).on("click",function(a,b){A(f.data.targets)||(Sb?Sb=!1:k.selectAll(".-shape-"+b).each(function(a){Yc(this,a,b)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Zc(d.mouse(this))}).on("dragstart",function(){$c(d.mouse(this))}).on("dragend",function(){ad()})).call(E).on("dblclick.zoom",null)}function Yd(a){a.append("rect").attr("x",0).attr("y",0).attr("width",n).attr("height",r).attr("class","event-rect").on("mouseout",function(){A(f.data.targets)||(Fc(), |
||||
R.style("display","none"),Kb())}).on("mousemove",function(){var a,c,e;Va||A(f.data.targets)||(a=d.mouse(this),c=Bc(f.data.targets,a),e=[lb(c)],Cc(e,a),Qb&&(Kb(),Jb(c.index,c.id).classed(ba,!0).attr("r",Rb)),Ec(e[0]),100>Fb(c,a)?d.select(".event-rect").style("cursor","pointer"):d.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;A(f.data.targets)||(a=d.mouse(this),c=Bc(f.data.targets,a),100>Fb(c,a)&&k.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){Yc(this, |
||||
c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Zc(d.mouse(this))}).on("dragstart",function(){$c(d.mouse(this))}).on("dragend",function(){ad()})).call(E).on("dblclick.zoom",null)}function Yc(a,b,c){var e=d.select(a),f=e.classed(la),g=!1,k;"circle"===a.nodeName?(g=Lc(a,1.5*Sa),k=Oc):"rect"===a.nodeName&&(g=Mc(a),k=Qc);if(ua||g)ja&&ka(b)&&(e.classed(la,!f),k(!f,e,b,c)),ce(b,e)}function Zc(a){var b,c,e,g,m,v,l;A(f.data.targets)||!ja||ta&&!E.altDomain||(b=Tb[0],c=Tb[1],e=a[0], |
||||
a=a[1],g=Math.min(b,e),m=Math.max(b,e),v=ua?q:Math.min(c,a),l=ua?r:Math.max(c,a),k.select(".dragarea").attr("x",g).attr("y",v).attr("width",m-g).attr("height",l-v),k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ka(a)}).each(function(a,b){var c=d.select(this),e=c.classed(la),h=c.classed(Ub),f,k,p,n;f=!1;"circle"===this.nodeName?(f=1*c.attr("cx"),k=1*c.attr("cy"),n=Oc,f=g<f&&f<m&&v<k&&k<l):"rect"===this.nodeName&&(f=1*c.attr("x"),k=1*c.attr("y"),p=1*c.attr("width"),n=Qc,f=g< |
||||
f+p&&f<m&&k<l);f^h&&(c.classed(Ub,!h),c.classed(la,!e),n(!e,c,a,b))}))}function $c(a){!A(f.data.targets)&&ja&&(Tb=a,k.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Va=!0)}function ad(){!A(f.data.targets)&&ja&&(k.select(".dragarea").transition().duration(100).style("opacity",0).remove(),k.selectAll(".-shape").classed(Ub,!1),Va=!1)}function B(a){var b,c,e=Id(),s=e.__max__+1,l,v,t,u,w;a=p(a)?a:{};b=p(a.withY)?a.withY:!0;u=p(a.withSubchart)?a.withSubchart:!0;w=p(a.withTransition)? |
||||
a.withTransition:!0;a=p(a.withUpdateXDomain)?a.withUpdateXDomain:!1;l=A(f.data.targets);w=w?250:0;a&&(m.domain(K.empty()?Z:K.extent()),ta&&E.x(m).updateScaleExtent());x.domain(ib("y"));Y.domain(ib("y2"));k.select(".x.axis").transition().duration(g?w:0).call(g?pa:D).style("opacity",l?0:1);k.select(".y.axis").transition().duration(g?0:w).call(g?D:pa).style("opacity",l?0:1);k.select(".y2.axis").transition().call(fb).style("opacity",l?0:1);k.select(".x.axis .-axis-x-label").attr("x",n);db.domain(x.domain()); |
||||
eb.domain(Y.domain());R.style("display","none");k.select("line.xgrid-focus").style("visibility","hidden").attr("y2",r);if(Uc){if("year"===de)for(a=[],v=ga.getFullYear(),l=qa.getFullYear();v<=l;v++)a.push(new Date(v+"-01-01 00:00:00"));else a=m.ticks(10);a=k.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.attr("x1",g?0:function(a){return m(a)-D.tickOffset()}).attr("x2",g?n:function(a){return m(a)-D.tickOffset()}).attr("y1",g?function(a){return m(a)-D.tickOffset()}: |
||||
q).attr("y2",g?function(a){return m(a)-D.tickOffset()}:r).style("opacity",function(){return+d.select(this).attr(g?"y1":"x1")===(g?r:0)?0:1});a.exit().remove()}Ob&&(a=k.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",g?0:Qa).attr("x2",g?n:Qa).attr("y1",g?Qa:q).attr("y2",g?Qa:r),a.selectAll("text").attr("x",g?n:0).attr("y",Qa));b&&Vc&&(a=k.select(".ygrids").selectAll(".ygrid").data(x.ticks(10)),a.enter().append("line").attr("class","ygrid"),a.attr("x1",g?x:0).attr("x2",g?x:n).attr("y1",g?0: |
||||
x).attr("y2",g?r:x),a.exit().remove());b&&Pb&&k.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",xc).attr("y2",xc);l=$?s?1.2*D.tickOffset()/s:0:0.6*((g?r:n)*Cb(!1)/(Pa()-1));v=Ic(g?null:r);b=Gc(l,s,e);a=Hc(v,e,g);c=k.selectAll(".-bars").selectAll(".-bar").data(Kc);c.transition().duration(w).attr("x",g?a:b).attr("y",g?b:a).attr("width",g?v:l).attr("height",g?l:v);c.enter().append("rect").attr("class",wc).attr("x",g?a:b).attr("y",g?b:a).attr("width",g?v:l).attr("height",g?l:v).style("opacity", |
||||
0).transition().duration(w).style("opacity",1);c.exit().transition().duration(w).style("opacity",0).remove();k.selectAll(".chart-line").select(".-line").transition().duration(w).attr("d",ee);b=k.selectAll(".-circles").selectAll(".-circle").data(Jd);b.transition().duration(w).style("opacity",function(a){return null===a.value?0:1}).attr("cx",g?ia:ha).attr("cy",g?ha:ia);b.enter().append("circle").style("opacity",function(a){return null===a.value?0:1}).attr("class",Gd).attr("cx",g?ia:ha).attr("cy",g? |
||||
ha:ia).attr("r",Lb);b.exit().remove();k.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(w).attrTween("d",function(a){a=Za(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Jc(a.data)?gb(a,!0):"M 0 0"}}).style("opacity",1);k.selectAll(".chart-arc").select("text").attr("transform",va).attr("opacity",0).transition().duration(w).text($a).attr("opacity", |
||||
function(a){return Jc(a.data)?1:0});za&&(null!==d.event&&"zoom"===d.event.type&&K.extent(m.orgDomain()).update(),u&&(y.select(".x.axis").transition().duration(g?w:0).call(g?pa:Ia),K.empty()||K.extent(m.orgDomain()).update(),l=$?s?1.2*Ia.tickOffset()/s:0:0.6*((g?r:n)*Cb(!0)/(Pa()-1)),v=Ic(oa,!0),b=Gc(l,s,e,!0),a=Hc(v,e,!1,!0),e=y.selectAll(".-bars").selectAll(".-bar").data(Kc),e.transition().duration(w).attr("x",b).attr("y",a).attr("width",l).attr("height",v),e.enter().append("rect").attr("class", |
||||
wc).attr("x",b).attr("y",a).attr("width",l).attr("height",v).style("opacity",0).transition().style("opacity",1),e.exit().transition().style("opacity",0).remove(),y.selectAll(".-line").transition().duration(w).attr("d",fe)));k.selectAll(".selected-circles").filter(function(a){return Ka(a)}).selectAll("circle").remove();k.selectAll(".selected-circle").transition().duration(w).attr("cx",g?ia:ha).attr("cy",g?ha:ia);aa||(Eb?(t=function(a,b){var c=0<b?f.data.targets[0].values[b-1].x:void 0,d=b<Pa()-1?f.data.targets[0].values[b+ |
||||
1].x:void 0;return(m(d?d:a.x+50)-m(c?c:a.x-50))/2},e=function(a,b){var c=0<b?f.data.targets[0].values[b-1].x:void 0;return(m(a.x)+m(c?c:a.x-50))/2}):(t=(g?r:n)*Cb()/(Pa()-1),e=function(a){return m(a.x)-t/2}),k.selectAll(".event-rect").attr("x",g?0:e).attr("y",g?e:0).attr("width",g?n:t).attr("height",g?t:r));e=k.select(".regions").selectAll("rect.region").data(O);e.enter().append("rect");e.attr("class",Hd).attr("x",g?0:Db).attr("y",g?Db:q).attr("width",g?n:pc).attr("height",g?pc:r).style("fill-opacity", |
||||
function(a){return p(a.opacity)?a.opacity:0.1});e.exit().transition().duration(w).style("fill-opacity",0).remove()}function ge(){"mousemove"===d.event.sourceEvent.type&&E.altDomain?(m.domain(E.altDomain),E.x(m).updateScaleExtent()):($&&m.orgDomain()[0]===Z[0]&&m.domain([Z[0]-1E-10,m.orgDomain()[1]]),B({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===d.event.sourceEvent.type&&(Sb=!0))}function be(){wa();Xb();K.x(fa);ta&&E.x(m);d.select("svg").attr("width",ub).attr("height",xa);d.select("#"+ |
||||
Nb).select("rect").attr("width",n).attr("height",r);d.select("#xaxis-clip").select("rect").attr("width",V);d.select(".zoom-rect").attr("width",n).attr("height",r);k.select(".x.axis").attr("transform",F.x);k.select(".y2.axis").attr("transform",F.y2);k.select(".chart-arcs").attr("transform",F.arc);za&&(y.select(".x.brush").selectAll("rect").attr("height",oa),y.attr("transform",F.context),y.select(".x.axis").attr("transform",F.subx));Ba&&(Aa.attr("transform",F.legend),sb(f.data.targets,{withTransition:!1})); |
||||
B({withTransition:!1,withUpdateXDomain:!0})}function Wc(a){var b;bd&&Ra(mb(a).filter(function(a){return!(a in N)}),bd);k.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",vc).style("fill",function(a){return S(a.id)}).style("stroke",function(a){return S(a.id)}).style("stroke-width",0).style("cursor",function(a){return ka(a)?"pointer":null}); |
||||
b=k.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class",uc).style("stroke",function(a){return S(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Ed).style("fill",function(a){return S(a.id)}).style("cursor",function(a){return ka(a)?"pointer":null});a.forEach(function(a){k.selectAll(".selected-circles-"+ |
||||
a.id).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});b=k.select(".chart-arcs").selectAll(".chart-arc").data(Ab(a)).enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}).style("opacity",0);b.append("path").attr("class",Fd).style("fill",function(a){return S(a.data.id)}).style("cursor",function(a){return ka(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){Ga(a.data.id);cd(a.data.id)}).on("mouseout",function(a){Ha(a.data.id); |
||||
dd()});b.append("text").attr("dy",".35em").style("text-anchor","middle").style("pointer-events","none");za&&(b=y.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",vc).style("fill",function(a){return S(a.id)}),b=y.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity", |
||||
0),b.append("path").attr("class",uc).style("stroke",function(a){return S(a.id)}));Ba&&sb(a);d.selectAll(".target").transition().style("opacity",1)}function Wa(a,b){f.data.targets.forEach(function(b){for(var d=0;d<a.length;d++)if(b.id===a[d].id){b.values=a[d].values;a.splice(d,1);break}});f.data.targets=f.data.targets.concat(a);Wc(f.data.targets);B();b()}function cd(a){d.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3)}function dd(){d.selectAll(".legend-item").transition().duration(100).style("opacity", |
||||
1)}function sb(a,b){var c=mb(a),d,e=n/2-Xa*Object.keys(a).length/2,g;b=t(b)?{}:b;g=p(b.withTransition)?b.withTransition:!0;d=Aa.selectAll(".legend-item").data(c).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){he(a)}).on("mouseover",function(a){cd(a);f.focus(a)}).on("mouseout",function(){dd();f.revert()});d.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return na/ |
||||
2-16}).attr("width",Xa).attr("height",24);d.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return S(a)}).attr("x",-200).attr("y",function(){return na/2-9}).attr("width",10).attr("height",10);d.append("text").text(function(a){return p(Na[a])?Na[a]:a}).style("pointer-events","none").attr("x",-200).attr("y",function(){return na/2});Aa.selectAll("rect.legend-item-event").data(c).transition().duration(g?250:0).attr("x",function(a,b){return e+Xa* |
||||
b});Aa.selectAll("rect.legend-item-tile").data(c).transition().duration(g?250:0).attr("x",function(a,b){return e+Xa*b});Aa.selectAll("text").data(c).transition().duration(g?250:0).attr("x",function(a,b){return e+Xa*b+14})}function Ya(a){return p(a)?".target-"+a:".target"}function Vb(a){return tc(a.id)}function Wb(a){return"data"in a&&tc(a.data.id)}var f={data:{}},kb={},ba="_expanded_",la="_selected_",Ub="_included_",ya=e(["bindto"],"#chart"),ab=e(["size","width"],null),ic=e(["size","height"],null), |
||||
ec=e(["padding","left"],null),cc=e(["padding","right"],null),ta=e(["zoom","enabled"],!1),ed=e(["zoom","extent"],null),$d=e(["zoom","privileged"],!1),Td=e(["onenter"],function(){}),Ud=e(["onleave"],function(){});if(!("data"in ca))throw Error("data is required in config");var sa=e(["data","x"],null),aa=e(["data","xs"],null),Hb=e(["data","x_format"],"%Y-%m-%d"),Dd=e(["data","id_converter"],function(a){return a}),Na=e(["data","names"],{}),u=e(["data","groups"],[]),nc=e(["data","axes"],{}),bd=e(["data", |
||||
"type"],null),N=e(["data","types"],{}),fd=e(["data","regions"],{}),ie=e(["data","colors"],{}),ja=e(["data","selection","enabled"],!1),ua=e(["data","selection","grouped"],!1),ka=e(["data","selection","isselectable"],function(){return!0}),za=e(["subchart","show"],!1),ac=za?e(["subchart","size","height"],60):0,je=e(["color","pattern"],null),Ba=e(["legend","show"],!0),Xa=e(["legend","item","width"],80),he=e(["legend","item","onclick"],function(){}),gd=e(["axis","x","type"],"indexed"),Ja=e(["axis","x", |
||||
"categories"],[]),od=e(["axis","x","tick","centered"],!1),hb=e(["axis","x","tick","format"],null),rb=e(["axis","x","default"],null),Vd=e(["axis","x","label"],null),vd=e(["axis","y","max"],null),td=e(["axis","y","min"],null),xd=e(["axis","y","center"],null),Wd=e(["axis","y","label"],null),wb=e(["axis","y","inner"],!1),Qd=e(["axis","y","tick","format"],function(a){return a}),La=e(["axis","y","padding"],null),Pd=e(["axis","y","ticks"],10),dc=e(["axis","y2","show"],!1),ud=e(["axis","y2","max"],null), |
||||
sd=e(["axis","y2","min"],null),wd=e(["axis","y2","center"],null),vb=e(["axis","y2","inner"],!1),Sd=e(["axis","y2","tick","format"],function(a){return a}),Ma=e(["axis","y2","padding"],null),Rd=e(["axis","y2","ticks"],10),g=e(["axis","rotated"],!1),Uc=e(["grid","x","show"],!1),de=e(["grid","x","type"],"tick"),Ob=e(["grid","x","lines"],null),Vc=e(["grid","y","show"],!1),Pb=e(["grid","y","lines"],null),Lb=e(["point","show"],!0)?e(["point","r"],2.5):0,Xd=e(["point","focus","line","enabled"],!0),Qb=e(["point", |
||||
"focus","expand","enabled"],!0),Rb=e(["point","focus","expand","r"],Qb?4:Lb),Sa=e(["point","focus","select","r"],8),ce=e(["point","onclick"],function(){}),Ld=e(["point","onselected"],function(){}),Md=e(["point","onunselected"],function(){}),O=e(["regions"],[]),Dc=e(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+M()(a[0].x)+"</th></tr>",c,d,e;for(c=0;c<a.length;c++)p(a[c])?(d=p(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",e=a[c].name):e=d="-", |
||||
b+="<tr class='-tooltip-name-"+a[c].id+"'><td class='name'><span style='background-color:"+S(a[c].id)+"'></span>"+e+"</td><td class='value'>"+d+"</td></tr>";return b+"</table>"}),ae=e(["tooltip","init","show"],!1),Ca=e(["tooltip","init","x"],0),Xc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Nb=ya.replace("#","")+"-clip",Ua="url(#"+Nb+")",z="timeseries"===gd,$="categorized"===gd,Eb=!z&&(sa||aa),Tb=null,Va=!1,Sb=!1,na=Ba?40:0,S=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" "); |
||||
return function(b){if(b in a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(ie,je),pd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"), |
||||
function(a){return a.getSeconds()}],[d.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)}}(),$b,gc,bc,bb,fc,hc,n,r,oa,ub,xa,cb,xb,gb,lc,mc,Ab,jc,kc,yb,zb,m,x,Y,fa,db,eb,D,pa,fb,Ia,kd=g?"left":"bottom",ld=g?wb?"top":"bottom":wb?"right":"left",md=g?vb?"bottom":"top":vb?"left":"right",nd="bottom",F={main:function(){return"translate("+C+","+q+")"},context:function(){return"translate("+l+","+Da+")"},legend:function(){return"translate("+ |
||||
Zb+","+Yb+")"},y2:function(){return"translate("+(g?0:n)+","+(g?10:0)+")"},x:function(){return"translate(0,"+r+")"},subx:function(){return"translate(0,"+oa+")"},arc:function(){return"translate("+n/2+","+r/2+")"}};Ab=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var ee=function(){var a=d.svg.line().x(g?function(a){return H(a.id)(a.value)}:ob).y(g?ob:function(a){return H(a.id)(a.value)});return function(b){var c=Rc(b.values),d;if(Gb(b))return"spline"=== |
||||
N["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),fd[b.id]?Od(c,m,H(b.id),fd[b.id]):a(c);d=m(c[0].x);b=H(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),fe=function(){var a=d.svg.line().x(function(a){return fa(a.x)}).y(function(a){return W(a.id)(a.value)});return function(b){var c=Rc(b.values);return Gb(b)?a(c):"M "+fa(c[0].x)+" "+W(b.id)(c[0].value)}}(),K=d.svg.brush().on("brush",function(){B({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}), |
||||
E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ta?ge:null);K.update=function(){y&&y.select(".x.brush").call(this);return this};E.orgScaleExtent=function(){var a=ed?ed:[1,10];return[a[0],Math.max(Pa()/a[1],a[1])]};E.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(Z[1]-Z[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Ta,qb,k,y,Aa,R,pb,ga=null,qa=null,Z;f.focus=function(a){var b=d.selectAll(Ya(a)), |
||||
c=b.filter(Vb),b=b.filter(Wb);f.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);A(f.data.targets)&&Ga(a,!0)};f.defocus=function(a){var b=d.selectAll(Ya(a)),c=b.filter(Vb),b=b.filter(Wb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);A(f.data.targets)&&Ha(a)};f.revert=function(a){var b=d.selectAll(Ya(a)),c=b.filter(Vb),b=b.filter(Wb);c.classed("focused", |
||||
!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);A(f.data.targets)&&Ha(a)};f.show=function(a){d.selectAll(Ya(a)).transition().style("opacity",1)};f.hide=function(a){d.selectAll(Ya(a)).transition().style("opacity",0)};f.unzoom=function(){K.clear().update();B({withUpdateXDomain:!0})};f.load=function(a){t(a.done)&&(a.done=function(){});"categories"in a&&$&&(Ja=a.categories,D.categories(Ja));if("cacheIds"in a&&zd(a.cacheIds))Wa(Ad(a.cacheIds),a.done);else if("data"in |
||||
a)Wa(Oa(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Wa(Oa(c),a.done)});else if("rows"in a)Wa(Oa(rc(a.rows)),a.done);else if("columns"in a)Wa(Oa(sc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};f.unload=function(a){f.data.targets=f.data.targets.filter(function(b){return b.id!==a});d.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(d.selectAll(".legend-item-"+a).remove(),sb(f.data.targets));0<f.data.targets.length&&B()};f.selected= |
||||
function(a){a=p(a)?"-"+a:"";return d.merge(k.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d.select(this).classed(la)}).map(function(a){return a.map(function(a){return a.__data__})}))};f.select=function(a,b,c){ja&&k.selectAll(".-shapes").selectAll(".-shape").each(function(e,f){var g="circle"===this.nodeName?Nc:Nd,k="circle"===this.nodeName?Ib:Pc;0<=b.indexOf(f)?ka(e)&&(ua||t(a)||0<=a.indexOf(e.id))&&g(d.select(this).classed(la,!0),e,f):p(c)&&c&&k(d.select(this).classed(la, |
||||
!1),e,f)})};f.unselect=function(a,b){ja&&k.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?Ib:Pc;(t(b)||0<=b.indexOf(e))&&ka(c)&&(ua||t(a)||0<=a.indexOf(c.id))&&f(d.select(this).classed(la,!1),c,e)})};f.toLine=function(a){Ra(a,"line");B()};f.toSpline=function(a){Ra(a,"spline");B()};f.toBar=function(a){Ra(a,"bar");B()};f.toScatter=function(a){Ra(a,"scatter");B()};f.groups=function(a){if(t(a))return u;u=a;B();return u};f.regions=function(a){if(t(a))return O; |
||||
O=a;B();return O};f.regions.add=function(a){if(t(a))return O;O=O.concat(a);B();return O};f.regions.remove=function(a,b){var c=[].concat(a);b=p(b)?b:{};c.forEach(function(a){var c=d.selectAll("."+a);p(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();O=O.filter(function(b){return 0>b.classes.indexOf(a)})});return O};f.data.get=function(a){a=f.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};f.data.getAsTarget=function(a){var b= |
||||
jb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};f.destroy=function(){f.data.targets=void 0;f.data.x={};pb.html("");T.onresize=null};if("url"in ca.data)d.csv(ca.data.url,function(a,b){Mb(b)});else if("rows"in ca.data)Mb(rc(ca.data.rows));else if("columns"in ca.data)Mb(sc(ca.data.columns));else throw Error("url or rows or columns is required.");return f}})(window); |
||||
(function(U){function gd(){function p(d,e){d.attr("transform",function(d){return"translate("+(e(d)+da)+", 0)"})}function t(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function U(d){var e=d[0];d=d[d.length-1];return e<d?[e,d]:[d,e]}function Ba(d){for(var e=[],p=Math.ceil(d[0]);p<d[1];p++)e.push(p);0<e.length&&0<e[0]&&e.unshift(e[0]-(e[1]-e[0]));return e}function Ca(d){d=d<V.length?V[d]:d;return W?W(d):d}function n(n){n.each(function(){var n=d.select(this),ka=Ba(s.domain()), |
||||
K=n.selectAll(".tick.major").data(ka,String),H=K.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),I=d.transition(K.exit()).style("opacity",1E-6).remove(),X=d.transition(K).style("opacity",1),O,P=s.rangeExtent?s.rangeExtent():U(s.range()),n=n.selectAll(".domain").data([0]);n.enter().append("path").attr("class","domain");var n=d.transition(n),L=s.copy(),W=this.__chart__||L;this.__chart__=L;H.append("line");H.append("text");var V=H.select("line"),Da=X.select("line"),sa=K.select("text"), |
||||
Ya=H.select("text"),Ea=X.select("text");da=(L(1)-L(0))/2;K=ta?0:da;switch(ea){case "bottom":O=p;V.attr("y2",J);Ya.attr("y",Math.max(J,0)+e);Da.attr("x1",K).attr("x2",K).attr("y2",J);Ea.attr("x",0).attr("y",Math.max(J,0)+e);sa.attr("dy",".71em").style("text-anchor","middle");sa.text(function(d){return ka.length<Y||0===d%Math.ceil(ka.length/Y)?Ca(d):""});n.attr("d","M"+P[0]+","+D+"V0H"+P[1]+"V"+D);break;case "left":O=t,V.attr("x2",-J),Ya.attr("x",-(Math.max(J,0)+e)),Da.attr("x2",-J).attr("y2",0),Ea.attr("x", |
||||
-(Math.max(J,0)+e)).attr("y",da),sa.attr("dy",".32em").style("text-anchor","end"),sa.text(function(d){return ka.length<Y||0===d%Math.ceil(ka.length/Y)?Ca(d):""}),n.attr("d","M"+-D+","+P[0]+"H0V"+P[1]+"H"+-D)}if(s.ticks)H.call(O,W),X.call(O,L),I.call(O,L);else{var Fa=L.rangeBand()/2,I=function(d){return L(d)+Fa};H.call(O,I);X.call(O,I)}})}var s=d.scale.linear(),ea="bottom",J=6,D=6,e=3,ta=!1,Y=10,da=0,W=null,V=[];n.scale=function(d){if(!arguments.length)return s;s=d;return n};n.orient=function(d){if(!arguments.length)return ea; |
||||
ea=d in{top:1,right:1,bottom:1,left:1}?d+"":"bottom";return n};n.categories=function(d){if(!arguments.length)return V;V=d;return n};n.tickCentered=function(d){if(!arguments.length)return ta;ta=d;return n};n.tickTextNum=function(d){if(!arguments.length)return Y;Y=d;return n};n.tickFormat=function(d){if(!arguments.length)return W;W=d;return n};n.tickOffset=function(){return da};n.ticks=function(){};return n}function t(d){return"undefined"===typeof d}function p(d){return"undefined"!==typeof d}var sb= |
||||
U.c3={},d=U.d3;sb.generate=function(ca){var Xb,Yb,Ba,Ca,n,s,ea,J,D;function e(a,b){for(var c=ca,k=0;k<a.length;k++){if(!(a[k]in c))return b;c=c[a[k]]}return c}function ta(){tb=null===Za?da():Za;ua=Y();Zb=20+$b+la;ac=bc?bc:cc?ub||h?1:40:20;$a=dc?dc:vb?1:40;ec=ua-$b-la;fc=20+la;gc=ua-la;s=0;ea=ac;J=Zb;D=$a;Ba=ec;Ca=fc;n=$a;Xb=gc;Yb=$a;r=tb-D-ea;q=ua-s-J;ma=ua-Ba-Ca;wb=q/2;ab=0.95*wb}function Y(){var a=null===hc?+d.select(va).style("height").replace("px",""):hc;return 0<a?a:320}function da(){return+d.select(va).style("width").replace("px", |
||||
"")}function W(){return r+2+D+ea}function V(){return 40}function ka(){return D+20}function sb(){return q-s+42}function Wb(){ic=h?10:0;jc=h?q:r;xb=h?0:q;yb=h?r:1;m=K(ic,jc,p(m)?m.domain():void 0,function(){return E.tickOffset()});x=H(xb,yb,p(x)?x.domain():void 0);Z=H(xb,yb,p(Z)?Z.domain():void 0);Q=K(0,r,p(R)?R:void 0,function(a){return 0===a%1?Ga.tickOffset():0});bb=H(ma,10);cb=H(ma,10);E=O(m,jd);na=d.svg.axis().scale(x).orient(kd);db=d.svg.axis().scale(Z).orient(ld);Ga=O(Q,md);eb=hd();kc=Da();lc= |
||||
Da(0.98)}function K(a,b,c,k){var f=(z?d.time.scale():d.scale.linear()).range([a,b]);f.orgDomain=function(){return f.domain()};p(c)&&f.domain(c);t(k)&&(k=function(){return 0});if($){var wa=f,e,f=function(a){return wa(a)+k(a)};for(e in wa)f[e]=wa[e];f.orgDomain=function(){return wa.domain()};f.domain=function(a){if(!arguments.length)return a=wa.domain(),[a[0],a[1]+1];wa.domain(a);return f}}return f}function H(a,b){return d.scale.linear().range([a,b])}function I(a){return"y2"===P(a)?Z:x}function X(a){return"y2"=== |
||||
P(a)?cb:bb}function O(a,b){var c=($?gd():d.svg.axis()).scale(a).orient(b);c.tickFormat(L());$?c.categories(Ha).tickCentered(nd):c.tickOffset=function(){return 0};return c}function P(a){return a in mc?mc[a]:"y"}function L(){var a=z?od:$?pd:function(a){return a};fb&&(a="function"===typeof fb?fb:z?function(a){return d.time.format(fb)(a)}:a);return a}function Xa(a){var b=!1;zb(g.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function hd(){var a=d.svg.arc().outerRadius(ab).innerRadius(0), |
||||
b=function(b,k){var f;return k?a(b):(f=Xa(b))?a(f):"M 0 0"};b.centroid=a.centroid;return b}function Da(a){var b=d.svg.arc().outerRadius(wb*(a?a:1)).innerRadius(0);return function(a){return(a=Xa(a))?b(a):"M 0 0"}}function sa(a){a=Xa(a);var b,c;b="";a&&(b=eb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*ab+","+0.8*(b/c)*ab+")");return b}function Ya(a){return(100*(a.endAngle-a.startAngle)/(2*Math.PI)).toFixed(1)+"%"}function Ea(a,b){var c=d.selectAll(".chart-arc.target"+(a? |
||||
"-"+a:"")),k=d.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",kc).transition().duration(100).attr("d",lc);b||k.style("opacity",0.3)}function Fa(a){d.selectAll(".chart-arc.target"+(a?"-"+a:"")).selectAll("path").transition().duration(50).attr("d",eb);d.selectAll(".-arc").style("opacity",1)}function id(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.value})})}function qd(a){var b={},c,k;a.forEach(function(a){b[a.id]= |
||||
[];a.values.forEach(function(c){b[a.id].push(c.value)})});for(c=0;c<u.length;c++)for(k=1;k<u[c].length;k++)Ia(u[c][k])&&(t(b[u[c][k]])||b[u[c][k]].forEach(function(a,d){P(u[c][k])===P(u[c][0])&&(b[u[c][0]][d]+=1*a)}));return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function gb(a){var b=hb(function(b){return P(b.id)===a}),c="y2"===a?rd:sd,k="y2"===a?td:ud,c=null!==c?c:id(b),k=null!==k?k:qd(b),f=0.1*Math.abs(k-c),d=f,e=f,g="y2"===a?vd:wd;null!==g&&(c=Math.max(Math.abs(c),Math.abs(k)), |
||||
k=c-g,c=g-c);"y"===a&&null!==Ja&&(d=p(Ja.top)?Ja.top:f,e=p(Ja.bottom)?Ja.bottom:f);"y2"===a&&null!==Ka&&(d=p(Ka.top)?Ka.top:f,e=p(Ka.bottom)?Ka.bottom:f);return[Ab(b,"bar")?0:c-e,k+d]}function Bb(a){var b;a?(a=m.domain(),b=F.extent()):(a=R,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function xd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function yd(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function ib(a){var b=[xd(a),yd(a)]; |
||||
a=b[0];var b=b[1],c=$?0:0.01*Math.abs(a-b);a=z?new Date(a.getTime()-c):a-c;b=z?new Date(b.getTime()+c):b+c;return[a,b]}function zd(a){for(var b=0;b<a.length;b++)if(!(a[b]in jb))return!1;return!0}function Ad(a){for(var b=[],c=0;c<a.length;c++)a[c]in jb&&b.push(nc(jb[a[c]]));return b}function Cb(a){return"start"in a?m(z?oa(a.start):a.start):0}function oc(a){var b=Cb(a);a=("end"in a?m(z?oa(a.end):a.end):r)-b;return 0>a?0:a}function pc(a){return pa&&a===pa||aa&&Bd(aa,a)}function Cd(a){return!pc(a)}function kb(a){var b= |
||||
La[a.id];a.name=p(b)?b:a.id;return a}function qc(a){var b=a[0],c={},k=[],f,d;for(f=1;f<a.length;f++){c={};for(d=0;d<a[f].length;d++)c[b[d]]=a[f][d];k.push(c)}return k}function rc(a){var b=[],c,k,d;for(c=0;c<a.length;c++)for(d=a[c][0],k=1;k<a[c].length;k++)t(b[k-1])&&(b[k-1]={}),b[k-1][d]=a[c][k];return b}function Ma(a){var b=d.keys(a[0]).filter(Cd),c=d.keys(a[0]).filter(pc);if(z&&0===c.length)return U.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];Db&&b.forEach(function(b){var d= |
||||
pa?pa:aa?aa[b]:null;0<=c.indexOf(d)&&(g.data.x[b]=a.map(function(a){return a[d]}))});b=b.map(function(b){var c=Dd(b);return{id:c,id_org:b,values:a.map(function(a,d){var e;e=pa?pa:aa?aa[b]:null;e=z?oa(a[e]):Db?a[e]?a[e]:b in g.data.x&&g.data.x[d]?g.data.x[d]:d:d;a.x=e;return{x:e,value:null===a[b]||isNaN(a[b])?null:+a[b],id:c}})}});b.forEach(function(a){var b;a.values=a.values.sort(function(a,b){return(a.x||0===a.x?a.x:Infinity)-(b.x||0===b.x?b.x:Infinity)});b=0;a.values.forEach(function(a){a.index= |
||||
b++})});b.forEach(function(a){jb[a.id_org]=nc(a)});return b}function nc(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 Na(){return d.max(g.data.targets,function(a){return a.values.length})}function lb(a){a=t(a)?g.data.targets:a;return a.map(function(a){return a.id})}function sc(a){var b=lb(),c;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1}function hb(a){return p(a)?g.data.targets.filter(a):g.data.targets}function pd(a){return a< |
||||
Ha.length?Ha[a]:a}function mb(a){return"-shapes -shapes-"+a.id}function tc(a){return mb(a)+" -line -line-"+a.id}function Ed(a){return mb(a)+" -circles -circles-"+a.id}function uc(a){return mb(a)+" -bars -bars-"+a.id}function Fd(a){return mb(a.data)+" -arc -arc-"+a.data.id}function Gd(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function vc(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function Hd(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function nb(a){return m(a.x)} |
||||
function Oa(a){return m(z?oa(a.value):a.value)}function wc(a){return x(a.value)}function xc(a,b){var c,k=a[b].x,d=[];for(c=b-1;0<=c&&k===a[c].x;c--)d.push(a[c]);for(c=b;c<a.length&&k===a[c].x;c++)d.push(a[c]);return d}function yc(a,b,c,k){c=c?c:0;k=k?k:a.length-1;var d=Math.floor((k-c)/2)+c;0<m(a[d].x)-b[0]?k=d:c=d;return 1===k-c?(d=[],a[c].x&&(d=d.concat(xc(a,c))),a[k].x&&(d=d.concat(xc(a,k))),zc(d,b)):yc(a,b,c,k)}function Ac(a,b){var c;c=a.map(function(a){return yc(a.values,b)});return zc(c,b)} |
||||
function zc(a,b){var c,k;a.forEach(function(a){var d=Eb(a,b);if(d<c||!c)c=d,k=a});return k}function Bc(a,b){S.html(Cc(a)).style("visibility","hidden").style("display","block");var c=S.property("offsetWidth"),d=S.property("offsetHeight");S.style("top",(b[1]+15+d<Y()?b[1]+15:b[1]-d)+"px").style("left",h?b[0]:m(a[0].x)+60+c<(null===Za?da():Za)?m(a[0].x)+60+"px":m(a[0].x)-c+30+"px").style("visibility","visible")}function Dc(a){Ab(g.data.targets,"scatter")||A(g.data.targets)||l.selectAll("line.xgrid-focus").style("visibility", |
||||
"visible").data([a]).attr(h?"y1":"x1",nb).attr(h?"y2":"x2",nb)}function Ec(){l.select("line.xgrid-focus").style("visibility","hidden")}function fa(a){return a.x||0===a.x?m(a.x):null}function ga(a){return I(a.id)(a.value)}function Id(){var a={},b=0,c,d;hb(Ia).forEach(function(f){for(c=0;c<u.length;c++)if(!(0>u[c].indexOf(f.id)))for(d=0;d<u[c].length;d++)if(u[c][d]in a){a[f.id]=a[u[c][d]];break}t(a[f.id])&&(a[f.id]=b++)});a.__max__=b-1;return a}function Fc(a,b,c,d){var f=d?Q:m;return b?function(d){var k= |
||||
d.id in c?c[d.id]:0;return d.x||0===d.x?f(d.x)-a*(b/2-k):0}:function(){return 0}}function Gc(a,b,c,d){var f=Object.keys(b);return function(e,g){var h=0,l=d?X(e.id):I(e.id);hb(Ia).forEach(function(c){c.id!==e.id&&b[c.id]===b[e.id]&&f.indexOf(c.id)<f.indexOf(e.id)&&(h+=a(c.values[g]))});return c?h:l(e.value)-h}}function Hc(a,b){var c=null===a?function(a){return a}:function(b){return a>b?a-b:0};return function(a){var d=b?X(a.id):I(a.id);return c(d(a.value))}}function Pa(a,b){var c=t(a)?lb():a;"string"=== |
||||
typeof c&&(c=[c]);for(var d=0;d<c.length;d++)M[c[d]]=b}function Ab(a,b){var c=!1;a.forEach(function(a){M[a.id]===b&&(c=!0);a.id in M||"line"!==b||(c=!0)});return c}function A(a){return Ab(a,"pie")}function Fb(a){a="string"===typeof a?a:a.id;return!(a in M)||"line"===M[a]||"spline"===M[a]}function Ia(a){return"bar"===M["string"===typeof a?a:a.id]}function Ic(a){return"pie"===M["string"===typeof a?a:a.id]}function Jc(a){return Ia(a)?a.values:[]}function Jd(a){var b;(b=Fb(a))||(b="scatter"===M["string"=== |
||||
typeof a?a:a.id]);return b?a.values:[]}function oa(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+Gb+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");b=d.time.format(Gb).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+Gb);return b}function Kc(a,b){var c=d.mouse(a),k=d.select(a),f=1*k.attr("cx"),k=1*k.attr("cy");return Math.sqrt(Math.pow(f-c[0],2)+Math.pow(k-c[1],2))<b}function Lc(a){var b=d.mouse(a),c=d.select(a);a=1*c.attr("x"); |
||||
var k=1*c.attr("y"),c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&k-10<b[1]}function Kd(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function Bd(a,b){var c=!1;Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)});return c}function Eb(a,b){return Math.pow(m(a.x)-b[0],2)+Math.pow(x(a.value)-b[1],2)}function Mc(a,b,c){Ld(a,b);l.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",h?ga:fa).attr("cy",h?fa:ga).attr("stroke",function(){return T(b.id)}).attr("r",1.4*Qa).transition().duration(100).attr("r",Qa)}function Hb(a,b,c){Md(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",0).remove()}function Nc(a,b,c,d){a?Mc(b,c,d):Hb(b,c,d)}function Nd(){}function Oc(){}function Pc(a,b,c,d){}function Qc(a){return a.filter(function(a){return null!==a.value})}function Ib(a,b){return(b?l.selectAll(".-circles-"+b): |
||||
l).selectAll(".-circle"+(a||0===a?"-"+a:""))}function Jb(a){Ib(a).filter(function(){return d.select(this).classed(ba)}).classed(ba,!1).attr("r",Kb)}function Rc(a){return l.selectAll(".-bar"+(a||0===a?"-"+a:""))}function Od(a,b,c,d){var f,e,g="M",l,m,n,Sc,r,q=[];if(p(d))for(f=0;f<d.length;f++)q[f]={},t(d[f].start)?q[f].start=a[0].x:q[f].start=z?oa(d[f].start):d[f].start,t(d[f].end)?q[f].end=a[a.length-1].x:q[f].end=z?oa(d[f].end):d[f].end;Sc=h?function(a){return c(a.value)}:function(a){return b(a.x)}; |
||||
r=h?function(a){return b(a.x)}:function(a){return c(a.value)};d=z?function(a,d,k,f){var e=a.x.getTime();a=d.x-a.x;d=new Date(e+a*(k+f));return"M"+b(new Date(e+a*k))+" "+c(m(k))+" "+b(d)+" "+c(m(k+f))}:function(a,d,k,f){return"M"+b(l(k))+" "+c(m(k))+" "+b(l(k+f))+" "+c(m(k+f))};for(f=0;f<a.length;f++)if(t(q)||!Kd(a[f].x,q))g+=" "+Sc(a[f])+" "+r(a[f]);else{l=K(a[f-1].x,a[f].x);m=H(a[f-1].value,a[f].value);e=b(a[f].x)-b(a[f-1].x);n=c(a[f].value)-c(a[f-1].value);e=Math.sqrt(Math.pow(e,2)+Math.pow(n,2)); |
||||
n=2/e;var s=2*n;for(e=n;1>=e;e+=s)g+=d(a[f-1],a[f],e,n)}return g}function Lb(a){var b,c;ob=d.select(va);if(ob.empty())U.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{ob.html("");g.data.x={};g.data.targets=Ma(a);ta();Wb();m.domain(d.extent(ib(g.data.targets)));x.domain(gb("y"));Z.domain(gb("y2"));Q.domain(m.domain());bb.domain(x.domain());cb.domain(Z.domain());E.ticks(10>a.length?a.length:10);na.ticks(Pd).outerTickSize(0).tickFormat(Qd); |
||||
db.ticks(Rd).outerTickSize(0).tickFormat(Sd);R=m.domain();F.x(Q);qa&&B.x(m);Ra=d.select(va).append("svg").attr("width",r+D+ea).attr("height",q+s+J).on("mouseenter",Td).on("mouseleave",Ud);pb=Ra.append("defs");pb.append("clipPath").attr("id",Mb).append("rect").attr("y",s).attr("width",r).attr("height",q-s);pb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-D).attr("y",-20).attr("width",W).attr("height",V);pb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-D+ |
||||
1).attr("y",s-1).attr("width",ka).attr("height",sb);l=Ra.append("g").attr("transform",G.main);y=xa?Ra.append("g").attr("transform",G.context):null;ya=za?Ra.append("g").attr("transform",G.legend):null;S=d.select(va).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",h?"":"url(#xaxis-clip)").attr("transform",G.x).call(h?na:E).append("text").attr("class","-axis-x-label").attr("x", |
||||
r).attr("dy","-.5em").style("text-anchor","end").text(Vd);l.append("g").attr("class","y axis").attr("clip-path",h?"url(#yaxis-clip)":"").call(h?E:na).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Wd);cc&&l.append("g").attr("class","y2 axis").attr("transform",G.y2).call(db);b=l.append("g").attr("clip-path",Sa).attr("class","grid");Tc&&b.append("g").attr("class","xgrids");Nb&&(c=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Nb).enter().append("g").attr("class", |
||||
"xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",h?"":"rotate(-90)").attr("dx",h?0:-s).attr("dy",-6).text(function(a){return a.text}));Xd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",h?0:-10).attr("x2",h?r:-10).attr("y1",h?-10:s).attr("y2",h?-10:q);Uc&&b.append("g").attr("class","ygrids");Ob&&b.append("g").attr("class", |
||||
"ygrid-lines").selectAll("ygrid-line").data(Ob).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});l.append("g").attr("clip-path",Sa).attr("class","regions");l.append("g").attr("clip-path",Sa).attr("class","chart");b=l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",qa?"ew-resize":null);aa?Yd(b):Zd(b,a);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class", |
||||
"chart-arcs").attr("transform",G.arc);if(qa)l.insert("rect",$d?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",q).style("opacity",0).style("cursor","ew-resize").call(B).on("dblclick.zoom",null);null!==qb&&F.extent("function"!==typeof qb?qb:qb(ib()));xa&&(y.append("g").attr("clip-path",Sa).attr("class","chart"),y.select(".chart").append("g").attr("class","chart-bars"),y.select(".chart").append("g").attr("class","chart-lines"),y.append("g").attr("clip-path",Sa).attr("class","x brush").call(F).selectAll("rect").attr("height", |
||||
ma),y.append("g").attr("class","x axis").attr("transform",G.subx).call(Ga));za&&rb(g.data.targets);Vc(g.data.targets);C({withTransition:!1,withUpdateXDomain:!0});if(ae){if(z&&"string"===typeof Aa){Aa=oa(Aa);for(a=0;a<g.data.targets[0].values.length&&0!==g.data.targets[0].values[a].x-Aa;a++);Aa=a}S.html(Cc(g.data.targets.map(function(a){return kb(a.values[Aa])})));S.style("top",Wc.top).style("left",Wc.left).style("display","block")}null==U.onresize&&(U.onresize=be)}}function Zd(a,b){a.selectAll(".event-rects").data(b).enter().append("rect").attr("class", |
||||
function(a,b){return"event-rect event-rect-"+b}).style("cursor",ha&&ra?"pointer":null).on("mouseover",function(a,b){if(!Ta&&!A(g.data.targets)){var d=g.data.targets.map(function(a){return kb(a.values[b])}),e,h;if(0<Object.keys(La).length){h=[];for(var l in La)for(e=0;e<d.length;e++)if(d[e].id===l){h.push(d[e]);d.shift(e);break}d=h.concat(d)}Pb&&Ib(b,void 0).classed(ba,!0).attr("r",Qb);Rc(b).classed(ba,!1);Dc(d[0])}}).on("mouseout",function(a,b){A(g.data.targets)||(Ec(),S.style("display","none"),Jb(b), |
||||
Rc(void 0).classed(ba,!1))}).on("mousemove",function(a,b){var e;Ta||A(g.data.targets)||(e=g.data.targets.map(function(a){return kb(a.values[b])}),Bc(e,d.mouse(this)),ha&&(ra||l.selectAll(".-shape-"+b).filter(function(a){return ia(a)}).each(function(){var a=d.select(this).classed(ba,!0);"circle"===this.nodeName&&a.attr("r",Qb);d.select(".event-rect-"+b).style("cursor",null)}).filter(function(){var a=d.select(this);if("circle"===this.nodeName)return Kc(this,Qa);if("rect"===this.nodeName)return Lc(this, |
||||
a.attr("x"),a.attr("y"))}).each(function(){var a=d.select(this);a.classed(ba)||(a.classed(ba,!0),"circle"===this.nodeName&&a.attr("r",Qa));d.select(".event-rect-"+b).style("cursor","pointer")})))}).on("click",function(a,b){A(g.data.targets)||(Rb?Rb=!1:l.selectAll(".-shape-"+b).each(function(a){Xc(this,a,b)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Yc(d.mouse(this))}).on("dragstart",function(){Zc(d.mouse(this))}).on("dragend",function(){$c()})).call(B).on("dblclick.zoom",null)} |
||||
function Yd(a){a.append("rect").attr("x",0).attr("y",0).attr("width",r).attr("height",q).attr("class","event-rect").on("mouseout",function(){A(g.data.targets)||(Ec(),S.style("display","none"),Jb())}).on("mousemove",function(){var a,c,e;Ta||A(g.data.targets)||(a=d.mouse(this),c=Ac(g.data.targets,a),e=[kb(c)],Bc(e,a),Pb&&(Jb(),Ib(c.index,c.id).classed(ba,!0).attr("r",Qb)),Dc(e[0]),100>Eb(c,a)?d.select(".event-rect").style("cursor","pointer"):d.select(".event-rect").style("cursor",null))}).on("click", |
||||
function(){var a,c;A(g.data.targets)||(a=d.mouse(this),c=Ac(g.data.targets,a),100>Eb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){Xc(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Yc(d.mouse(this))}).on("dragstart",function(){Zc(d.mouse(this))}).on("dragend",function(){$c()})).call(B).on("dblclick.zoom",null)}function Xc(a,b,c){var e=d.select(a),f=e.classed(ja),g=!1,h;"circle"===a.nodeName?(g=Kc(a,1.5*Qa),h=Nc):"rect"===a.nodeName&& |
||||
(g=Lc(a),h=Pc);if(ra||g)ha&&ia(b)&&(e.classed(ja,!f),h(!f,e,b,c)),ce(b,e)}function Yc(a){var b,c,e,f,h,m,n;A(g.data.targets)||!ha||qa&&!B.altDomain||(b=Sb[0],c=Sb[1],e=a[0],a=a[1],f=Math.min(b,e),h=Math.max(b,e),m=ra?s:Math.min(c,a),n=ra?q:Math.max(c,a),l.select(".dragarea").attr("x",f).attr("y",m).attr("width",h-f).attr("height",n-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ia(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ja),k=c.classed(Tb),g,l,p,q;g=!1; |
||||
"circle"===this.nodeName?(g=1*c.attr("cx"),l=1*c.attr("cy"),q=Nc,g=f<g&&g<h&&m<l&&l<n):"rect"===this.nodeName&&(g=1*c.attr("x"),l=1*c.attr("y"),p=1*c.attr("width"),q=Pc,g=f<g+p&&g<h&&l<n);g^k&&(c.classed(Tb,!k),c.classed(ja,!e),q(!e,c,a,b))}))}function Zc(a){!A(g.data.targets)&&ha&&(Sb=a,l.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Ta=!0)}function $c(){!A(g.data.targets)&&ha&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),l.selectAll(".-shape").classed(Tb, |
||||
!1),Ta=!1)}function C(a){var b,c,e,f=Id(),n=f.__max__+1,v,t,u,w;a=p(a)?a:{};c=p(a.withY)?a.withY:!0;u=p(a.withSubchart)?a.withSubchart:!0;w=p(a.withTransition)?a.withTransition:!0;b=p(a.withUpdateXDomain)?a.withUpdateXDomain:!1;a=p(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1;v=A(g.data.targets);w=w?250:0;a&&(m.domain(d.extent(ib(g.data.targets))),R=m.domain(),B.x(m).updateScaleExtent(),Q.domain(m.domain()),F.x(Q));b&&(m.domain(F.empty()?R:F.extent()),qa&&B.x(m).updateScaleExtent());x.domain(gb("y")); |
||||
Z.domain(gb("y2"));l.select(".x.axis").transition().duration(h?w:0).call(h?na:E).style("opacity",v?0:1);l.select(".y.axis").transition().duration(h?0:w).call(h?E:na).style("opacity",v?0:1);l.select(".y2.axis").transition().call(db).style("opacity",v?0:1);l.select(".x.axis .-axis-x-label").attr("x",r);bb.domain(x.domain());cb.domain(Z.domain());S.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",q);if(Tc){if("year"===de)for(b=[],v=ib(),a=v[0].getFullYear(), |
||||
v=v[1].getFullYear();a<=v;a++)b.push(new Date(a+"-01-01 00:00:00"));else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",h?0:function(a){return m(a)-E.tickOffset()}).attr("x2",h?r:function(a){return m(a)-E.tickOffset()}).attr("y1",h?function(a){return m(a)-E.tickOffset()}:s).attr("y2",h?function(a){return m(a)-E.tickOffset()}:q).style("opacity",function(){return+d.select(this).attr(h?"y1":"x1")===(h?q:0)?0:1});b.exit().remove()}Nb&& |
||||
(b=l.selectAll(".xgrid-lines"),b.selectAll("line").attr("x1",h?0:Oa).attr("x2",h?r:Oa).attr("y1",h?Oa:s).attr("y2",h?Oa:q),b.selectAll("text").attr("x",h?r:0).attr("y",Oa));c&&Uc&&(b=l.select(".ygrids").selectAll(".ygrid").data(x.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",h?x:0).attr("x2",h?x:r).attr("y1",h?0:x).attr("y2",h?q:x),b.exit().remove());c&&Ob&&l.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",wc).attr("y2",wc);a=$?n?1.2*E.tickOffset()/n:0:0.6*((h?q: |
||||
r)*Bb(!1)/(Na()-1));v=Hc(h?null:q);c=Fc(a,n,f);b=Gc(v,f,h);e=l.selectAll(".-bars").selectAll(".-bar").data(Jc);e.transition().duration(w).attr("x",h?b:c).attr("y",h?c:b).attr("width",h?v:a).attr("height",h?a:v);e.enter().append("rect").attr("class",vc).attr("x",h?b:c).attr("y",h?c:b).attr("width",h?v:a).attr("height",h?a:v).style("opacity",0).transition().duration(w).style("opacity",1);e.exit().transition().duration(w).style("opacity",0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(w).attr("d", |
||||
ee);c=l.selectAll(".-circles").selectAll(".-circle").data(Jd);c.transition().duration(w).style("opacity",function(a){return null===a.value?0:1}).attr("cx",h?ga:fa).attr("cy",h?fa:ga);c.enter().append("circle").style("opacity",function(a){return null===a.value?0:1}).attr("class",Gd).attr("cx",h?ga:fa).attr("cy",h?fa:ga).attr("r",Kb);c.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(w).attrTween("d",function(a){a= |
||||
Xa(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Ic(a.data)?eb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",sa).attr("opacity",0).transition().duration(w).text(Ya).attr("opacity",function(a){return Ic(a.data)?1:0});xa&&(null!==d.event&&"zoom"===d.event.type&&F.extent(m.orgDomain()).update(),u&&(y.select(".x.axis").transition().duration(h?w:0).call(h?na:Ga),F.empty()|| |
||||
F.extent(m.orgDomain()).update(),a=$?n?1.2*Ga.tickOffset()/n:0:0.6*((h?q:r)*Bb(!0)/(Na()-1)),v=Hc(ma,!0),c=Fc(a,n,f,!0),b=Gc(v,f,!1,!0),f=y.selectAll(".-bars").selectAll(".-bar").data(Jc),f.transition().duration(w).attr("x",c).attr("y",b).attr("width",a).attr("height",v),f.enter().append("rect").attr("class",vc).attr("x",c).attr("y",b).attr("width",a).attr("height",v).style("opacity",0).transition().style("opacity",1),f.exit().transition().style("opacity",0).remove(),y.selectAll(".-line").transition().duration(w).attr("d", |
||||
fe)));l.selectAll(".selected-circles").filter(function(a){return Ia(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(w).attr("cx",h?ga:fa).attr("cy",h?fa:ga);aa||(Db?(t=function(a,b){var c=0<b?g.data.targets[0].values[b-1].x:void 0,d=b<Na()-1?g.data.targets[0].values[b+1].x:void 0;return(m(d?d:a.x+50)-m(c?c:a.x-50))/2},f=function(a,b){var c=0<b?g.data.targets[0].values[b-1].x:void 0;return(m(a.x)+m(c?c:a.x-50))/2}):(t=(h?q:r)*Bb()/(Na()-1),f=function(a){return m(a.x)- |
||||
t/2}),l.selectAll(".event-rect").attr("x",h?0:f).attr("y",h?f:0).attr("width",h?r:t).attr("height",h?t:q));f=l.select(".regions").selectAll("rect.region").data(N);f.enter().append("rect");f.attr("class",Hd).attr("x",h?0:Cb).attr("y",h?Cb:s).attr("width",h?r:oc).attr("height",h?oc:q).style("fill-opacity",function(a){return p(a.opacity)?a.opacity:0.1});f.exit().transition().duration(w).style("fill-opacity",0).remove()}function ge(){"mousemove"===d.event.sourceEvent.type&&B.altDomain?(m.domain(B.altDomain), |
||||
B.x(m).updateScaleExtent()):($&&m.orgDomain()[0]===R[0]&&m.domain([R[0]-1E-10,m.orgDomain()[1]]),C({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===d.event.sourceEvent.type&&(Rb=!0))}function be(){ta();Wb();F.x(Q);qa&&B.x(m);d.select("svg").attr("width",tb).attr("height",ua);d.select("#"+Mb).select("rect").attr("width",r).attr("height",q);d.select("#xaxis-clip").select("rect").attr("width",W);d.select(".zoom-rect").attr("width",r).attr("height",q);l.select(".x.axis").attr("transform",G.x); |
||||
l.select(".y2.axis").attr("transform",G.y2);l.select(".chart-arcs").attr("transform",G.arc);xa&&(y.select(".x.brush").selectAll("rect").attr("height",ma),y.attr("transform",G.context),y.select(".x.axis").attr("transform",G.subx));za&&(ya.attr("transform",G.legend),rb(g.data.targets,{withTransition:!1}));C({withTransition:!1,withUpdateXDomain:!0})}function Vc(a){var b;ad&&Pa(lb(a).filter(function(a){return!(a in M)}),ad);l.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class", |
||||
function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",uc).style("fill",function(a){return T(a.id)}).style("stroke",function(a){return T(a.id)}).style("stroke-width",0).style("cursor",function(a){return ia(a)?"pointer":null});b=l.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class", |
||||
tc).style("stroke",function(a){return T(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Ed).style("fill",function(a){return T(a.id)}).style("cursor",function(a){return ia(a)?"pointer":null});a.forEach(function(a){l.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});b=l.select(".chart-arcs").selectAll(".chart-arc").data(zb(a)).enter().append("g").attr("class", |
||||
function(a){return"chart-arc target target-"+a.data.id}).style("opacity",0);b.append("path").attr("class",Fd).style("fill",function(a){return T(a.data.id)}).style("cursor",function(a){return ia(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){Ea(a.data.id);bd(a.data.id)}).on("mouseout",function(a){Fa(a.data.id);cd()});b.append("text").attr("dy",".35em").style("text-anchor","middle").style("pointer-events","none");xa&&(b=y.select(".chart-bars").selectAll(".chart-bar").data(a), |
||||
b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",uc).style("fill",function(a){return T(a.id)}),b=y.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",tc).style("stroke",function(a){return T(a.id)}));za&&rb(a);d.selectAll(".target").transition().style("opacity",1)}function Ua(a, |
||||
b){g.data.targets.forEach(function(b){for(var d=0;d<a.length;d++)if(b.id===a[d].id){b.values=a[d].values;a.splice(d,1);break}});g.data.targets=g.data.targets.concat(a);Vc(g.data.targets);C({withUpdateOrgXDomain:!0,withUpdateXDomain:!0});b()}function bd(a){d.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3)}function cd(){d.selectAll(".legend-item").transition().duration(100).style("opacity",1)}function rb(a,b){var c=lb(a),d,e=r/2-Va*Object.keys(a).length/ |
||||
2,h;b=t(b)?{}:b;h=p(b.withTransition)?b.withTransition:!0;d=ya.selectAll(".legend-item").data(c).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){he(a)}).on("mouseover",function(a){bd(a);g.focus(a)}).on("mouseout",function(){cd();g.revert()});d.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return la/2-16}).attr("width",Va).attr("height",24);d.append("rect").attr("class", |
||||
"legend-item-tile").style("pointer-events","none").style("fill",function(a){return T(a)}).attr("x",-200).attr("y",function(){return la/2-9}).attr("width",10).attr("height",10);d.append("text").text(function(a){return p(La[a])?La[a]:a}).style("pointer-events","none").attr("x",-200).attr("y",function(){return la/2});ya.selectAll("rect.legend-item-event").data(c).transition().duration(h?250:0).attr("x",function(a,b){return e+Va*b});ya.selectAll("rect.legend-item-tile").data(c).transition().duration(h? |
||||
250:0).attr("x",function(a,b){return e+Va*b});ya.selectAll("text").data(c).transition().duration(h?250:0).attr("x",function(a,b){return e+Va*b+14})}function Wa(a){return p(a)?".target-"+a:".target"}function Ub(a){return sc(a.id)}function Vb(a){return"data"in a&&sc(a.data.id)}var g={data:{}},jb={},ba="_expanded_",ja="_selected_",Tb="_included_",va=e(["bindto"],"#chart"),Za=e(["size","width"],null),hc=e(["size","height"],null),dc=e(["padding","left"],null),bc=e(["padding","right"],null),qa=e(["zoom", |
||||
"enabled"],!1),dd=e(["zoom","extent"],null),$d=e(["zoom","privileged"],!1),Td=e(["onenter"],function(){}),Ud=e(["onleave"],function(){});if(!("data"in ca))throw Error("data is required in config");var pa=e(["data","x"],null),aa=e(["data","xs"],null),Gb=e(["data","x_format"],"%Y-%m-%d"),Dd=e(["data","id_converter"],function(a){return a}),La=e(["data","names"],{}),u=e(["data","groups"],[]),mc=e(["data","axes"],{}),ad=e(["data","type"],null),M=e(["data","types"],{}),ed=e(["data","regions"],{}),ie=e(["data", |
||||
"colors"],{}),ha=e(["data","selection","enabled"],!1),ra=e(["data","selection","grouped"],!1),ia=e(["data","selection","isselectable"],function(){return!0}),xa=e(["subchart","show"],!1),$b=xa?e(["subchart","size","height"],60):0,je=e(["color","pattern"],null),za=e(["legend","show"],!0),Va=e(["legend","item","width"],80),he=e(["legend","item","onclick"],function(){}),fd=e(["axis","x","type"],"indexed"),Ha=e(["axis","x","categories"],[]),nd=e(["axis","x","tick","centered"],!1),fb=e(["axis","x","tick", |
||||
"format"],null),qb=e(["axis","x","default"],null),Vd=e(["axis","x","label"],null),ud=e(["axis","y","max"],null),sd=e(["axis","y","min"],null),wd=e(["axis","y","center"],null),Wd=e(["axis","y","label"],null),vb=e(["axis","y","inner"],!1),Qd=e(["axis","y","tick","format"],function(a){return a}),Ja=e(["axis","y","padding"],null),Pd=e(["axis","y","ticks"],10),cc=e(["axis","y2","show"],!1),td=e(["axis","y2","max"],null),rd=e(["axis","y2","min"],null),vd=e(["axis","y2","center"],null),ub=e(["axis","y2", |
||||
"inner"],!1),Sd=e(["axis","y2","tick","format"],function(a){return a}),Ka=e(["axis","y2","padding"],null),Rd=e(["axis","y2","ticks"],10),h=e(["axis","rotated"],!1),Tc=e(["grid","x","show"],!1),de=e(["grid","x","type"],"tick"),Nb=e(["grid","x","lines"],null),Uc=e(["grid","y","show"],!1),Ob=e(["grid","y","lines"],null),Kb=e(["point","show"],!0)?e(["point","r"],2.5):0,Xd=e(["point","focus","line","enabled"],!0),Pb=e(["point","focus","expand","enabled"],!0),Qb=e(["point","focus","expand","r"],Pb?4:Kb), |
||||
Qa=e(["point","focus","select","r"],8),ce=e(["point","onclick"],function(){}),Ld=e(["point","onselected"],function(){}),Md=e(["point","onunselected"],function(){}),N=e(["regions"],[]),Cc=e(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+L()(a[0].x)+"</th></tr>",c,d,e;for(c=0;c<a.length;c++)p(a[c])?(d=p(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",e=a[c].name):e=d="-",b+="<tr class='-tooltip-name-"+a[c].id+"'><td class='name'><span style='background-color:"+ |
||||
T(a[c].id)+"'></span>"+e+"</td><td class='value'>"+d+"</td></tr>";return b+"</table>"}),ae=e(["tooltip","init","show"],!1),Aa=e(["tooltip","init","x"],0),Wc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Mb=va.replace("#","")+"-clip",Sa="url(#"+Mb+")",z="timeseries"===fd,$="categorized"===fd,Db=!z&&(pa||aa),Sb=null,Ta=!1,Rb=!1,la=za?40:0,T=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in |
||||
a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(ie,je),od=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"),function(a){return a.getSeconds()}], |
||||
[d.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)}}(),Zb,fc,ac,$a,ec,gc,r,q,ma,tb,ua,ab,wb,eb,kc,lc,zb,ic,jc,xb,yb,m,x,Z,Q,bb,cb,E,na,db,Ga,jd=h?"left":"bottom",kd=h?vb?"top":"bottom":vb?"right":"left",ld=h?ub?"bottom":"top":ub?"left":"right",md="bottom",G={main:function(){return"translate("+D+","+s+")"},context:function(){return"translate("+n+","+Ba+")"},legend:function(){return"translate("+Yb+","+Xb+")"}, |
||||
y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"},x:function(){return"translate(0,"+q+")"},subx:function(){return"translate(0,"+ma+")"},arc:function(){return"translate("+r/2+","+q/2+")"}};zb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var ee=function(){var a=d.svg.line().x(h?function(a){return I(a.id)(a.value)}:nb).y(h?nb:function(a){return I(a.id)(a.value)});return function(b){var c=Qc(b.values),d;if(Fb(b))return"spline"===M["string"===typeof b? |
||||
b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),ed[b.id]?Od(c,m,I(b.id),ed[b.id]):a(c);d=m(c[0].x);b=I(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),fe=function(){var a=d.svg.line().x(function(a){return Q(a.x)}).y(function(a){return X(a.id)(a.value)});return function(b){var c=Qc(b.values);return Fb(b)?a(c):"M "+Q(c[0].x)+" "+X(b.id)(c[0].value)}}(),F=d.svg.brush().on("brush",function(){C({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),B=d.behavior.zoom().on("zoomstart", |
||||
function(){B.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",qa?ge:null);F.update=function(){y&&y.select(".x.brush").call(this);return this};B.orgScaleExtent=function(){var a=dd?dd:[1,10];return[a[0],Math.max(Na()/a[1],a[1])]};B.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(R[1]-R[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Ra,pb,l,y,ya,S,ob,R;g.focus=function(a){var b=d.selectAll(Wa(a)),c=b.filter(Ub),b=b.filter(Vb);g.defocus(); |
||||
c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);A(g.data.targets)&&Ea(a,!0)};g.defocus=function(a){var b=d.selectAll(Wa(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);A(g.data.targets)&&Fa(a)};g.revert=function(a){var b=d.selectAll(Wa(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity", |
||||
1);b.transition().duration(100).style("opacity",1);A(g.data.targets)&&Fa(a)};g.show=function(a){d.selectAll(Wa(a)).transition().style("opacity",1)};g.hide=function(a){d.selectAll(Wa(a)).transition().style("opacity",0)};g.unzoom=function(){F.clear().update();C({withUpdateXDomain:!0})};g.load=function(a){t(a.done)&&(a.done=function(){});"categories"in a&&$&&(Ha=a.categories,E.categories(Ha));if("cacheIds"in a&&zd(a.cacheIds))Ua(Ad(a.cacheIds),a.done);else if("data"in a)Ua(Ma(a.data),a.done);else if("url"in |
||||
a)d.csv(a.url,function(b,c){Ua(Ma(c),a.done)});else if("rows"in a)Ua(Ma(qc(a.rows)),a.done);else if("columns"in a)Ua(Ma(rc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};g.unload=function(a){g.data.targets=g.data.targets.filter(function(b){return b.id!==a});d.selectAll(".target-"+a).transition().style("opacity",0).remove();za&&(d.selectAll(".legend-item-"+a).remove(),rb(g.data.targets));0<g.data.targets.length&&C({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})};g.selected= |
||||
function(a){a=p(a)?"-"+a:"";return d.merge(l.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d.select(this).classed(ja)}).map(function(a){return a.map(function(a){return a.__data__})}))};g.select=function(a,b,c){ha&&l.selectAll(".-shapes").selectAll(".-shape").each(function(e,f){var g="circle"===this.nodeName?Mc:Nd,h="circle"===this.nodeName?Hb:Oc;0<=b.indexOf(f)?ia(e)&&(ra||t(a)||0<=a.indexOf(e.id))&&g(d.select(this).classed(ja,!0),e,f):p(c)&&c&&h(d.select(this).classed(ja, |
||||
!1),e,f)})};g.unselect=function(a,b){ha&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?Hb:Oc;(t(b)||0<=b.indexOf(e))&&ia(c)&&(ra||t(a)||0<=a.indexOf(c.id))&&f(d.select(this).classed(ja,!1),c,e)})};g.toLine=function(a){Pa(a,"line");C()};g.toSpline=function(a){Pa(a,"spline");C()};g.toBar=function(a){Pa(a,"bar");C()};g.toScatter=function(a){Pa(a,"scatter");C()};g.groups=function(a){if(t(a))return u;u=a;C();return u};g.regions=function(a){if(t(a))return N; |
||||
N=a;C();return N};g.regions.add=function(a){if(t(a))return N;N=N.concat(a);C();return N};g.regions.remove=function(a,b){var c=[].concat(a);b=p(b)?b:{};c.forEach(function(a){var c=d.selectAll("."+a);p(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();N=N.filter(function(b){return 0>b.classes.indexOf(a)})});return N};g.data.get=function(a){a=g.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};g.data.getAsTarget=function(a){var b= |
||||
hb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};g.destroy=function(){g.data.targets=void 0;g.data.x={};ob.html("");U.onresize=null};if("url"in ca.data)d.csv(ca.data.url,function(a,b){Lb(b)});else if("rows"in ca.data)Lb(qc(ca.data.rows));else if("columns"in ca.data)Lb(rc(ca.data.columns));else throw Error("url or rows or columns is required.");return g}})(window); |
||||
|
Loading…
Reference in new issue