61733c0095674776b8c31428903f0d56df07f391
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 for(var _6
in this.datasets
){
22 var _7
=this.datasets
[_6
];
24 if(!this.minxval
||x1
<this.minxval
){
27 var x2
=_7
[_7
.length
-1][0];
28 if(!this.maxxval
||x2
>this.maxxval
){
32 this.xrange
=this.maxxval
-this.minxval
;
33 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
34 this.minyval
=this.options
.yAxis
[0];
35 this.maxyval
=this.options
.yAxis
[1];
36 this.yrange
=this.maxyval
-this.minyval
;
37 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
39 DygraphLayout
.prototype._evaluateLineCharts
=function(){
40 this.points
=new Array();
41 for(var _10
in this.datasets
){
42 var _11
=this.datasets
[_10
];
43 for(var j
=0;j
<_11
.length
;j
++){
45 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
};
52 if((_14
.x
>=0)&&(_14
.x
<=1)){
53 this.points
.push(_14
);
58 DygraphLayout
.prototype._evaluateLineTicks
=function(){
59 this.xticks
=new Array();
60 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
61 var _16
=this.options
.xTicks
[i
];
63 var pos
=this.xscale
*(_16
.v
-this.minxval
);
64 if((pos
>=0)&&(pos
<=1)){
65 this.xticks
.push([pos
,_17
]);
68 this.yticks
=new Array();
69 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
70 var _16
=this.options
.yTicks
[i
];
72 var pos
=1-(this.yscale
*(_16
.v
-this.minyval
));
73 if((pos
>=0)&&(pos
<=1)){
74 this.yticks
.push([pos
,_17
]);
78 DygraphLayout
.prototype.evaluateWithError
=function(){
80 if(!this.options
.errorBars
){
84 for(var _19
in this.datasets
){
86 var _20
=this.datasets
[_19
];
87 for(var j
=0;j
<_20
.length
;j
++,i
++){
89 var xv
=parseFloat(_21
[0]);
90 var yv
=parseFloat(_21
[1]);
91 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
92 this.points
[i
].errorMinus
=parseFloat(_21
[2]);
93 this.points
[i
].errorPlus
=parseFloat(_21
[3]);
98 DygraphLayout
.prototype.removeAllDatasets
=function(){
100 this.datasets
=new Array();
102 DygraphLayout
.prototype.updateOptions
=function(_24
){
103 Dygraph
.update(this.options
,_24
?_24
:{});
105 DygraphCanvasRenderer
=function(_25
,_26
,_27
,_28
){
107 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)"};
108 Dygraph
.update(this.options
,_28
);
111 this.container
=this.element
.parentNode
;
112 this.height
=this.element
.height
;
113 this.width
=this.element
.width
;
114 if(!this.isIE
&&!(DygraphCanvasRenderer
.isSupported(this.element
))){
115 throw "Canvas is not supported.";
117 this.xlabels
=new Array();
118 this.ylabels
=new Array();
119 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
120 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
121 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
122 this.container
.style
.position
="relative";
123 this.container
.style
.width
=this.width
+"px";
125 DygraphCanvasRenderer
.prototype.clear
=function(){
129 this.clearDelay
.cancel();
130 this.clearDelay
=null;
132 var _29
=this.element
.getContext("2d");
135 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
136 this.clearDelay
.addCallback(bind(this.clear
,this));
140 var _29
=this.element
.getContext("2d");
141 _29
.clearRect(0,0,this.width
,this.height
);
142 for(var i
=0;i
<this.xlabels
.length
;i
++){
143 var el
=this.xlabels
[i
];
144 el
.parentNode
.removeChild(el
);
146 for(var i
=0;i
<this.ylabels
.length
;i
++){
147 var el
=this.ylabels
[i
];
148 el
.parentNode
.removeChild(el
);
150 this.xlabels
=new Array();
151 this.ylabels
=new Array();
153 DygraphCanvasRenderer
.isSupported
=function(_31
){
156 if(typeof (_31
)=="undefined"||_31
==null){
157 _32
=document
.createElement("canvas");
161 var _33
=_32
.getContext("2d");
164 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
165 var _35
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
166 if((!ie
)||(ie
[1]<6)||(_35
)){
173 DygraphCanvasRenderer
.prototype.render
=function(){
174 var ctx
=this.element
.getContext("2d");
175 if(this.options
.drawYGrid
){
176 var _37
=this.layout
.yticks
;
178 ctx
.strokeStyle
=this.options
.gridLineColor
;
179 ctx
.lineWidth
=this.options
.axisLineWidth
;
180 for(var i
=0;i
<_37
.length
;i
++){
182 var y
=this.area
.y
+_37
[i
][0]*this.area
.h
;
185 ctx
.lineTo(x
+this.area
.w
,y
);
190 if(this.options
.drawXGrid
){
191 var _37
=this.layout
.xticks
;
193 ctx
.strokeStyle
=this.options
.gridLineColor
;
194 ctx
.lineWidth
=this.options
.axisLineWidth
;
195 for(var i
=0;i
<_37
.length
;i
++){
196 var x
=this.area
.x
+_37
[i
][0]*this.area
.w
;
197 var y
=this.area
.y
+this.area
.h
;
200 ctx
.lineTo(x
,this.area
.y
);
205 this._renderLineChart();
208 DygraphCanvasRenderer
.prototype._renderAxis
=function(){
209 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
212 var _40
=this.element
.getContext("2d");
213 var _41
={"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
,"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"};
214 var _42
=function(txt
){
215 var div
=document
.createElement("div");
217 div
.style
[_45
]=_41
[_45
];
219 div
.appendChild(document
.createTextNode(txt
));
223 _40
.strokeStyle
=this.options
.axisLineColor
;
224 _40
.lineWidth
=this.options
.axisLineWidth
;
225 if(this.options
.drawYAxis
){
226 if(this.layout
.yticks
){
227 for(var i
=0;i
<this.layout
.yticks
.length
;i
++){
228 var _46
=this.layout
.yticks
[i
];
229 if(typeof (_46
)=="function"){
233 var y
=this.area
.y
+_46
[0]*this.area
.h
;
236 _40
.lineTo(x
-this.options
.axisTickSize
,y
);
240 var top
=(y
-this.options
.axisLabelFontSize
/2);
244 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
245 _47
.style
.bottom
="0px";
247 _47
.style
.top
=top
+"px";
249 _47
.style
.left
="0px";
250 _47
.style
.textAlign
="right";
251 _47
.style
.width
=this.options
.yAxisLabelWidth
+"px";
252 this.container
.appendChild(_47
);
253 this.ylabels
.push(_47
);
255 var _49
=this.ylabels
[0];
256 var _50
=this.options
.axisLabelFontSize
;
257 var _51
=parseInt(_49
.style
.top
)+_50
;
258 if(_51
>this.height
-_50
){
259 _49
.style
.top
=(parseInt(_49
.style
.top
)-_50
/2)+"px";
263 _40
.moveTo(this.area
.x
,this.area
.y
);
264 _40
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
268 if(this.options
.drawXAxis
){
269 if(this.layout
.xticks
){
270 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
271 var _46
=this.layout
.xticks
[i
];
272 if(typeof (dataset
)=="function"){
275 var x
=this.area
.x
+_46
[0]*this.area
.w
;
276 var y
=this.area
.y
+this.area
.h
;
279 _40
.lineTo(x
,y
+this.options
.axisTickSize
);
283 _47
.style
.textAlign
="center";
284 _47
.style
.bottom
="0px";
285 var _52
=(x
-this.options
.axisLabelWidth
/2);
286 if(_52
+this.options
.axisLabelWidth
>this.width
){
287 _52
=this.width
-this.options
.xAxisLabelWidth
;
288 _47
.style
.textAlign
="right";
292 _47
.style
.textAlign
="left";
294 _47
.style
.left
=_52
+"px";
295 _47
.style
.width
=this.options
.xAxisLabelWidth
+"px";
296 this.container
.appendChild(_47
);
297 this.xlabels
.push(_47
);
301 _40
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
302 _40
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
308 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
309 var _53
=this.element
.getContext("2d");
310 var _54
=this.options
.colorScheme
.length
;
311 var _55
=this.options
.colorScheme
;
312 var _56
=this.layout
.options
.errorBars
;
314 for(var _58
in this.layout
.datasets
){
318 for(var i
=0;i
<this.layout
.points
.length
;i
++){
319 var _60
=this.layout
.points
[i
];
320 _60
.canvasx
=this.area
.w
*_60
.x
+this.area
.x
;
321 _60
.canvasy
=this.area
.h
*_60
.y
+this.area
.y
;
328 for(var i
=0;i
<_59
;i
++){
333 ctx
.lineWidth
=this.options
.strokeWidth
;
337 var _67
=this.layout
.yscale
;
338 var rgb
=new RGBColor(_63
);
339 var _69
="rgba("+rgb
.r
+","+rgb
.g
+","+rgb
.b
+",0.15)";
342 for(var j
=0;j
<this.layout
.points
.length
;j
++){
343 var _60
=this.layout
.points
[j
];
346 if(!_60
.y
||isNaN(_60
.y
)){
350 var _70
=[_60
.y
-_60
.errorPlus
*_67
,_60
.y
+_60
.errorMinus
*_67
];
351 _70
[0]=this.area
.h
*_70
[0]+this.area
.y
;
352 _70
[1]=this.area
.h
*_70
[1]+this.area
.y
;
354 ctx
.moveTo(_64
,_65
[0]);
355 ctx
.lineTo(_60
.canvasx
,_70
[0]);
356 ctx
.lineTo(_60
.canvasx
,_70
[1]);
357 ctx
.lineTo(_64
,_65
[1]);
368 for(var i
=0;i
<_59
;i
++){
372 var _60
=this.layout
.points
[0];
373 var _71
=this.dygraph_
.attr_("pointSize");
374 var _64
=null,prevY
=null;
375 var _72
=this.dygraph_
.attr_("drawPoints");
376 var _73
=this.layout
.points
;
377 for(var j
=0;j
<_73
.length
;j
++){
380 if(!_61(_60
.canvasy
)){
383 var _74
=(!_64
&&(j
==_73
.length
-1||!_61(_73
[j
+1].canvasy
)));
390 ctx
.lineWidth
=this.options
.strokeWidth
;
391 ctx
.moveTo(_64
,prevY
);
394 ctx
.lineTo(_64
,prevY
);
400 ctx
.arc(_60
.canvasx
,_60
.canvasy
,_71
,0,2*Math
.PI
,false);
409 Dygraph
=function(div
,_75
,_76
){
410 if(arguments
.length
>0){
411 if(arguments
.length
==4){
412 this.warn("Using deprecated four-argument dygraph constructor");
413 this.__old_init__(div
,_75
,arguments
[2],arguments
[3]);
415 this.__init__(div
,_75
,_76
);
419 Dygraph
.NAME
="Dygraph";
420 Dygraph
.VERSION
="1.2";
421 Dygraph
.__repr__
=function(){
422 return "["+this.NAME
+" "+this.VERSION
+"]";
424 Dygraph
.toString
=function(){
425 return this.__repr__();
427 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
428 Dygraph
.DEFAULT_WIDTH
=480;
429 Dygraph
.DEFAULT_HEIGHT
=320;
430 Dygraph
.AXIS_LINE_WIDTH
=0.3;
431 Dygraph
.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
,delimiter
:",",sigma
:2,errorBars
:false,fractions
:false,wilsonInterval
:true,customBars
:false};
436 Dygraph
.prototype.__old_init__
=function(div
,_77
,_78
,_79
){
439 for(var i
=0;i
<_78
.length
;i
++){
442 Dygraph
.update(_79
,{"labels":_80
});
444 this.__init__(div
,_77
,_79
);
446 Dygraph
.prototype.__init__
=function(div
,_81
,_82
){
452 this.rollPeriod_
=_82
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
453 this.previousVerticalX_
=-1;
454 this.fractions_
=_82
.fractions
||false;
455 this.dateWindow_
=_82
.dateWindow
||null;
456 this.valueRange_
=_82
.valueRange
||null;
457 this.wilsonInterval_
=_82
.wilsonInterval
||true;
459 if(div
.style
.width
==""){
460 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
462 if(div
.style
.height
==""){
463 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
465 this.width_
=parseInt(div
.style
.width
,10);
466 this.height_
=parseInt(div
.style
.height
,10);
468 Dygraph
.update(this.user_attrs_
,_82
);
470 Dygraph
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
471 this.labelsFromCSV_
=(this.attr_("labels")==null);
472 this.createInterface_();
473 this.layoutOptions_
={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
474 Dygraph
.update(this.layoutOptions_
,this.attrs_
);
475 Dygraph
.update(this.layoutOptions_
,this.user_attrs_
);
476 this.layout_
=new DygraphLayout(this,this.layoutOptions_
);
477 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
478 Dygraph
.update(this.renderOptions_
,this.attrs_
);
479 Dygraph
.update(this.renderOptions_
,this.user_attrs_
);
480 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
481 this.createStatusMessage_();
482 this.createRollInterface_();
483 this.createDragInterface_();
486 Dygraph
.prototype.attr_
=function(_83
){
487 if(typeof (this.user_attrs_
[_83
])!="undefined"){
488 return this.user_attrs_
[_83
];
490 if(typeof (this.attrs_
[_83
])!="undefined"){
491 return this.attrs_
[_83
];
497 Dygraph
.prototype.log
=function(_84
,_85
){
498 if(typeof (console
)!="undefined"){
501 console
.debug("dygraphs: "+_85
);
504 console
.info("dygraphs: "+_85
);
506 case Dygraph
.WARNING
:
507 console
.warn("dygraphs: "+_85
);
510 console
.error("dygraphs: "+_85
);
515 Dygraph
.prototype.info
=function(_86
){
516 this.log(Dygraph
.INFO
,_86
);
518 Dygraph
.prototype.warn
=function(_87
){
519 this.log(Dygraph
.WARNING
,_87
);
521 Dygraph
.prototype.error
=function(_88
){
522 this.log(Dygraph
.ERROR
,_88
);
524 Dygraph
.prototype.rollPeriod
=function(){
525 return this.rollPeriod_
;
527 Dygraph
.addEvent
=function(el
,evt
,fn
){
534 if(window
.addEventListener
){
535 el
.addEventListener(evt
,_91
,false);
537 el
.attachEvent("on"+evt
,_91
);
540 Dygraph
.prototype.createInterface_
=function(){
541 var _93
=this.maindiv_
;
542 this.graphDiv
=document
.createElement("div");
543 this.graphDiv
.style
.width
=this.width_
+"px";
544 this.graphDiv
.style
.height
=this.height_
+"px";
545 _93
.appendChild(this.graphDiv
);
546 this.canvas_
=Dygraph
.createCanvas();
547 this.canvas_
.style
.position
="absolute";
548 this.canvas_
.width
=this.width_
;
549 this.canvas_
.height
=this.height_
;
550 this.canvas_
.style
.width
=this.width_
+"px";
551 this.canvas_
.style
.height
=this.height_
+"px";
552 this.graphDiv
.appendChild(this.canvas_
);
553 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
555 Dygraph
.addEvent(this.hidden_
,"mousemove",function(e
){
558 Dygraph
.addEvent(this.hidden_
,"mouseout",function(e
){
562 Dygraph
.prototype.createPlotKitCanvas_
=function(_95
){
563 var h
=Dygraph
.createCanvas();
564 h
.style
.position
="absolute";
565 h
.style
.top
=_95
.style
.top
;
566 h
.style
.left
=_95
.style
.left
;
568 h
.height
=this.height_
;
569 h
.style
.width
=this.width_
+"px";
570 h
.style
.height
=this.height_
+"px";
571 this.graphDiv
.appendChild(h
);
574 Dygraph
.hsvToRGB
=function(hue
,_98
,_99
){
583 var i
=Math
.floor(hue
*6);
586 var q
=_99
*(1-(_98
*f
));
587 var t
=_99
*(1-(_98
*(1-f
)));
622 red
=Math
.floor(255*red
+0.5);
623 _101
=Math
.floor(255*_101
+0.5);
624 blue
=Math
.floor(255*blue
+0.5);
625 return "rgb("+red
+","+_101
+","+blue
+")";
627 Dygraph
.prototype.setColors_
=function(){
628 var num
=this.attr_("labels").length
-1;
630 var _108
=this.attr_("colors");
632 var sat
=this.attr_("colorSaturation")||1;
633 var val
=this.attr_("colorValue")||0.5;
634 for(var i
=1;i
<=num
;i
++){
635 var hue
=(1*i
/(1+num
));
636 this.colors_
.push(Dygraph
.hsvToRGB(hue
,sat
,val
));
639 for(var i
=0;i
<num
;i
++){
640 var _111
=_108
[i
%_108
.length
];
641 this.colors_
.push(_111
);
644 this.renderOptions_
.colorScheme
=this.colors_
;
645 Dygraph
.update(this.plotter_
.options
,this.renderOptions_
);
646 Dygraph
.update(this.layoutOptions_
,this.user_attrs_
);
647 Dygraph
.update(this.layoutOptions_
,this.attrs_
);
649 Dygraph
.findPosX
=function(obj
){
651 if(obj
.offsetParent
){
652 while(obj
.offsetParent
){
653 _113
+=obj
.offsetLeft
;
654 obj
=obj
.offsetParent
;
663 Dygraph
.findPosY
=function(obj
){
665 if(obj
.offsetParent
){
666 while(obj
.offsetParent
){
668 obj
=obj
.offsetParent
;
677 Dygraph
.prototype.createStatusMessage_
=function(){
678 if(!this.attr_("labelsDiv")){
679 var _115
=this.attr_("labelsDivWidth");
680 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"};
681 Dygraph
.update(_116
,this.attr_("labelsDivStyles"));
682 var div
=document
.createElement("div");
683 for(var name
in _116
){
684 div
.style
[name
]=_116
[name
];
686 this.graphDiv
.appendChild(div
);
687 this.attrs_
.labelsDiv
=div
;
690 Dygraph
.prototype.createRollInterface_
=function(){
691 var _118
=this.attr_("showRoller")?"block":"none";
692 var _119
={"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_118
};
693 var _120
=document
.createElement("input");
696 _120
.value
=this.rollPeriod_
;
697 for(var name
in _119
){
698 _120
.style
[name
]=_119
[name
];
700 var pa
=this.graphDiv
;
701 pa
.appendChild(_120
);
703 _120
.onchange
=function(){
704 _122
.adjustRoll(_120
.value
);
708 Dygraph
.pageX
=function(e
){
710 return (!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
714 return e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
717 Dygraph
.pageY
=function(e
){
719 return (!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
723 return e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
726 Dygraph
.prototype.createDragInterface_
=function(){
736 var getX
=function(e
){
737 return Dygraph
.pageX(e
)-px
;
739 var getY
=function(e
){
740 return Dygraph
.pageX(e
)-py
;
742 Dygraph
.addEvent(this.hidden_
,"mousemove",function(_136
){
746 self
.drawZoomRect_(_127
,_129
,_131
);
750 Dygraph
.addEvent(this.hidden_
,"mousedown",function(_137
){
752 px
=Dygraph
.findPosX(self
.canvas_
);
753 py
=Dygraph
.findPosY(self
.canvas_
);
757 Dygraph
.addEvent(document
,"mouseup",function(_138
){
764 Dygraph
.addEvent(this.hidden_
,"mouseout",function(_139
){
770 Dygraph
.addEvent(this.hidden_
,"mouseup",function(_140
){
775 var _141
=Math
.abs(_129
-_127
);
776 var _142
=Math
.abs(_130
-_128
);
777 if(_141
<2&&_142
<2&&self
.attr_("clickCallback")!=null&&self
.lastx_
!=undefined
){
778 self
.attr_("clickCallback")(_140
,self
.lastx_
,self
.selPoints_
);
781 self
.doZoom_(Math
.min(_127
,_129
),Math
.max(_127
,_129
));
783 self
.canvas_
.getContext("2d").clearRect(0,0,self
.canvas_
.width
,self
.canvas_
.height
);
789 Dygraph
.addEvent(this.hidden_
,"dblclick",function(_143
){
790 if(self
.dateWindow_
==null){
793 self
.dateWindow_
=null;
794 self
.drawGraph_(self
.rawData_
);
795 var _144
=self
.rawData_
[0][0];
796 var _145
=self
.rawData_
[self
.rawData_
.length
-1][0];
797 if(self
.attr_("zoomCallback")){
798 self
.attr_("zoomCallback")(_144
,_145
);
802 Dygraph
.prototype.drawZoomRect_
=function(_146
,endX
,_148
){
803 var ctx
=this.canvas_
.getContext("2d");
805 ctx
.clearRect(Math
.min(_146
,_148
),0,Math
.abs(_146
-_148
),this.height_
);
808 ctx
.fillStyle
="rgba(128,128,128,0.33)";
809 ctx
.fillRect(Math
.min(_146
,endX
),0,Math
.abs(endX
-_146
),this.height_
);
812 Dygraph
.prototype.doZoom_
=function(lowX
,_150
){
813 var _151
=this.layout_
.points
;
816 for(var i
=0;i
<_151
.length
;i
++){
817 var cx
=_151
[i
].canvasx
;
819 if(cx
<lowX
&&(_152
==null||x
>_152
)){
822 if(cx
>_150
&&(_153
==null||x
<_153
)){
830 _153
=_151
[_151
.length
-1].xval
;
832 this.dateWindow_
=[_152
,_153
];
833 this.drawGraph_(this.rawData_
);
834 if(this.attr_("zoomCallback")){
835 this.attr_("zoomCallback")(_152
,_153
);
838 Dygraph
.prototype.mouseMove_
=function(_155
){
839 var _156
=Dygraph
.pageX(_155
)-Dygraph
.findPosX(this.hidden_
);
840 var _157
=this.layout_
.points
;
845 for(var i
=0;i
<_157
.length
;i
++){
846 var dist
=Math
.abs(_157
[i
].canvasx
-_156
);
856 if(_156
>_157
[_157
.length
-1].canvasx
){
857 _158
=_157
[_157
.length
-1].xval
;
860 for(var i
=0;i
<_157
.length
;i
++){
861 if(_157
[i
].xval
==_158
){
862 this.selPoints_
.push(_157
[i
]);
865 if(this.attr_("highlightCallback")){
866 this.attr_("highlightCallback")(_155
,_158
,this.selPoints_
);
868 var _163
=this.attr_("highlightCircleSize");
869 var ctx
=this.canvas_
.getContext("2d");
870 if(this.previousVerticalX_
>=0){
871 var px
=this.previousVerticalX_
;
872 ctx
.clearRect(px
-_163
-1,0,2*_163
+2,this.height_
);
874 var isOK
=function(x
){
877 if(this.selPoints_
.length
>0){
878 var _156
=this.selPoints_
[0].canvasx
;
879 var _165
=this.attr_("xValueFormatter")(_158
,this)+":";
880 var clen
=this.colors_
.length
;
881 for(var i
=0;i
<this.selPoints_
.length
;i
++){
882 if(!isOK(this.selPoints_
[i
].canvasy
)){
885 if(this.attr_("labelsSeparateLines")){
888 var _167
=this.selPoints_
[i
];
889 var c
=new RGBColor(this.colors_
[i
%clen
]);
890 _165
+=" <b><font color='"+c
.toHex()+"'>"+_167
.name
+"</font></b>:"+this.round_(_167
.yval
,2);
892 this.attr_("labelsDiv").innerHTML
=_165
;
895 for(var i
=0;i
<this.selPoints_
.length
;i
++){
896 if(!isOK(this.selPoints_
[i
%clen
].canvasy
)){
900 ctx
.fillStyle
=this.colors_
[i
%clen
];
901 ctx
.arc(_156
,this.selPoints_
[i
%clen
].canvasy
,_163
,0,2*Math
.PI
,false);
905 this.previousVerticalX_
=_156
;
908 Dygraph
.prototype.mouseOut_
=function(_169
){
909 var ctx
=this.canvas_
.getContext("2d");
910 ctx
.clearRect(0,0,this.width_
,this.height_
);
911 this.attr_("labelsDiv").innerHTML
="";
913 Dygraph
.zeropad
=function(x
){
920 Dygraph
.prototype.hmsString_
=function(date
){
921 var _171
=Dygraph
.zeropad
;
922 var d
=new Date(date
);
924 return _171(d
.getHours())+":"+_171(d
.getMinutes())+":"+_171(d
.getSeconds());
927 return _171(d
.getHours())+":"+_171(d
.getMinutes());
929 return _171(d
.getHours());
933 Dygraph
.dateString_
=function(date
,self
){
934 var _173
=Dygraph
.zeropad
;
935 var d
=new Date(date
);
936 var year
=""+d
.getFullYear();
937 var _175
=_173(d
.getMonth()+1);
938 var day
=_173(d
.getDate());
940 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
942 ret
=" "+self
.hmsString_(date
);
944 return year
+"/"+_175+"/"+day
+ret
;
946 Dygraph
.prototype.round_
=function(num
,_179
){
947 var _180
=Math
.pow(10,_179
);
948 return Math
.round(num
*_180
)/_180
;
950 Dygraph
.prototype.loadedEvent_
=function(data
){
951 this.rawData_
=this.parseCSV_(data
);
952 this.drawGraph_(this.rawData_
);
954 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
955 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
956 Dygraph
.prototype.addXTicks_
=function(){
958 if(this.dateWindow_
){
959 _182
=this.dateWindow_
[0];
960 endDate
=this.dateWindow_
[1];
962 _182
=this.rawData_
[0][0];
963 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
965 var _183
=this.attr_("xTicker")(_182
,endDate
,this);
966 this.layout_
.updateOptions({xTicks
:_183
});
969 Dygraph
.TEN_SECONDLY
=1;
970 Dygraph
.THIRTY_SECONDLY
=2;
972 Dygraph
.TEN_MINUTELY
=4;
973 Dygraph
.THIRTY_MINUTELY
=5;
975 Dygraph
.SIX_HOURLY
=7;
979 Dygraph
.QUARTERLY
=11;
983 Dygraph
.NUM_GRANULARITIES
=15;
984 Dygraph
.SHORT_SPACINGS
=[];
985 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
986 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
987 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
988 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
989 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
990 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
991 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
992 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600*6;
993 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
994 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
995 Dygraph
.prototype.NumXTicks
=function(_184
,_185
,_186
){
996 if(_186
<Dygraph
.MONTHLY
){
997 var _187
=Dygraph
.SHORT_SPACINGS
[_186
];
998 return Math
.floor(0.5+1*(_185
-_184
)/_187
);
1002 if(_186
==Dygraph
.QUARTERLY
){
1005 if(_186
==Dygraph
.BIANNUAL
){
1008 if(_186
==Dygraph
.ANNUAL
){
1011 if(_186
==Dygraph
.DECADAL
){
1015 var _190
=365.2524*24*3600*1000;
1016 var _191
=1*(_185
-_184
)/_190
;
1017 return Math
.floor(0.5+1*_191
*_189
/_188
);
1020 Dygraph
.prototype.GetXAxis
=function(_192
,_193
,_194
){
1022 if(_194
<Dygraph
.MONTHLY
){
1023 var _196
=Dygraph
.SHORT_SPACINGS
[_194
];
1025 if(_194
<Dygraph
.HOURLY
){
1026 _192
=_196
*Math
.floor(0.5+_192
/_196
);
1028 for(var t
=_192
;t
<=_193
;t
+=_196
){
1030 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
1031 if(frac
==0||_194
>=Dygraph
.DAILY
){
1032 _195
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_197
)});
1034 _195
.push({v
:t
,label
:this.hmsString_(t
)});
1040 if(_194
==Dygraph
.MONTHLY
){
1041 _198
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
1043 if(_194
==Dygraph
.QUARTERLY
){
1046 if(_194
==Dygraph
.BIANNUAL
){
1049 if(_194
==Dygraph
.ANNUAL
){
1052 if(_194
==Dygraph
.DECADAL
){
1060 var _200
=new Date(_192
).getFullYear();
1061 var _201
=new Date(_193
).getFullYear();
1062 var _202
=Dygraph
.zeropad
;
1063 for(var i
=_200
;i
<=_201
;i
++){
1067 for(var j
=0;j
<_198
.length
;j
++){
1068 var _203
=i
+"/"+_202(1+_198[j])+"/01";
1069 var t
=Date
.parse(_203
);
1073 _195
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
1079 Dygraph
.dateTicker
=function(_204
,_205
,self
){
1081 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
1082 var _207
=self
.NumXTicks(_204
,_205
,i
);
1083 if(self
.width_
/_207
>=self
.attr_("pixelsPerXLabel")){
1089 return self
.GetXAxis(_204
,_205
,_206
);
1093 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
1095 var _211
,low_val
,high_val
,nTicks
;
1096 var _212
=self
.attr_("pixelsPerYLabel");
1097 for(var i
=-10;i
<50;i
++){
1098 var _213
=Math
.pow(10,i
);
1099 for(var j
=0;j
<_210
.length
;j
++){
1101 low_val
=Math
.floor(minV
/_211
)*_211
;
1102 high_val
=Math
.ceil(maxV
/_211
)*_211
;
1103 nTicks
=(high_val
-low_val
)/_211
;
1104 var _214
=self
.height_
/nTicks
;
1114 for(var i
=0;i
<nTicks
;i
++){
1115 var _216
=low_val
+i
*_211
;
1116 var _217
=self
.round_(_216
,2);
1117 if(self
.attr_("labelsKMB")){
1120 _217
=self
.round_(_216
/(k
*k
*k
),1)+"B";
1123 _217
=self
.round_(_216
/(k
*k
),1)+"M";
1126 _217
=self
.round_(_216
/k
,1)+"K";
1131 _215
.push({label
:_217
,v
:_216
});
1135 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
1136 var _221
=Dygraph
.numericTicks(minY
,maxY
,this);
1137 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_221
});
1139 Dygraph
.prototype.extremeValues_
=function(_222
){
1140 var minY
=null,maxY
=null;
1141 var bars
=this.attr_("errorBars")||this.attr_("customBars");
1143 for(var j
=0;j
<_222
.length
;j
++){
1144 var y
=_222
[j
][1][0];
1148 var low
=y
-_222
[j
][1][1];
1149 var high
=y
+_222
[j
][1][2];
1156 if(maxY
==null||high
>maxY
){
1159 if(minY
==null||low
<minY
){
1164 for(var j
=0;j
<_222
.length
;j
++){
1169 if(maxY
==null||y
>maxY
){
1172 if(minY
==null||y
<minY
){
1179 Dygraph
.prototype.drawGraph_
=function(data
){
1180 var minY
=null,maxY
=null;
1181 this.layout_
.removeAllDatasets();
1183 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
1184 for(var i
=1;i
<data
[0].length
;i
++){
1186 for(var j
=0;j
<data
.length
;j
++){
1187 var date
=data
[j
][0];
1188 _226
[j
]=[date
,data
[j
][i
]];
1190 _226
=this.rollingAverage(_226
,this.rollPeriod_
);
1191 var bars
=this.attr_("errorBars")||this.attr_("customBars");
1192 if(this.dateWindow_
){
1193 var low
=this.dateWindow_
[0];
1194 var high
=this.dateWindow_
[1];
1196 for(var k
=0;k
<_226
.length
;k
++){
1197 if(_226
[k
][0]>=low
&&_226
[k
][0]<=high
){
1203 var _228
=this.extremeValues_(_226
);
1206 if(!minY
||_229
<minY
){
1209 if(!maxY
||_230
>maxY
){
1214 for(var j
=0;j
<_226
.length
;j
++){
1215 vals
[j
]=[_226
[j
][0],_226
[j
][1][0],_226
[j
][1][1],_226
[j
][1][2]];
1217 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
1219 this.layout_
.addDataset(this.attr_("labels")[i
],_226
);
1222 if(this.valueRange_
!=null){
1223 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
1226 var _233
=maxY
+0.1*span
;
1227 var _234
=minY
-0.1*span
;
1228 if(_234
<0&&minY
>=0){
1231 if(_233
>0&&maxY
<=0){
1234 if(this.attr_("includeZero")){
1242 this.addYTicks_(_234
,_233
);
1245 this.layout_
.evaluateWithError();
1246 this.plotter_
.clear();
1247 this.plotter_
.render();
1248 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
1250 Dygraph
.prototype.rollingAverage
=function(_235
,_236
){
1254 var _236
=Math
.min(_236
,_235
.length
-1);
1256 var _238
=this.attr_("sigma");
1257 if(this.fractions_
){
1261 for(var i
=0;i
<_235
.length
;i
++){
1265 num
-=_235
[i
-_236
][1][0];
1266 den
-=_235
[i
-_236
][1][1];
1268 var date
=_235
[i
][0];
1269 var _241
=den
?num
/den
:0;
1270 if(this.attr_("errorBars")){
1271 if(this.wilsonInterval_
){
1273 var p
=_241
<0?0:_241
,n
=den
;
1274 var pm
=_238
*Math
.sqrt(p
*(1-p
)/n+_238*_238/(4*n
*n
));
1275 var _243
=1+_238
*_238
/den
;
1276 var low
=(p
+_238
*_238
/(2*den)-pm)/_243
;
1277 var high
=(p
+_238
*_238
/(2*den)+pm)/_243
;
1278 _237
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
1280 _237
[i
]=[date
,[0,0,0]];
1283 var _244
=den
?_238
*Math
.sqrt(_241
*(1-_241
)/den
):1;
1284 _237
[i
]=[date
,[mult
*_241
,mult
*_244
,mult
*_244
]];
1287 _237
[i
]=[date
,mult
*_241
];
1291 if(this.attr_("customBars")){
1296 for(var i
=0;i
<_235
.length
;i
++){
1297 var data
=_235
[i
][1];
1299 _237
[i
]=[_235
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
1305 var prev
=_235
[i
-_236
];
1311 _237
[i
]=[_235
[i
][0],[1*mid
/_246,1*(mid-low)/_246
,1*(high
-mid
)/_246
]];
1314 var _248
=Math
.min(_236
-1,_235
.length
-2);
1315 if(!this.attr_("errorBars")){
1319 for(var i
=0;i
<_235
.length
;i
++){
1322 for(var j
=Math
.max(0,i
-_236
+1);j
<i
+1;j
++){
1331 _237
[i
]=[_235
[i
][0],sum
/_250
];
1333 _237
[i
]=[_235
[i
][0],null];
1337 for(var i
=0;i
<_235
.length
;i
++){
1341 for(var j
=Math
.max(0,i
-_236
+1);j
<i
+1;j
++){
1342 var y
=_235
[j
][1][0];
1348 _251
+=Math
.pow(_235
[j
][1][1],2);
1351 var _244
=Math
.sqrt(_251
)/_250
;
1352 _237
[i
]=[_235
[i
][0],[sum
/_250
,_238
*_244
,_238
*_244
]];
1354 _237
[i
]=[_235
[i
][0],[null,null,null]];
1362 Dygraph
.dateParser
=function(_252
,self
){
1365 if(_252
.length
==10&&_252
.search("-")!=-1){
1366 _253
=_252
.replace("-","/","g");
1367 while(_253
.search("-")!=-1){
1368 _253
=_253
.replace("-","/");
1373 _253
=_252
.substr(0,4)+"/"+_252.substr(4,2)+"/"+_252
.substr(6,2);
1380 self
.error("Couldn't parse "+_252
+" as a date");
1384 Dygraph
.prototype.detectTypeFromString_
=function(str
){
1386 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
1389 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
1394 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
1395 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
1396 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
1398 this.attrs_
.xValueFormatter
=function(x
){
1401 this.attrs_
.xValueParser
=function(x
){
1402 return parseFloat(x
);
1404 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
1407 Dygraph
.prototype.parseCSV_
=function(data
){
1409 var _256
=data
.split("\n");
1410 var _257
=this.attr_("delimiter");
1411 if(_256
[0].indexOf(_257
)==-1&&_256
[0].indexOf("\t")>=0){
1415 if(this.labelsFromCSV_
){
1417 this.attrs_
.labels
=_256
[0].split(_257
);
1421 var _261
=this.attr_("labels").length
;
1422 for(var i
=_258
;i
<_256
.length
;i
++){
1430 var _263
=line
.split(_257
);
1436 this.detectTypeFromString_(_263
[0]);
1437 _259
=this.attr_("xValueParser");
1440 _264
[0]=_259(_263
[0],this);
1441 if(this.fractions_
){
1442 for(var j
=1;j
<_263
.length
;j
++){
1443 var vals
=_263
[j
].split("/");
1444 _264
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
1447 if(this.attr_("errorBars")){
1448 for(var j
=1;j
<_263
.length
;j
+=2){
1449 _264
[(j
+1)/2]=[parseFloat(_263
[j
]),parseFloat(_263
[j
+1])];
1452 if(this.attr_("customBars")){
1453 for(var j
=1;j
<_263
.length
;j
++){
1454 var vals
=_263
[j
].split(";");
1455 _264
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
1458 for(var j
=1;j
<_263
.length
;j
++){
1459 _264
[j
]=parseFloat(_263
[j
]);
1465 if(_264
.length
!=_261
){
1466 this.error("Number of columns in line "+i
+" ("+_264
.length
+") does not agree with number of labels ("+_261
+") "+line
);
1471 Dygraph
.prototype.parseArray_
=function(data
){
1473 this.error("Can't plot empty data set");
1476 if(data
[0].length
==0){
1477 this.error("Data set cannot contain an empty row");
1480 if(this.attr_("labels")==null){
1481 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
1482 this.attrs_
.labels
=["X"];
1483 for(var i
=1;i
<data
[0].length
;i
++){
1484 this.attrs_
.labels
.push("Y"+i
);
1487 if(Dygraph
.isDateLike(data
[0][0])){
1488 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
1489 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
1490 var _265
=Dygraph
.clone(data
);
1491 for(var i
=0;i
<data
.length
;i
++){
1492 if(_265
[i
].length
==0){
1493 this.error("Row "<<(1+i
)<<" of data is empty");
1496 if(_265
[i
][0]==null||typeof (_265
[i
][0].getTime
)!="function"){
1497 this.error("x value in row "<<(1+i
)<<" is not a Date");
1500 _265
[i
][0]=_265
[i
][0].getTime();
1504 this.attrs_
.xValueFormatter
=function(x
){
1507 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
1511 Dygraph
.prototype.parseDataTable_
=function(data
){
1512 var cols
=data
.getNumberOfColumns();
1513 var rows
=data
.getNumberOfRows();
1515 for(var i
=0;i
<cols
;i
++){
1516 _268
.push(data
.getColumnLabel(i
));
1518 this.attrs_
.labels
=_268
;
1519 var _269
=data
.getColumnType(0);
1521 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
1522 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
1523 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
1526 this.attrs_
.xValueFormatter
=function(x
){
1529 this.attrs_
.xValueParser
=function(x
){
1530 return parseFloat(x
);
1532 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
1534 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_269
+"')");
1539 for(var i
=0;i
<rows
;i
++){
1541 if(!data
.getValue(i
,0)){
1545 row
.push(data
.getValue(i
,0).getTime());
1547 row
.push(data
.getValue(i
,0));
1549 for(var j
=1;j
<cols
;j
++){
1550 row
.push(data
.getValue(i
,j
));
1556 Dygraph
.update
=function(self
,o
){
1557 if(typeof (o
)!="undefined"&&o
!==null){
1564 Dygraph
.isArrayLike
=function(o
){
1566 if((typ
!="object"&&!(typ
=="function"&&typeof (o
.item
)=="function"))||o
===null||typeof (o
.length
)!="number"||o
.nodeType
===3){
1571 Dygraph
.isDateLike
=function(o
){
1572 if(typeof (o
)!="object"||o
===null||typeof (o
.getTime
)!="function"){
1577 Dygraph
.clone
=function(o
){
1579 for(var i
=0;i
<o
.length
;i
++){
1580 if(Dygraph
.isArrayLike(o
[i
])){
1581 r
.push(Dygraph
.clone(o
[i
]));
1588 Dygraph
.prototype.start_
=function(){
1589 if(typeof this.file_
=="function"){
1590 this.loadedEvent_(this.file_());
1592 if(Dygraph
.isArrayLike(this.file_
)){
1593 this.rawData_
=this.parseArray_(this.file_
);
1594 this.drawGraph_(this.rawData_
);
1596 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
1597 this.rawData_
=this.parseDataTable_(this.file_
);
1598 this.drawGraph_(this.rawData_
);
1600 if(typeof this.file_
=="string"){
1601 if(this.file_
.indexOf("\n")>=0){
1602 this.loadedEvent_(this.file_
);
1604 var req
=new XMLHttpRequest();
1606 req
.onreadystatechange
=function(){
1607 if(req
.readyState
==4){
1608 if(req
.status
==200){
1609 _275
.loadedEvent_(req
.responseText
);
1613 req
.open("GET",this.file_
,true);
1617 this.error("Unknown data format: "+(typeof this.file_
));
1623 Dygraph
.prototype.updateOptions
=function(_276
){
1624 if(_276
.rollPeriod
){
1625 this.rollPeriod_
=_276
.rollPeriod
;
1627 if(_276
.dateWindow
){
1628 this.dateWindow_
=_276
.dateWindow
;
1630 if(_276
.valueRange
){
1631 this.valueRange_
=_276
.valueRange
;
1633 Dygraph
.update(this.user_attrs_
,_276
);
1634 this.labelsFromCSV_
=(this.attr_("labels")==null);
1635 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
1636 if(_276
["file"]&&_276
["file"]!=this.file_
){
1637 this.file_
=_276
["file"];
1640 this.drawGraph_(this.rawData_
);
1643 Dygraph
.prototype.adjustRoll
=function(_277
){
1644 this.rollPeriod_
=_277
;
1645 this.drawGraph_(this.rawData_
);
1647 Dygraph
.createCanvas
=function(){
1648 var _278
=document
.createElement("canvas");
1649 isIE
=(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
);
1651 _278
=G_vmlCanvasManager
.initElement(_278
);
1655 Dygraph
.GVizChart
=function(_279
){
1656 this.container
=_279
;
1658 Dygraph
.GVizChart
.prototype.draw
=function(data
,_280
){
1659 this.container
.innerHTML
="";
1660 this.date_graph
=new Dygraph(this.container
,data
,_280
);
1663 function RGBColor(_281
){
1665 if(_281
.charAt(0)=="#"){
1666 _281
=_281
.substr(1,6);
1668 _281
=_281
.replace(/ /g,"");
1669 _281
=_281
.toLowerCase();
1670 var _282
={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"};
1671 for(var key
in _282
){
1676 var _284
=[{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
){
1677 return [parseInt(bits
[1]),parseInt(bits
[2]),parseInt(bits
[3])];
1678 }},{re
:/^(\w{2})(\w{2})(\w{2})$/,example
:["#00ff00","336699"],process
:function(bits
){
1679 return [parseInt(bits
[1],16),parseInt(bits
[2],16),parseInt(bits
[3],16)];
1680 }},{re
:/^(\w{1})(\w{1})(\w{1})$/,example
:["#fb0","f0f"],process
:function(bits
){
1681 return [parseInt(bits
[1]+bits
[1],16),parseInt(bits
[2]+bits
[2],16),parseInt(bits
[3]+bits
[3],16)];
1683 for(var i
=0;i
<_284
.length
;i
++){
1685 var _287
=_284
[i
].process
;
1686 var bits
=re
.exec(_281
);
1688 channels
=_287(bits
);
1695 this.r
=(this.r
<0||isNaN(this.r
))?0:((this.r
>255)?255:this.r
);
1696 this.g
=(this.g
<0||isNaN(this.g
))?0:((this.g
>255)?255:this.g
);
1697 this.b
=(this.b
<0||isNaN(this.b
))?0:((this.b
>255)?255:this.b
);
1698 this.toRGB
=function(){
1699 return "rgb("+this.r
+", "+this.g
+", "+this.b
+")";
1701 this.toHex
=function(){
1702 var r
=this.r
.toString(16);
1703 var g
=this.g
.toString(16);
1704 var b
=this.b
.toString(16);