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