1 Date
.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
};
2 DygraphLayout
=function(_1
,_2
){
5 Dygraph
.update(this.options
,_2
?_2
:{});
6 this.datasets
=new Array();
8 DygraphLayout
.prototype.attr_
=function(_3
){
9 return this.dygraph_
.attr_(_3
);
11 DygraphLayout
.prototype.addDataset
=function(_4
,_5
){
14 DygraphLayout
.prototype.evaluate
=function(){
15 this._evaluateLimits();
16 this._evaluateLineCharts();
17 this._evaluateLineTicks();
19 DygraphLayout
.prototype._evaluateLimits
=function(){
20 this.minxval
=this.maxxval
=null;
21 if(this.options
.dateWindow
){
22 this.minxval
=this.options
.dateWindow
[0];
23 this.maxxval
=this.options
.dateWindow
[1];
25 for(var _6
in this.datasets
){
26 if(!this.datasets
.hasOwnProperty(_6
)){
29 var _7
=this.datasets
[_6
];
31 if(!this.minxval
||x1
<this.minxval
){
34 var x2
=_7
[_7
.length
-1][0];
35 if(!this.maxxval
||x2
>this.maxxval
){
40 this.xrange
=this.maxxval
-this.minxval
;
41 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
42 this.minyval
=this.options
.yAxis
[0];
43 this.maxyval
=this.options
.yAxis
[1];
44 this.yrange
=this.maxyval
-this.minyval
;
45 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
47 DygraphLayout
.prototype._evaluateLineCharts
=function(){
48 this.points
=new Array();
49 for(var _10
in this.datasets
){
50 if(!this.datasets
.hasOwnProperty(_10
)){
53 var _11
=this.datasets
[_10
];
54 for(var j
=0;j
<_11
.length
;j
++){
56 var _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
};
63 if((_14
.x
>=0)&&(_14
.x
<=1)){
64 this.points
.push(_14
);
69 DygraphLayout
.prototype._evaluateLineTicks
=function(){
70 this.xticks
=new Array();
71 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
72 var _16
=this.options
.xTicks
[i
];
74 var pos
=this.xscale
*(_16
.v
-this.minxval
);
75 if((pos
>=0)&&(pos
<=1)){
76 this.xticks
.push([pos
,_17
]);
79 this.yticks
=new Array();
80 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
81 var _16
=this.options
.yTicks
[i
];
83 var pos
=1-(this.yscale
*(_16
.v
-this.minyval
));
84 if((pos
>=0)&&(pos
<=1)){
85 this.yticks
.push([pos
,_17
]);
89 DygraphLayout
.prototype.evaluateWithError
=function(){
91 if(!this.options
.errorBars
){
95 for(var _19
in this.datasets
){
96 if(!this.datasets
.hasOwnProperty(_19
)){
100 var _20
=this.datasets
[_19
];
101 for(var j
=0;j
<_20
.length
;j
++,i
++){
103 var xv
=parseFloat(_21
[0]);
104 var yv
=parseFloat(_21
[1]);
105 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
106 this.points
[i
].errorMinus
=parseFloat(_21
[2]);
107 this.points
[i
].errorPlus
=parseFloat(_21
[3]);
112 DygraphLayout
.prototype.removeAllDatasets
=function(){
113 delete this.datasets
;
114 this.datasets
=new Array();
116 DygraphLayout
.prototype.updateOptions
=function(_24
){
117 Dygraph
.update(this.options
,_24
?_24
:{});
119 DygraphCanvasRenderer
=function(_25
,_26
,_27
,_28
){
121 this.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)"};
122 Dygraph
.update(this.options
,_28
);
125 this.container
=this.element
.parentNode
;
126 this.height
=this.element
.height
;
127 this.width
=this.element
.width
;
128 if(!this.isIE
&&!(DygraphCanvasRenderer
.isSupported(this.element
))){
129 throw "Canvas is not supported.";
131 this.xlabels
=new Array();
132 this.ylabels
=new Array();
133 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
134 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
135 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
136 this.container
.style
.position
="relative";
137 this.container
.style
.width
=this.width
+"px";
139 DygraphCanvasRenderer
.prototype.clear
=function(){
143 this.clearDelay
.cancel();
144 this.clearDelay
=null;
146 var _29
=this.element
.getContext("2d");
149 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
150 this.clearDelay
.addCallback(bind(this.clear
,this));
154 var _29
=this.element
.getContext("2d");
155 _29
.clearRect(0,0,this.width
,this.height
);
156 for(var i
=0;i
<this.xlabels
.length
;i
++){
157 var el
=this.xlabels
[i
];
158 el
.parentNode
.removeChild(el
);
160 for(var i
=0;i
<this.ylabels
.length
;i
++){
161 var el
=this.ylabels
[i
];
162 el
.parentNode
.removeChild(el
);
164 this.xlabels
=new Array();
165 this.ylabels
=new Array();
167 DygraphCanvasRenderer
.isSupported
=function(_31
){
170 if(typeof (_31
)=="undefined"||_31
==null){
171 _32
=document
.createElement("canvas");
175 var _33
=_32
.getContext("2d");
178 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
179 var _35
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
180 if((!ie
)||(ie
[1]<6)||(_35
)){
187 DygraphCanvasRenderer
.prototype.render
=function(){
188 var ctx
=this.element
.getContext("2d");
189 if(this.options
.drawYGrid
){
190 var _37
=this.layout
.yticks
;
192 ctx
.strokeStyle
=this.options
.gridLineColor
;
193 ctx
.lineWidth
=this.options
.axisLineWidth
;
194 for(var i
=0;i
<_37
.length
;i
++){
196 var y
=this.area
.y
+_37
[i
][0]*this.area
.h
;
199 ctx
.lineTo(x
+this.area
.w
,y
);
204 if(this.options
.drawXGrid
){
205 var _37
=this.layout
.xticks
;
207 ctx
.strokeStyle
=this.options
.gridLineColor
;
208 ctx
.lineWidth
=this.options
.axisLineWidth
;
209 for(var i
=0;i
<_37
.length
;i
++){
210 var x
=this.area
.x
+_37
[i
][0]*this.area
.w
;
211 var y
=this.area
.y
+this.area
.h
;
214 ctx
.lineTo(x
,this.area
.y
);
219 this._renderLineChart();
222 DygraphCanvasRenderer
.prototype._renderAxis
=function(){
223 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
226 var _40
=this.element
.getContext("2d");
227 var _41
={"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
,"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"};
228 var _42
=function(txt
){
229 var div
=document
.createElement("div");
231 if(_41
.hasOwnProperty(_45
)){
232 div
.style
[_45
]=_41
[_45
];
235 div
.appendChild(document
.createTextNode(txt
));
239 _40
.strokeStyle
=this.options
.axisLineColor
;
240 _40
.lineWidth
=this.options
.axisLineWidth
;
241 if(this.options
.drawYAxis
){
242 if(this.layout
.yticks
&&this.layout
.yticks
.length
>0){
243 for(var i
=0;i
<this.layout
.yticks
.length
;i
++){
244 var _46
=this.layout
.yticks
[i
];
245 if(typeof (_46
)=="function"){
249 var y
=this.area
.y
+_46
[0]*this.area
.h
;
252 _40
.lineTo(x
-this.options
.axisTickSize
,y
);
256 var top
=(y
-this.options
.axisLabelFontSize
/2);
260 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
261 _47
.style
.bottom
="0px";
263 _47
.style
.top
=top
+"px";
265 _47
.style
.left
="0px";
266 _47
.style
.textAlign
="right";
267 _47
.style
.width
=this.options
.yAxisLabelWidth
+"px";
268 this.container
.appendChild(_47
);
269 this.ylabels
.push(_47
);
271 var _49
=this.ylabels
[0];
272 var _50
=this.options
.axisLabelFontSize
;
273 var _51
=parseInt(_49
.style
.top
)+_50
;
274 if(_51
>this.height
-_50
){
275 _49
.style
.top
=(parseInt(_49
.style
.top
)-_50
/2)+"px";
279 _40
.moveTo(this.area
.x
,this.area
.y
);
280 _40
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
284 if(this.options
.drawXAxis
){
285 if(this.layout
.xticks
){
286 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
287 var _46
=this.layout
.xticks
[i
];
288 if(typeof (dataset
)=="function"){
291 var x
=this.area
.x
+_46
[0]*this.area
.w
;
292 var y
=this.area
.y
+this.area
.h
;
295 _40
.lineTo(x
,y
+this.options
.axisTickSize
);
299 _47
.style
.textAlign
="center";
300 _47
.style
.bottom
="0px";
301 var _52
=(x
-this.options
.axisLabelWidth
/2);
302 if(_52
+this.options
.axisLabelWidth
>this.width
){
303 _52
=this.width
-this.options
.xAxisLabelWidth
;
304 _47
.style
.textAlign
="right";
308 _47
.style
.textAlign
="left";
310 _47
.style
.left
=_52
+"px";
311 _47
.style
.width
=this.options
.xAxisLabelWidth
+"px";
312 this.container
.appendChild(_47
);
313 this.xlabels
.push(_47
);
317 _40
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
318 _40
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
324 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
325 var _53
=this.element
.getContext("2d");
326 var _54
=this.options
.colorScheme
.length
;
327 var _55
=this.options
.colorScheme
;
328 var _56
=this.layout
.options
.errorBars
;
330 for(var _58
in this.layout
.datasets
){
331 if(this.layout
.datasets
.hasOwnProperty(_58
)){
336 for(var i
=0;i
<this.layout
.points
.length
;i
++){
337 var _60
=this.layout
.points
[i
];
338 _60
.canvasx
=this.area
.w
*_60
.x
+this.area
.x
;
339 _60
.canvasy
=this.area
.h
*_60
.y
+this.area
.y
;
346 for(var i
=0;i
<_59
;i
++){
351 ctx
.lineWidth
=this.options
.strokeWidth
;
355 var _67
=this.layout
.yscale
;
356 var rgb
=new RGBColor(_63
);
357 var _69
="rgba("+rgb
.r
+","+rgb
.g
+","+rgb
.b
+",0.15)";
360 for(var j
=0;j
<this.layout
.points
.length
;j
++){
361 var _60
=this.layout
.points
[j
];
364 if(!_60
.y
||isNaN(_60
.y
)){
368 var _70
=[_60
.y
-_60
.errorPlus
*_67
,_60
.y
+_60
.errorMinus
*_67
];
369 _70
[0]=this.area
.h
*_70
[0]+this.area
.y
;
370 _70
[1]=this.area
.h
*_70
[1]+this.area
.y
;
372 ctx
.moveTo(_64
,_65
[0]);
373 ctx
.lineTo(_60
.canvasx
,_70
[0]);
374 ctx
.lineTo(_60
.canvasx
,_70
[1]);
375 ctx
.lineTo(_64
,_65
[1]);
386 for(var i
=0;i
<_59
;i
++){
390 var _60
=this.layout
.points
[0];
391 var _71
=this.dygraph_
.attr_("pointSize");
392 var _64
=null,prevY
=null;
393 var _72
=this.dygraph_
.attr_("drawPoints");
394 var _73
=this.layout
.points
;
395 for(var j
=0;j
<_73
.length
;j
++){
398 if(!_61(_60
.canvasy
)){
401 var _74
=(!_64
&&(j
==_73
.length
-1||!_61(_73
[j
+1].canvasy
)));
408 ctx
.lineWidth
=this.options
.strokeWidth
;
409 ctx
.moveTo(_64
,prevY
);
412 ctx
.lineTo(_64
,prevY
);
418 ctx
.arc(_60
.canvasx
,_60
.canvasy
,_71
,0,2*Math
.PI
,false);
427 Dygraph
=function(div
,_75
,_76
){
428 if(arguments
.length
>0){
429 if(arguments
.length
==4){
430 this.warn("Using deprecated four-argument dygraph constructor");
431 this.__old_init__(div
,_75
,arguments
[2],arguments
[3]);
433 this.__init__(div
,_75
,_76
);
437 Dygraph
.NAME
="Dygraph";
438 Dygraph
.VERSION
="1.2";
439 Dygraph
.__repr__
=function(){
440 return "["+this.NAME
+" "+this.VERSION
+"]";
442 Dygraph
.toString
=function(){
443 return this.__repr__();
445 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
446 Dygraph
.DEFAULT_WIDTH
=480;
447 Dygraph
.DEFAULT_HEIGHT
=320;
448 Dygraph
.AXIS_LINE_WIDTH
=0.3;
449 Dygraph
.DEFAULT_ATTRS
={highlightCircleSize
:3,pixelsPerXLabel
:60,pixelsPerYLabel
:30,labelsDivWidth
:250,labelsDivStyles
:{},labelsSeparateLines
:false,labelsKMB
:false,labelsKMG2
:false,strokeWidth
:1,axisTickSize
:3,axisLabelFontSize
:14,xAxisLabelWidth
:50,yAxisLabelWidth
:50,rightGap
:5,showRoller
:false,xValueFormatter
:Dygraph
.dateString_
,xValueParser
:Dygraph
.dateParser
,xTicker
:Dygraph
.dateTicker
,delimiter
:",",sigma
:2,errorBars
:false,fractions
:false,wilsonInterval
:true,customBars
:false};
454 Dygraph
.prototype.__old_init__
=function(div
,_77
,_78
,_79
){
457 for(var i
=0;i
<_78
.length
;i
++){
460 Dygraph
.update(_79
,{"labels":_80
});
462 this.__init__(div
,_77
,_79
);
464 Dygraph
.prototype.__init__
=function(div
,_81
,_82
){
470 this.rollPeriod_
=_82
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
471 this.previousVerticalX_
=-1;
472 this.fractions_
=_82
.fractions
||false;
473 this.dateWindow_
=_82
.dateWindow
||null;
474 this.valueRange_
=_82
.valueRange
||null;
475 this.wilsonInterval_
=_82
.wilsonInterval
||true;
477 if(div
.style
.width
==""){
478 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
480 if(div
.style
.height
==""){
481 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
483 this.width_
=parseInt(div
.style
.width
,10);
484 this.height_
=parseInt(div
.style
.height
,10);
486 Dygraph
.update(this.user_attrs_
,_82
);
488 Dygraph
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
489 this.labelsFromCSV_
=(this.attr_("labels")==null);
490 this.createInterface_();
493 Dygraph
.prototype.attr_
=function(_83
){
494 if(typeof (this.user_attrs_
[_83
])!="undefined"){
495 return this.user_attrs_
[_83
];
497 if(typeof (this.attrs_
[_83
])!="undefined"){
498 return this.attrs_
[_83
];
504 Dygraph
.prototype.log
=function(_84
,_85
){
505 if(typeof (console
)!="undefined"){
508 console
.debug("dygraphs: "+_85
);
511 console
.info("dygraphs: "+_85
);
513 case Dygraph
.WARNING
:
514 console
.warn("dygraphs: "+_85
);
517 console
.error("dygraphs: "+_85
);
522 Dygraph
.prototype.info
=function(_86
){
523 this.log(Dygraph
.INFO
,_86
);
525 Dygraph
.prototype.warn
=function(_87
){
526 this.log(Dygraph
.WARNING
,_87
);
528 Dygraph
.prototype.error
=function(_88
){
529 this.log(Dygraph
.ERROR
,_88
);
531 Dygraph
.prototype.rollPeriod
=function(){
532 return this.rollPeriod_
;
534 Dygraph
.addEvent
=function(el
,evt
,fn
){
541 if(window
.addEventListener
){
542 el
.addEventListener(evt
,_91
,false);
544 el
.attachEvent("on"+evt
,_91
);
547 Dygraph
.prototype.createInterface_
=function(){
548 var _93
=this.maindiv_
;
549 this.graphDiv
=document
.createElement("div");
550 this.graphDiv
.style
.width
=this.width_
+"px";
551 this.graphDiv
.style
.height
=this.height_
+"px";
552 _93
.appendChild(this.graphDiv
);
553 this.canvas_
=Dygraph
.createCanvas();
554 this.canvas_
.style
.position
="absolute";
555 this.canvas_
.width
=this.width_
;
556 this.canvas_
.height
=this.height_
;
557 this.canvas_
.style
.width
=this.width_
+"px";
558 this.canvas_
.style
.height
=this.height_
+"px";
559 this.graphDiv
.appendChild(this.canvas_
);
560 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
562 Dygraph
.addEvent(this.hidden_
,"mousemove",function(e
){
565 Dygraph
.addEvent(this.hidden_
,"mouseout",function(e
){
568 this.layoutOptions_
={"xOriginIsZero":false};
569 Dygraph
.update(this.layoutOptions_
,this.attrs_
);
570 Dygraph
.update(this.layoutOptions_
,this.user_attrs_
);
571 Dygraph
.update(this.layoutOptions_
,{"errorBars":(this.attr_("errorBars")||this.attr_("customBars"))});
572 this.layout_
=new DygraphLayout(this,this.layoutOptions_
);
573 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
574 Dygraph
.update(this.renderOptions_
,this.attrs_
);
575 Dygraph
.update(this.renderOptions_
,this.user_attrs_
);
576 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
577 this.createStatusMessage_();
578 this.createRollInterface_();
579 this.createDragInterface_();
581 Dygraph
.prototype.createPlotKitCanvas_
=function(_95
){
582 var h
=Dygraph
.createCanvas();
583 h
.style
.position
="absolute";
584 h
.style
.top
=_95
.style
.top
;
585 h
.style
.left
=_95
.style
.left
;
587 h
.height
=this.height_
;
588 h
.style
.width
=this.width_
+"px";
589 h
.style
.height
=this.height_
+"px";
590 this.graphDiv
.appendChild(h
);
593 Dygraph
.hsvToRGB
=function(hue
,_98
,_99
){
602 var i
=Math
.floor(hue
*6);
605 var q
=_99
*(1-(_98
*f
));
606 var t
=_99
*(1-(_98
*(1-f
)));
641 red
=Math
.floor(255*red
+0.5);
642 _101
=Math
.floor(255*_101
+0.5);
643 blue
=Math
.floor(255*blue
+0.5);
644 return "rgb("+red
+","+_101
+","+blue
+")";
646 Dygraph
.prototype.setColors_
=function(){
647 var num
=this.attr_("labels").length
-1;
649 var _108
=this.attr_("colors");
651 var sat
=this.attr_("colorSaturation")||1;
652 var val
=this.attr_("colorValue")||0.5;
653 for(var i
=1;i
<=num
;i
++){
654 var hue
=(1*i
/(1+num
));
655 this.colors_
.push(Dygraph
.hsvToRGB(hue
,sat
,val
));
658 for(var i
=0;i
<num
;i
++){
659 var _111
=_108
[i
%_108
.length
];
660 this.colors_
.push(_111
);
663 this.renderOptions_
.colorScheme
=this.colors_
;
664 Dygraph
.update(this.plotter_
.options
,this.renderOptions_
);
665 Dygraph
.update(this.layoutOptions_
,this.user_attrs_
);
666 Dygraph
.update(this.layoutOptions_
,this.attrs_
);
668 Dygraph
.findPosX
=function(obj
){
670 if(obj
.offsetParent
){
671 while(obj
.offsetParent
){
672 _113
+=obj
.offsetLeft
;
673 obj
=obj
.offsetParent
;
682 Dygraph
.findPosY
=function(obj
){
684 if(obj
.offsetParent
){
685 while(obj
.offsetParent
){
687 obj
=obj
.offsetParent
;
696 Dygraph
.prototype.createStatusMessage_
=function(){
697 if(!this.attr_("labelsDiv")){
698 var _115
=this.attr_("labelsDivWidth");
699 var _116
={"position":"absolute","fontSize":"14px","zIndex":10,"width":_115
+"px","top":"0px","left":(this.width_
-_115
-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
700 Dygraph
.update(_116
,this.attr_("labelsDivStyles"));
701 var div
=document
.createElement("div");
702 for(var name
in _116
){
703 if(_116
.hasOwnProperty(name
)){
704 div
.style
[name
]=_116
[name
];
707 this.graphDiv
.appendChild(div
);
708 this.attrs_
.labelsDiv
=div
;
711 Dygraph
.prototype.createRollInterface_
=function(){
712 var _118
=this.attr_("showRoller")?"block":"none";
713 var _119
={"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_118
};
714 var _120
=document
.createElement("input");
717 _120
.value
=this.rollPeriod_
;
718 for(var name
in _119
){
719 if(_119
.hasOwnProperty(name
)){
720 _120
.style
[name
]=_119
[name
];
723 var pa
=this.graphDiv
;
724 pa
.appendChild(_120
);
726 _120
.onchange
=function(){
727 _122
.adjustRoll(_120
.value
);
731 Dygraph
.pageX
=function(e
){
733 return (!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
737 return e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
740 Dygraph
.pageY
=function(e
){
742 return (!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
746 return e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
749 Dygraph
.prototype.createDragInterface_
=function(){
762 var getX
=function(e
){
763 return Dygraph
.pageX(e
)-px
;
765 var getY
=function(e
){
766 return Dygraph
.pageX(e
)-py
;
768 Dygraph
.addEvent(this.hidden_
,"mousemove",function(_139
){
772 self
.drawZoomRect_(_128
,_130
,_132
);
778 self
.dateWindow_
[0]=_133
-(_130
/self
.width_
)*_134
;
779 self
.dateWindow_
[1]=self
.dateWindow_
[0]+_134
;
780 self
.drawGraph_(self
.rawData_
);
784 Dygraph
.addEvent(this.hidden_
,"mousedown",function(_140
){
785 px
=Dygraph
.findPosX(self
.canvas_
);
786 py
=Dygraph
.findPosY(self
.canvas_
);
789 if(_140
.altKey
||_140
.shiftKey
){
790 if(!self
.dateWindow_
){
794 _134
=self
.dateWindow_
[1]-self
.dateWindow_
[0];
795 _133
=(_128
/self
.width_
)*_134
+self
.dateWindow_
[0];
800 Dygraph
.addEvent(document
,"mouseup",function(_141
){
812 Dygraph
.addEvent(this.hidden_
,"mouseout",function(_142
){
818 Dygraph
.addEvent(this.hidden_
,"mouseup",function(_143
){
823 var _144
=Math
.abs(_130
-_128
);
824 var _145
=Math
.abs(_131
-_129
);
825 if(_144
<2&&_145
<2&&self
.attr_("clickCallback")!=null&&self
.lastx_
!=undefined
){
826 self
.attr_("clickCallback")(_143
,self
.lastx_
,self
.selPoints_
);
829 self
.doZoom_(Math
.min(_128
,_130
),Math
.max(_128
,_130
));
831 self
.canvas_
.getContext("2d").clearRect(0,0,self
.canvas_
.width
,self
.canvas_
.height
);
842 Dygraph
.addEvent(this.hidden_
,"dblclick",function(_146
){
843 if(self
.dateWindow_
==null){
846 self
.dateWindow_
=null;
847 self
.drawGraph_(self
.rawData_
);
848 var _147
=self
.rawData_
[0][0];
849 var _148
=self
.rawData_
[self
.rawData_
.length
-1][0];
850 if(self
.attr_("zoomCallback")){
851 self
.attr_("zoomCallback")(_147
,_148
);
855 Dygraph
.prototype.drawZoomRect_
=function(_149
,endX
,_151
){
856 var ctx
=this.canvas_
.getContext("2d");
858 ctx
.clearRect(Math
.min(_149
,_151
),0,Math
.abs(_149
-_151
),this.height_
);
861 ctx
.fillStyle
="rgba(128,128,128,0.33)";
862 ctx
.fillRect(Math
.min(_149
,endX
),0,Math
.abs(endX
-_149
),this.height_
);
865 Dygraph
.prototype.doZoom_
=function(lowX
,_153
){
866 var _154
=this.layout_
.points
;
869 for(var i
=0;i
<_154
.length
;i
++){
870 var cx
=_154
[i
].canvasx
;
872 if(cx
<lowX
&&(_155
==null||x
>_155
)){
875 if(cx
>_153
&&(_156
==null||x
<_156
)){
883 _156
=_154
[_154
.length
-1].xval
;
885 this.dateWindow_
=[_155
,_156
];
886 this.drawGraph_(this.rawData_
);
887 if(this.attr_("zoomCallback")){
888 this.attr_("zoomCallback")(_155
,_156
);
891 Dygraph
.prototype.mouseMove_
=function(_158
){
892 var _159
=Dygraph
.pageX(_158
)-Dygraph
.findPosX(this.hidden_
);
893 var _160
=this.layout_
.points
;
898 for(var i
=0;i
<_160
.length
;i
++){
899 var dist
=Math
.abs(_160
[i
].canvasx
-_159
);
909 if(_159
>_160
[_160
.length
-1].canvasx
){
910 _161
=_160
[_160
.length
-1].xval
;
913 for(var i
=0;i
<_160
.length
;i
++){
914 if(_160
[i
].xval
==_161
){
915 this.selPoints_
.push(_160
[i
]);
918 if(this.attr_("highlightCallback")){
919 this.attr_("highlightCallback")(_158
,_161
,this.selPoints_
);
921 var _166
=this.attr_("highlightCircleSize");
922 var ctx
=this.canvas_
.getContext("2d");
923 if(this.previousVerticalX_
>=0){
924 var px
=this.previousVerticalX_
;
925 ctx
.clearRect(px
-_166
-1,0,2*_166
+2,this.height_
);
927 var isOK
=function(x
){
930 if(this.selPoints_
.length
>0){
931 var _159
=this.selPoints_
[0].canvasx
;
932 var _168
=this.attr_("xValueFormatter")(_161
,this)+":";
933 var clen
=this.colors_
.length
;
934 for(var i
=0;i
<this.selPoints_
.length
;i
++){
935 if(!isOK(this.selPoints_
[i
].canvasy
)){
938 if(this.attr_("labelsSeparateLines")){
941 var _170
=this.selPoints_
[i
];
942 var c
=new RGBColor(this.colors_
[i
%clen
]);
943 _168
+=" <b><font color='"+c
.toHex()+"'>"+_170
.name
+"</font></b>:"+this.round_(_170
.yval
,2);
945 this.attr_("labelsDiv").innerHTML
=_168
;
948 for(var i
=0;i
<this.selPoints_
.length
;i
++){
949 if(!isOK(this.selPoints_
[i
%clen
].canvasy
)){
953 ctx
.fillStyle
=this.colors_
[i
%clen
];
954 ctx
.arc(_159
,this.selPoints_
[i
%clen
].canvasy
,_166
,0,2*Math
.PI
,false);
958 this.previousVerticalX_
=_159
;
961 Dygraph
.prototype.mouseOut_
=function(_172
){
962 var ctx
=this.canvas_
.getContext("2d");
963 ctx
.clearRect(0,0,this.width_
,this.height_
);
964 this.attr_("labelsDiv").innerHTML
="";
966 Dygraph
.zeropad
=function(x
){
973 Dygraph
.prototype.hmsString_
=function(date
){
974 var _174
=Dygraph
.zeropad
;
975 var d
=new Date(date
);
977 return _174(d
.getHours())+":"+_174(d
.getMinutes())+":"+_174(d
.getSeconds());
980 return _174(d
.getHours())+":"+_174(d
.getMinutes());
982 return _174(d
.getHours());
986 Dygraph
.dateString_
=function(date
,self
){
987 var _176
=Dygraph
.zeropad
;
988 var d
=new Date(date
);
989 var year
=""+d
.getFullYear();
990 var _178
=_176(d
.getMonth()+1);
991 var day
=_176(d
.getDate());
993 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
995 ret
=" "+self
.hmsString_(date
);
997 return year
+"/"+_178+"/"+day
+ret
;
999 Dygraph
.prototype.round_
=function(num
,_182
){
1000 var _183
=Math
.pow(10,_182
);
1001 return Math
.round(num
*_183
)/_183
;
1003 Dygraph
.prototype.loadedEvent_
=function(data
){
1004 this.rawData_
=this.parseCSV_(data
);
1005 this.drawGraph_(this.rawData_
);
1007 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
1008 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
1009 Dygraph
.prototype.addXTicks_
=function(){
1011 if(this.dateWindow_
){
1012 _185
=this.dateWindow_
[0];
1013 endDate
=this.dateWindow_
[1];
1015 _185
=this.rawData_
[0][0];
1016 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
1018 var _186
=this.attr_("xTicker")(_185
,endDate
,this);
1019 this.layout_
.updateOptions({xTicks
:_186
});
1022 Dygraph
.TWO_SECONDLY
=1;
1023 Dygraph
.FIVE_SECONDLY
=2;
1024 Dygraph
.TEN_SECONDLY
=3;
1025 Dygraph
.THIRTY_SECONDLY
=4;
1027 Dygraph
.TWO_MINUTELY
=6;
1028 Dygraph
.FIVE_MINUTELY
=7;
1029 Dygraph
.TEN_MINUTELY
=8;
1030 Dygraph
.THIRTY_MINUTELY
=9;
1032 Dygraph
.TWO_HOURLY
=11;
1033 Dygraph
.SIX_HOURLY
=12;
1037 Dygraph
.QUARTERLY
=16;
1038 Dygraph
.BIANNUAL
=17;
1041 Dygraph
.NUM_GRANULARITIES
=20;
1042 Dygraph
.SHORT_SPACINGS
=[];
1043 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
1044 Dygraph
.SHORT_SPACINGS
[Dygraph
.TWO_SECONDLY
]=1000*2;
1045 Dygraph
.SHORT_SPACINGS
[Dygraph
.FIVE_SECONDLY
]=1000*5;
1046 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
1047 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
1048 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
1049 Dygraph
.SHORT_SPACINGS
[Dygraph
.TWO_MINUTELY
]=1000*60*2;
1050 Dygraph
.SHORT_SPACINGS
[Dygraph
.FIVE_MINUTELY
]=1000*60*5;
1051 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
1052 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
1053 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
1054 Dygraph
.SHORT_SPACINGS
[Dygraph
.TWO_HOURLY
]=1000*3600*2;
1055 Dygraph
.SHORT_SPACINGS
[Dygraph
.SIX_HOURLY
]=1000*3600*6;
1056 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
1057 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
1058 Dygraph
.prototype.NumXTicks
=function(_187
,_188
,_189
){
1059 if(_189
<Dygraph
.MONTHLY
){
1060 var _190
=Dygraph
.SHORT_SPACINGS
[_189
];
1061 return Math
.floor(0.5+1*(_188
-_187
)/_190
);
1065 if(_189
==Dygraph
.QUARTERLY
){
1068 if(_189
==Dygraph
.BIANNUAL
){
1071 if(_189
==Dygraph
.ANNUAL
){
1074 if(_189
==Dygraph
.DECADAL
){
1078 var _193
=365.2524*24*3600*1000;
1079 var _194
=1*(_188
-_187
)/_193
;
1080 return Math
.floor(0.5+1*_194
*_192
/_191
);
1083 Dygraph
.prototype.GetXAxis
=function(_195
,_196
,_197
){
1085 if(_197
<Dygraph
.MONTHLY
){
1086 var _199
=Dygraph
.SHORT_SPACINGS
[_197
];
1089 var d
=new Date(_195
);
1091 var x
=d
.getSeconds();
1092 d
.setSeconds(x
-x
%g
);
1097 var x
=d
.getMinutes();
1098 d
.setMinutes(x
-x
%g
);
1109 d
.setDate(d
.getDate()-d
.getDay());
1115 for(var t
=_195
;t
<=_196
;t
+=_199
){
1117 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
1118 if(frac
==0||_197
>=Dygraph
.DAILY
){
1119 _198
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_200
)});
1121 _198
.push({v
:t
,label
:this.hmsString_(t
)});
1127 if(_197
==Dygraph
.MONTHLY
){
1128 _202
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
1130 if(_197
==Dygraph
.QUARTERLY
){
1133 if(_197
==Dygraph
.BIANNUAL
){
1136 if(_197
==Dygraph
.ANNUAL
){
1139 if(_197
==Dygraph
.DECADAL
){
1147 var _204
=new Date(_195
).getFullYear();
1148 var _205
=new Date(_196
).getFullYear();
1149 var _206
=Dygraph
.zeropad
;
1150 for(var i
=_204
;i
<=_205
;i
++){
1154 for(var j
=0;j
<_202
.length
;j
++){
1155 var _207
=i
+"/"+_206(1+_202[j])+"/01";
1156 var t
=Date
.parse(_207
);
1160 _198
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
1166 Dygraph
.dateTicker
=function(_208
,_209
,self
){
1168 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
1169 var _211
=self
.NumXTicks(_208
,_209
,i
);
1170 if(self
.width_
/_211
>=self
.attr_("pixelsPerXLabel")){
1176 return self
.GetXAxis(_208
,_209
,_210
);
1180 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
1181 if(self
.attr_("labelsKMG2")){
1186 var _215
,low_val
,high_val
,nTicks
;
1187 var _216
=self
.attr_("pixelsPerYLabel");
1188 for(var i
=-10;i
<50;i
++){
1189 if(self
.attr_("labelsKMG2")){
1190 var _217
=Math
.pow(16,i
);
1192 var _217
=Math
.pow(10,i
);
1194 for(var j
=0;j
<_214
.length
;j
++){
1196 low_val
=Math
.floor(minV
/_215
)*_215
;
1197 high_val
=Math
.ceil(maxV
/_215
)*_215
;
1198 nTicks
=(high_val
-low_val
)/_215
;
1199 var _218
=self
.height_
/nTicks
;
1211 if(self
.attr_("labelsKMB")){
1213 _221
=["K","M","B","T"];
1215 if(self
.attr_("labelsKMG2")){
1217 self
.warn("Setting both labelsKMB and labelsKMG2. Pick one!");
1220 _221
=["k","M","G","T"];
1222 for(var i
=0;i
<nTicks
;i
++){
1223 var _222
=low_val
+i
*_215
;
1224 var _223
=Math
.abs(_222
);
1225 var _224
=self
.round_(_222
,2);
1228 for(var j
=3;j
>=0;j
--,n
/=k
){
1230 _224
=self
.round_(_222
/n
,1)+_221
[j
];
1235 _219
.push({label
:_224
,v
:_222
});
1239 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
1240 var _228
=Dygraph
.numericTicks(minY
,maxY
,this);
1241 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_228
});
1243 Dygraph
.prototype.extremeValues_
=function(_229
){
1244 var minY
=null,maxY
=null;
1245 var bars
=this.attr_("errorBars")||this.attr_("customBars");
1247 for(var j
=0;j
<_229
.length
;j
++){
1248 var y
=_229
[j
][1][0];
1252 var low
=y
-_229
[j
][1][1];
1253 var high
=y
+_229
[j
][1][2];
1260 if(maxY
==null||high
>maxY
){
1263 if(minY
==null||low
<minY
){
1268 for(var j
=0;j
<_229
.length
;j
++){
1270 if(y
===null||isNaN(y
)){
1273 if(maxY
==null||y
>maxY
){
1276 if(minY
==null||y
<minY
){
1283 Dygraph
.prototype.drawGraph_
=function(data
){
1284 var minY
=null,maxY
=null;
1285 this.layout_
.removeAllDatasets();
1287 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
1288 for(var i
=1;i
<data
[0].length
;i
++){
1290 for(var j
=0;j
<data
.length
;j
++){
1291 var date
=data
[j
][0];
1292 _233
[j
]=[date
,data
[j
][i
]];
1294 _233
=this.rollingAverage(_233
,this.rollPeriod_
);
1295 var bars
=this.attr_("errorBars")||this.attr_("customBars");
1296 if(this.dateWindow_
){
1297 var low
=this.dateWindow_
[0];
1298 var high
=this.dateWindow_
[1];
1300 for(var k
=0;k
<_233
.length
;k
++){
1301 if(_233
[k
][0]>=low
&&_233
[k
][0]<=high
){
1307 var _235
=this.extremeValues_(_233
);
1310 if(!minY
||_236
<minY
){
1313 if(!maxY
||_237
>maxY
){
1318 for(var j
=0;j
<_233
.length
;j
++){
1319 vals
[j
]=[_233
[j
][0],_233
[j
][1][0],_233
[j
][1][1],_233
[j
][1][2]];
1321 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
1323 this.layout_
.addDataset(this.attr_("labels")[i
],_233
);
1326 if(this.valueRange_
!=null){
1327 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
1330 var _240
=maxY
+0.1*span
;
1331 var _241
=minY
-0.1*span
;
1332 if(_241
<0&&minY
>=0){
1335 if(_240
>0&&maxY
<=0){
1338 if(this.attr_("includeZero")){
1346 this.addYTicks_(_241
,_240
);
1349 this.layout_
.updateOptions({dateWindow
:this.dateWindow_
});
1350 this.layout_
.evaluateWithError();
1351 this.plotter_
.clear();
1352 this.plotter_
.render();
1353 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
1355 Dygraph
.prototype.rollingAverage
=function(_242
,_243
){
1359 var _243
=Math
.min(_243
,_242
.length
-1);
1361 var _245
=this.attr_("sigma");
1362 if(this.fractions_
){
1366 for(var i
=0;i
<_242
.length
;i
++){
1370 num
-=_242
[i
-_243
][1][0];
1371 den
-=_242
[i
-_243
][1][1];
1373 var date
=_242
[i
][0];
1374 var _248
=den
?num
/den
:0;
1375 if(this.attr_("errorBars")){
1376 if(this.wilsonInterval_
){
1378 var p
=_248
<0?0:_248
,n
=den
;
1379 var pm
=_245
*Math
.sqrt(p
*(1-p
)/n+_245*_245/(4*n
*n
));
1380 var _250
=1+_245
*_245
/den
;
1381 var low
=(p
+_245
*_245
/(2*den)-pm)/_250
;
1382 var high
=(p
+_245
*_245
/(2*den)+pm)/_250
;
1383 _244
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
1385 _244
[i
]=[date
,[0,0,0]];
1388 var _251
=den
?_245
*Math
.sqrt(_248
*(1-_248
)/den
):1;
1389 _244
[i
]=[date
,[mult
*_248
,mult
*_251
,mult
*_251
]];
1392 _244
[i
]=[date
,mult
*_248
];
1396 if(this.attr_("customBars")){
1401 for(var i
=0;i
<_242
.length
;i
++){
1402 var data
=_242
[i
][1];
1404 _244
[i
]=[_242
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
1405 if(y
!=null&&!isNaN(y
)){
1412 var prev
=_242
[i
-_243
];
1413 if(prev
[1][1]!=null&&!isNaN(prev
[1][1])){
1420 _244
[i
]=[_242
[i
][0],[1*mid
/_253,1*(mid-low)/_253
,1*(high
-mid
)/_253
]];
1423 var _255
=Math
.min(_243
-1,_242
.length
-2);
1424 if(!this.attr_("errorBars")){
1428 for(var i
=0;i
<_242
.length
;i
++){
1431 for(var j
=Math
.max(0,i
-_243
+1);j
<i
+1;j
++){
1433 if(y
==null||isNaN(y
)){
1440 _244
[i
]=[_242
[i
][0],sum
/_257
];
1442 _244
[i
]=[_242
[i
][0],null];
1446 for(var i
=0;i
<_242
.length
;i
++){
1450 for(var j
=Math
.max(0,i
-_243
+1);j
<i
+1;j
++){
1451 var y
=_242
[j
][1][0];
1452 if(y
==null||isNaN(y
)){
1457 _258
+=Math
.pow(_242
[j
][1][1],2);
1460 var _251
=Math
.sqrt(_258
)/_257
;
1461 _244
[i
]=[_242
[i
][0],[sum
/_257
,_245
*_251
,_245
*_251
]];
1463 _244
[i
]=[_242
[i
][0],[null,null,null]];
1471 Dygraph
.dateParser
=function(_259
,self
){
1474 if(_259
.length
==10&&_259
.search("-")!=-1){
1475 _260
=_259
.replace("-","/","g");
1476 while(_260
.search("-")!=-1){
1477 _260
=_260
.replace("-","/");
1482 _260
=_259
.substr(0,4)+"/"+_259.substr(4,2)+"/"+_259
.substr(6,2);
1489 self
.error("Couldn't parse "+_259
+" as a date");
1493 Dygraph
.prototype.detectTypeFromString_
=function(str
){
1495 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
1498 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
1503 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
1504 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
1505 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
1507 this.attrs_
.xValueFormatter
=function(x
){
1510 this.attrs_
.xValueParser
=function(x
){
1511 return parseFloat(x
);
1513 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
1516 Dygraph
.prototype.parseCSV_
=function(data
){
1518 var _263
=data
.split("\n");
1519 var _264
=this.attr_("delimiter");
1520 if(_263
[0].indexOf(_264
)==-1&&_263
[0].indexOf("\t")>=0){
1524 if(this.labelsFromCSV_
){
1526 this.attrs_
.labels
=_263
[0].split(_264
);
1530 var _268
=this.attr_("labels").length
;
1531 for(var i
=_265
;i
<_263
.length
;i
++){
1539 var _270
=line
.split(_264
);
1545 this.detectTypeFromString_(_270
[0]);
1546 _266
=this.attr_("xValueParser");
1549 _271
[0]=_266(_270
[0],this);
1550 if(this.fractions_
){
1551 for(var j
=1;j
<_270
.length
;j
++){
1552 var vals
=_270
[j
].split("/");
1553 _271
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
1556 if(this.attr_("errorBars")){
1557 for(var j
=1;j
<_270
.length
;j
+=2){
1558 _271
[(j
+1)/2]=[parseFloat(_270
[j
]),parseFloat(_270
[j
+1])];
1561 if(this.attr_("customBars")){
1562 for(var j
=1;j
<_270
.length
;j
++){
1563 var vals
=_270
[j
].split(";");
1564 _271
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
1567 for(var j
=1;j
<_270
.length
;j
++){
1568 _271
[j
]=parseFloat(_270
[j
]);
1574 if(_271
.length
!=_268
){
1575 this.error("Number of columns in line "+i
+" ("+_271
.length
+") does not agree with number of labels ("+_268
+") "+line
);
1580 Dygraph
.prototype.parseArray_
=function(data
){
1582 this.error("Can't plot empty data set");
1585 if(data
[0].length
==0){
1586 this.error("Data set cannot contain an empty row");
1589 if(this.attr_("labels")==null){
1590 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
1591 this.attrs_
.labels
=["X"];
1592 for(var i
=1;i
<data
[0].length
;i
++){
1593 this.attrs_
.labels
.push("Y"+i
);
1596 if(Dygraph
.isDateLike(data
[0][0])){
1597 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
1598 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
1599 var _272
=Dygraph
.clone(data
);
1600 for(var i
=0;i
<data
.length
;i
++){
1601 if(_272
[i
].length
==0){
1602 this.error("Row "<<(1+i
)<<" of data is empty");
1605 if(_272
[i
][0]==null||typeof (_272
[i
][0].getTime
)!="function"){
1606 this.error("x value in row "<<(1+i
)<<" is not a Date");
1609 _272
[i
][0]=_272
[i
][0].getTime();
1613 this.attrs_
.xValueFormatter
=function(x
){
1616 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
1620 Dygraph
.prototype.parseDataTable_
=function(data
){
1621 var cols
=data
.getNumberOfColumns();
1622 var rows
=data
.getNumberOfRows();
1624 for(var i
=0;i
<cols
;i
++){
1625 _275
.push(data
.getColumnLabel(i
));
1626 if(i
!=0&&this.attr_("errorBars")){
1630 this.attrs_
.labels
=_275
;
1632 var _276
=data
.getColumnType(0);
1634 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
1635 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
1636 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
1639 this.attrs_
.xValueFormatter
=function(x
){
1642 this.attrs_
.xValueParser
=function(x
){
1643 return parseFloat(x
);
1645 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
1647 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_276
+"')");
1652 for(var i
=0;i
<rows
;i
++){
1654 if(typeof (data
.getValue(i
,0))==="undefined"||data
.getValue(i
,0)===null){
1655 this.warning("Ignoring row "+i
+" of DataTable because of undefined or null first column.");
1659 row
.push(data
.getValue(i
,0).getTime());
1661 row
.push(data
.getValue(i
,0));
1663 if(!this.attr_("errorBars")){
1664 for(var j
=1;j
<cols
;j
++){
1665 row
.push(data
.getValue(i
,j
));
1668 for(var j
=0;j
<cols
-1;j
++){
1669 row
.push([data
.getValue(i
,1+2*j
),data
.getValue(i
,2+2*j
)]);
1676 Dygraph
.update
=function(self
,o
){
1677 if(typeof (o
)!="undefined"&&o
!==null){
1679 if(o
.hasOwnProperty(k
)){
1686 Dygraph
.isArrayLike
=function(o
){
1688 if((typ
!="object"&&!(typ
=="function"&&typeof (o
.item
)=="function"))||o
===null||typeof (o
.length
)!="number"||o
.nodeType
===3){
1693 Dygraph
.isDateLike
=function(o
){
1694 if(typeof (o
)!="object"||o
===null||typeof (o
.getTime
)!="function"){
1699 Dygraph
.clone
=function(o
){
1701 for(var i
=0;i
<o
.length
;i
++){
1702 if(Dygraph
.isArrayLike(o
[i
])){
1703 r
.push(Dygraph
.clone(o
[i
]));
1710 Dygraph
.prototype.start_
=function(){
1711 if(typeof this.file_
=="function"){
1712 this.loadedEvent_(this.file_());
1714 if(Dygraph
.isArrayLike(this.file_
)){
1715 this.rawData_
=this.parseArray_(this.file_
);
1716 this.drawGraph_(this.rawData_
);
1718 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
1719 this.rawData_
=this.parseDataTable_(this.file_
);
1720 this.drawGraph_(this.rawData_
);
1722 if(typeof this.file_
=="string"){
1723 if(this.file_
.indexOf("\n")>=0){
1724 this.loadedEvent_(this.file_
);
1726 var req
=new XMLHttpRequest();
1728 req
.onreadystatechange
=function(){
1729 if(req
.readyState
==4){
1730 if(req
.status
==200){
1731 _282
.loadedEvent_(req
.responseText
);
1735 req
.open("GET",this.file_
,true);
1739 this.error("Unknown data format: "+(typeof this.file_
));
1745 Dygraph
.prototype.updateOptions
=function(_283
){
1746 if(_283
.rollPeriod
){
1747 this.rollPeriod_
=_283
.rollPeriod
;
1749 if(_283
.dateWindow
){
1750 this.dateWindow_
=_283
.dateWindow
;
1752 if(_283
.valueRange
){
1753 this.valueRange_
=_283
.valueRange
;
1755 Dygraph
.update(this.user_attrs_
,_283
);
1756 this.labelsFromCSV_
=(this.attr_("labels")==null);
1757 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
1758 if(_283
["file"]&&_283
["file"]!=this.file_
){
1759 this.file_
=_283
["file"];
1762 this.drawGraph_(this.rawData_
);
1765 Dygraph
.prototype.resize
=function(_284
,_285
){
1766 if((_284
===null)!=(_285
===null)){
1767 this.warn("Dygraph.resize() should be called with zero parameters or "+"two non-NULL parameters. Pretending it was zero.");
1770 this.maindiv_
.innerHTML
="";
1771 this.attrs_
.labelsDiv
=null;
1773 this.maindiv_
.style
.width
=_284
+"px";
1774 this.maindiv_
.style
.height
=_285
+"px";
1778 this.width_
=this.maindiv_
.offsetWidth
;
1779 this.height_
=this.maindiv_
.offsetHeight
;
1781 this.createInterface_();
1782 this.drawGraph_(this.rawData_
);
1784 Dygraph
.prototype.adjustRoll
=function(_286
){
1785 this.rollPeriod_
=_286
;
1786 this.drawGraph_(this.rawData_
);
1788 Dygraph
.createCanvas
=function(){
1789 var _287
=document
.createElement("canvas");
1790 isIE
=(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
);
1792 _287
=G_vmlCanvasManager
.initElement(_287
);
1796 Dygraph
.GVizChart
=function(_288
){
1797 this.container
=_288
;
1799 Dygraph
.GVizChart
.prototype.draw
=function(data
,_289
){
1800 this.container
.innerHTML
="";
1801 this.date_graph
=new Dygraph(this.container
,data
,_289
);
1804 function RGBColor(_290
){
1806 if(_290
.charAt(0)=="#"){
1807 _290
=_290
.substr(1,6);
1809 _290
=_290
.replace(/ /g,"");
1810 _290
=_290
.toLowerCase();
1811 var _291
={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"};
1812 for(var key
in _291
){
1817 var _293
=[{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
){
1818 return [parseInt(bits
[1]),parseInt(bits
[2]),parseInt(bits
[3])];
1819 }},{re
:/^(\w{2})(\w{2})(\w{2})$/,example
:["#00ff00","336699"],process
:function(bits
){
1820 return [parseInt(bits
[1],16),parseInt(bits
[2],16),parseInt(bits
[3],16)];
1821 }},{re
:/^(\w{1})(\w{1})(\w{1})$/,example
:["#fb0","f0f"],process
:function(bits
){
1822 return [parseInt(bits
[1]+bits
[1],16),parseInt(bits
[2]+bits
[2],16),parseInt(bits
[3]+bits
[3],16)];
1824 for(var i
=0;i
<_293
.length
;i
++){
1826 var _296
=_293
[i
].process
;
1827 var bits
=re
.exec(_290
);
1829 channels
=_296(bits
);
1836 this.r
=(this.r
<0||isNaN(this.r
))?0:((this.r
>255)?255:this.r
);
1837 this.g
=(this.g
<0||isNaN(this.g
))?0:((this.g
>255)?255:this.g
);
1838 this.b
=(this.b
<0||isNaN(this.b
))?0:((this.b
>255)?255:this.b
);
1839 this.toRGB
=function(){
1840 return "rgb("+this.r
+", "+this.g
+", "+this.b
+")";
1842 this.toHex
=function(){
1843 var r
=this.r
.toString(16);
1844 var g
=this.g
.toString(16);
1845 var b
=this.b
.toString(16);