diff --git a/c3.js b/c3.js index a8cae00..edabf35 100644 --- a/c3.js +++ b/c3.js @@ -445,12 +445,12 @@ if (__data_groups.length > 0) { hasNegativeValue = hasNegativeValueInTargets(targets); for (j = 0; j < __data_groups.length; j++) { - if (hasNegativeValue) { - ys[__data_groups[j][0]].forEach(function (v, i) { - ys[__data_groups[j][0]][i] = v < 0 ? v : 0; + baseId = __data_groups[j][0]; + if (hasNegativeValue && ys[baseId]) { + ys[baseId].forEach(function (v, i) { + ys[baseId][i] = v < 0 ? v : 0; }); } - baseId = __data_groups[j][0]; for (k = 1; k < __data_groups[j].length; k++) { id = __data_groups[j][k]; if (! ys[id]) { continue; } @@ -469,12 +469,12 @@ if (__data_groups.length > 0) { hasPositiveValue = hasPositiveValueInTargets(targets); for (j = 0; j < __data_groups.length; j++) { - if (hasPositiveValue) { - ys[__data_groups[j][0]].forEach(function (v, i) { - ys[__data_groups[j][0]][i] = v > 0 ? v : 0; + baseId = __data_groups[j][0]; + if (hasPositiveValue && ys[baseId]) { + ys[baseId].forEach(function (v, i) { + ys[baseId][i] = v > 0 ? v : 0; }); } - baseId = __data_groups[j][0]; for (k = 1; k < __data_groups[j].length; k++) { id = __data_groups[j][k]; if (! ys[id]) { continue; } diff --git a/c3.min.js b/c3.min.js index 4a08be0..a09d073 100644 --- a/c3.min.js +++ b/c3.min.js @@ -9,20 +9,20 @@ d.svg.axis().scale(Y).orient(nd);fb=ac(U,od);jb=Ua();mc=ma();nc=ma(0.98)}functio b])}function v(a){return"y2"===y(a)?Y:z}function H(a){return"y2"===y(a)?hb:gb}function ac(a,b){var c=(ea?jd():d.svg.axis()).scale(a).orient(b);c.tickFormat(bc());ea?c.categories(Fa).tickCentered(pd):c.tickOffset=function(){return 0};return c}function y(a){return a in oc?oc[a]:"y"}function bc(){var a=B?qd:ea?rd:function(a){return a};kb&&(a="function"===typeof kb?kb:B?function(a){return d.time.format(kb)(a)}:a);return a}function la(a){var b=!1;Db(g.data.targets).forEach(function(c){b||c.data.id!==a.data.id|| (b=!0,a=c)});return b?a:null}function Ua(){var a=d.svg.arc().outerRadius(db).innerRadius(0),b=function(b,e){var k;return e?a(b):(k=la(b))?a(k):"M 0 0"};b.centroid=a.centroid;return b}function ma(a){var b=d.svg.arc().outerRadius(Ab*(a?a:1)).innerRadius(0);return function(a){return(a=la(a))?b(a):"M 0 0"}}function Va(a){a=la(a);var b,c;b="";a&&(b=jb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*db+","+0.8*(b/c)*db+")");return b}function Wa(a){return(100*(a.endAngle-a.startAngle)/ (2*Math.PI)).toFixed(1)+"%"}function Xa(a,b){var c=p.selectAll(".chart-arc.target"+(a?"-"+a:"")),e=p.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",mc).transition().duration(100).attr("d",nc);b||e.style("opacity",0.3)}function wb(a){p.selectAll(".chart-arc.target"+(a?"-"+a:"")).selectAll("path").transition().duration(50).attr("d",jb);p.selectAll(".-arc").style("opacity",1)}function sd(a){var b=pc(a),c,e,k,D;if(0a?a:0}),e=s[c][0],a=1;a+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function lb(a){var b=mb(function(b){return y(b.id)===a}),c="y2"===a?vd:wd,e="y2"===a?xd:yd,c=c?c:sd(b),e=e?e:td(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?zd:Ad;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ga&&(d=Ga.top?Ga.top:k,f=Ga.bottom?Ga.bottom:k);"y2"===a&&Ha&&(d=Ha.top?Ha.top:k,f=Ha.bottom?Ha.bottom:k);Ia(b,"bar")&&!qc(b)&&(f=c);return[c-f,e+d]}function jc(a){var b;a?(a=m.domain(), -b=K.extent()):(a=V,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function Bd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function Cd(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function nb(a){var b=[Bd(a),Cd(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function Dd(a){for(var b=0;ba?0:a}function tc(a){return qa&&a===qa||Z&&Fd(Z,a)}function Gd(a){return!tc(a)}function Hd(a){Object.keys(a).forEach(function(b){Z[b]=a[b]})}function pb(a){var b;a&&(b=Ja[a.id],a.name=b?b:a.id);return a}function uc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function qb(a){a=x(a)?g.data.targets:a;return a.map(function(a){return a.id})} -function xc(a){var b=qb(),c;for(c=0;ca})}function ud(a){return yc(a,function(a){return 0< -a})}function rd(a){return ak&&(d-=c+30));c=b[1]+15+es[c].indexOf(k.id)))for(e=0;ea?a:0}),c=1;c ++a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function lb(a){var b=mb(function(b){return y(b.id)===a}),c="y2"===a?vd:wd,e="y2"===a?xd:yd,c=c?c:sd(b),e=e?e:td(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?zd:Ad;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ga&&(d=Ga.top?Ga.top:k,f=Ga.bottom?Ga.bottom:k);"y2"===a&&Ha&&(d=Ha.top?Ha.top:k,f=Ha.bottom?Ha.bottom:k);Ia(b,"bar")&&!qc(b)&&(f=c);return[c-f,e+d]}function jc(a){var b;a?(a=m.domain(),b=K.extent()): +(a=V,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function Bd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function Cd(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function nb(a){var b=[Bd(a),Cd(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function Dd(a){for(var b=0;ba?0:a}function tc(a){return qa&&a===qa||Z&&Fd(Z,a)}function Gd(a){return!tc(a)}function Hd(a){Object.keys(a).forEach(function(b){Z[b]=a[b]})}function pb(a){var b;a&&(b=Ja[a.id],a.name=b?b:a.id);return a}function uc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function qb(a){a=x(a)?g.data.targets:a;return a.map(function(a){return a.id})}function xc(a){var b= +qb(),c;for(c=0;ca})}function ud(a){return yc(a,function(a){return 0k&&(d-=c+30));c=b[1]+ +15+es[c].indexOf(k.id)))for(e=0;e",c,d,f;for(c=0;c"+f+""+d+"");return b+""}),ie=f(["tooltip","init","show"],!1),Ca=f(["tooltip","init","x"],0),Zc=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Pb=wa.replace("#","")+"-clip",Pa="url(#"+Pb+")",B="timeseries"===id,ea="categorized"===id,Fb=!B&&(qa||Z),Vb=null,Qa=!1,Ub=!1,na=Ba?40:0,L=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" "); +"focus","expand","enabled"],!0),Tb=f(["point","focus","expand","r"],Sb?4:Nb),Oa=f(["point","focus","select","r"],8),ne=f(["point","onclick"],function(){}),Vd=f(["point","onselected"],function(){}),Wd=f(["point","onunselected"],function(){}),Q=f(["regions"],[]),Jc=f(["tooltip","contents"],function(a){var b="",c,e,d;for(c=0;c");return b+"
"+bc()(a[0].x)+"
"+d+""+e+"
"}),ie=f(["tooltip","init","show"],!1),Ca=f(["tooltip","init","x"],0),Zc=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Pb=wa.replace("#","")+"-clip",Pa="url(#"+Pb+")",B="timeseries"===id,ea="categorized"===id,Fb=!B&&(qa||Z),Vb=null,Qa=!1,Ub=!1,na=Ba?40:0,L=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]}}(ue,ve),qd=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)}}(),cc,gc,ec,ab,fc,hc,q,t,va,yb,ua,db,Ab,jb,mc,nc,Db,kc,lc,Bb,Cb,m,z,Y,U,gb,hb,J,oa,ib,fb,ld=l?"left":"bottom",md=l?cb?"top":"bottom":cb?"right":"left",nd=l?$a?"bottom":"top":$a?"left":"right",od="bottom",M={main:function(){return"translate("+I+","+u+")"},context:function(){return"translate("+n+","+Da+")"},legend:function(){return"translate("+ $b+","+Zb+")"},y2:function(){return"translate("+(l?0:q)+","+(l?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+va+")"},arc:function(){return"translate("+q/2+","+t/2+")"}};Db=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var pe=function(){var a=d.svg.line().x(l?function(a){return v(a.id)(a.value)}:xa).y(l?xa:function(a){return v(a.id)(a.value)});return function(b){var c=Kb(b.values),d;if(Hb(b))return Mc(b)?a.interpolate("cardinal"):