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