symlink excanvas
[dygraphs.git] / dygraph-combined.js
CommitLineData
6219c9d6 1Date.ext={};Date.ext.util={};Date.ext.util.xPad=function(x,pad,r){if(typeof (r)=="undefined"){r=10}for(;parseInt(x,10)<r&&r>1;r/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(d){return Date.ext.util.xPad(parseInt(Date.ext.util.G(d)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date.ext.util.xPad(doy,0,100)},m:function(d){return Date.ext.util.xPad(d.getMonth()+1,0)},M:["getMinutes","0"],p:function(d){return Date.ext.locales[d.locale].p[d.getHours()>=12?1:0]},P:function(d){return Date.ext.locales[d.locale].P[d.getHours()>=12?1:0]},S:["getSeconds","0"],u:function(d){var dow=d.getDay();return dow===0?7:dow},U:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=6-d.getDay();var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0,10)},y:function(d){return Date.ext.util.xPad(d.getFullYear()%100,0)},Y:"getFullYear",z:function(d){var o=d.getTimezoneOffset();var H=Date.ext.util.xPad(parseInt(Math.abs(o/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a-zA-Z]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a-zA-Z]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY%])/g,function(m0,m1){var f=Date.ext.formats[m1];if(typeof (f)=="string"){return d[f]()}else{if(typeof (f)=="function"){return f.call(d,d)}else{if(typeof (f)=="object"&&typeof (f[0])=="string"){return Date.ext.util.xPad(d[f[0]](),f[1])}else{return m1}}}});d=null;return str};
efe0829a
DV
2DygraphLayout=function(_1,_2){
3this.dygraph_=_1;
4this.options={};
9c97d733 5Dygraph.update(this.options,_2?_2:{});
efe0829a
DV
6this.datasets=new Array();
7};
8DygraphLayout.prototype.attr_=function(_3){
9return this.dygraph_.attr_(_3);
10};
11DygraphLayout.prototype.addDataset=function(_4,_5){
12this.datasets[_4]=_5;
13};
14DygraphLayout.prototype.evaluate=function(){
15this._evaluateLimits();
16this._evaluateLineCharts();
17this._evaluateLineTicks();
18};
19DygraphLayout.prototype._evaluateLimits=function(){
20this.minxval=this.maxxval=null;
21for(var _6 in this.datasets){
22var _7=this.datasets[_6];
23var x1=_7[0][0];
24if(!this.minxval||x1<this.minxval){
25this.minxval=x1;
26}
27var x2=_7[_7.length-1][0];
28if(!this.maxxval||x2>this.maxxval){
29this.maxxval=x2;
30}
31}
32this.xrange=this.maxxval-this.minxval;
33this.xscale=(this.xrange!=0?1/this.xrange:1);
34this.minyval=this.options.yAxis[0];
35this.maxyval=this.options.yAxis[1];
36this.yrange=this.maxyval-this.minyval;
37this.yscale=(this.yrange!=0?1/this.yrange:1);
38};
39DygraphLayout.prototype._evaluateLineCharts=function(){
40this.points=new Array();
41for(var _10 in this.datasets){
42var _11=this.datasets[_10];
43for(var j=0;j<_11.length;j++){
44var _13=_11[j];
45var _14={x:((parseFloat(_13[0])-this.minxval)*this.xscale),y:1-((parseFloat(_13[1])-this.minyval)*this.yscale),xval:parseFloat(_13[0]),yval:parseFloat(_13[1]),name:_10};
46if(_14.y<=0){
47_14.y=0;
48}
49if(_14.y>=1){
50_14.y=1;
51}
52if((_14.x>=0)&&(_14.x<=1)){
53this.points.push(_14);
54}
55}
56}
57};
58DygraphLayout.prototype._evaluateLineTicks=function(){
59this.xticks=new Array();
60for(var i=0;i<this.options.xTicks.length;i++){
61var _16=this.options.xTicks[i];
62var _17=_16.label;
63var pos=this.xscale*(_16.v-this.minxval);
64if((pos>=0)&&(pos<=1)){
65this.xticks.push([pos,_17]);
66}
67}
68this.yticks=new Array();
69for(var i=0;i<this.options.yTicks.length;i++){
70var _16=this.options.yTicks[i];
71var _17=_16.label;
72var pos=1-(this.yscale*(_16.v-this.minyval));
73if((pos>=0)&&(pos<=1)){
74this.yticks.push([pos,_17]);
75}
76}
6a1aa64f 77};
285a6bda 78DygraphLayout.prototype.evaluateWithError=function(){
b2a516b8
DV
79this.evaluate();
80if(!this.options.errorBars){
81return;
82}
83var i=0;
efe0829a 84for(var _19 in this.datasets){
b2a516b8 85var j=0;
efe0829a 86var _20=this.datasets[_19];
efe0829a
DV
87for(var j=0;j<_20.length;j++,i++){
88var _21=_20[j];
89var xv=parseFloat(_21[0]);
90var yv=parseFloat(_21[1]);
b2a516b8 91if(xv==this.points[i].xval&&yv==this.points[i].yval){
efe0829a
DV
92this.points[i].errorMinus=parseFloat(_21[2]);
93this.points[i].errorPlus=parseFloat(_21[3]);
b2a516b8
DV
94}
95}
96}
6a1aa64f 97};
285a6bda 98DygraphLayout.prototype.removeAllDatasets=function(){
b2a516b8
DV
99delete this.datasets;
100this.datasets=new Array();
6a1aa64f 101};
efe0829a 102DygraphLayout.prototype.updateOptions=function(_24){
9c97d733 103Dygraph.update(this.options,_24?_24:{});
b2a516b8 104};
efe0829a 105DygraphCanvasRenderer=function(_25,_26,_27,_28){
efe0829a 106this.dygraph_=_25;
f474c2a3 107this.options={"strokeWidth":0.5,"drawXAxis":true,"drawYAxis":true,"axisLineColor":"black","axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":"black","axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"drawYGrid":true,"drawXGrid":true,"gridLineColor":"rgb(128,128,128)"};
9c97d733 108Dygraph.update(this.options,_28);
fbe31dc8 109this.layout=_27;
b0c3b730 110this.element=_26;
fbe31dc8 111this.container=this.element.parentNode;
3df0ccf0 112this.isIE=(/MSIE/.test(navigator.userAgent)&&!window.opera);
fbe31dc8
DV
113if(this.isIE&&!isNil(G_vmlCanvasManager)){
114this.IEDelay=0.5;
115this.maxTries=5;
116this.renderDelay=null;
117this.clearDelay=null;
118this.element=G_vmlCanvasManager.initElement(this.element);
119}
120this.height=this.element.height;
121this.width=this.element.width;
122if(!this.isIE&&!(DygraphCanvasRenderer.isSupported(this.element))){
123throw "Canvas is not supported.";
124}
125this.xlabels=new Array();
126this.ylabels=new Array();
127this.area={x:this.options.yAxisLabelWidth+2*this.options.axisTickSize,y:0};
128this.area.w=this.width-this.area.x-this.options.rightGap;
129this.area.h=this.height-this.options.axisLabelFontSize-2*this.options.axisTickSize;
b0c3b730
DV
130this.container.style.position="relative";
131this.container.style.width=this.width+"px";
fbe31dc8
DV
132};
133DygraphCanvasRenderer.prototype.clear=function(){
134if(this.isIE){
135try{
136if(this.clearDelay){
137this.clearDelay.cancel();
138this.clearDelay=null;
139}
140var _29=this.element.getContext("2d");
141}
142catch(e){
143this.clearDelay=MochiKit.Async.wait(this.IEDelay);
144this.clearDelay.addCallback(bind(this.clear,this));
145return;
146}
147}
148var _29=this.element.getContext("2d");
149_29.clearRect(0,0,this.width,this.height);
2160ed4a 150for(var i=0;i<this.xlabels.length;i++){
b0c3b730
DV
151var el=this.xlabels[i];
152el.parentNode.removeChild(el);
2160ed4a
DV
153}
154for(var i=0;i<this.ylabels.length;i++){
b0c3b730
DV
155var el=this.ylabels[i];
156el.parentNode.removeChild(el);
2160ed4a 157}
fbe31dc8
DV
158this.xlabels=new Array();
159this.ylabels=new Array();
160};
b0c3b730
DV
161DygraphCanvasRenderer.isSupported=function(_31){
162var _32=null;
fbe31dc8 163try{
21d3323f 164if(typeof (_31)=="undefined"||_31==null){
b0c3b730 165_32=document.createElement("canvas");
fbe31dc8 166}else{
b0c3b730 167_32=_31;
fbe31dc8 168}
b0c3b730 169var _33=_32.getContext("2d");
fbe31dc8
DV
170}
171catch(e){
172var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
b0c3b730
DV
173var _35=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
174if((!ie)||(ie[1]<6)||(_35)){
fbe31dc8
DV
175return false;
176}
177return true;
178}
179return true;
b2a516b8 180};
285a6bda 181DygraphCanvasRenderer.prototype.render=function(){
b2a516b8
DV
182var ctx=this.element.getContext("2d");
183if(this.options.drawYGrid){
b0c3b730 184var _37=this.layout.yticks;
b2a516b8 185ctx.save();
f474c2a3 186ctx.strokeStyle=this.options.gridLineColor;
b2a516b8 187ctx.lineWidth=this.options.axisLineWidth;
b0c3b730 188for(var i=0;i<_37.length;i++){
b2a516b8 189var x=this.area.x;
b0c3b730 190var y=this.area.y+_37[i][0]*this.area.h;
b2a516b8
DV
191ctx.beginPath();
192ctx.moveTo(x,y);
193ctx.lineTo(x+this.area.w,y);
194ctx.closePath();
195ctx.stroke();
196}
197}
198if(this.options.drawXGrid){
b0c3b730 199var _37=this.layout.xticks;
b2a516b8 200ctx.save();
f474c2a3 201ctx.strokeStyle=this.options.gridLineColor;
b2a516b8 202ctx.lineWidth=this.options.axisLineWidth;
b0c3b730
DV
203for(var i=0;i<_37.length;i++){
204var x=this.area.x+_37[i][0]*this.area.w;
b2a516b8
DV
205var y=this.area.y+this.area.h;
206ctx.beginPath();
207ctx.moveTo(x,y);
208ctx.lineTo(x,this.area.y);
209ctx.closePath();
210ctx.stroke();
211}
212}
2ce09b19 213this._renderLineChart();
fbe31dc8 214this._renderAxis();
b2a516b8 215};
fbe31dc8
DV
216DygraphCanvasRenderer.prototype._renderAxis=function(){
217if(!this.options.drawXAxis&&!this.options.drawYAxis){
218return;
219}
b0c3b730 220var _40=this.element.getContext("2d");
f474c2a3 221var _41={"position":"absolute","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor,"width":this.options.axisLabelWidth+"px","overflow":"hidden"};
bd597afc
DV
222var _42=function(txt){
223var div=document.createElement("div");
224for(var _45 in _41){
225div.style[_45]=_41[_45];
226}
227div.appendChild(document.createTextNode(txt));
228return div;
229};
b0c3b730 230_40.save();
f474c2a3 231_40.strokeStyle=this.options.axisLineColor;
b0c3b730 232_40.lineWidth=this.options.axisLineWidth;
fbe31dc8
DV
233if(this.options.drawYAxis){
234if(this.layout.yticks){
2160ed4a 235for(var i=0;i<this.layout.yticks.length;i++){
bd597afc
DV
236var _46=this.layout.yticks[i];
237if(typeof (_46)=="function"){
fbe31dc8
DV
238return;
239}
240var x=this.area.x;
bd597afc 241var y=this.area.y+_46[0]*this.area.h;
b0c3b730
DV
242_40.beginPath();
243_40.moveTo(x,y);
244_40.lineTo(x-this.options.axisTickSize,y);
245_40.closePath();
246_40.stroke();
bd597afc 247var _47=_42(_46[1]);
fbe31dc8
DV
248var top=(y-this.options.axisLabelFontSize/2);
249if(top<0){
250top=0;
251}
252if(top+this.options.axisLabelFontSize+3>this.height){
bd597afc 253_47.style.bottom="0px";
fbe31dc8 254}else{
bd597afc 255_47.style.top=top+"px";
fbe31dc8 256}
bd597afc
DV
257_47.style.left="0px";
258_47.style.textAlign="right";
259_47.style.width=this.options.yAxisLabelWidth+"px";
260this.container.appendChild(_47);
261this.ylabels.push(_47);
2160ed4a 262}
bd597afc
DV
263var _49=this.ylabels[0];
264var _50=this.options.axisLabelFontSize;
265var _51=parseInt(_49.style.top)+_50;
266if(_51>this.height-_50){
267_49.style.top=(parseInt(_49.style.top)-_50/2)+"px";
fbe31dc8
DV
268}
269}
b0c3b730
DV
270_40.beginPath();
271_40.moveTo(this.area.x,this.area.y);
272_40.lineTo(this.area.x,this.area.y+this.area.h);
273_40.closePath();
274_40.stroke();
fbe31dc8
DV
275}
276if(this.options.drawXAxis){
277if(this.layout.xticks){
2160ed4a 278for(var i=0;i<this.layout.xticks.length;i++){
bd597afc 279var _46=this.layout.xticks[i];
fbe31dc8
DV
280if(typeof (dataset)=="function"){
281return;
282}
bd597afc 283var x=this.area.x+_46[0]*this.area.w;
fbe31dc8 284var y=this.area.y+this.area.h;
b0c3b730
DV
285_40.beginPath();
286_40.moveTo(x,y);
287_40.lineTo(x,y+this.options.axisTickSize);
288_40.closePath();
289_40.stroke();
bd597afc
DV
290var _47=_42(_46[1]);
291_47.style.textAlign="center";
292_47.style.bottom="0px";
293var _52=(x-this.options.axisLabelWidth/2);
294if(_52+this.options.axisLabelWidth>this.width){
295_52=this.width-this.options.xAxisLabelWidth;
296_47.style.textAlign="right";
b0c3b730 297}
bd597afc
DV
298if(_52<0){
299_52=0;
300_47.style.textAlign="left";
b0c3b730 301}
bd597afc
DV
302_47.style.left=_52+"px";
303_47.style.width=this.options.xAxisLabelWidth+"px";
304this.container.appendChild(_47);
305this.xlabels.push(_47);
b0c3b730
DV
306}
307}
308_40.beginPath();
309_40.moveTo(this.area.x,this.area.y+this.area.h);
310_40.lineTo(this.area.x+this.area.w,this.area.y+this.area.h);
311_40.closePath();
312_40.stroke();
313}
314_40.restore();
efe0829a 315};
fbe31dc8 316DygraphCanvasRenderer.prototype._renderLineChart=function(){
bd597afc
DV
317var _53=this.element.getContext("2d");
318var _54=this.options.colorScheme.length;
319var _55=this.options.colorScheme;
21d3323f 320var _56=this.layout.options.errorBars;
9c97d733
DV
321var _57=[];
322for(var _58 in this.layout.datasets){
323_57.push(_58);
21d3323f 324}
9c97d733 325var _59=_57.length;
2160ed4a 326for(var i=0;i<this.layout.points.length;i++){
9c97d733
DV
327var _60=this.layout.points[i];
328_60.canvasx=this.area.w*_60.x+this.area.x;
329_60.canvasy=this.area.h*_60.y+this.area.y;
2160ed4a 330}
9c97d733 331var _61=function(x){
9317362d
DV
332return x&&!isNaN(x);
333};
9c97d733
DV
334var ctx=_53;
335if(_56){
336for(var i=0;i<_59;i++){
337var _62=_57[i];
338var _63=_55[i%_54];
339ctx.save();
340ctx.strokeStyle=_63;
f474c2a3 341ctx.lineWidth=this.options.strokeWidth;
9c97d733
DV
342var _64=-1;
343var _65=[-1,-1];
344var _66=0;
345var _67=this.layout.yscale;
346var rgb=new RGBColor(_63);
347var _69="rgba("+rgb.r+","+rgb.g+","+rgb.b+",0.15)";
348ctx.fillStyle=_69;
9317362d 349ctx.beginPath();
9c97d733
DV
350for(var j=0;j<this.layout.points.length;j++){
351var _60=this.layout.points[j];
352_66++;
353if(_60.name==_62){
354if(!_60.y||isNaN(_60.y)){
355_64=-1;
356continue;
357}
358var _70=[_60.y-_60.errorPlus*_67,_60.y+_60.errorMinus*_67];
359_70[0]=this.area.h*_70[0]+this.area.y;
360_70[1]=this.area.h*_70[1]+this.area.y;
361if(_64>=0){
362ctx.moveTo(_64,_65[0]);
363ctx.lineTo(_60.canvasx,_70[0]);
364ctx.lineTo(_60.canvasx,_70[1]);
365ctx.lineTo(_64,_65[1]);
366ctx.closePath();
9317362d 367}
9c97d733
DV
368_65[0]=_70[0];
369_65[1]=_70[1];
370_64=_60.canvasx;
b2a516b8 371}
648acd28 372}
9c97d733 373ctx.fill();
b2a516b8 374}
b2a516b8 375}
9c97d733
DV
376for(var i=0;i<_59;i++){
377var _62=_57[i];
378var _63=_55[i%_54];
bd597afc 379_53.save();
9c97d733
DV
380var _60=this.layout.points[0];
381var _71=this.dygraph_.attr_("pointSize");
382var _64=null,prevY=null;
383var _72=this.dygraph_.attr_("drawPoints");
384var _73=this.layout.points;
385for(var j=0;j<_73.length;j++){
386var _60=_73[j];
387if(_60.name==_62){
388if(!_61(_60.canvasy)){
389_64=prevY=null;
390}else{
391var _74=(!_64&&(j==_73.length-1||!_61(_73[j+1].canvasy)));
392if(!_64){
393_64=_60.canvasx;
394prevY=_60.canvasy;
395}else{
5fb1199a 396ctx.beginPath();
9c97d733
DV
397ctx.strokeStyle=_63;
398ctx.lineWidth=this.options.strokeWidth;
399ctx.moveTo(_64,prevY);
400_64=_60.canvasx;
401prevY=_60.canvasy;
402ctx.lineTo(_64,prevY);
403ctx.stroke();
648acd28 404}
9c97d733
DV
405if(_72||_74){
406ctx.beginPath();
407ctx.fillStyle=_63;
408ctx.arc(_60.canvasx,_60.canvasy,_71,0,360,false);
409ctx.fill();
5fb1199a 410}
b2a516b8 411}
b2a516b8 412}
b2a516b8 413}
b2a516b8 414}
bd597afc 415_53.restore();
6a1aa64f 416};
9c97d733 417Dygraph=function(div,_75,_76){
b2a516b8 418if(arguments.length>0){
285a6bda
DV
419if(arguments.length==4){
420this.warn("Using deprecated four-argument dygraph constructor");
9c97d733 421this.__old_init__(div,_75,arguments[2],arguments[3]);
285a6bda 422}else{
9c97d733 423this.__init__(div,_75,_76);
285a6bda 424}
b2a516b8 425}
6a1aa64f 426};
285a6bda
DV
427Dygraph.NAME="Dygraph";
428Dygraph.VERSION="1.2";
429Dygraph.__repr__=function(){
b2a516b8 430return "["+this.NAME+" "+this.VERSION+"]";
6a1aa64f 431};
285a6bda 432Dygraph.toString=function(){
b2a516b8 433return this.__repr__();
6a1aa64f 434};
285a6bda
DV
435Dygraph.DEFAULT_ROLL_PERIOD=1;
436Dygraph.DEFAULT_WIDTH=480;
437Dygraph.DEFAULT_HEIGHT=320;
438Dygraph.AXIS_LINE_WIDTH=0.3;
8846615a 439Dygraph.DEFAULT_ATTRS={highlightCircleSize:3,pixelsPerXLabel:60,pixelsPerYLabel:30,labelsDivWidth:250,labelsDivStyles:{},labelsSeparateLines:false,labelsKMB:false,strokeWidth:1,axisTickSize:3,axisLabelFontSize:14,xAxisLabelWidth:50,yAxisLabelWidth:50,rightGap:5,showRoller:false,xValueFormatter:Dygraph.dateString_,xValueParser:Dygraph.dateParser,xTicker:Dygraph.dateTicker,sigma:2,errorBars:false,fractions:false,wilsonInterval:true,customBars:false};
285a6bda
DV
440Dygraph.DEBUG=1;
441Dygraph.INFO=2;
442Dygraph.WARNING=3;
443Dygraph.ERROR=3;
9c97d733
DV
444Dygraph.prototype.__old_init__=function(div,_77,_78,_79){
445if(_78!=null){
446var _80=["Date"];
447for(var i=0;i<_78.length;i++){
448_80.push(_78[i]);
285a6bda 449}
9c97d733 450Dygraph.update(_79,{"labels":_80});
285a6bda 451}
9c97d733 452this.__init__(div,_77,_79);
285a6bda 453};
9c97d733
DV
454Dygraph.prototype.__init__=function(div,_81,_82){
455if(_82==null){
456_82={};
285a6bda 457}
b2a516b8 458this.maindiv_=div;
9c97d733
DV
459this.file_=_81;
460this.rollPeriod_=_82.rollPeriod||Dygraph.DEFAULT_ROLL_PERIOD;
b2a516b8 461this.previousVerticalX_=-1;
9c97d733
DV
462this.fractions_=_82.fractions||false;
463this.dateWindow_=_82.dateWindow||null;
464this.valueRange_=_82.valueRange||null;
465this.wilsonInterval_=_82.wilsonInterval||true;
caf49918 466div.innerHTML="";
285a6bda
DV
467if(div.style.width==""){
468div.style.width=Dygraph.DEFAULT_WIDTH+"px";
469}
470if(div.style.height==""){
471div.style.height=Dygraph.DEFAULT_HEIGHT+"px";
472}
b2a516b8
DV
473this.width_=parseInt(div.style.width,10);
474this.height_=parseInt(div.style.height,10);
285a6bda 475this.user_attrs_={};
9c97d733 476Dygraph.update(this.user_attrs_,_82);
b8339f6e 477this.attrs_={};
9c97d733 478Dygraph.update(this.attrs_,Dygraph.DEFAULT_ATTRS);
285a6bda 479this.labelsFromCSV_=(this.attr_("labels")==null);
b2a516b8 480this.createInterface_();
b64a4f1a 481this.layoutOptions_={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
9c97d733
DV
482Dygraph.update(this.layoutOptions_,this.attrs_);
483Dygraph.update(this.layoutOptions_,this.user_attrs_);
efe0829a 484this.layout_=new DygraphLayout(this,this.layoutOptions_);
8846615a 485this.renderOptions_={colorScheme:this.colors_,strokeColor:null,axisLineWidth:Dygraph.AXIS_LINE_WIDTH};
9c97d733
DV
486Dygraph.update(this.renderOptions_,this.attrs_);
487Dygraph.update(this.renderOptions_,this.user_attrs_);
9317362d 488this.plotter_=new DygraphCanvasRenderer(this,this.hidden_,this.layout_,this.renderOptions_);
b2a516b8
DV
489this.createStatusMessage_();
490this.createRollInterface_();
491this.createDragInterface_();
b2a516b8 492this.start_();
6a1aa64f 493};
9c97d733
DV
494Dygraph.prototype.attr_=function(_83){
495if(typeof (this.user_attrs_[_83])!="undefined"){
496return this.user_attrs_[_83];
285a6bda 497}else{
9c97d733
DV
498if(typeof (this.attrs_[_83])!="undefined"){
499return this.attrs_[_83];
285a6bda
DV
500}else{
501return null;
502}
503}
504};
9c97d733 505Dygraph.prototype.log=function(_84,_85){
285a6bda 506if(typeof (console)!="undefined"){
9c97d733 507switch(_84){
285a6bda 508case Dygraph.DEBUG:
9c97d733 509console.debug("dygraphs: "+_85);
285a6bda
DV
510break;
511case Dygraph.INFO:
9c97d733 512console.info("dygraphs: "+_85);
285a6bda
DV
513break;
514case Dygraph.WARNING:
9c97d733 515console.warn("dygraphs: "+_85);
285a6bda
DV
516break;
517case Dygraph.ERROR:
9c97d733 518console.error("dygraphs: "+_85);
285a6bda
DV
519break;
520}
521}
522};
9c97d733
DV
523Dygraph.prototype.info=function(_86){
524this.log(Dygraph.INFO,_86);
285a6bda 525};
9c97d733
DV
526Dygraph.prototype.warn=function(_87){
527this.log(Dygraph.WARNING,_87);
285a6bda 528};
9c97d733
DV
529Dygraph.prototype.error=function(_88){
530this.log(Dygraph.ERROR,_88);
285a6bda
DV
531};
532Dygraph.prototype.rollPeriod=function(){
b2a516b8
DV
533return this.rollPeriod_;
534};
76171648 535Dygraph.addEvent=function(el,evt,fn){
9c97d733 536var _91=function(e){
76171648
DV
537if(!e){
538var e=window.event;
539}
540fn(e);
541};
542if(window.addEventListener){
9c97d733 543el.addEventListener(evt,_91,false);
76171648 544}else{
9c97d733 545el.attachEvent("on"+evt,_91);
76171648
DV
546}
547};
285a6bda 548Dygraph.prototype.createInterface_=function(){
9c97d733 549var _93=this.maindiv_;
b0c3b730
DV
550this.graphDiv=document.createElement("div");
551this.graphDiv.style.width=this.width_+"px";
552this.graphDiv.style.height=this.height_+"px";
9c97d733 553_93.appendChild(this.graphDiv);
b0c3b730
DV
554this.canvas_=document.createElement("canvas");
555this.canvas_.style.position="absolute";
556this.canvas_.width=this.width_;
557this.canvas_.height=this.height_;
558this.graphDiv.appendChild(this.canvas_);
b2a516b8 559this.hidden_=this.createPlotKitCanvas_(this.canvas_);
9c97d733 560var _94=this;
76171648 561Dygraph.addEvent(this.hidden_,"mousemove",function(e){
9c97d733 562_94.mouseMove_(e);
b2a516b8 563});
76171648 564Dygraph.addEvent(this.hidden_,"mouseout",function(e){
9c97d733 565_94.mouseOut_(e);
b2a516b8 566});
6a1aa64f 567};
9c97d733 568Dygraph.prototype.createPlotKitCanvas_=function(_95){
b2a516b8
DV
569var h=document.createElement("canvas");
570h.style.position="absolute";
9c97d733
DV
571h.style.top=_95.style.top;
572h.style.left=_95.style.left;
b2a516b8
DV
573h.width=this.width_;
574h.height=this.height_;
b0c3b730 575this.graphDiv.appendChild(h);
b2a516b8
DV
576return h;
577};
9c97d733 578Dygraph.hsvToRGB=function(hue,_98,_99){
f474c2a3 579var red;
9c97d733 580var _101;
f474c2a3 581var blue;
9c97d733
DV
582if(_98===0){
583red=_99;
584_101=_99;
585blue=_99;
f474c2a3
DV
586}else{
587var i=Math.floor(hue*6);
588var f=(hue*6)-i;
9c97d733
DV
589var p=_99*(1-_98);
590var q=_99*(1-(_98*f));
591var t=_99*(1-(_98*(1-f)));
f474c2a3
DV
592switch(i){
593case 1:
594red=q;
9c97d733 595_101=_99;
f474c2a3
DV
596blue=p;
597break;
598case 2:
599red=p;
9c97d733 600_101=_99;
f474c2a3
DV
601blue=t;
602break;
603case 3:
604red=p;
9c97d733
DV
605_101=q;
606blue=_99;
f474c2a3
DV
607break;
608case 4:
609red=t;
9c97d733
DV
610_101=p;
611blue=_99;
f474c2a3
DV
612break;
613case 5:
9c97d733
DV
614red=_99;
615_101=p;
f474c2a3
DV
616blue=q;
617break;
618case 6:
619case 0:
9c97d733
DV
620red=_99;
621_101=t;
f474c2a3
DV
622blue=p;
623break;
624}
625}
626red=Math.floor(255*red+0.5);
9c97d733 627_101=Math.floor(255*_101+0.5);
f474c2a3 628blue=Math.floor(255*blue+0.5);
9c97d733 629return "rgb("+red+","+_101+","+blue+")";
f474c2a3 630};
285a6bda
DV
631Dygraph.prototype.setColors_=function(){
632var num=this.attr_("labels").length-1;
b2a516b8 633this.colors_=[];
9c97d733
DV
634var _108=this.attr_("colors");
635if(!_108){
285a6bda
DV
636var sat=this.attr_("colorSaturation")||1;
637var val=this.attr_("colorValue")||0.5;
b2a516b8
DV
638for(var i=1;i<=num;i++){
639var hue=(1*i/(1+num));
f474c2a3 640this.colors_.push(Dygraph.hsvToRGB(hue,sat,val));
b2a516b8
DV
641}
642}else{
643for(var i=0;i<num;i++){
9c97d733
DV
644var _111=_108[i%_108.length];
645this.colors_.push(_111);
b2a516b8 646}
b2a516b8 647}
285a6bda 648this.renderOptions_.colorScheme=this.colors_;
9c97d733
DV
649Dygraph.update(this.plotter_.options,this.renderOptions_);
650Dygraph.update(this.layoutOptions_,this.user_attrs_);
651Dygraph.update(this.layoutOptions_,this.attrs_);
b2a516b8 652};
3df0ccf0 653Dygraph.findPosX=function(obj){
9c97d733 654var _113=0;
3df0ccf0
DV
655if(obj.offsetParent){
656while(obj.offsetParent){
9c97d733 657_113+=obj.offsetLeft;
3df0ccf0
DV
658obj=obj.offsetParent;
659}
660}else{
661if(obj.x){
9c97d733 662_113+=obj.x;
3df0ccf0
DV
663}
664}
9c97d733 665return _113;
3df0ccf0
DV
666};
667Dygraph.findPosY=function(obj){
9c97d733 668var _114=0;
3df0ccf0
DV
669if(obj.offsetParent){
670while(obj.offsetParent){
9c97d733 671_114+=obj.offsetTop;
3df0ccf0
DV
672obj=obj.offsetParent;
673}
674}else{
675if(obj.y){
9c97d733 676_114+=obj.y;
3df0ccf0
DV
677}
678}
9c97d733 679return _114;
3df0ccf0 680};
285a6bda
DV
681Dygraph.prototype.createStatusMessage_=function(){
682if(!this.attr_("labelsDiv")){
9c97d733
DV
683var _115=this.attr_("labelsDivWidth");
684var _116={"position":"absolute","fontSize":"14px","zIndex":10,"width":_115+"px","top":"0px","left":(this.width_-_115-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
685Dygraph.update(_116,this.attr_("labelsDivStyles"));
b0c3b730 686var div=document.createElement("div");
9c97d733
DV
687for(var name in _116){
688div.style[name]=_116[name];
b0c3b730
DV
689}
690this.graphDiv.appendChild(div);
285a6bda
DV
691this.attrs_.labelsDiv=div;
692}
693};
694Dygraph.prototype.createRollInterface_=function(){
9c97d733
DV
695var _118=this.attr_("showRoller")?"block":"none";
696var _119={"position":"absolute","zIndex":10,"top":(this.plotter_.area.h-25)+"px","left":(this.plotter_.area.x+1)+"px","display":_118};
697var _120=document.createElement("input");
698_120.type="text";
699_120.size="2";
700_120.value=this.rollPeriod_;
701for(var name in _119){
702_120.style[name]=_119[name];
b0c3b730 703}
b2a516b8 704var pa=this.graphDiv;
9c97d733
DV
705pa.appendChild(_120);
706var _122=this;
707_120.onchange=function(){
708_122.adjustRoll(_120.value);
76171648 709};
9c97d733 710return _120;
76171648
DV
711};
712Dygraph.pageX=function(e){
713if(e.pageX){
714return (!e.pageX||e.pageX<0)?0:e.pageX;
715}else{
716var de=document;
717var b=document.body;
718return e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
719}
720};
721Dygraph.pageY=function(e){
722if(e.pageY){
723return (!e.pageY||e.pageY<0)?0:e.pageY;
724}else{
725var de=document;
726var b=document.body;
727return e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
728}
285a6bda
DV
729};
730Dygraph.prototype.createDragInterface_=function(){
fbe31dc8 731var self=this;
9c97d733
DV
732var _126=false;
733var _127=null;
734var _128=null;
735var _129=null;
736var _130=null;
737var _131=null;
353a0294
DV
738var px=0;
739var py=0;
efe0829a 740var getX=function(e){
76171648 741return Dygraph.pageX(e)-px;
b2a516b8 742};
efe0829a 743var getY=function(e){
76171648 744return Dygraph.pageX(e)-py;
b2a516b8 745};
9c97d733
DV
746Dygraph.addEvent(this.hidden_,"mousemove",function(_136){
747if(_126){
748_129=getX(_136);
749_130=getY(_136);
750self.drawZoomRect_(_127,_129,_131);
751_131=_129;
6a1aa64f 752}
b2a516b8 753});
9c97d733
DV
754Dygraph.addEvent(this.hidden_,"mousedown",function(_137){
755_126=true;
3df0ccf0
DV
756px=Dygraph.findPosX(self.canvas_);
757py=Dygraph.findPosY(self.canvas_);
9c97d733
DV
758_127=getX(_137);
759_128=getY(_137);
b2a516b8 760});
9c97d733
DV
761Dygraph.addEvent(document,"mouseup",function(_138){
762if(_126){
763_126=false;
764_127=null;
765_128=null;
6a1aa64f 766}
b2a516b8 767});
9c97d733
DV
768Dygraph.addEvent(this.hidden_,"mouseout",function(_139){
769if(_126){
770_129=null;
771_130=null;
6a1aa64f 772}
b2a516b8 773});
9c97d733
DV
774Dygraph.addEvent(this.hidden_,"mouseup",function(_140){
775if(_126){
776_126=false;
777_129=getX(_140);
778_130=getY(_140);
779var _141=Math.abs(_129-_127);
780var _142=Math.abs(_130-_128);
781if(_141<2&&_142<2&&self.attr_("clickCallback")!=null&&self.lastx_!=undefined){
782self.attr_("clickCallback")(_140,new Date(self.lastx_));
783}
784if(_141>=10){
785self.doZoom_(Math.min(_127,_129),Math.max(_127,_129));
b2a516b8 786}else{
fbe31dc8 787self.canvas_.getContext("2d").clearRect(0,0,self.canvas_.width,self.canvas_.height);
b2a516b8 788}
9c97d733
DV
789_127=null;
790_128=null;
b2a516b8
DV
791}
792});
9c97d733 793Dygraph.addEvent(this.hidden_,"dblclick",function(_143){
fbe31dc8
DV
794self.dateWindow_=null;
795self.drawGraph_(self.rawData_);
9c97d733
DV
796var _144=self.rawData_[0][0];
797var _145=self.rawData_[self.rawData_.length-1][0];
fbe31dc8 798if(self.attr_("zoomCallback")){
9c97d733 799self.attr_("zoomCallback")(_144,_145);
67e650dc 800}
b2a516b8 801});
6a1aa64f 802};
9c97d733 803Dygraph.prototype.drawZoomRect_=function(_146,endX,_148){
b2a516b8 804var ctx=this.canvas_.getContext("2d");
9c97d733
DV
805if(_148){
806ctx.clearRect(Math.min(_146,_148),0,Math.abs(_146-_148),this.height_);
b2a516b8 807}
9c97d733 808if(endX&&_146){
b2a516b8 809ctx.fillStyle="rgba(128,128,128,0.33)";
9c97d733 810ctx.fillRect(Math.min(_146,endX),0,Math.abs(endX-_146),this.height_);
b2a516b8
DV
811}
812};
9c97d733
DV
813Dygraph.prototype.doZoom_=function(lowX,_150){
814var _151=this.layout_.points;
815var _152=null;
816var _153=null;
817for(var i=0;i<_151.length;i++){
818var cx=_151[i].canvasx;
819var x=_151[i].xval;
820if(cx<lowX&&(_152==null||x>_152)){
821_152=x;
b2a516b8 822}
9c97d733
DV
823if(cx>_150&&(_153==null||x<_153)){
824_153=x;
b2a516b8 825}
b2a516b8 826}
9c97d733
DV
827if(_152==null){
828_152=_151[0].xval;
b2a516b8 829}
9c97d733
DV
830if(_153==null){
831_153=_151[_151.length-1].xval;
b0c3b730 832}
9c97d733 833this.dateWindow_=[_152,_153];
b2a516b8 834this.drawGraph_(this.rawData_);
285a6bda 835if(this.attr_("zoomCallback")){
9c97d733 836this.attr_("zoomCallback")(_152,_153);
67e650dc 837}
b2a516b8 838};
9c97d733
DV
839Dygraph.prototype.mouseMove_=function(_155){
840var _156=Dygraph.pageX(_155)-Dygraph.findPosX(this.hidden_);
841var _157=this.layout_.points;
842var _158=-1;
843var _159=-1;
844var _160=1e+100;
b2a516b8 845var idx=-1;
9c97d733
DV
846for(var i=0;i<_157.length;i++){
847var dist=Math.abs(_157[i].canvasx-_156);
848if(dist>_160){
b2a516b8
DV
849break;
850}
9c97d733 851_160=dist;
b2a516b8
DV
852idx=i;
853}
854if(idx>=0){
9c97d733 855_158=_157[idx].xval;
b2a516b8 856}
9c97d733
DV
857if(_156>_157[_157.length-1].canvasx){
858_158=_157[_157.length-1].xval;
b2a516b8 859}
9c97d733
DV
860var _163=[];
861for(var i=0;i<_157.length;i++){
862if(_157[i].xval==_158){
863_163.push(_157[i]);
b2a516b8
DV
864}
865}
9c97d733 866var _164=this.attr_("highlightCircleSize");
b2a516b8
DV
867var ctx=this.canvas_.getContext("2d");
868if(this.previousVerticalX_>=0){
869var px=this.previousVerticalX_;
9c97d733 870ctx.clearRect(px-_164-1,0,2*_164+2,this.height_);
b2a516b8 871}
648acd28
DV
872var isOK=function(x){
873return x&&!isNaN(x);
874};
9c97d733
DV
875if(_163.length>0){
876var _156=_163[0].canvasx;
877var _166=this.attr_("xValueFormatter")(_158,this)+":";
b2a516b8 878var clen=this.colors_.length;
9c97d733
DV
879for(var i=0;i<_163.length;i++){
880if(!isOK(_163[i].canvasy)){
648acd28
DV
881continue;
882}
285a6bda 883if(this.attr_("labelsSeparateLines")){
9c97d733 884_166+="<br/>";
b2a516b8 885}
9c97d733 886var _168=_163[i];
f474c2a3 887var c=new RGBColor(this.colors_[i%clen]);
9c97d733 888_166+=" <b><font color='"+c.toHex()+"'>"+_168.name+"</font></b>:"+this.round_(_168.yval,2);
b2a516b8 889}
9c97d733
DV
890this.attr_("labelsDiv").innerHTML=_166;
891this.lastx_=_158;
b2a516b8 892ctx.save();
9c97d733
DV
893for(var i=0;i<_163.length;i++){
894if(!isOK(_163[i%clen].canvasy)){
648acd28
DV
895continue;
896}
b2a516b8 897ctx.beginPath();
f474c2a3 898ctx.fillStyle=this.colors_[i%clen];
9c97d733 899ctx.arc(_156,_163[i%clen].canvasy,_164,0,360,false);
b2a516b8
DV
900ctx.fill();
901}
902ctx.restore();
9c97d733 903this.previousVerticalX_=_156;
b2a516b8 904}
6a1aa64f 905};
9c97d733 906Dygraph.prototype.mouseOut_=function(_170){
b2a516b8
DV
907var ctx=this.canvas_.getContext("2d");
908ctx.clearRect(0,0,this.width_,this.height_);
285a6bda 909this.attr_("labelsDiv").innerHTML="";
6a1aa64f 910};
285a6bda 911Dygraph.zeropad=function(x){
6372d433
DV
912if(x<10){
913return "0"+x;
914}else{
915return ""+x;
916}
917};
285a6bda 918Dygraph.prototype.hmsString_=function(date){
9c97d733 919var _172=Dygraph.zeropad;
6372d433
DV
920var d=new Date(date);
921if(d.getSeconds()){
9c97d733 922return _172(d.getHours())+":"+_172(d.getMinutes())+":"+_172(d.getSeconds());
6372d433
DV
923}else{
924if(d.getMinutes()){
9c97d733 925return _172(d.getHours())+":"+_172(d.getMinutes());
6372d433 926}else{
9c97d733 927return _172(d.getHours());
6372d433
DV
928}
929}
930};
285a6bda 931Dygraph.dateString_=function(date,self){
9c97d733 932var _174=Dygraph.zeropad;
b2a516b8
DV
933var d=new Date(date);
934var year=""+d.getFullYear();
9c97d733
DV
935var _176=_174(d.getMonth()+1);
936var day=_174(d.getDate());
6372d433
DV
937var ret="";
938var frac=d.getHours()*3600+d.getMinutes()*60+d.getSeconds();
939if(frac){
285a6bda 940ret=" "+self.hmsString_(date);
b2a516b8 941}
9c97d733 942return year+"/"+_176+"/"+day+ret;
6a1aa64f 943};
9c97d733
DV
944Dygraph.prototype.round_=function(num,_180){
945var _181=Math.pow(10,_180);
946return Math.round(num*_181)/_181;
6a1aa64f 947};
285a6bda 948Dygraph.prototype.loadedEvent_=function(data){
b2a516b8
DV
949this.rawData_=this.parseCSV_(data);
950this.drawGraph_(this.rawData_);
6a1aa64f 951};
285a6bda
DV
952Dygraph.prototype.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
953Dygraph.prototype.quarters=["Jan","Apr","Jul","Oct"];
954Dygraph.prototype.addXTicks_=function(){
9c97d733 955var _183,endDate;
b2a516b8 956if(this.dateWindow_){
9c97d733 957_183=this.dateWindow_[0];
b2a516b8
DV
958endDate=this.dateWindow_[1];
959}else{
9c97d733 960_183=this.rawData_[0][0];
b2a516b8
DV
961endDate=this.rawData_[this.rawData_.length-1][0];
962}
9c97d733
DV
963var _184=this.attr_("xTicker")(_183,endDate,this);
964this.layout_.updateOptions({xTicks:_184});
285a6bda
DV
965};
966Dygraph.SECONDLY=0;
967Dygraph.TEN_SECONDLY=1;
968Dygraph.THIRTY_SECONDLY=2;
969Dygraph.MINUTELY=3;
970Dygraph.TEN_MINUTELY=4;
971Dygraph.THIRTY_MINUTELY=5;
972Dygraph.HOURLY=6;
973Dygraph.SIX_HOURLY=7;
974Dygraph.DAILY=8;
975Dygraph.WEEKLY=9;
976Dygraph.MONTHLY=10;
977Dygraph.QUARTERLY=11;
978Dygraph.BIANNUAL=12;
979Dygraph.ANNUAL=13;
980Dygraph.DECADAL=14;
981Dygraph.NUM_GRANULARITIES=15;
982Dygraph.SHORT_SPACINGS=[];
983Dygraph.SHORT_SPACINGS[Dygraph.SECONDLY]=1000*1;
984Dygraph.SHORT_SPACINGS[Dygraph.TEN_SECONDLY]=1000*10;
985Dygraph.SHORT_SPACINGS[Dygraph.THIRTY_SECONDLY]=1000*30;
986Dygraph.SHORT_SPACINGS[Dygraph.MINUTELY]=1000*60;
987Dygraph.SHORT_SPACINGS[Dygraph.TEN_MINUTELY]=1000*60*10;
988Dygraph.SHORT_SPACINGS[Dygraph.THIRTY_MINUTELY]=1000*60*30;
989Dygraph.SHORT_SPACINGS[Dygraph.HOURLY]=1000*3600;
990Dygraph.SHORT_SPACINGS[Dygraph.HOURLY]=1000*3600*6;
991Dygraph.SHORT_SPACINGS[Dygraph.DAILY]=1000*86400;
992Dygraph.SHORT_SPACINGS[Dygraph.WEEKLY]=1000*604800;
9c97d733
DV
993Dygraph.prototype.NumXTicks=function(_185,_186,_187){
994if(_187<Dygraph.MONTHLY){
995var _188=Dygraph.SHORT_SPACINGS[_187];
996return Math.floor(0.5+1*(_186-_185)/_188);
285a6bda 997}else{
9c97d733
DV
998var _189=1;
999var _190=12;
1000if(_187==Dygraph.QUARTERLY){
1001_190=3;
285a6bda 1002}
9c97d733
DV
1003if(_187==Dygraph.BIANNUAL){
1004_190=2;
285a6bda 1005}
9c97d733
DV
1006if(_187==Dygraph.ANNUAL){
1007_190=1;
285a6bda 1008}
9c97d733
DV
1009if(_187==Dygraph.DECADAL){
1010_190=1;
1011_189=10;
285a6bda 1012}
9c97d733
DV
1013var _191=365.2524*24*3600*1000;
1014var _192=1*(_186-_185)/_191;
1015return Math.floor(0.5+1*_192*_190/_189);
285a6bda
DV
1016}
1017};
9c97d733
DV
1018Dygraph.prototype.GetXAxis=function(_193,_194,_195){
1019var _196=[];
1020if(_195<Dygraph.MONTHLY){
1021var _197=Dygraph.SHORT_SPACINGS[_195];
1022var _198="%d%b";
1023if(_195<Dygraph.HOURLY){
1024_193=_197*Math.floor(0.5+_193/_197);
bd597afc 1025}
9c97d733 1026for(var t=_193;t<=_194;t+=_197){
36615faf
DV
1027var d=new Date(t);
1028var frac=d.getHours()*3600+d.getMinutes()*60+d.getSeconds();
9c97d733
DV
1029if(frac==0||_195>=Dygraph.DAILY){
1030_196.push({v:t,label:new Date(t+3600*1000).strftime(_198)});
b2a516b8 1031}else{
9c97d733 1032_196.push({v:t,label:this.hmsString_(t)});
36615faf
DV
1033}
1034}
b2a516b8 1035}else{
9c97d733
DV
1036var _199;
1037var _200=1;
1038if(_195==Dygraph.MONTHLY){
1039_199=[0,1,2,3,4,5,6,7,8,9,10,11,12];
b2a516b8 1040}else{
9c97d733
DV
1041if(_195==Dygraph.QUARTERLY){
1042_199=[0,3,6,9];
b2a516b8 1043}else{
9c97d733
DV
1044if(_195==Dygraph.BIANNUAL){
1045_199=[0,6];
b2a516b8 1046}else{
9c97d733
DV
1047if(_195==Dygraph.ANNUAL){
1048_199=[0];
6372d433 1049}else{
9c97d733
DV
1050if(_195==Dygraph.DECADAL){
1051_199=[0];
1052_200=10;
b2a516b8
DV
1053}
1054}
1055}
1056}
6372d433 1057}
9c97d733
DV
1058var _201=new Date(_193).getFullYear();
1059var _202=new Date(_194).getFullYear();
1060var _203=Dygraph.zeropad;
1061for(var i=_201;i<=_202;i++){
1062if(i%_200!=0){
36615faf 1063continue;
6372d433 1064}
9c97d733
DV
1065for(var j=0;j<_199.length;j++){
1066var _204=i+"/"+_203(1+_199[j])+"/01";
1067var t=Date.parse(_204);
1068if(t<_193||t>_194){
b2a516b8
DV
1069continue;
1070}
9c97d733 1071_196.push({v:t,label:new Date(t).strftime("%b %y")});
b2a516b8
DV
1072}
1073}
b2a516b8 1074}
9c97d733 1075return _196;
36615faf 1076};
9c97d733
DV
1077Dygraph.dateTicker=function(_205,_206,self){
1078var _207=-1;
285a6bda 1079for(var i=0;i<Dygraph.NUM_GRANULARITIES;i++){
9c97d733
DV
1080var _208=self.NumXTicks(_205,_206,i);
1081if(self.width_/_208>=self.attr_("pixelsPerXLabel")){
1082_207=i;
36615faf
DV
1083break;
1084}
b2a516b8 1085}
9c97d733
DV
1086if(_207>=0){
1087return self.GetXAxis(_205,_206,_207);
36615faf 1088}else{
6372d433 1089}
6a1aa64f 1090};
285a6bda 1091Dygraph.numericTicks=function(minV,maxV,self){
9c97d733
DV
1092var _211=[1,2,5];
1093var _212,low_val,high_val,nTicks;
1094var _213=self.attr_("pixelsPerYLabel");
2ce09b19 1095for(var i=-10;i<50;i++){
9c97d733
DV
1096var _214=Math.pow(10,i);
1097for(var j=0;j<_211.length;j++){
1098_212=_214*_211[j];
1099low_val=Math.floor(minV/_212)*_212;
1100high_val=Math.ceil(maxV/_212)*_212;
1101nTicks=(high_val-low_val)/_212;
1102var _215=self.height_/nTicks;
1103if(_215>_213){
2ce09b19 1104break;
6a1aa64f 1105}
b2a516b8 1106}
9c97d733 1107if(_215>_213){
2ce09b19 1108break;
b2a516b8 1109}
2ce09b19 1110}
9c97d733 1111var _216=[];
2ce09b19 1112for(var i=0;i<nTicks;i++){
9c97d733
DV
1113var _217=low_val+i*_212;
1114var _218=self.round_(_217,2);
285a6bda 1115if(self.attr_("labelsKMB")){
b2a516b8 1116var k=1000;
9c97d733
DV
1117if(_217>=k*k*k){
1118_218=self.round_(_217/(k*k*k),1)+"B";
b2a516b8 1119}else{
9c97d733
DV
1120if(_217>=k*k){
1121_218=self.round_(_217/(k*k),1)+"M";
b2a516b8 1122}else{
9c97d733
DV
1123if(_217>=k){
1124_218=self.round_(_217/k,1)+"K";
b2a516b8
DV
1125}
1126}
1127}
1128}
9c97d733 1129_216.push({label:_218,v:_217});
b2a516b8 1130}
9c97d733 1131return _216;
6a1aa64f 1132};
285a6bda 1133Dygraph.prototype.addYTicks_=function(minY,maxY){
9c97d733
DV
1134var _222=Dygraph.numericTicks(minY,maxY,this);
1135this.layout_.updateOptions({yAxis:[minY,maxY],yTicks:_222});
6a1aa64f 1136};
9c97d733 1137Dygraph.prototype.extremeValues_=function(_223){
e4007107 1138var minY=null,maxY=null;
b64a4f1a 1139var bars=this.attr_("errorBars")||this.attr_("customBars");
648acd28 1140if(bars){
9c97d733
DV
1141for(var j=0;j<_223.length;j++){
1142var y=_223[j][1][0];
648acd28
DV
1143if(!y){
1144continue;
e4007107 1145}
9c97d733
DV
1146var low=y-_223[j][1][1];
1147var high=y+_223[j][1][2];
648acd28
DV
1148if(low>y){
1149low=y;
b2a516b8 1150}
648acd28
DV
1151if(high<y){
1152high=y;
b2a516b8 1153}
648acd28
DV
1154if(maxY==null||high>maxY){
1155maxY=high;
285a6bda 1156}
648acd28
DV
1157if(minY==null||low<minY){
1158minY=low;
e4007107 1159}
285a6bda 1160}
b2a516b8 1161}else{
9c97d733
DV
1162for(var j=0;j<_223.length;j++){
1163var y=_223[j][1];
648acd28
DV
1164if(!y){
1165continue;
285a6bda 1166}
b2a516b8 1167if(maxY==null||y>maxY){
285a6bda
DV
1168maxY=y;
1169}
e4007107
DV
1170if(minY==null||y<minY){
1171minY=y;
1172}
b2a516b8
DV
1173}
1174}
648acd28
DV
1175return [minY,maxY];
1176};
1177Dygraph.prototype.drawGraph_=function(data){
1178var minY=null,maxY=null;
1179this.layout_.removeAllDatasets();
1180this.setColors_();
9317362d 1181this.attrs_["pointSize"]=0.5*this.attr_("highlightCircleSize");
648acd28 1182for(var i=1;i<data[0].length;i++){
9c97d733 1183var _227=[];
648acd28
DV
1184for(var j=0;j<data.length;j++){
1185var date=data[j][0];
9c97d733 1186_227[j]=[date,data[j][i]];
648acd28 1187}
9c97d733 1188_227=this.rollingAverage(_227,this.rollPeriod_);
b64a4f1a 1189var bars=this.attr_("errorBars")||this.attr_("customBars");
648acd28
DV
1190if(this.dateWindow_){
1191var low=this.dateWindow_[0];
1192var high=this.dateWindow_[1];
9c97d733
DV
1193var _228=[];
1194for(var k=0;k<_227.length;k++){
1195if(_227[k][0]>=low&&_227[k][0]<=high){
1196_228.push(_227[k]);
648acd28
DV
1197}
1198}
9c97d733 1199_227=_228;
648acd28 1200}
9c97d733
DV
1201var _229=this.extremeValues_(_227);
1202var _230=_229[0];
1203var _231=_229[1];
1204if(!minY||_230<minY){
1205minY=_230;
648acd28 1206}
9c97d733
DV
1207if(!maxY||_231>maxY){
1208maxY=_231;
b2a516b8
DV
1209}
1210if(bars){
1211var vals=[];
9c97d733
DV
1212for(var j=0;j<_227.length;j++){
1213vals[j]=[_227[j][0],_227[j][1][0],_227[j][1][1],_227[j][1][2]];
b2a516b8 1214}
285a6bda 1215this.layout_.addDataset(this.attr_("labels")[i],vals);
b2a516b8 1216}else{
9c97d733 1217this.layout_.addDataset(this.attr_("labels")[i],_227);
b2a516b8
DV
1218}
1219}
1220if(this.valueRange_!=null){
1221this.addYTicks_(this.valueRange_[0],this.valueRange_[1]);
1222}else{
e4007107 1223var span=maxY-minY;
9c97d733
DV
1224var _234=maxY+0.1*span;
1225var _235=minY-0.1*span;
1226if(_235<0&&minY>=0){
1227_235=0;
e4007107 1228}
9c97d733
DV
1229if(_234>0&&maxY<=0){
1230_234=0;
e4007107
DV
1231}
1232if(this.attr_("includeZero")){
1233if(maxY<0){
9c97d733 1234_234=0;
e4007107
DV
1235}
1236if(minY>0){
9c97d733 1237_235=0;
e4007107 1238}
b2a516b8 1239}
9c97d733 1240this.addYTicks_(_235,_234);
b2a516b8
DV
1241}
1242this.addXTicks_();
1243this.layout_.evaluateWithError();
1244this.plotter_.clear();
1245this.plotter_.render();
1246this.canvas_.getContext("2d").clearRect(0,0,this.canvas_.width,this.canvas_.height);
6a1aa64f 1247};
9c97d733
DV
1248Dygraph.prototype.rollingAverage=function(_236,_237){
1249if(_236.length<2){
1250return _236;
b2a516b8 1251}
9c97d733
DV
1252var _237=Math.min(_237,_236.length-1);
1253var _238=[];
1254var _239=this.attr_("sigma");
b2a516b8
DV
1255if(this.fractions_){
1256var num=0;
1257var den=0;
1258var mult=100;
9c97d733
DV
1259for(var i=0;i<_236.length;i++){
1260num+=_236[i][1][0];
1261den+=_236[i][1][1];
1262if(i-_237>=0){
1263num-=_236[i-_237][1][0];
1264den-=_236[i-_237][1][1];
1265}
1266var date=_236[i][0];
1267var _242=den?num/den:0;
285a6bda 1268if(this.attr_("errorBars")){
b2a516b8
DV
1269if(this.wilsonInterval_){
1270if(den){
9c97d733
DV
1271var p=_242<0?0:_242,n=den;
1272var pm=_239*Math.sqrt(p*(1-p)/n+_239*_239/(4*n*n));
1273var _244=1+_239*_239/den;
1274var low=(p+_239*_239/(2*den)-pm)/_244;
1275var high=(p+_239*_239/(2*den)+pm)/_244;
1276_238[i]=[date,[p*mult,(p-low)*mult,(high-p)*mult]];
b2a516b8 1277}else{
9c97d733 1278_238[i]=[date,[0,0,0]];
b2a516b8
DV
1279}
1280}else{
9c97d733
DV
1281var _245=den?_239*Math.sqrt(_242*(1-_242)/den):1;
1282_238[i]=[date,[mult*_242,mult*_245,mult*_245]];
b2a516b8
DV
1283}
1284}else{
9c97d733 1285_238[i]=[date,mult*_242];
b2a516b8
DV
1286}
1287}
1288}else{
b64a4f1a 1289if(this.attr_("customBars")){
6372d433
DV
1290var low=0;
1291var mid=0;
1292var high=0;
9c97d733
DV
1293var _247=0;
1294for(var i=0;i<_236.length;i++){
1295var data=_236[i][1];
b2a516b8 1296var y=data[1];
9c97d733 1297_238[i]=[_236[i][0],[y,y-data[0],data[2]-y]];
6372d433
DV
1298low+=data[0];
1299mid+=y;
1300high+=data[2];
9c97d733
DV
1301_247+=1;
1302if(i-_237>=0){
1303var prev=_236[i-_237];
6372d433
DV
1304low-=prev[1][0];
1305mid-=prev[1][1];
1306high-=prev[1][2];
9c97d733 1307_247-=1;
6372d433 1308}
9c97d733 1309_238[i]=[_236[i][0],[1*mid/_247,1*(mid-low)/_247,1*(high-mid)/_247]];
6372d433
DV
1310}
1311}else{
9c97d733 1312var _249=Math.min(_237-1,_236.length-2);
285a6bda 1313if(!this.attr_("errorBars")){
9c97d733
DV
1314if(_237==1){
1315return _236;
648acd28 1316}
9c97d733 1317for(var i=0;i<_236.length;i++){
b2a516b8 1318var sum=0;
9c97d733
DV
1319var _251=0;
1320for(var j=Math.max(0,i-_237+1);j<i+1;j++){
1321var y=_236[j][1];
648acd28
DV
1322if(!y||isNaN(y)){
1323continue;
b2a516b8 1324}
9c97d733
DV
1325_251++;
1326sum+=_236[j][1];
648acd28 1327}
9c97d733
DV
1328if(_251){
1329_238[i]=[_236[i][0],sum/_251];
648acd28 1330}else{
9c97d733 1331_238[i]=[_236[i][0],null];
b2a516b8 1332}
648acd28 1333}
2847c1cf 1334}else{
9c97d733 1335for(var i=0;i<_236.length;i++){
b2a516b8 1336var sum=0;
9c97d733
DV
1337var _252=0;
1338var _251=0;
1339for(var j=Math.max(0,i-_237+1);j<i+1;j++){
1340var y=_236[j][1][0];
648acd28
DV
1341if(!y||isNaN(y)){
1342continue;
b2a516b8 1343}
9c97d733
DV
1344_251++;
1345sum+=_236[j][1][0];
1346_252+=Math.pow(_236[j][1][1],2);
b2a516b8 1347}
9c97d733
DV
1348if(_251){
1349var _245=Math.sqrt(_252)/_251;
1350_238[i]=[_236[i][0],[sum/_251,_239*_245,_239*_245]];
648acd28 1351}else{
9c97d733 1352_238[i]=[_236[i][0],[null,null,null]];
b2a516b8
DV
1353}
1354}
1355}
648acd28
DV
1356}
1357}
9c97d733 1358return _238;
6a1aa64f 1359};
9c97d733
DV
1360Dygraph.dateParser=function(_253,self){
1361var _254;
285a6bda 1362var d;
9c97d733
DV
1363if(_253.length==10&&_253.search("-")!=-1){
1364_254=_253.replace("-","/","g");
1365while(_254.search("-")!=-1){
1366_254=_254.replace("-","/");
353a0294 1367}
9c97d733 1368d=Date.parse(_254);
b2a516b8 1369}else{
9c97d733
DV
1370if(_253.length==8){
1371_254=_253.substr(0,4)+"/"+_253.substr(4,2)+"/"+_253.substr(6,2);
1372d=Date.parse(_254);
8846615a 1373}else{
9c97d733 1374d=Date.parse(_253);
285a6bda 1375}
b2a516b8 1376}
285a6bda 1377if(!d||isNaN(d)){
9c97d733 1378self.error("Couldn't parse "+_253+" as a date");
b2a516b8 1379}
285a6bda 1380return d;
6a1aa64f 1381};
285a6bda 1382Dygraph.prototype.detectTypeFromString_=function(str){
9c97d733 1383var _256=false;
285a6bda 1384if(str.indexOf("-")>=0||str.indexOf("/")>=0||isNaN(parseFloat(str))){
9c97d733 1385_256=true;
285a6bda
DV
1386}else{
1387if(str.length==8&&str>"19700101"&&str<"20371231"){
9c97d733 1388_256=true;
285a6bda
DV
1389}
1390}
9c97d733 1391if(_256){
285a6bda
DV
1392this.attrs_.xValueFormatter=Dygraph.dateString_;
1393this.attrs_.xValueParser=Dygraph.dateParser;
1394this.attrs_.xTicker=Dygraph.dateTicker;
1395}else{
1396this.attrs_.xValueFormatter=function(x){
1397return x;
1398};
1399this.attrs_.xValueParser=function(x){
1400return parseFloat(x);
1401};
1402this.attrs_.xTicker=Dygraph.numericTicks;
1403}
1404};
1405Dygraph.prototype.parseCSV_=function(data){
b2a516b8 1406var ret=[];
9c97d733
DV
1407var _257=data.split("\n");
1408var _258=0;
b2a516b8 1409if(this.labelsFromCSV_){
9c97d733
DV
1410_258=1;
1411this.attrs_.labels=_257[0].split(",");
1412}
1413var _259;
1414var _260=false;
1415var _261=this.attr_("labels").length;
1416for(var i=_258;i<_257.length;i++){
1417var line=_257[i];
b2a516b8
DV
1418if(line.length==0){
1419continue;
1420}
9c97d733
DV
1421var _263=line.split(",");
1422if(_263.length<2){
b2a516b8
DV
1423continue;
1424}
9c97d733
DV
1425var _264=[];
1426if(!_260){
1427this.detectTypeFromString_(_263[0]);
1428_259=this.attr_("xValueParser");
1429_260=true;
285a6bda 1430}
9c97d733 1431_264[0]=_259(_263[0],this);
b2a516b8 1432if(this.fractions_){
9c97d733
DV
1433for(var j=1;j<_263.length;j++){
1434var vals=_263[j].split("/");
1435_264[j]=[parseFloat(vals[0]),parseFloat(vals[1])];
b2a516b8
DV
1436}
1437}else{
285a6bda 1438if(this.attr_("errorBars")){
9c97d733
DV
1439for(var j=1;j<_263.length;j+=2){
1440_264[(j+1)/2]=[parseFloat(_263[j]),parseFloat(_263[j+1])];
b2a516b8
DV
1441}
1442}else{
b64a4f1a 1443if(this.attr_("customBars")){
9c97d733
DV
1444for(var j=1;j<_263.length;j++){
1445var vals=_263[j].split(";");
1446_264[j]=[parseFloat(vals[0]),parseFloat(vals[1]),parseFloat(vals[2])];
b2a516b8
DV
1447}
1448}else{
9c97d733
DV
1449for(var j=1;j<_263.length;j++){
1450_264[j]=parseFloat(_263[j]);
285a6bda 1451}
b2a516b8
DV
1452}
1453}
1454}
9c97d733
DV
1455ret.push(_264);
1456if(_264.length!=_261){
1457this.error("Number of columns in line "+i+" ("+_264.length+") does not agree with number of labels ("+_261+") "+line);
b2a516b8 1458}
b2a516b8
DV
1459}
1460return ret;
6a1aa64f 1461};
285a6bda
DV
1462Dygraph.prototype.parseArray_=function(data){
1463if(data.length==0){
1464this.error("Can't plot empty data set");
1465return null;
1466}
1467if(data[0].length==0){
1468this.error("Data set cannot contain an empty row");
1469return null;
1470}
1471if(this.attr_("labels")==null){
1472this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
1473this.attrs_.labels=["X"];
1474for(var i=1;i<data[0].length;i++){
1475this.attrs_.labels.push("Y"+i);
1476}
1477}
9c97d733 1478if(Dygraph.isDateLike(data[0][0])){
285a6bda
DV
1479this.attrs_.xValueFormatter=Dygraph.dateString_;
1480this.attrs_.xTicker=Dygraph.dateTicker;
9c97d733 1481var _265=Dygraph.clone(data);
285a6bda 1482for(var i=0;i<data.length;i++){
9c97d733 1483if(_265[i].length==0){
285a6bda
DV
1484this.error("Row "<<(1+i)<<" of data is empty");
1485return null;
1486}
9c97d733 1487if(_265[i][0]==null||typeof (_265[i][0].getTime)!="function"){
285a6bda
DV
1488this.error("x value in row "<<(1+i)<<" is not a Date");
1489return null;
1490}
9c97d733 1491_265[i][0]=_265[i][0].getTime();
285a6bda 1492}
9c97d733 1493return _265;
285a6bda
DV
1494}else{
1495this.attrs_.xValueFormatter=function(x){
1496return x;
1497};
1498this.attrs_.xTicker=Dygraph.numericTicks;
1499return data;
1500}
1501};
1502Dygraph.prototype.parseDataTable_=function(data){
6219c9d6
DV
1503var cols=data.getNumberOfColumns();
1504var rows=data.getNumberOfRows();
9c97d733 1505var _268=[];
6219c9d6 1506for(var i=0;i<cols;i++){
9c97d733 1507_268.push(data.getColumnLabel(i));
6219c9d6 1508}
9c97d733
DV
1509this.attrs_.labels=_268;
1510var _269=data.getColumnType(0);
1511if(_269=="date"){
285a6bda
DV
1512this.attrs_.xValueFormatter=Dygraph.dateString_;
1513this.attrs_.xValueParser=Dygraph.dateParser;
1514this.attrs_.xTicker=Dygraph.dateTicker;
1515}else{
9c97d733 1516if(_269=="number"){
285a6bda
DV
1517this.attrs_.xValueFormatter=function(x){
1518return x;
1519};
1520this.attrs_.xValueParser=function(x){
1521return parseFloat(x);
1522};
1523this.attrs_.xTicker=Dygraph.numericTicks;
1524}else{
9c97d733 1525this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_269+"')");
6219c9d6
DV
1526return null;
1527}
285a6bda 1528}
6219c9d6
DV
1529var ret=[];
1530for(var i=0;i<rows;i++){
1531var row=[];
b3b20e24
DV
1532if(!data.getValue(i,0)){
1533continue;
1534}
9c97d733 1535if(_269=="date"){
6219c9d6 1536row.push(data.getValue(i,0).getTime());
36615faf
DV
1537}else{
1538row.push(data.getValue(i,0));
1539}
6219c9d6
DV
1540for(var j=1;j<cols;j++){
1541row.push(data.getValue(i,j));
1542}
1543ret.push(row);
1544}
1545return ret;
1546};
9c97d733
DV
1547Dygraph.update=function(self,o){
1548if(typeof (o)!="undefined"&&o!==null){
1549for(var k in o){
1550self[k]=o[k];
1551}
1552}
1553return self;
1554};
1555Dygraph.isArrayLike=function(o){
1556var typ=typeof (o);
1557if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o===null||typeof (o.length)!="number"||o.nodeType===3){
1558return false;
1559}
1560return true;
1561};
1562Dygraph.isDateLike=function(o){
1563if(typeof (o)!="object"||o===null||typeof (o.getTime)!="function"){
1564return false;
1565}
1566return true;
1567};
1568Dygraph.clone=function(o){
1569var r=[];
1570for(var i=0;i<o.length;i++){
1571if(Dygraph.isArrayLike(o[i])){
1572r.push(Dygraph.clone(o[i]));
1573}else{
1574r.push(o[i]);
1575}
1576}
1577return r;
1578};
285a6bda 1579Dygraph.prototype.start_=function(){
b2a516b8
DV
1580if(typeof this.file_=="function"){
1581this.loadedEvent_(this.file_());
1582}else{
9c97d733 1583if(Dygraph.isArrayLike(this.file_)){
285a6bda
DV
1584this.rawData_=this.parseArray_(this.file_);
1585this.drawGraph_(this.rawData_);
1586}else{
6219c9d6
DV
1587if(typeof this.file_=="object"&&typeof this.file_.getColumnRange=="function"){
1588this.rawData_=this.parseDataTable_(this.file_);
1589this.drawGraph_(this.rawData_);
1590}else{
285a6bda
DV
1591if(typeof this.file_=="string"){
1592if(this.file_.indexOf("\n")>=0){
1593this.loadedEvent_(this.file_);
1594}else{
b2a516b8 1595var req=new XMLHttpRequest();
9c97d733 1596var _275=this;
b2a516b8
DV
1597req.onreadystatechange=function(){
1598if(req.readyState==4){
1599if(req.status==200){
9c97d733 1600_275.loadedEvent_(req.responseText);
b2a516b8
DV
1601}
1602}
6a1aa64f 1603};
b2a516b8
DV
1604req.open("GET",this.file_,true);
1605req.send(null);
1606}
285a6bda
DV
1607}else{
1608this.error("Unknown data format: "+(typeof this.file_));
6219c9d6 1609}
b2a516b8 1610}
b2a516b8 1611}
b2a516b8 1612}
285a6bda 1613};
9c97d733
DV
1614Dygraph.prototype.updateOptions=function(_276){
1615if(_276.rollPeriod){
1616this.rollPeriod_=_276.rollPeriod;
b2a516b8 1617}
9c97d733
DV
1618if(_276.dateWindow){
1619this.dateWindow_=_276.dateWindow;
b2a516b8 1620}
9c97d733
DV
1621if(_276.valueRange){
1622this.valueRange_=_276.valueRange;
b2a516b8 1623}
9c97d733 1624Dygraph.update(this.user_attrs_,_276);
285a6bda
DV
1625this.labelsFromCSV_=(this.attr_("labels")==null);
1626this.layout_.updateOptions({"errorBars":this.attr_("errorBars")});
9c97d733
DV
1627if(_276["file"]&&_276["file"]!=this.file_){
1628this.file_=_276["file"];
b2a516b8
DV
1629this.start_();
1630}else{
1631this.drawGraph_(this.rawData_);
1632}
6a1aa64f 1633};
9c97d733
DV
1634Dygraph.prototype.adjustRoll=function(_277){
1635this.rollPeriod_=_277;
b2a516b8 1636this.drawGraph_(this.rawData_);
6a1aa64f 1637};
9c97d733
DV
1638Dygraph.GVizChart=function(_278){
1639this.container=_278;
6219c9d6 1640};
9c97d733 1641Dygraph.GVizChart.prototype.draw=function(data,_279){
6219c9d6 1642this.container.innerHTML="";
9c97d733 1643this.date_graph=new Dygraph(this.container,data,_279);
6219c9d6 1644};
285a6bda 1645DateGraph=Dygraph;
9c97d733 1646function RGBColor(_280){
f474c2a3 1647this.ok=false;
9c97d733
DV
1648if(_280.charAt(0)=="#"){
1649_280=_280.substr(1,6);
f474c2a3 1650}
9c97d733
DV
1651_280=_280.replace(/ /g,"");
1652_280=_280.toLowerCase();
1653var _281={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};
1654for(var key in _281){
1655if(_280==key){
1656_280=_281[key];
f474c2a3
DV
1657}
1658}
9c97d733 1659var _283=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(bits){
f474c2a3
DV
1660return [parseInt(bits[1]),parseInt(bits[2]),parseInt(bits[3])];
1661}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(bits){
1662return [parseInt(bits[1],16),parseInt(bits[2],16),parseInt(bits[3],16)];
1663}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(bits){
1664return [parseInt(bits[1]+bits[1],16),parseInt(bits[2]+bits[2],16),parseInt(bits[3]+bits[3],16)];
1665}}];
9c97d733
DV
1666for(var i=0;i<_283.length;i++){
1667var re=_283[i].re;
1668var _286=_283[i].process;
1669var bits=re.exec(_280);
f474c2a3 1670if(bits){
9c97d733 1671channels=_286(bits);
f474c2a3
DV
1672this.r=channels[0];
1673this.g=channels[1];
1674this.b=channels[2];
1675this.ok=true;
1676}
1677}
1678this.r=(this.r<0||isNaN(this.r))?0:((this.r>255)?255:this.r);
1679this.g=(this.g<0||isNaN(this.g))?0:((this.g>255)?255:this.g);
1680this.b=(this.b<0||isNaN(this.b))?0:((this.b>255)?255:this.b);
1681this.toRGB=function(){
1682return "rgb("+this.r+", "+this.g+", "+this.b+")";
1683};
1684this.toHex=function(){
1685var r=this.r.toString(16);
1686var g=this.g.toString(16);
1687var b=this.b.toString(16);
1688if(r.length==1){
1689r="0"+r;
1690}
1691if(g.length==1){
1692g="0"+g;
1693}
1694if(b.length==1){
1695b="0"+b;
1696}
1697return "#"+r+g+b;
1698};
1699}
b2a516b8 1700