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