Browse Source

Fix 0 height bug

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
e072a95038
  1. 3
      c3.js
  2. 4
      c3.min.js

3
c3.js

@ -374,7 +374,8 @@
return __size_width === null ? getParentWidth() : __size_width;
}
function getCurrentHeight () {
return __size_height === null ? getParentHeight() : __size_height;
var h = __size_height === null ? getParentHeight() : __size_height;
return h > 0 ? h : 320;
}
function getParentWidth () {
return +d3.select(__bindto).style("width").replace('px',''); // TODO: if rotated, use height

4
c3.min.js vendored

@ -3,8 +3,8 @@
B(0))/2;D=c?0:U;switch(p){case "bottom":A=k;ua.attr("y2",F);wa.attr("y",Math.max(F,0)+J);va.attr("x1",D).attr("x2",D).attr("y2",F);ba.attr("x",0).attr("y",Math.max(F,0)+J);O.attr("dy",".71em").style("text-anchor","middle");O.text(function(c){return n.length<Q||0==c%Math.ceil(n.length/Q)?c<P.length?P[c]:c:""});w.attr("d","M"+E[0]+","+V+"V0H"+E[1]+"V"+V);break;case "left":A=s,ua.attr("x2",-F),wa.attr("x",-(Math.max(F,0)+J)),va.attr("x2",-F).attr("y2",0),ba.attr("x",-(Math.max(F,0)+J)).attr("y",U),O.attr("dy",
".32em").style("text-anchor","end"),O.text(function(c){return n.length<Q||0==c%Math.ceil(n.length/Q)?c<P.length?P[c]:c:""}),w.attr("d","M"+-V+","+E[0]+"H0V"+E[1]+"H"+-V)}if(I.ticks)N.call(A,Ma),ma.call(A,B),la.call(A,B);else{var xa=B.rangeBand()/2,la=function(c){return B(c)+xa};N.call(A,la);ma.call(A,la)}})}var I=d3.scale.linear(),p="bottom",F=6,V=6,J=3,c=!1,Q=10,U=0,P=[];n.scale=function(c){if(!arguments.length)return I;I=c;return n};n.orient=function(c){if(!arguments.length)return p;p=c in{top:1,
right:1,bottom:1,left:1}?c+"":"bottom";return n};n.categories=function(c){if(!arguments.length)return P;P=c;return n};n.tickCentered=function(k){if(!arguments.length)return c;c=k;return n};n.tickTextNum=function(c){if(!arguments.length)return Q;Q=c;return n};n.tickOffset=function(){return U};n.ticks=function(){};return n}function s(k){return"undefined"===typeof k}function k(k){return"undefined"!==typeof k}vb.c3={};c3.generate=function(T){var xb,La,ta,n,I,p,F,V,J;function c(a,b){for(var d=T,e=0;e<
a.length;e++){if(!(a[e]in d))return b;d=d[a[e]]}return d}function Q(){bb=null===yb?+d3.select(ya).style("width").replace("px",""):yb;na=null===zb?+d3.select(ya).style("height").replace("px",""):zb;Ab=20+Bb+ca;Cb=!Db||f||cb?1:50;Na=db?0:40;Eb=na-Bb-ca;Fb=20+ca;Gb=na-ca;p=0;F=Cb;V=Ab;J=Na;ta=Eb;n=Fb;I=Na;xb=Gb;La=Na;r=bb-J-F;u=na-p-V;da=na-ta-n}function U(){var a,b,d,e;Hb=f?10:0;Ib=f?u:r;eb=f?0:u;fb=f?r:1;a=P(Hb,Ib);b=w(eb,fb);d=w(eb,fb);e=P(0,r);m=k(m)?a.domain(m.domain()):a;y=k(y)?b.domain(y.domain()):
b;R=k(R)?d.domain(R.domain()):d;z=k(z)?e.domain(z.domain()):e;Oa=w(da,10);Pa=w(da,10);C.scale(m).orient(f?"left":"bottom");ea.scale(y).orient(f?db?"top":"bottom":db?"right":"left");Qa.scale(R).orient(f?cb?"bottom":"top":cb?"left":"right");fa.scale(z).orient("bottom");ga&&function(){var a=m,b=z,d=Object.keys(m),e,c;m=function(b){return a(b)+C.tickOffset()};z=function(a){return b(a)+fa.tickOffset()};for(c=0;c<d.length;c++)e=d[c],m[e]=a[e],z[e]=b[e];m.domain=function(b){if(!arguments.length)return b=
a.length;e++){if(!(a[e]in d))return b;d=d[a[e]]}return d}function Q(){bb=null===yb?+d3.select(ya).style("width").replace("px",""):yb;var a=null===zb?+d3.select(ya).style("height").replace("px",""):zb;na=0<a?a:320;Ab=20+Bb+ca;Cb=!Db||f||cb?1:50;Na=db?0:40;Eb=na-Bb-ca;Fb=20+ca;Gb=na-ca;p=0;F=Cb;V=Ab;J=Na;ta=Eb;n=Fb;I=Na;xb=Gb;La=Na;r=bb-J-F;u=na-p-V;da=na-ta-n}function U(){var a,b,d,e;Hb=f?10:0;Ib=f?u:r;eb=f?0:u;fb=f?r:1;a=P(Hb,Ib);b=w(eb,fb);d=w(eb,fb);e=P(0,r);m=k(m)?a.domain(m.domain()):a;y=k(y)?
b.domain(y.domain()):b;R=k(R)?d.domain(R.domain()):d;z=k(z)?e.domain(z.domain()):e;Oa=w(da,10);Pa=w(da,10);C.scale(m).orient(f?"left":"bottom");ea.scale(y).orient(f?db?"top":"bottom":db?"right":"left");Qa.scale(R).orient(f?cb?"bottom":"top":cb?"left":"right");fa.scale(z).orient("bottom");ga&&function(){var a=m,b=z,d=Object.keys(m),e,c;m=function(b){return a(b)+C.tickOffset()};z=function(a){return b(a)+fa.tickOffset()};for(c=0;c<d.length;c++)e=d[c],m[e]=a[e],z[e]=b[e];m.domain=function(b){if(!arguments.length)return b=
a.domain(),b[1]++,b;a.domain(b);return m}}()}function P(a,b){return(G?d3.time.scale():d3.scale.linear()).range([a,b])}function w(a,b){return d3.scale.linear().range([a,b])}function $a(a){return d3.min(a,function(a){return d3.min(a.values,function(a){return a.value})})}function jc(a){var b={},d,e;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(e=1;e<v[d].length;e++)za(v[d][e])&&(s(b[v[d][e]])||b[v[d][e]].forEach(function(a,c){A(v[d][e])===
A(v[d][0])&&(b[v[d][0]][c]+=1*a)}));return d3.max(Object.keys(b).map(function(a){return d3.max(b[a])}))}function D(a,b){var d=Ra(function(a){return A(a.id)===b}),e="y2"===b?kc:lc,g="y2"===b?mc:nc,e=null!==e?e:$a(d),g=null!==g?g:jc(d),c=0.1*Math.abs(g-e),q=c,f=c,h="y2"===b?oc:pc;null!==h&&(yDomainAbs=Math.max(Math.abs(e),Math.abs(g)),g=yDomainAbs-h,e=h-yDomainAbs);"y"===b&&null!==Aa&&(q=k(Aa.top)?Aa.top:c,f=k(Aa.bottom)?Aa.bottom:c);"y2"===b&&null!==Ba&&(q=k(Ba.top)?Ba.top:c,f=k(Ba.bottom)?Ba.bottom:
c);return[qc(d,"bar")?0:e-f,g+q]}function N(a){var b;a?(a=m.domain(),b=K.extent()):(a=Jb,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function la(a){for(var b=0;b<a.length;b++)if(!(a[b]in Sa))return!1;return!0}function ma(a){for(var b=[],d=0;d<a.length;d++)a[d]in Sa&&b.push(wa(Sa[a[d]]));return b}function A(a){return a in Kb?Kb[a]:"y"}function E(a){return"y2"===A(a)?R:y}function B(a){return"y2"===A(a)?Pa:Oa}function Ma(a){var b=Ca[a.id];a.name=k(b)?b:a.id;return a}function ua(a){var b=a[0],d={},e=

Loading…
Cancel
Save