From e400710707cb87fd125142e6c9235470c67c1b0e Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Fri, 27 Nov 2009 14:51:44 -0500 Subject: [PATCH] update combined --- dygraph-combined.js | 310 ++++++++++++++++++++++++++++------------------------ 1 file changed, 166 insertions(+), 144 deletions(-) diff --git a/dygraph-combined.js b/dygraph-combined.js index 6b90a70..5a954d8 100644 --- a/dygraph-combined.js +++ b/dygraph-combined.js @@ -5375,7 +5375,7 @@ var _177=Dygraph.numericTicks(minY,maxY,this); this.layout_.updateOptions({yAxis:[minY,maxY],yTicks:_177}); }; Dygraph.prototype.drawGraph_=function(data){ -var maxY=null; +var minY=null,maxY=null; this.layout_.removeAllDatasets(); this.setColors_(); for(var i=1;imaxY){ maxY=y; } +if(minY==null||ymaxY){ maxY=bars?y+_178[j][1][1]:y; } +if(minY==null||ymaxY){ maxY=y; } +if(minY==null||y=0){ +_186=0; +} +if(_185>0&&maxY<=0){ +_185=0; +} +if(this.attr_("includeZero")){ +if(maxY<0){ +_185=0; +} +if(minY>0){ +_186=0; +} } -this.addYTicks_(0,maxY); +this.addYTicks_(_186,_185); } this.addXTicks_(); this.layout_.evaluateWithError(); @@ -5446,44 +5468,44 @@ this.plotter_.clear(); this.plotter_.render(); this.canvas_.getContext("2d").clearRect(0,0,this.canvas_.width,this.canvas_.height); }; -Dygraph.prototype.rollingAverage=function(_184,_185){ -if(_184.length<2){ -return _184; +Dygraph.prototype.rollingAverage=function(_187,_188){ +if(_187.length<2){ +return _187; } -var _185=Math.min(_185,_184.length-1); -var _186=[]; -var _187=this.attr_("sigma"); +var _188=Math.min(_188,_187.length-1); +var _189=[]; +var _190=this.attr_("sigma"); if(this.fractions_){ var num=0; var den=0; var mult=100; -for(var i=0;i<_184.length;i++){ -num+=_184[i][1][0]; -den+=_184[i][1][1]; -if(i-_185>=0){ -num-=_184[i-_185][1][0]; -den-=_184[i-_185][1][1]; -} -var date=_184[i][0]; -var _190=den?num/den:0; +for(var i=0;i<_187.length;i++){ +num+=_187[i][1][0]; +den+=_187[i][1][1]; +if(i-_188>=0){ +num-=_187[i-_188][1][0]; +den-=_187[i-_188][1][1]; +} +var date=_187[i][0]; +var _193=den?num/den:0; if(this.attr_("errorBars")){ if(this.wilsonInterval_){ if(den){ -var p=_190<0?0:_190,n=den; -var pm=_187*Math.sqrt(p*(1-p)/n+_187*_187/(4*n*n)); -var _193=1+_187*_187/den; -var low=(p+_187*_187/(2*den)-pm)/_193; -var high=(p+_187*_187/(2*den)+pm)/_193; -_186[i]=[date,[p*mult,(p-low)*mult,(high-p)*mult]]; +var p=_193<0?0:_193,n=den; +var pm=_190*Math.sqrt(p*(1-p)/n+_190*_190/(4*n*n)); +var _196=1+_190*_190/den; +var low=(p+_190*_190/(2*den)-pm)/_196; +var high=(p+_190*_190/(2*den)+pm)/_196; +_189[i]=[date,[p*mult,(p-low)*mult,(high-p)*mult]]; }else{ -_186[i]=[date,[0,0,0]]; +_189[i]=[date,[0,0,0]]; } }else{ -var _194=den?_187*Math.sqrt(_190*(1-_190)/den):1; -_186[i]=[date,[mult*_190,mult*_194,mult*_194]]; +var _197=den?_190*Math.sqrt(_193*(1-_193)/den):1; +_189[i]=[date,[mult*_193,mult*_197,mult*_197]]; } }else{ -_186[i]=[date,mult*_190]; +_189[i]=[date,mult*_193]; } } }else{ @@ -5491,99 +5513,99 @@ if(this.customBars_){ var low=0; var mid=0; var high=0; -var _196=0; -for(var i=0;i<_184.length;i++){ -var data=_184[i][1]; +var _199=0; +for(var i=0;i<_187.length;i++){ +var data=_187[i][1]; var y=data[1]; -_186[i]=[_184[i][0],[y,y-data[0],data[2]-y]]; +_189[i]=[_187[i][0],[y,y-data[0],data[2]-y]]; low+=data[0]; mid+=y; high+=data[2]; -_196+=1; -if(i-_185>=0){ -var prev=_184[i-_185]; +_199+=1; +if(i-_188>=0){ +var prev=_187[i-_188]; low-=prev[1][0]; mid-=prev[1][1]; high-=prev[1][2]; -_196-=1; +_199-=1; } -_186[i]=[_184[i][0],[1*mid/_196,1*(mid-low)/_196,1*(high-mid)/_196]]; +_189[i]=[_187[i][0],[1*mid/_199,1*(mid-low)/_199,1*(high-mid)/_199]]; } }else{ -var _198=Math.min(_185-1,_184.length-2); +var _201=Math.min(_188-1,_187.length-2); if(!this.attr_("errorBars")){ -for(var i=0;i<_198;i++){ +for(var i=0;i<_201;i++){ var sum=0; for(var j=0;j=0||str.indexOf("/")>=0||isNaN(parseFloat(str))){ -_204=true; +_207=true; }else{ if(str.length==8&&str>"19700101"&&str<"20371231"){ -_204=true; +_207=true; } } -if(_204){ +if(_207){ this.attrs_.xValueFormatter=Dygraph.dateString_; this.attrs_.xValueParser=Dygraph.dateParser; this.attrs_.xTicker=Dygraph.dateTicker; @@ -5599,57 +5621,57 @@ this.attrs_.xTicker=Dygraph.numericTicks; }; Dygraph.prototype.parseCSV_=function(data){ var ret=[]; -var _205=data.split("\n"); -var _206=0; +var _208=data.split("\n"); +var _209=0; if(this.labelsFromCSV_){ -_206=1; -this.attrs_.labels=_205[0].split(","); -} -var _207; -var _208=false; -var _209=this.attr_("labels").length; -for(var i=_206;i<_205.length;i++){ -var line=_205[i]; +_209=1; +this.attrs_.labels=_208[0].split(","); +} +var _210; +var _211=false; +var _212=this.attr_("labels").length; +for(var i=_209;i<_208.length;i++){ +var line=_208[i]; if(line.length==0){ continue; } -var _211=line.split(","); -if(_211.length<2){ +var _214=line.split(","); +if(_214.length<2){ continue; } -var _212=[]; -if(!_208){ -this.detectTypeFromString_(_211[0]); -_207=this.attr_("xValueParser"); -_208=true; +var _215=[]; +if(!_211){ +this.detectTypeFromString_(_214[0]); +_210=this.attr_("xValueParser"); +_211=true; } -_212[0]=_207(_211[0],this); +_215[0]=_210(_214[0],this); if(this.fractions_){ -for(var j=1;j<_211.length;j++){ -var vals=_211[j].split("/"); -_212[j]=[parseFloat(vals[0]),parseFloat(vals[1])]; +for(var j=1;j<_214.length;j++){ +var vals=_214[j].split("/"); +_215[j]=[parseFloat(vals[0]),parseFloat(vals[1])]; } }else{ if(this.attr_("errorBars")){ -for(var j=1;j<_211.length;j+=2){ -_212[(j+1)/2]=[parseFloat(_211[j]),parseFloat(_211[j+1])]; +for(var j=1;j<_214.length;j+=2){ +_215[(j+1)/2]=[parseFloat(_214[j]),parseFloat(_214[j+1])]; } }else{ if(this.customBars_){ -for(var j=1;j<_211.length;j++){ -var vals=_211[j].split(";"); -_212[j]=[parseFloat(vals[0]),parseFloat(vals[1]),parseFloat(vals[2])]; +for(var j=1;j<_214.length;j++){ +var vals=_214[j].split(";"); +_215[j]=[parseFloat(vals[0]),parseFloat(vals[1]),parseFloat(vals[2])]; } }else{ -for(var j=1;j<_211.length;j++){ -_212[j]=parseFloat(_211[j]); +for(var j=1;j<_214.length;j++){ +_215[j]=parseFloat(_214[j]); } } } } -ret.push(_212); -if(_212.length!=_209){ -this.error("Number of columns in line "+i+" ("+_212.length+") does not agree with number of labels ("+_209+") "+line); +ret.push(_215); +if(_215.length!=_212){ +this.error("Number of columns in line "+i+" ("+_215.length+") does not agree with number of labels ("+_212+") "+line); } } return ret; @@ -5673,19 +5695,19 @@ this.attrs_.labels.push("Y"+i); if(MochiKit.Base.isDateLike(data[0][0])){ this.attrs_.xValueFormatter=Dygraph.dateString_; this.attrs_.xTicker=Dygraph.dateTicker; -var _213=MochiKit.Base.clone(data); +var _216=MochiKit.Base.clone(data); for(var i=0;i=0){ this.loadedEvent_(this.file_); }else{ var req=new XMLHttpRequest(); -var _221=this; +var _224=this; req.onreadystatechange=function(){ if(req.readyState==4){ if(req.status==200){ -_221.loadedEvent_(req.responseText); +_224.loadedEvent_(req.responseText); } } }; @@ -5780,39 +5802,39 @@ this.error("Unknown data format: "+(typeof this.file_)); } } }; -Dygraph.prototype.updateOptions=function(_222){ -if(_222.customBars){ -this.customBars_=_222.customBars; +Dygraph.prototype.updateOptions=function(_225){ +if(_225.customBars){ +this.customBars_=_225.customBars; } -if(_222.rollPeriod){ -this.rollPeriod_=_222.rollPeriod; +if(_225.rollPeriod){ +this.rollPeriod_=_225.rollPeriod; } -if(_222.dateWindow){ -this.dateWindow_=_222.dateWindow; +if(_225.dateWindow){ +this.dateWindow_=_225.dateWindow; } -if(_222.valueRange){ -this.valueRange_=_222.valueRange; +if(_225.valueRange){ +this.valueRange_=_225.valueRange; } -MochiKit.Base.update(this.user_attrs_,_222); +MochiKit.Base.update(this.user_attrs_,_225); this.labelsFromCSV_=(this.attr_("labels")==null); this.layout_.updateOptions({"errorBars":this.attr_("errorBars")}); -if(_222["file"]&&_222["file"]!=this.file_){ -this.file_=_222["file"]; +if(_225["file"]&&_225["file"]!=this.file_){ +this.file_=_225["file"]; this.start_(); }else{ this.drawGraph_(this.rawData_); } }; -Dygraph.prototype.adjustRoll=function(_223){ -this.rollPeriod_=_223; +Dygraph.prototype.adjustRoll=function(_226){ +this.rollPeriod_=_226; this.drawGraph_(this.rawData_); }; -Dygraph.GVizChart=function(_224){ -this.container=_224; +Dygraph.GVizChart=function(_227){ +this.container=_227; }; -Dygraph.GVizChart.prototype.draw=function(data,_225){ +Dygraph.GVizChart.prototype.draw=function(data,_228){ this.container.innerHTML=""; -this.date_graph=new Dygraph(this.container,data,_225); +this.date_graph=new Dygraph(this.container,data,_228); }; DateGraph=Dygraph; -- 2.7.4