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