Browse Source

Fix y label when rotated axis

pull/8/head
Masayuki Tanaka 11 years ago
parent
commit
535d4ac2c6
  1. 6
      c3.js
  2. 16
      c3.min.js

6
c3.js

@ -260,7 +260,7 @@
return 40; return 40;
} }
function getYAxisClipWidth() { function getYAxisClipWidth() {
return margin.left; return margin.left + 20;
} }
function getYAxisClipHeight() { function getYAxisClipHeight() {
return height - margin.top + 2 + getXAxisClipHeight(); return height - margin.top + 2 + getXAxisClipHeight();
@ -989,6 +989,7 @@
.attr("transform", translate.x) .attr("transform", translate.x)
.call(__axis_rotated ? yAxis : xAxis) .call(__axis_rotated ? yAxis : xAxis)
.append("text") .append("text")
.attr("class", "label")
.attr("x", width) .attr("x", width)
.attr("dy", "-.5em") .attr("dy", "-.5em")
.style("text-anchor", "end") .style("text-anchor", "end")
@ -1375,6 +1376,9 @@
main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis); main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis);
main.select(".y2.axis").transition().call(yAxis2); main.select(".y2.axis").transition().call(yAxis2);
// Update label position
main.select(".x.axis text.label").attr("x", width);
// Update sub domain // Update sub domain
subY.domain(y.domain()); subY.domain(y.domain());
subY2.domain(y2.domain()); subY2.domain(y2.domain());

16
c3.min.js vendored

