Browse Source

Fix axis label class

pull/8/head 0.1.3
Masayuki Tanaka 11 years ago
parent
commit
1b5140b222
  1. 4
      c3.js
  2. 4
      c3.min.js

4
c3.js

@ -989,7 +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("class", "-axis-x-label")
.attr("x", width) .attr("x", width)
.attr("dy", "-.5em") .attr("dy", "-.5em")
.style("text-anchor", "end") .style("text-anchor", "end")
@ -1377,7 +1377,7 @@
main.select(".y2.axis").transition().call(yAxis2); main.select(".y2.axis").transition().call(yAxis2);
// Update label position // Update label position
main.select(".x.axis text.label").attr("x", width); main.select(".x.axis .-axis-x-label").attr("x", width);
// Update sub domain // Update sub domain
subY.domain(y.domain()); subY.domain(y.domain());

4
c3.min.js vendored

@ -21,7 +21,7 @@ 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("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", "x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform",K.x).call(f?la:J).append("text").attr("class","-axis-x-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",
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", 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,
@ -32,7 +32,7 @@ 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);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", !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 .-axis-x-label").attr("x",q);Ua.domain(y.domain());Va.domain(R.domain());ca.style("visibility","hidden");g.select("line.xgrid-focus").style("visibility",
"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", "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?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); 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);
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=$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);

Loading…
Cancel
Save