From 430b231528349ff79d74476ecb0e8a3753ac71f4 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Sat, 18 Jan 2014 21:00:15 +0900 Subject: [PATCH] Accept NaN as null --- c3.js | 2 +- c3.min.js | 132 +++++++++++++++++++++++++++--------------------------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/c3.js b/c3.js index e5b2567..7c03e55 100644 --- a/c3.js +++ b/c3.js @@ -477,7 +477,7 @@ id: convertedId, id_org: id, values: data.map(function (d) { - return {x: d.x, value: d[id] !== null ? +d[id] : null, id: convertedId}; + return {x: d.x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId}; }) }; }); diff --git a/c3.min.js b/c3.min.js index 6f9a78b..5320833 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,66 +1,66 @@ -(function(fa){function sc(){function n(e,c){e.attr("transform",function(e){return"translate("+(c(e)+U)+", 0)"})}function s(e,c){e.attr("transform",function(e){return"translate(0,"+c(e)+")"})}function fa(e){var c=e[0];e=e[e.length-1];return ca?0:a}function ha(a){var b=La[a.id];a.name=n(b)?b:a.id;return a}function Ea(a){var b=a[0],d={},h=[],e,c;for(e=1;ev[d].indexOf(e.id)))for(h=0;h=g;g+=t)r+=e(a[c-1],a[c],g,u)}return r} -function tb(a){var b=k.data.targets=ia(a),d,c;hc=e.select(ua);if(hc.empty())fa.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{P();U();l.domain(e.extent(a.map(function(a){return a.x})));z.domain(D(b,"y"));Q.domain(D(b,"y2"));X.domain(l.domain());Wa.domain(z.domain());Xa.domain(Q.domain());J.ticks(10>a.length?a.length:10);la.ticks(Qc).outerTickSize(0).tickFormat(Rc);Ya.ticks(Sc).outerTickSize(0).tickFormat(Tc); -R=l.domain();F.x(X);oa&&G.x(l);Oa=e.select(ua).append("svg").attr("width",q+I+E).attr("height",t+w+W).on("mouseenter",Uc).on("mouseleave",Vc);cb=Oa.append("defs");cb.append("clipPath").attr("id",ub).append("rect").attr("y",w).attr("width",q).attr("height",t-w);cb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",q+2).attr("height",40);cb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-I+1).attr("y",w-1).attr("width",I).attr("height", -t-w+2);g=Oa.append("g").attr("transform",K.main);y=ya?Oa.append("g").attr("transform",K.context):null;za=Aa?Oa.append("g").attr("transform",K.legend):null;ba=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);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.4em").attr("dx","-.8em").style("text-anchor","end").text(Wc);Jb&&g.append("g").attr("class","y2 axis").attr("transform",K.y2).call(Ya);d=g.append("g").attr("clip-path",Pa).attr("class","grid");ic&&d.append("g").attr("class","xgrids");vb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(vb).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}));Xc&&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);jc&&d.append("g").attr("class","ygrids");wb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(wb).enter().append("line").attr("class", -function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Pa).attr("class","regions");g.append("g").attr("clip-path",Pa).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",ca&&pa?"pointer":null).on("mouseover",function(a,b){if(!db){var d=k.data.targets.map(function(a){return ha(a.values[b])}), -c,h;if(0",d,c,e;for(d=0;d"+ -e+""+c+"";return b+""}),$c=c(["tooltip","init","show"],!1),Ba=c(["tooltip","init","x"],0),oc=c(["tooltip","init","position"],{top:"0px",left:"50px"}),ub=ua.replace("#","")+"-clip",Pa="url(#"+ub+")",A="timeseries"===rc,Y="categorized"===rc,Rb=!A&&na,zb=null,db=!1,yb=!1,ja=Aa?40:0,ma=e.time.format(fd).parse,S=function(a,b){var d=[],c=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===d.indexOf(b)&&d.push(b);return c[d.indexOf(b)%c.length]}}(gd,hd),xc=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}],[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[e.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[e.time.format("%I %p"),function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"),function(a){return a.getSeconds()}], -[e.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var d=a.length-1,c=a[d];!c[1](b);)c=a[--d];return c[0](b)}}(),Gb,Lb,Ib,Va,Kb,Mb,q,t,ka,hb,va,Nb,Ob,kb,lb,l,z,Q,X,Wa,Xa,J,la,Ya,Ga,tc=f?"left":"bottom",uc=f?jb?"top":"bottom":jb?"right":"left",vc=f?ib?"bottom":"top":ib?"left":"right",wc="bottom",K={main:function(){return"translate("+I+","+w+")"},context:function(){return"translate("+H+","+Ca+")"},legend:function(){return"translate("+Cb+","+Bb+")"},y2:function(){return"translate("+ -(f?0:q)+","+(f?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+ka+")"}},bd=function(){var a=e.svg.line().x(f?function(a){return ga(a.id)(a.value)}:bb).y(f?bb:function(a){return ga(a.id)(a.value)});return function(b){var d=fc(b.values),c;if(rb(b))return"spline"===aa["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0b.classes.indexOf(a)})});return L};k.data.get=function(a){a=k.data.getAsTarget(a);return n(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b= -Za(function(b){return b.id===a});return 0a?0:a}function ga(a){var b=Ka[a.id];a.name=p(b)?b:a.id;return a}function Da(a){var b=a[0],c={},f=[],k,d;for(k=1;kv[c].indexOf(d.id)))for(f=0;f=e;e+=u)s+=d(a[k-1],a[k],e,m)}return s}function sb(a){var b=l.data.targets=ha(a),c,f;gc=d.select(ta);if(gc.empty())ea.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{O();T();m.domain(d.extent(a.map(function(a){return a.x})));y.domain(C(b,"y"));P.domain(C(b,"y2"));W.domain(m.domain());Va.domain(y.domain());Wa.domain(P.domain());I.ticks(10>a.length?a.length:10);ka.ticks(Pc).outerTickSize(0).tickFormat(Qc); +Xa.ticks(Rc).outerTickSize(0).tickFormat(Sc);Q=m.domain();E.x(W);na&&F.x(m);Na=d.select(ta).append("svg").attr("width",r+H+D).attr("height",u+w+V).on("mouseenter",Tc).on("mouseleave",Uc);bb=Na.append("defs");bb.append("clipPath").attr("id",tb).append("rect").attr("y",w).attr("width",r).attr("height",u-w);bb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",r+2).attr("height",40);bb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-H+ +1).attr("y",w-1).attr("width",H).attr("height",u-w+2);h=Na.append("g").attr("transform",J.main);x=xa?Na.append("g").attr("transform",J.context):null;ya=za?Na.append("g").attr("transform",J.legend):null;aa=d.select(ta).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden");h.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",J.x).call(g?ka:I);h.append("g").attr("class", +"y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?I:ka).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Vc);Ib&&h.append("g").attr("class","y2 axis").attr("transform",J.y2).call(Xa);c=h.append("g").attr("clip-path",Oa).attr("class","grid");hc&&c.append("g").attr("class","xgrids");ub&&(f=c.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(ub).enter().append("g").attr("class","xgrid-line"),f.append("line").attr("class", +function(a){return""+a["class"]}),f.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-w).attr("dy",-6).text(function(a){return a.text}));Wc&&c.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?r:-10).attr("y1",g?-10:w).attr("y2",g?-10:u);ic&&c.append("g").attr("class","ygrids");vb&&c.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(vb).enter().append("line").attr("class", +function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Oa).attr("class","regions");h.append("g").attr("clip-path",Oa).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",na?"ew-resize":null).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",ba&&oa?"pointer":null).on("mouseover",function(a,b){if(!cb){var c=l.data.targets.map(function(a){return ga(a.values[b])}), +f,e;if(0",c,d,e;for(c=0;c"+ +e+""+d+"";return b+""}),Zc=e(["tooltip","init","show"],!1),Aa=e(["tooltip","init","x"],0),nc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),tb=ta.replace("#","")+"-clip",Oa="url(#"+tb+")",z="timeseries"===qc,X="categorized"===qc,Qb=!z&&ma,yb=null,cb=!1,xb=!1,ia=za?40:0,la=d.time.format(ed).parse,R=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]}}(fd,gd),wc=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)}}(),Fb,Kb,Hb,Ua,Jb,Lb,r,u,ja,gb,ua,Mb,Nb,jb,kb,m,y,P,W,Va,Wa,I,ka,Xa,Fa,sc=g?"left":"bottom",tc=g?ib?"top":"bottom":ib?"right":"left",uc=g?hb?"bottom":"top":hb?"left":"right",vc="bottom",J={main:function(){return"translate("+H+","+w+")"},context:function(){return"translate("+G+","+Ba+")"},legend:function(){return"translate("+Bb+","+Ab+")"},y2:function(){return"translate("+ +(g?0:r)+","+(g?10:0)+")"},x:function(){return"translate(0,"+u+")"},subx:function(){return"translate(0,"+ja+")"}},ad=function(){var a=d.svg.line().x(g?function(a){return fa(a.id)(a.value)}:ab).y(g?ab:function(a){return fa(a.id)(a.value)});return function(b){var c=ec(b.values),d;if(qb(b))return"spline"===$["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0b.classes.indexOf(a)})});return K};l.data.get=function(a){a=l.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b= +Ya(function(b){return b.id===a});return 0