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