@ -3,8 +3,8 @@
2;I=c?0:V;switch(w){case "bottom":M=p;ia.attr("y2",A);Ra.attr("y",Math.max(A,0)+B);ra.attr("x1",I).attr("x2",I).attr("y2",A);ta.attr("x",0).attr("y",Math.max(A,0)+B);sa.attr("dy",".71em").style("text-anchor","middle");sa.text(function(e){return ha.length<Q||0===e%Math.ceil(ha.length/Q)?e<W.length?W[e]:e:""});n.attr("d","M"+N[0]+","+X+"V0H"+N[1]+"V"+X);break;case "left":M=s,ia.attr("x2",-A),Ra.attr("x",-(Math.max(A,0)+B)),ra.attr("x2",-A).attr("y2",0),ta.attr("x",-(Math.max(A,0)+B)).attr("y",V),sa.attr("dy", 2;I=c?0:V;switch(w){case "bottom":M=p;ia.attr("y2",A);Ra.attr("y",Math.max(A,0)+B);ra.attr("x1",I).attr("x2",I).attr("y2",A);ta.attr("x",0).attr("y",Math.max(A,0)+B);sa.attr("dy",".71em").style("text-anchor","middle");sa.text(function(e){return ha.length<Q||0===e%Math.ceil(ha.length/Q)?e<W.length?W[e]:e:""});n.attr("d","M"+N[0]+","+X+"V0H"+N[1]+"V"+X);break;case "left":M=s,ia.attr("x2",-A),Ra.attr("x",-(Math.max(A,0)+B)),ra.attr("x2",-A).attr("y2",0),ta.attr("x",-(Math.max(A,0)+B)).attr("y",V),sa.attr("dy",
".32em").style("text-anchor","end"),sa.text(function(e){return ha.length<Q||0===e%Math.ceil(ha.length/Q)?e<W.length?W[e]:e:""}),n.attr("d","M"+-X+","+N[0]+"H0V"+N[1]+"H"+-X)}if(H.ticks)D.call(M,db),P.call(M,O),E.call(M,O);else{var Sa=O.rangeBand()/2,E=function(e){return O(e)+Sa};D.call(M,E);P.call(M,E)}})}var H=e.scale.linear(),w="bottom",A=6,X=6,B=3,c=!1,Q=10,V=0,W=[];n.scale=function(e){if(!arguments.length)return H;H=e;return n};n.orient=function(e){if(!arguments.length)return w;w=e in{top:1,right:1, ".32em").style("text-anchor","end"),sa.text(function(e){return ha.length<Q||0===e%Math.ceil(ha.length/Q)?e<W.length?W[e]:e:""}),n.attr("d","M"+-X+","+N[0]+"H0V"+N[1]+"H"+-X)}if(H.ticks)D.call(M,db),P.call(M,O),E.call(M,O);else{var Sa=O.rangeBand()/2,E=function(e){return O(e)+Sa};D.call(M,E);P.call(M,E)}})}var H=e.scale.linear(),w="bottom",A=6,X=6,B=3,c=!1,Q=10,V=0,W=[];n.scale=function(e){if(!arguments.length)return H;H=e;return n};n.orient=function(e){if(!arguments.length)return w;w=e in{top:1,right:1,
bottom:1,left:1}?e+"":"bottom";return n};n.categories=function(e){if(!arguments.length)return W;W=e;return n};n.tickCentered=function(e){if(!arguments.length)return c;c=e;return n};n.tickTextNum=function(e){if(!arguments.length)return Q;Q=e;return n};n.tickOffset=function(){return V};n.ticks=function(){};return n}function s(e){return"undefined"===typeof e}function p(e){return"undefined"!==typeof e}var eb=ga.c3={},e=ga.d3;eb.generate=function(U){var Ab,Bb,Ba,n,H,w,A,X,B;function c(a,b){for(var d=U, bottom:1,left:1}?e+"":"bottom";return n};n.categories=function(e){if(!arguments.length)return W;W=e;return n};n.tickCentered=function(e){if(!arguments.length)return c;c=e;return n};n.tickTextNum=function(e){if(!arguments.length)return Q;Q=e;return n};n.tickOffset=function(){return V};n.ticks=function(){};return n}function s(e){return"undefined"===typeof e}function p(e){return"undefined"!==typeof e}var eb=ga.c3={},e=ga.d3;eb.generate=function(U){var Ab,Bb,Ba,n,H,w,A,X,B;function c(a,b){for(var d=U,
h=0;h<a.length;h++){if(!(a[h]in d))return b;d=d[a[h]]}return d}function Q(){fb=null===Db?+e.select(ua).style("width").replace("px",""):Db;var a=null===Eb?+e.select(ua).style("height").replace("px",""):Eb;va=0<a?a:320;Fb=20+Gb+ja;Hb=Ib?Ib:Jb?gb||f?1:40:20;Ta=Kb?Kb:hb?1:40;Lb=va-Gb-ja;Mb=20+ja;Nb=va-ja;w=0;A=Hb;X=Fb;B=Ta;Ba=Lb;n=Mb;H=Ta;Ab=Nb;Bb=Ta;q=fb-B-A;t=va-w-X;ka=va-Ba-n}function V(){return q+2+B+A}function W(){return 40}function ha(){return B}function eb(){return t-w+42}function zb(){Ob=f?10: h=0;h<a.length;h++){if(!(a[h]in d))return b;d=d[a[h]]}return d}function Q(){fb=null===Db?+e.select(ua).style("width").replace("px",""):Db;var a=null===Eb?+e.select(ua).style("height").replace("px",""):Eb;va=0<a?a:320;Fb=20+Gb+ja;Hb=Ib?Ib:Jb?gb||f?1:40:20;Ta=Kb?Kb:hb?1:40;Lb=va-Gb-ja;Mb=20+ja;Nb=va-ja;w=0;A=Hb;X=Fb;B=Ta;Ba=Lb;n=Mb;H=Ta;Ab=Nb;Bb=Ta;q=fb-B-A;t=va-w-X;ka=va-Ba-n}function V(){return q+2+B+A}function W(){return 40}function ha(){return B+20}function eb(){return t-w+42}function zb(){Ob=f?
0;Pb=f?t:q;ib=f?0:t;jb=f?q:1;l=I(Ob,Pb,p(l)?l.domain():void 0,function(){return J.tickOffset()});y=D(ib,jb,p(y)?y.domain():void 0);R=D(ib,jb,p(R)?R.domain():void 0);Y=I(0,q,p(S)?S:void 0,function(a){return 0===a%1?Ca.tickOffset():0});Ua=D(ka,10);Va=D(ka,10);J=M(l,xc);la=e.svg.axis().scale(y).orient(yc);Wa=e.svg.axis().scale(R).orient(zc);Ca=M(Y,Ac)}function I(a,b,d,h){var m=(z?e.time.scale():e.scale.linear()).range([a,b]);m.orgDomain=function(){return m.domain()};p(d)&&m.domain(d);s(h)&&(h=function(){return 0}); 10:0;Pb=f?t:q;ib=f?0:t;jb=f?q:1;l=I(Ob,Pb,p(l)?l.domain():void 0,function(){return J.tickOffset()});y=D(ib,jb,p(y)?y.domain():void 0);R=D(ib,jb,p(R)?R.domain():void 0);Y=I(0,q,p(S)?S:void 0,function(a){return 0===a%1?Ca.tickOffset():0});Ua=D(ka,10);Va=D(ka,10);J=M(l,xc);la=e.svg.axis().scale(y).orient(yc);Wa=e.svg.axis().scale(R).orient(zc);Ca=M(Y,Ac)}function I(a,b,d,h){var m=(z?e.time.scale():e.scale.linear()).range([a,b]);m.orgDomain=function(){return m.domain()};p(d)&&m.domain(d);s(h)&&(h=function(){return 0});
if(Z){var c=m,r,m=function(a){return c(a)+h(a)};for(r in c)m[r]=c[r];m.orgDomain=function(){return c.domain()};m.domain=function(a){if(!arguments.length)return a=c.domain(),[a[0],a[1]+1];c.domain(a);return m}}return m}function D(a,b){return e.scale.linear().range([a,b])}function E(a){return"y2"===N(a)?R:y}function P(a){return"y2"===N(a)?Va:Ua}function M(a,b){var d=(Z?wc():e.svg.axis()).scale(a).orient(b);z&&d.tickFormat(Qb?function(a){return e.time.format(Qb)(a)}:Bc);Z?d.categories(Da).tickCentered(Cc): if(Z){var c=m,r,m=function(a){return c(a)+h(a)};for(r in c)m[r]=c[r];m.orgDomain=function(){return c.domain()};m.domain=function(a){if(!arguments.length)return a=c.domain(),[a[0],a[1]+1];c.domain(a);return m}}return m}function D(a,b){return e.scale.linear().range([a,b])}function E(a){return"y2"===N(a)?R:y}function P(a){return"y2"===N(a)?Va:Ua}function M(a,b){var d=(Z?wc():e.svg.axis()).scale(a).orient(b);z&&d.tickFormat(Qb?function(a){return e.time.format(Qb)(a)}:Bc);Z?d.categories(Da).tickCentered(Cc):
d.tickOffset=function(){return 0};return d}function N(a){return a in Rb?Rb[a]:"y"}function O(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.value})})}function db(a){var b={},d,h;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})});for(d=0;d<v.length;d++)for(h=1;h<v[d].length;h++)Ea(v[d][h])&&(s(b[v[d][h]])||b[v[d][h]].forEach(function(a,e){N(v[d][h])===N(v[d][0])&&(b[v[d][0]][e]+=1*a)}));return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))} d.tickOffset=function(){return 0};return d}function N(a){return a in Rb?Rb[a]:"y"}function O(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.value})})}function db(a){var b={},d,h;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})});for(d=0;d<v.length;d++)for(h=1;h<v[d].length;h++)Ea(v[d][h])&&(s(b[v[d][h]])||b[v[d][h]].forEach(function(a,e){N(v[d][h])===N(v[d][0])&&(b[v[d][0]][e]+=1*a)}));return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}
function ia(a){var b=Xa(function(b){return N(b.id)===a}),d="y2"===a?Dc:Ec,h="y2"===a?Fc:Gc,d=null!==d?d:O(b),h=null!==h?h:db(b),m=0.1*Math.abs(h-d),e=m,c=m,f="y2"===a?Hc:Ic;null!==f&&(d=Math.max(Math.abs(d),Math.abs(h)),h=d-f,d=f-d);"y"===a&&null!==Fa&&(e=p(Fa.top)?Fa.top:m,c=p(Fa.bottom)?Fa.bottom:m);"y2"===a&&null!==Ga&&(e=p(Ga.top)?Ga.top:m,c=p(Ga.bottom)?Ga.bottom:m);return[Jc(b,"bar")?0:d-c,h+e]}function ra(a){var b;a?(a=l.domain(),b=F.extent()):(a=S,b=l.domain());return(a[1]-a[0])/(b[1]-b[0])} function ia(a){var b=Xa(function(b){return N(b.id)===a}),d="y2"===a?Dc:Ec,h="y2"===a?Fc:Gc,d=null!==d?d:O(b),h=null!==h?h:db(b),m=0.1*Math.abs(h-d),e=m,c=m,f="y2"===a?Hc:Ic;null!==f&&(d=Math.max(Math.abs(d),Math.abs(h)),h=d-f,d=f-d);"y"===a&&null!==Fa&&(e=p(Fa.top)?Fa.top:m,c=p(Fa.bottom)?Fa.bottom:m);"y2"===a&&null!==Ga&&(e=p(Ga.top)?Ga.top:m,c=p(Ga.bottom)?Ga.bottom:m);return[Jc(b,"bar")?0:d-c,h+e]}function ra(a){var b;a?(a=l.domain(),b=F.extent()):(a=S,b=l.domain());return(a[1]-a[0])/(b[1]-b[0])}
@ -21,8 +21,8 @@ s(e[c].end)?q[c].end=a[a.length-1].x:z&&(q[c].end=ma(e[c].end));kc=f?function(a)
l=D(a[c-1].value,a[c].value);g=b(a[c].x)-b(a[c-1].x);u=d(a[c].value)-d(a[c-1].value);g=Math.sqrt(Math.pow(g,2)+Math.pow(u,2));u=2/g;var t=2*u;for(g=u;1>=g;g+=t)r+=e(a[c-1],a[c],g,u)}return r}function rb(a){var b=k.data.targets=Ia(a),d,c;lc=e.select(ua);if(lc.empty())ga.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{Q();zb();l.domain(e.extent(a.map(function(a){return a.x})));y.domain(ia("y"));R.domain(ia("y2")); l=D(a[c-1].value,a[c].value);g=b(a[c].x)-b(a[c-1].x);u=d(a[c].value)-d(a[c-1].value);g=Math.sqrt(Math.pow(g,2)+Math.pow(u,2));u=2/g;var t=2*u;for(g=u;1>=g;g+=t)r+=e(a[c-1],a[c],g,u)}return r}function rb(a){var b=k.data.targets=Ia(a),d,c;lc=e.select(ua);if(lc.empty())ga.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{Q();zb();l.domain(e.extent(a.map(function(a){return a.x})));y.domain(ia("y"));R.domain(ia("y2"));
Y.domain(l.domain());Ua.domain(y.domain());Va.domain(R.domain());J.ticks(10>a.length?a.length:10);la.ticks(Vc).outerTickSize(0).tickFormat(Wc);Wa.ticks(Xc).outerTickSize(0).tickFormat(Yc);S=l.domain();F.x(Y);oa&&G.x(l);La=e.select(ua).append("svg").attr("width",q+B+A).attr("height",t+w+X).on("mouseenter",Zc).on("mouseleave",$c);ab=La.append("defs");ab.append("clipPath").attr("id",sb).append("rect").attr("y",w).attr("width",q).attr("height",t-w);ab.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x", Y.domain(l.domain());Ua.domain(y.domain());Va.domain(R.domain());J.ticks(10>a.length?a.length:10);la.ticks(Vc).outerTickSize(0).tickFormat(Wc);Wa.ticks(Xc).outerTickSize(0).tickFormat(Yc);S=l.domain();F.x(Y);oa&&G.x(l);La=e.select(ua).append("svg").attr("width",q+B+A).attr("height",t+w+X).on("mouseenter",Zc).on("mouseleave",$c);ab=La.append("defs");ab.append("clipPath").attr("id",sb).append("rect").attr("y",w).attr("width",q).attr("height",t-w);ab.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",
-1-B).attr("y",-20).attr("width",V).attr("height",W);ab.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-B+1).attr("y",w-1).attr("width",ha).attr("height",eb);g=La.append("g").attr("transform",K.main);x=xa?La.append("g").attr("transform",K.context):null;ya=za?La.append("g").attr("transform",K.legend):null;ca=e.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", -1-B).attr("y",-20).attr("width",V).attr("height",W);ab.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-B+1).attr("y",w-1).attr("width",ha).attr("height",eb);g=La.append("g").attr("transform",K.main);x=xa?La.append("g").attr("transform",K.context):null;ya=za?La.append("g").attr("transform",K.legend):null;ca=e.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?la:J).append("text").attr("x",q).attr("dy","-.5em").style("text-anchor","end").text(ad);g.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?J:la).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(bd);Jb&&g.append("g").attr("class","y2 axis").attr("transform",K.y2).call(Wa);d=g.append("g").attr("clip-path",Ma).attr("class", "x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform",K.x).call(f?la:J).append("text").attr("class","label").attr("x",q).attr("dy","-.5em").style("text-anchor","end").text(ad);g.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?J:la).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(bd);Jb&&g.append("g").attr("class","y2 axis").attr("transform",K.y2).call(Wa);d=g.append("g").attr("clip-path",
"grid");mc&&d.append("g").attr("class","xgrids");tb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(tb).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:-w).attr("dy",-6).text(function(a){return a.text}));cd&&d.append("g").attr("class","xgrid-focus").append("line").attr("class", Ma).attr("class","grid");mc&&d.append("g").attr("class","xgrids");tb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(tb).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:-w).attr("dy",-6).text(function(a){return a.text}));cd&&d.append("g").attr("class","xgrid-focus").append("line").attr("class",
"xgrid-focus").attr("x1",f?0:-10).attr("x2",f?q:-10).attr("y1",f?-10:w).attr("y2",f?-10:t);nc&&d.append("g").attr("class","ygrids");ub&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(ub).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Ma).attr("class","regions");g.append("g").attr("clip-path",Ma).attr("class","chart");g.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor", "xgrid-focus").attr("x1",f?0:-10).attr("x2",f?q:-10).attr("y1",f?-10:w).attr("y2",f?-10:t);nc&&d.append("g").attr("class","ygrids");ub&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(ub).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Ma).attr("class","regions");g.append("g").attr("clip-path",Ma).attr("class","chart");g.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",
oa?"ew-resize":null).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",da&&pa?"pointer":null).on("mouseover",function(a,b){if(!bb){var d=k.data.targets.map(function(a){return Cb(a.values[b])}),c,h;if(0<Object.keys(Ha).length){h=[];for(var p in Ha)for(c=0;c<d.length;c++)if(d[c].id===p){h.push(d[c]);d.shift(c);break}d=h.concat(d)}oc&&g.selectAll(".-circle-"+b).classed(ea,!0).attr("r",pc);g.selectAll(".-bar-"+b).classed(ea, oa?"ew-resize":null).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",da&&pa?"pointer":null).on("mouseover",function(a,b){if(!bb){var d=k.data.targets.map(function(a){return Cb(a.values[b])}),c,h;if(0<Object.keys(Ha).length){h=[];for(var p in Ha)for(c=0;c<d.length;c++)if(d[c].id===p){h.push(d[c]);d.shift(c);break}d=h.concat(d)}oc&&g.selectAll(".-circle-"+b).classed(ea,!0).attr("r",pc);g.selectAll(".-bar-"+b).classed(ea,
!0);g.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?"y1":"x1",$a).attr(f?"y2":"x2",$a);ca.style("top",e.mouse(this)[1]+30+"px").style("left",(f?e.mouse(this)[0]:l(d[0].x))+60+"px");ca.html(qc(d));ca.style("visibility","visible")}}).on("mouseout",function(a,b){g.select("line.xgrid-focus").style("visibility","hidden");ca.style("visibility","hidden");g.selectAll(".-circle-"+b).filter(function(){return e.select(this).classed(ea)}).classed(ea,!1).attr("r",vb);g.selectAll(".-bar-"+ !0);g.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?"y1":"x1",$a).attr(f?"y2":"x2",$a);ca.style("top",e.mouse(this)[1]+30+"px").style("left",(f?e.mouse(this)[0]:l(d[0].x))+60+"px");ca.html(qc(d));ca.style("visibility","visible")}}).on("mouseout",function(a,b){g.select("line.xgrid-focus").style("visibility","hidden");ca.style("visibility","hidden");g.selectAll(".-circle-"+b).filter(function(){return e.select(this).classed(ea)}).classed(ea,!1).attr("r",vb);g.selectAll(".-bar-"+
@ -32,10 +32,10 @@ h=Math.min(a,c),f=Math.max(a,c),k=pa?w:Math.min(b,d),l=pa?t:Math.max(b,d);g.sele
f&&r<l);m^g&&(d.classed(yb,!g),d.classed(fa,!c),q(!c,d,a,b))})}}).on("dragstart",function(){da&&(xb=e.mouse(this),g.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),bb=!0)}).on("dragend",function(){da&&(g.select(".dragarea").transition().duration(100).style("opacity",0).remove(),g.selectAll(".-shape").classed(yb,!1),bb=!1)})).call(G).on("dblclick.zoom",null);g.select(".chart").append("g").attr("class","chart-bars");g.select(".chart").append("g").attr("class","chart-lines"); f&&r<l);m^g&&(d.classed(yb,!g),d.classed(fa,!c),q(!c,d,a,b))})}}).on("dragstart",function(){da&&(xb=e.mouse(this),g.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),bb=!0)}).on("dragend",function(){da&&(g.select(".dragarea").transition().duration(100).style("opacity",0).remove(),g.selectAll(".-shape").classed(yb,!1),bb=!1)})).call(G).on("dblclick.zoom",null);g.select(".chart").append("g").attr("class","chart-bars");g.select(".chart").append("g").attr("class","chart-lines");
if(oa)g.insert("rect",ed?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(G).on("dblclick.zoom",null);null!==Na&&F.extent("function"!==typeof Na?Na:z?Na(Za,kb):Na(0,wa()-1));xa&&(x.append("g").attr("clip-path",Ma).attr("class","chart"),x.select(".chart").append("g").attr("class","chart-bars"),x.select(".chart").append("g").attr("class","chart-lines"),x.append("g").attr("clip-path",Ma).attr("class","x brush").call(F).selectAll("rect").attr("height", if(oa)g.insert("rect",ed?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(G).on("dblclick.zoom",null);null!==Na&&F.extent("function"!==typeof Na?Na:z?Na(Za,kb):Na(0,wa()-1));xa&&(x.append("g").attr("clip-path",Ma).attr("class","chart"),x.select(".chart").append("g").attr("class","chart-bars"),x.select(".chart").append("g").attr("class","chart-lines"),x.append("g").attr("clip-path",Ma).attr("class","x brush").call(F).selectAll("rect").attr("height",
ka),x.append("g").attr("class","x axis").attr("transform",K.subx).call(Ca));za&&cb(b);rc(b);C({withTransition:!1,withUpdateXDomain:!0});if(fd){if(z&&"string"===typeof Aa){Aa=ma(Aa);for(a=0;a<b[0].values.length&&0!==b[0].values[a].x-Aa;a++);Aa=a}ca.html(qc(b.map(function(a){return Cb(a.values[Aa])})));ca.style("top",sc.top).style("left",sc.left).style("visibility","visible")}}}function C(a){var b,d,c=Oc(),m=c.__max__+1,n,r,s,v,u;a=p(a)?a:{};b=p(a.withY)?a.withY:!0;v=p(a.withSubchart)?a.withSubchart: ka),x.append("g").attr("class","x axis").attr("transform",K.subx).call(Ca));za&&cb(b);rc(b);C({withTransition:!1,withUpdateXDomain:!0});if(fd){if(z&&"string"===typeof Aa){Aa=ma(Aa);for(a=0;a<b[0].values.length&&0!==b[0].values[a].x-Aa;a++);Aa=a}ca.html(qc(b.map(function(a){return Cb(a.values[Aa])})));ca.style("top",sc.top).style("left",sc.left).style("visibility","visible")}}}function C(a){var b,d,c=Oc(),m=c.__max__+1,n,r,s,v,u;a=p(a)?a:{};b=p(a.withY)?a.withY:!0;v=p(a.withSubchart)?a.withSubchart:
!0;u=p(a.withTransition)?a.withTransition:!0;a=p(a.withUpdateXDomain)?a.withUpdateXDomain:!1;u=u?250:0;a&&(l.domain(F.empty()?S:F.extent()),oa&&G.x(l).updateScaleExtent());y.domain(ia("y"));R.domain(ia("y2"));g.select(".x.axis").transition().duration(f?u:0).call(f?la:J);g.select(".y.axis").transition().duration(f?0:u).call(f?J:la);g.select(".y2.axis").transition().call(Wa);Ua.domain(y.domain());Va.domain(R.domain());ca.style("visibility","hidden");g.select("line.xgrid-focus").style("visibility","hidden").attr("y2", !0;u=p(a.withTransition)?a.withTransition:!0;a=p(a.withUpdateXDomain)?a.withUpdateXDomain:!1;u=u?250:0;a&&(l.domain(F.empty()?S:F.extent()),oa&&G.x(l).updateScaleExtent());y.domain(ia("y"));R.domain(ia("y2"));g.select(".x.axis").transition().duration(f?u:0).call(f?la:J);g.select(".y.axis").transition().duration(f?0:u).call(f?J:la);g.select(".y2.axis").transition().call(Wa);g.select(".x.axis text.label").attr("x",q);Ua.domain(y.domain());Va.domain(R.domain());ca.style("visibility","hidden");g.select("line.xgrid-focus").style("visibility",
t);if(mc){if("year"===gd)for(a=[],r=Za.getFullYear(),n=kb.getFullYear();r<=n;r++)a.push(new Date(r+"-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)-J.tickOffset()}).attr("x2",function(a){return l(a)-J.tickOffset()}).attr("y1",w).attr("y2",t)}tb&&(a=g.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?0:Ja).attr("x2",f?q:Ja).attr("y1", "hidden").attr("y2",t);if(mc){if("year"===gd)for(a=[],r=Za.getFullYear(),n=kb.getFullYear();r<=n;r++)a.push(new Date(r+"-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)-J.tickOffset()}).attr("x2",function(a){return l(a)-J.tickOffset()}).attr("y1",w).attr("y2",t)}tb&&(a=g.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?0:Ja).attr("x2",
f?Ja:w).attr("y2",f?Ja:t),a.selectAll("text").attr("x",f?q:0).attr("y",Ja));b&&nc&&(a=g.select(".ygrids").selectAll(".ygrid").data(y.ticks(10)),a.enter().append("line").attr("class","ygrid"),a.attr("x1",f?y:0).attr("x2",f?y:q).attr("y1",f?0:y).attr("y2",f?t:y).attr("opacity",0).transition().attr("opacity",1),a.exit().remove());b&&ub&&g.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",Zb).attr("y2",Zb);n=Z?1.2*J.tickOffset()/m:0.6*((f?t:q)*ra(!1)/(wa()-1));r=bc(f?null:t);b=$b(n,m,c);a=ac(r, f?q:Ja).attr("y1",f?Ja:w).attr("y2",f?Ja:t),a.selectAll("text").attr("x",f?q:0).attr("y",Ja));b&&nc&&(a=g.select(".ygrids").selectAll(".ygrid").data(y.ticks(10)),a.enter().append("line").attr("class","ygrid"),a.attr("x1",f?y:0).attr("x2",f?y:q).attr("y1",f?0:y).attr("y2",f?t:y).attr("opacity",0).transition().attr("opacity",1),a.exit().remove());b&&ub&&g.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",Zb).attr("y2",Zb);n=Z?1.2*J.tickOffset()/m:0.6*((f?t:q)*ra(!1)/(wa()-1));r=bc(f?null:t);
c,f);d=g.selectAll(".-bars").selectAll(".-bar").data(cc);d.transition().duration(u).attr("x",f?a:b).attr("y",f?b:a).attr("width",f?r:n).attr("height",f?n:r);d.enter().append("rect").attr("class",Yb).attr("x",f?a:b).attr("y",f?b:a).attr("width",f?r:n).attr("height",f?n:r).style("opacity",0).transition().duration(u).style("opacity",1);d.exit().transition().duration(u).style("opacity",0).remove();g.selectAll(".-line").transition().duration(u).attr("d",hd);b=g.selectAll(".-circles").selectAll(".-circle").data(Pc); b=$b(n,m,c);a=ac(r,c,f);d=g.selectAll(".-bars").selectAll(".-bar").data(cc);d.transition().duration(u).attr("x",f?a:b).attr("y",f?b:a).attr("width",f?r:n).attr("height",f?n:r);d.enter().append("rect").attr("class",Yb).attr("x",f?a:b).attr("y",f?b:a).attr("width",f?r:n).attr("height",f?n:r).style("opacity",0).transition().duration(u).style("opacity",1);d.exit().transition().duration(u).style("opacity",0).remove();g.selectAll(".-line").transition().duration(u).attr("d",hd);b=g.selectAll(".-circles").selectAll(".-circle").data(Pc);
b.transition().duration(u).style("opacity",function(a){return null===a.value?0:1}).attr("cx",f?aa:$).attr("cy",f?$:aa);b.enter().append("circle").style("opacity",function(a){return null===a.value?0:1}).attr("class",Mc).attr("cx",f?aa:$).attr("cy",f?$:aa).attr("r",vb);b.exit().remove();xa&&(null!==e.event&&"zoom"===e.event.type&&F.extent(l.orgDomain()).update(),v&&(x.select(".x.axis").transition().duration(f?u:0).call(f?la:Ca),F.empty()||F.extent(l.orgDomain()).update(),n=Z?1.2*Ca.tickOffset()/m:0.6* b.transition().duration(u).style("opacity",function(a){return null===a.value?0:1}).attr("cx",f?aa:$).attr("cy",f?$:aa);b.enter().append("circle").style("opacity",function(a){return null===a.value?0:1}).attr("class",Mc).attr("cx",f?aa:$).attr("cy",f?$:aa).attr("r",vb);b.exit().remove();xa&&(null!==e.event&&"zoom"===e.event.type&&F.extent(l.orgDomain()).update(),v&&(x.select(".x.axis").transition().duration(f?u:0).call(f?la:Ca),F.empty()||F.extent(l.orgDomain()).update(),n=Z?1.2*Ca.tickOffset()/m:0.6*
((f?t:q)*ra(!0)/(wa()-1)),r=bc(ka,!0),b=$b(n,m,c,!0),a=ac(r,c,!1,!0),c=x.selectAll(".-bars").selectAll(".-bar").data(cc),c.transition().duration(u).attr("x",b).attr("y",a).attr("width",n).attr("height",r),c.enter().append("rect").attr("class",Yb).attr("x",b).attr("y",a).attr("width",n).attr("height",r).style("opacity",0).transition().style("opacity",1),c.exit().transition().style("opacity",0).remove(),x.selectAll(".-line").transition().duration(u).attr("d",id)));g.selectAll(".selected-circles").filter(function(a){return Ea(a)}).selectAll("circle").remove(); ((f?t:q)*ra(!0)/(wa()-1)),r=bc(ka,!0),b=$b(n,m,c,!0),a=ac(r,c,!1,!0),c=x.selectAll(".-bars").selectAll(".-bar").data(cc),c.transition().duration(u).attr("x",b).attr("y",a).attr("width",n).attr("height",r),c.enter().append("rect").attr("class",Yb).attr("x",b).attr("y",a).attr("width",n).attr("height",r).style("opacity",0).transition().style("opacity",1),c.exit().transition().style("opacity",0).remove(),x.selectAll(".-line").transition().duration(u).attr("d",id)));g.selectAll(".selected-circles").filter(function(a){return Ea(a)}).selectAll("circle").remove();
g.selectAll(".selected-circle").transition().duration(u).attr("cx",f?aa:$).attr("cy",f?$:aa);Vb?(s=function(a,b){var d=0<b?k.data.targets[0].values[b-1].x:void 0,c=b<wa()-1?k.data.targets[0].values[b+1].x:void 0;return(l(c?c:a.x+50)-l(d?d:a.x-50))/2},c=function(a,b){var d=0<b?k.data.targets[0].values[b-1].x:void 0;return(l(a.x)+l(d?d:a.x-50))/2}):(s=(f?t:q)*ra()/(wa()-1),c=function(a){return l(a.x)-s/2});g.selectAll(".event-rect").attr("x",f?0:c).attr("y",f?c:0).attr("width",f?q:s).attr("height", g.selectAll(".selected-circle").transition().duration(u).attr("cx",f?aa:$).attr("cy",f?$:aa);Vb?(s=function(a,b){var d=0<b?k.data.targets[0].values[b-1].x:void 0,c=b<wa()-1?k.data.targets[0].values[b+1].x:void 0;return(l(c?c:a.x+50)-l(d?d:a.x-50))/2},c=function(a,b){var d=0<b?k.data.targets[0].values[b-1].x:void 0;return(l(a.x)+l(d?d:a.x-50))/2}):(s=(f?t:q)*ra()/(wa()-1),c=function(a){return l(a.x)-s/2});g.selectAll(".event-rect").attr("x",f?0:c).attr("y",f?c:0).attr("width",f?q:s).attr("height",

Loading…
Cancel
Save