3 MochiKit.MochiKit 1.4 : PACKED VERSION
5 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6 diff against the source tree, not this file.
8 See <http://mochikit.com/> for documentation, downloads, license, etc.
10 (c) 2005 Bob Ippolito. All rights Reserved.
14 if(typeof (dojo
)!="undefined"){
15 dojo
.provide("MochiKit.Base");
17 if(typeof (MochiKit
)=="undefined"){
20 if(typeof (MochiKit
.Base
)=="undefined"){
23 if(typeof (MochiKit
.__export__
)=="undefined"){
24 MochiKit
.__export__
=(MochiKit
.__compat__
||(typeof (JSAN
)=="undefined"&&typeof (dojo
)=="undefined"));
26 MochiKit
.Base
.VERSION
="1.4";
27 MochiKit
.Base
.NAME
="MochiKit.Base";
28 MochiKit
.Base
.update
=function(_1
,_2
){
32 for(var i
=1;i
<arguments
.length
;i
++){
34 if(typeof (o
)!="undefined"&&o
!==null){
42 MochiKit
.Base
.update(MochiKit
.Base
,{__repr__
:function(){
43 return "["+this.NAME
+" "+this.VERSION
+"]";
44 },toString
:function(){
45 return this.__repr__();
46 },camelize
:function(_6
){
49 for(var i
=1;i
<_7
.length
;i
++){
50 cc
+=_7
[i
].charAt(0).toUpperCase()+_7
[i
].substring(1);
53 },counter
:function(n
){
54 if(arguments
.length
===0){
61 var me
=arguments
.callee
;
62 if(arguments
.length
==1){
66 },_flattenArray
:function(_d
,_e
){
67 for(var i
=0;i
<_e
.length
;i
++){
69 if(o
instanceof Array
){
70 arguments
.callee(_d
,o
);
76 },flattenArray
:function(lst
){
77 return MochiKit
.Base
._flattenArray([],lst
);
78 },flattenArguments
:function(lst
){
81 var _15
=m
.extend(null,arguments
);
84 if(o
&&typeof (o
)=="object"&&typeof (o
.length
)=="number"){
85 for(var i
=o
.length
-1;i
>=0;i
--){
93 },extend
:function(_18
,obj
,_1a
){
99 if(typeof (l
)!="number"){
100 if(typeof (MochiKit
.Iter
)!="undefined"){
101 obj
=MochiKit
.Iter
.list(obj
);
104 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
110 for(var i
=_1a
;i
<l
;i
++){
115 },updatetree
:function(_1d
,obj
){
119 for(var i
=1;i
<arguments
.length
;i
++){
121 if(typeof (o
)!="undefined"&&o
!==null){
124 if(typeof (_1d
[k
])=="object"&&typeof (v
)=="object"){
125 arguments
.callee(_1d
[k
],v
);
133 },setdefault
:function(_23
,obj
){
137 for(var i
=1;i
<arguments
.length
;i
++){
146 },keys
:function(obj
){
152 },values
:function(obj
){
158 },items
:function(obj
){
172 },_newNamedError
:function(_33
,_34
,_35
){
173 _35
.prototype=new MochiKit
.Base
.NamedError(_33
.NAME
+"."+_34
);
175 },operator
:{truth
:function(a
){
177 },lognot
:function(a
){
179 },identity
:function(a
){
201 },lshift
:function(a
,b
){
203 },rshift
:function(a
,b
){
205 },zrshift
:function(a
,b
){
224 return MochiKit
.Base
.compare(a
,b
)===0;
226 return MochiKit
.Base
.compare(a
,b
)!==0;
228 return MochiKit
.Base
.compare(a
,b
)==1;
230 return MochiKit
.Base
.compare(a
,b
)!=-1;
232 return MochiKit
.Base
.compare(a
,b
)==-1;
234 return MochiKit
.Base
.compare(a
,b
)!=1;
235 },logand
:function(a
,b
){
237 },logor
:function(a
,b
){
239 },contains
:function(a
,b
){
241 }},forwardCall
:function(_73
){
243 return this[_73
].apply(this,arguments
);
245 },itemgetter
:function(_74
){
246 return function(arg
){
249 },typeMatcher
:function(){
251 for(var i
=0;i
<arguments
.length
;i
++){
252 var typ
=arguments
[i
];
256 for(var i
=0;i
<arguments
.length
;i
++){
257 if(!(typeof (arguments
[i
]) in _76
)){
264 for(var i
=0;i
<arguments
.length
;i
++){
265 if(arguments
[i
]!==null){
270 },isUndefinedOrNull
:function(){
271 for(var i
=0;i
<arguments
.length
;i
++){
273 if(!(typeof (o
)=="undefined"||o
===null)){
278 },isEmpty
:function(obj
){
279 return !MochiKit
.Base
.isNotEmpty
.apply(this,arguments
);
280 },isNotEmpty
:function(obj
){
281 for(var i
=0;i
<arguments
.length
;i
++){
288 },isArrayLike
:function(){
289 for(var i
=0;i
<arguments
.length
;i
++){
292 if((typ
!="object"&&!(typ
=="function"&&typeof (o
.item
)=="function"))||o
===null||typeof (o
.length
)!="number"||o
.nodeType
===3){
297 },isDateLike
:function(){
298 for(var i
=0;i
<arguments
.length
;i
++){
300 if(typeof (o
)!="object"||o
===null||typeof (o
.getTime
)!="function"){
307 return MochiKit
.Base
.extend(null,arguments
,1);
310 for(var i
=1;i
<arguments
.length
;i
++){
311 _87
.push(fn(arguments
[i
]));
314 },map
:function(fn
,lst
){
316 var itr
=MochiKit
.Iter
;
317 var _8d
=m
.isArrayLike
;
318 if(arguments
.length
<=2){
326 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
330 return m
.extend(null,lst
);
333 for(var i
=0;i
<lst
.length
;i
++){
334 _8e
.push(fn(lst
[i
]));
342 for(i
=1;i
<arguments
.length
;i
++){
343 if(!_8d(arguments
[i
])){
345 return itr
.list(itr
.imap
.apply(null,arguments
));
347 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
350 var l
=arguments
[i
].length
;
351 if(_90
===null||_90
>l
){
358 for(var j
=1;j
<arguments
.length
;j
++){
359 _92
.push(arguments
[j
][i
]);
361 _8e
.push(fn
.apply(this,_92
));
365 },xfilter
:function(fn
){
368 fn
=MochiKit
.Base
.operator
.truth
;
370 for(var i
=1;i
<arguments
.length
;i
++){
377 },filter
:function(fn
,lst
,_9a
){
380 if(!m
.isArrayLike(lst
)){
382 lst
=MochiKit
.Iter
.list(lst
);
384 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
390 if(typeof (Array
.prototype.filter
)=="function"){
391 return Array
.prototype.filter
.call(lst
,fn
,_9a
);
393 if(typeof (_9a
)=="undefined"||_9a
===null){
394 for(var i
=0;i
<lst
.length
;i
++){
401 for(i
=0;i
<lst
.length
;i
++){
410 },_wrapDumbFunction
:function(_9f
){
412 switch(arguments
.length
){
416 return _9f(arguments
[0]);
418 return _9f(arguments
[0],arguments
[1]);
420 return _9f(arguments
[0],arguments
[1],arguments
[2]);
423 for(var i
=0;i
<arguments
.length
;i
++){
424 _a0
.push("arguments["+i
+"]");
426 return eval("(func("+_a0
.join(",")+"))");
428 },methodcaller
:function(_a2
){
429 var _a3
=MochiKit
.Base
.extend(null,arguments
,1);
430 if(typeof (_a2
)=="function"){
431 return function(obj
){
432 return _a2
.apply(obj
,_a3
);
435 return function(obj
){
436 return obj
[_a2
].apply(obj
,_a3
);
439 },method
:function(_a6
,_a7
){
441 return m
.bind
.apply(this,m
.extend([_a7
,_a6
],arguments
,2));
442 },compose
:function(f1
,f2
){
445 if(arguments
.length
===0){
446 throw new TypeError("compose() requires at least one argument");
448 for(var i
=0;i
<arguments
.length
;i
++){
450 if(typeof (fn
)!="function"){
451 throw new TypeError(m
.repr(fn
)+" is not a function");
457 for(var i
=_ab
.length
-1;i
>=0;i
--){
458 _af
=[_ab
[i
].apply(this,_af
)];
462 },bind
:function(_b1
,_b2
){
463 if(typeof (_b1
)=="string"){
467 var _b4
=_b1
.im_preargs
;
470 if(typeof (_b1
)=="function"&&typeof (_b1
.apply
)=="undefined"){
471 _b1
=m
._wrapDumbFunction(_b1
);
473 if(typeof (_b3
)!="function"){
476 if(typeof (_b2
)!="undefined"){
479 if(typeof (_b4
)=="undefined"){
484 m
.extend(_b4
,arguments
,2);
487 var me
=arguments
.callee
;
488 if(me
.im_preargs
.length
>0){
489 _b8
=m
.concat(me
.im_preargs
,_b8
);
495 return me
.im_func
.apply(_ba
,_b8
);
501 },bindMethods
:function(_bb
){
502 var _bc
=MochiKit
.Base
.bind
;
505 if(typeof (_be
)=="function"){
509 },registerComparator
:function(_bf
,_c0
,_c1
,_c2
){
510 MochiKit
.Base
.comparatorRegistry
.register(_bf
,_c0
,_c1
,_c2
);
511 },_primitives
:{"boolean":true,"string":true,"number":true},compare
:function(a
,b
){
515 var _c5
=(typeof (a
)=="undefined"||a
===null);
516 var _c6
=(typeof (b
)=="undefined"||b
===null);
529 var _c8
=m
._primitives
;
530 if(!(typeof (a
) in _c8
&&typeof (b
) in _c8
)){
532 return m
.comparatorRegistry
.match(a
,b
);
548 throw new TypeError(_c9(a
)+" and "+_c9(b
)+" can not be compared");
549 },compareDateLike
:function(a
,b
){
550 return MochiKit
.Base
.compare(a
.getTime(),b
.getTime());
551 },compareArrayLike
:function(a
,b
){
552 var _ce
=MochiKit
.Base
.compare
;
563 for(var i
=0;i
<_cf
;i
++){
564 var cmp
=_ce(a
[i
],b
[i
]);
570 },registerRepr
:function(_d3
,_d4
,_d5
,_d6
){
571 MochiKit
.Base
.reprRegistry
.register(_d3
,_d4
,_d5
,_d6
);
573 if(typeof (o
)=="undefined"){
581 if(typeof (o
.__repr__
)=="function"){
584 if(typeof (o
.repr
)=="function"&&o
.repr
!=arguments
.callee
){
588 return MochiKit
.Base
.reprRegistry
.match(o
);
591 if(typeof (o
.NAME
)=="string"&&(o
.toString
==Function
.prototype.toString
||o
.toString
==Object
.prototype.toString
)){
599 return "["+typeof (o
)+"]";
601 if(typeof (o
)=="function"){
602 o
=_d8
.replace(/^\s+/,"");
603 var idx
=o
.indexOf("{");
605 o
=o
.substr(0,idx
)+"{...}";
609 },reprArrayLike
:function(o
){
611 return "["+m
.map(m
.repr
,o
).join(", ")+"]";
612 },reprString
:function(o
){
613 return ("\""+o
.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
614 },reprNumber
:function(o
){
616 },registerJSON
:function(_de
,_df
,_e0
,_e1
){
617 MochiKit
.Base
.jsonRegistry
.register(_de
,_df
,_e0
,_e1
);
618 },evalJSON
:function(){
619 return eval("("+arguments
[0]+")");
620 },serializeJSON
:function(o
){
622 if(_e3
=="number"||_e3
=="boolean"){
630 var _e5
=m
.reprString
;
634 var me
=arguments
.callee
;
636 if(typeof (o
.__json__
)=="function"){
642 if(typeof (o
.json
)=="function"){
648 if(_e3
!="function"&&typeof (o
.length
)=="number"){
650 for(var i
=0;i
<o
.length
;i
++){
652 if(typeof (val
)!="string"){
657 return "["+res
.join(", ")+"]";
660 _e7
=m
.jsonRegistry
.match(o
);
670 if(_e3
=="undefined"){
671 throw new TypeError("undefined can not be serialized as JSON");
679 if(typeof (k
)=="number"){
682 if(typeof (k
)=="string"){
689 if(typeof (val
)!="string"){
692 res
.push(_ec
+":"+val
);
694 return "{"+res
.join(", ")+"}";
695 },objEqual
:function(a
,b
){
696 return (MochiKit
.Base
.compare(a
,b
)===0);
697 },arrayEqual
:function(_ef
,arr
){
698 if(_ef
.length
!=arr
.length
){
701 return (MochiKit
.Base
.compare(_ef
,arr
)===0);
704 var _f2
=MochiKit
.Base
.extend
;
705 for(var i
=0;i
<arguments
.length
;i
++){
706 _f2(_f1
,arguments
[i
]);
709 },keyComparator
:function(key
){
712 if(arguments
.length
==1){
713 return function(a
,b
){
714 return _f6(a
[key
],b
[key
]);
717 var _f9
=m
.extend(null,arguments
);
718 return function(a
,b
){
720 for(var i
=0;(_fc
===0)&&(i
<_f9
.length
);i
++){
722 _fc
=_f6(a
[key
],b
[key
]);
726 },reverseKeyComparator
:function(key
){
727 var _100
=MochiKit
.Base
.keyComparator
.apply(this,arguments
);
728 return function(a
,b
){
731 },partial
:function(func
){
733 return m
.bind
.apply(this,m
.extend([func
,undefined
],arguments
,1));
734 },listMinMax
:function(_105
,lst
){
739 var _108
=MochiKit
.Base
.compare
;
740 for(var i
=1;i
<lst
.length
;i
++){
742 if(_108(o
,cur
)==_105
){
748 return MochiKit
.Base
.listMinMax(1,arguments
);
750 return MochiKit
.Base
.listMinMax(-1,arguments
);
751 },findIdentical
:function(lst
,_10c
,_10d
,end
){
752 if(typeof (end
)=="undefined"||end
===null){
755 if(typeof (_10d
)=="undefined"||_10d
===null){
758 for(var i
=_10d
;i
<end
;i
++){
767 var args
=m
.extend(null,arguments
);
768 var _113
=args
.length
;
771 if(o
&&typeof (o
)=="object"&&typeof (o
.length
)=="number"){
773 for(var i
=o
.length
-1;i
>=0;i
--){
781 throw new TypeError("mean() requires at least one argument");
785 var data
=MochiKit
.Base
.flattenArguments(arguments
);
787 throw new TypeError("median() requires at least one argument");
790 if(data
.length
%2==0){
791 var _117
=data
.length
/2;
792 return (data
[_117
]+data
[_117
-1])/2;
794 return data
[(data
.length
-1)/2];
796 },findValue
:function(lst
,_119
,_11a
,end
){
797 if(typeof (end
)=="undefined"||end
===null){
800 if(typeof (_11a
)=="undefined"||_11a
===null){
803 var cmp
=MochiKit
.Base
.compare
;
804 for(var i
=_11a
;i
<end
;i
++){
805 if(cmp(lst
[i
],_119
)===0){
810 },nodeWalk
:function(node
,_11f
){
812 var _121
=MochiKit
.Base
.extend
;
814 var res
=_11f(_120
.shift());
819 },nameFunctions
:function(_123
){
821 if(typeof (base
)=="undefined"){
826 for(var name
in _123
){
828 if(typeof (o
)=="function"&&typeof (o
.NAME
)=="undefined"){
836 },queryString
:function(_127
,_128
){
837 if(typeof (MochiKit
.DOM
)!="undefined"&&arguments
.length
==1&&(typeof (_127
)=="string"||(typeof (_127
.nodeType
)!="undefined"&&_127
.nodeType
>0))){
838 var kv
=MochiKit
.DOM
.formContents(_127
);
842 if(arguments
.length
==1){
843 if(typeof (_127
.length
)=="number"&&_127
.length
==2){
844 return arguments
.callee(_127
[0],_127
[1]);
851 if(typeof (v
)=="function"){
854 if(typeof (v
)!="string"&&typeof (v
.length
)=="number"){
855 for(var i
=0;i
<v
.length
;i
++){
868 var len
=Math
.min(_127
.length
,_128
.length
);
869 var _130
=MochiKit
.Base
.urlEncode
;
870 for(var i
=0;i
<len
;i
++){
872 if(typeof (v
)!="undefined"&&v
!==null){
873 rval
.push(_130(_127
[i
])+"="+_130(v
));
876 return rval
.join("&");
877 },parseQueryString
:function(_131
,_132
){
878 var qstr
=(_131
.charAt(0)=="?")?_131
.substring(1):_131
;
879 var _134
=qstr
.replace(/\+/g,"%20").split(/(\&\;|\&\#38\;|\&|\&)/);
882 if(typeof (decodeURIComponent
)!="undefined"){
883 _136
=decodeURIComponent
;
888 for(var i
=0;i
<_134
.length
;i
++){
889 var pair
=_134
[i
].split("=");
890 var name
=_136(pair
.shift());
895 if(!(arr
instanceof Array
)){
899 arr
.push(_136(pair
.join("=")));
902 for(i
=0;i
<_134
.length
;i
++){
903 pair
=_134
[i
].split("=");
904 var name
=pair
.shift();
908 o
[_136(name
)]=_136(pair
.join("="));
913 MochiKit
.Base
.AdapterRegistry
=function(){
916 MochiKit
.Base
.AdapterRegistry
.prototype={register
:function(name
,_13c
,wrap
,_13e
){
918 this.pairs
.unshift([name
,_13c
,wrap
]);
920 this.pairs
.push([name
,_13c
,wrap
]);
923 for(var i
=0;i
<this.pairs
.length
;i
++){
924 var pair
=this.pairs
[i
];
925 if(pair
[1].apply(this,arguments
)){
926 return pair
[2].apply(this,arguments
);
929 throw MochiKit
.Base
.NotFound
;
930 },unregister
:function(name
){
931 for(var i
=0;i
<this.pairs
.length
;i
++){
932 var pair
=this.pairs
[i
];
934 this.pairs
.splice(i
,1);
940 MochiKit
.Base
.EXPORT
=["flattenArray","noop","camelize","counter","clone","extend","update","updatetree","setdefault","keys","values","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","methodcaller","compose","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments","method","average","mean","median"];
941 MochiKit
.Base
.EXPORT_OK
=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
942 MochiKit
.Base
._exportSymbols
=function(_144
,_145
){
943 if(!MochiKit
.__export__
){
946 var all
=_145
.EXPORT_TAGS
[":all"];
947 for(var i
=0;i
<all
.length
;i
++){
948 _144
[all
[i
]]=_145
[all
[i
]];
951 MochiKit
.Base
.__new__
=function(){
953 m
.noop
=m
.operator
.identity
;
954 m
.forward
=m
.forwardCall
;
956 if(typeof (encodeURIComponent
)!="undefined"){
957 m
.urlEncode
=function(_149
){
958 return encodeURIComponent(_149
).replace(/\'/g,"%27");
961 m
.urlEncode
=function(_14a
){
962 return escape(_14a
).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval
.replace(/\'/g,"%27");
965 m
.NamedError
=function(name
){
969 m
.NamedError
.prototype=new Error();
970 m
.update(m
.NamedError
.prototype,{repr
:function(){
971 if(this.message
&&this.message
!=this.name
){
972 return this.name
+"("+m
.repr(this.message
)+")";
974 return this.name
+"()";
976 },toString
:m
.forwardCall("repr")});
977 m
.NotFound
=new m
.NamedError("MochiKit.Base.NotFound");
978 m
.listMax
=m
.partial(m
.listMinMax
,1);
979 m
.listMin
=m
.partial(m
.listMinMax
,-1);
980 m
.isCallable
=m
.typeMatcher("function");
981 m
.isUndefined
=m
.typeMatcher("undefined");
982 m
.merge
=m
.partial(m
.update
,null);
983 m
.zip
=m
.partial(m
.map
,null);
985 m
.comparatorRegistry
=new m
.AdapterRegistry();
986 m
.registerComparator("dateLike",m
.isDateLike
,m
.compareDateLike
);
987 m
.registerComparator("arrayLike",m
.isArrayLike
,m
.compareArrayLike
);
988 m
.reprRegistry
=new m
.AdapterRegistry();
989 m
.registerRepr("arrayLike",m
.isArrayLike
,m
.reprArrayLike
);
990 m
.registerRepr("string",m
.typeMatcher("string"),m
.reprString
);
991 m
.registerRepr("numbers",m
.typeMatcher("number","boolean"),m
.reprNumber
);
992 m
.jsonRegistry
=new m
.AdapterRegistry();
993 var all
=m
.concat(m
.EXPORT
,m
.EXPORT_OK
);
994 m
.EXPORT_TAGS
={":common":m
.concat(m
.EXPORT_OK
),":all":all
};
995 m
.nameFunctions(this);
997 MochiKit
.Base
.__new__();
998 if(MochiKit
.__export__
){
999 compare
=MochiKit
.Base
.compare
;
1000 compose
=MochiKit
.Base
.compose
;
1001 serializeJSON
=MochiKit
.Base
.serializeJSON
;
1003 MochiKit
.Base
._exportSymbols(this,MochiKit
.Base
);
1006 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
};
1007 DygraphLayout
=function(_1
,_2
){
1010 MochiKit
.Base
.update(this.options
,_2
?_2
:{});
1011 this.datasets
=new Array();
1013 DygraphLayout
.prototype.attr_
=function(_3
){
1014 return this.dygraph_
.attr_(_3
);
1016 DygraphLayout
.prototype.addDataset
=function(_4
,_5
){
1017 this.datasets
[_4
]=_5
;
1019 DygraphLayout
.prototype.evaluate
=function(){
1020 this._evaluateLimits();
1021 this._evaluateLineCharts();
1022 this._evaluateLineTicks();
1024 DygraphLayout
.prototype._evaluateLimits
=function(){
1025 this.minxval
=this.maxxval
=null;
1026 for(var _6
in this.datasets
){
1027 var _7
=this.datasets
[_6
];
1029 if(!this.minxval
||x1
<this.minxval
){
1032 var x2
=_7
[_7
.length
-1][0];
1033 if(!this.maxxval
||x2
>this.maxxval
){
1037 this.xrange
=this.maxxval
-this.minxval
;
1038 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
1039 this.minyval
=this.options
.yAxis
[0];
1040 this.maxyval
=this.options
.yAxis
[1];
1041 this.yrange
=this.maxyval
-this.minyval
;
1042 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
1044 DygraphLayout
.prototype._evaluateLineCharts
=function(){
1045 this.points
=new Array();
1046 for(var _10
in this.datasets
){
1047 var _11
=this.datasets
[_10
];
1048 for(var j
=0;j
<_11
.length
;j
++){
1050 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
};
1057 if((_14
.x
>=0)&&(_14
.x
<=1)){
1058 this.points
.push(_14
);
1063 DygraphLayout
.prototype._evaluateLineTicks
=function(){
1064 this.xticks
=new Array();
1065 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
1066 var _16
=this.options
.xTicks
[i
];
1068 var pos
=this.xscale
*(_16
.v
-this.minxval
);
1069 if((pos
>=0)&&(pos
<=1)){
1070 this.xticks
.push([pos
,_17
]);
1073 this.yticks
=new Array();
1074 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
1075 var _16
=this.options
.yTicks
[i
];
1077 var pos
=1-(this.yscale
*(_16
.v
-this.minyval
));
1078 if((pos
>=0)&&(pos
<=1)){
1079 this.yticks
.push([pos
,_17
]);
1083 DygraphLayout
.prototype.evaluateWithError
=function(){
1085 if(!this.options
.errorBars
){
1089 for(var _19
in this.datasets
){
1091 var _20
=this.datasets
[_19
];
1092 for(var j
=0;j
<_20
.length
;j
++,i
++){
1094 var xv
=parseFloat(_21
[0]);
1095 var yv
=parseFloat(_21
[1]);
1096 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
1097 this.points
[i
].errorMinus
=parseFloat(_21
[2]);
1098 this.points
[i
].errorPlus
=parseFloat(_21
[3]);
1103 DygraphLayout
.prototype.removeAllDatasets
=function(){
1104 delete this.datasets
;
1105 this.datasets
=new Array();
1107 DygraphLayout
.prototype.updateOptions
=function(_24
){
1108 MochiKit
.Base
.update(this.options
,_24
?_24
:{});
1110 DygraphCanvasRenderer
=function(_25
,_26
,_27
,_28
){
1112 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)"};
1113 MochiKit
.Base
.update(this.options
,_28
);
1116 this.container
=this.element
.parentNode
;
1117 this.isIE
=(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
);
1118 if(this.isIE
&&!isNil(G_vmlCanvasManager
)){
1121 this.renderDelay
=null;
1122 this.clearDelay
=null;
1123 this.element
=G_vmlCanvasManager
.initElement(this.element
);
1125 this.height
=this.element
.height
;
1126 this.width
=this.element
.width
;
1127 if(!this.isIE
&&!(DygraphCanvasRenderer
.isSupported(this.element
))){
1128 throw "Canvas is not supported.";
1130 this.xlabels
=new Array();
1131 this.ylabels
=new Array();
1132 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
1133 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
1134 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
1135 this.container
.style
.position
="relative";
1136 this.container
.style
.width
=this.width
+"px";
1138 DygraphCanvasRenderer
.prototype.clear
=function(){
1141 if(this.clearDelay
){
1142 this.clearDelay
.cancel();
1143 this.clearDelay
=null;
1145 var _29
=this.element
.getContext("2d");
1148 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
1149 this.clearDelay
.addCallback(bind(this.clear
,this));
1153 var _29
=this.element
.getContext("2d");
1154 _29
.clearRect(0,0,this.width
,this.height
);
1155 for(var i
=0;i
<this.xlabels
.length
;i
++){
1156 var el
=this.xlabels
[i
];
1157 el
.parentNode
.removeChild(el
);
1159 for(var i
=0;i
<this.ylabels
.length
;i
++){
1160 var el
=this.ylabels
[i
];
1161 el
.parentNode
.removeChild(el
);
1163 this.xlabels
=new Array();
1164 this.ylabels
=new Array();
1166 DygraphCanvasRenderer
.isSupported
=function(_31
){
1169 if(MochiKit
.Base
.isUndefinedOrNull(_31
)){
1170 _32
=document
.createElement("canvas");
1174 var _33
=_32
.getContext("2d");
1177 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
1178 var _35
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
1179 if((!ie
)||(ie
[1]<6)||(_35
)){
1186 DygraphCanvasRenderer
.prototype.render
=function(){
1187 var ctx
=this.element
.getContext("2d");
1188 if(this.options
.drawYGrid
){
1189 var _37
=this.layout
.yticks
;
1191 ctx
.strokeStyle
=this.options
.gridLineColor
;
1192 ctx
.lineWidth
=this.options
.axisLineWidth
;
1193 for(var i
=0;i
<_37
.length
;i
++){
1195 var y
=this.area
.y
+_37
[i
][0]*this.area
.h
;
1198 ctx
.lineTo(x
+this.area
.w
,y
);
1203 if(this.options
.drawXGrid
){
1204 var _37
=this.layout
.xticks
;
1206 ctx
.strokeStyle
=this.options
.gridLineColor
;
1207 ctx
.lineWidth
=this.options
.axisLineWidth
;
1208 for(var i
=0;i
<_37
.length
;i
++){
1209 var x
=this.area
.x
+_37
[i
][0]*this.area
.w
;
1210 var y
=this.area
.y
+this.area
.h
;
1213 ctx
.lineTo(x
,this.area
.y
);
1218 this._renderLineChart();
1221 DygraphCanvasRenderer
.prototype._renderAxis
=function(){
1222 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
1225 var _40
=this.element
.getContext("2d");
1226 var _41
={"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
,"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"};
1227 var _42
=function(txt
){
1228 var div
=document
.createElement("div");
1229 for(var _45
in _41
){
1230 div
.style
[_45
]=_41
[_45
];
1232 div
.appendChild(document
.createTextNode(txt
));
1236 _40
.strokeStyle
=this.options
.axisLineColor
;
1237 _40
.lineWidth
=this.options
.axisLineWidth
;
1238 if(this.options
.drawYAxis
){
1239 if(this.layout
.yticks
){
1240 for(var i
=0;i
<this.layout
.yticks
.length
;i
++){
1241 var _46
=this.layout
.yticks
[i
];
1242 if(typeof (_46
)=="function"){
1246 var y
=this.area
.y
+_46
[0]*this.area
.h
;
1249 _40
.lineTo(x
-this.options
.axisTickSize
,y
);
1252 var _47
=_42(_46
[1]);
1253 var top
=(y
-this.options
.axisLabelFontSize
/2);
1257 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
1258 _47
.style
.bottom
="0px";
1260 _47
.style
.top
=top
+"px";
1262 _47
.style
.left
="0px";
1263 _47
.style
.textAlign
="right";
1264 _47
.style
.width
=this.options
.yAxisLabelWidth
+"px";
1265 this.container
.appendChild(_47
);
1266 this.ylabels
.push(_47
);
1268 var _49
=this.ylabels
[0];
1269 var _50
=this.options
.axisLabelFontSize
;
1270 var _51
=parseInt(_49
.style
.top
)+_50
;
1271 if(_51
>this.height
-_50
){
1272 _49
.style
.top
=(parseInt(_49
.style
.top
)-_50
/2)+"px";
1276 _40
.moveTo(this.area
.x
,this.area
.y
);
1277 _40
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
1281 if(this.options
.drawXAxis
){
1282 if(this.layout
.xticks
){
1283 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
1284 var _46
=this.layout
.xticks
[i
];
1285 if(typeof (dataset
)=="function"){
1288 var x
=this.area
.x
+_46
[0]*this.area
.w
;
1289 var y
=this.area
.y
+this.area
.h
;
1292 _40
.lineTo(x
,y
+this.options
.axisTickSize
);
1295 var _47
=_42(_46
[1]);
1296 _47
.style
.textAlign
="center";
1297 _47
.style
.bottom
="0px";
1298 var _52
=(x
-this.options
.axisLabelWidth
/2);
1299 if(_52
+this.options
.axisLabelWidth
>this.width
){
1300 _52
=this.width
-this.options
.xAxisLabelWidth
;
1301 _47
.style
.textAlign
="right";
1305 _47
.style
.textAlign
="left";
1307 _47
.style
.left
=_52
+"px";
1308 _47
.style
.width
=this.options
.xAxisLabelWidth
+"px";
1309 this.container
.appendChild(_47
);
1310 this.xlabels
.push(_47
);
1314 _40
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
1315 _40
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
1321 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
1322 var _53
=this.element
.getContext("2d");
1323 var _54
=this.options
.colorScheme
.length
;
1324 var _55
=this.options
.colorScheme
;
1325 var _56
=MochiKit
.Base
.keys(this.layout
.datasets
);
1326 var _57
=this.layout
.options
.errorBars
;
1328 var _59
=MochiKit
.Base
.bind
;
1329 var _60
=MochiKit
.Base
.partial
;
1330 for(var i
=0;i
<this.layout
.points
.length
;i
++){
1331 var _61
=this.layout
.points
[i
];
1332 _61
.canvasx
=this.area
.w
*_61
.x
+this.area
.x
;
1333 _61
.canvasy
=this.area
.h
*_61
.y
+this.area
.y
;
1335 var _62
=function(x
){
1336 return x
&&!isNaN(x
);
1338 var _63
=function(ctx
){
1339 for(var i
=0;i
<_58
;i
++){
1343 var _61
=this.layout
.points
[0];
1344 var _66
=this.dygraph_
.attr_("pointSize");
1345 var _67
=null,prevY
=null;
1346 var _68
=this.dygraph_
.attr_("drawPoints");
1347 var _69
=this.layout
.points
;
1348 for(var j
=0;j
<_69
.length
;j
++){
1351 if(!_62(_61
.canvasy
)){
1354 var _70
=(!_67
&&(j
==_69
.length
-1||!_62(_69
[j
+1].canvasy
)));
1360 ctx
.strokeStyle
=_65
;
1361 ctx
.lineWidth
=this.options
.strokeWidth
;
1362 ctx
.moveTo(_67
,prevY
);
1365 ctx
.lineTo(_67
,prevY
);
1371 ctx
.arc(_61
.canvasx
,_61
.canvasy
,_66
,0,360,false);
1379 var _71
=function(ctx
){
1380 for(var i
=0;i
<_58
;i
++){
1384 _53
.strokeStyle
=_73
;
1385 _53
.lineWidth
=this.options
.strokeWidth
;
1389 var _77
=this.layout
.yscale
;
1390 var rgb
=new RGBColor(_73
);
1391 var _79
="rgba("+rgb
.r
+","+rgb
.g
+","+rgb
.b
+",0.15)";
1394 for(var j
=0;j
<this.layout
.points
.length
;j
++){
1395 var _80
=this.layout
.points
[j
];
1398 if(!_80
.y
||isNaN(_80
.y
)){
1402 var _81
=[_80
.y
-_80
.errorPlus
*_77
,_80
.y
+_80
.errorMinus
*_77
];
1403 _81
[0]=this.area
.h
*_81
[0]+this.area
.y
;
1404 _81
[1]=this.area
.h
*_81
[1]+this.area
.y
;
1406 ctx
.moveTo(_74
,_75
[0]);
1407 ctx
.lineTo(_80
.canvasx
,_81
[0]);
1408 ctx
.lineTo(_80
.canvasx
,_81
[1]);
1409 ctx
.lineTo(_74
,_75
[1]);
1426 Dygraph
=function(div
,_82
,_83
){
1427 if(arguments
.length
>0){
1428 if(arguments
.length
==4){
1429 this.warn("Using deprecated four-argument dygraph constructor");
1430 this.__old_init__(div
,_82
,arguments
[2],arguments
[3]);
1432 this.__init__(div
,_82
,_83
);
1436 Dygraph
.NAME
="Dygraph";
1437 Dygraph
.VERSION
="1.2";
1438 Dygraph
.__repr__
=function(){
1439 return "["+this.NAME
+" "+this.VERSION
+"]";
1441 Dygraph
.toString
=function(){
1442 return this.__repr__();
1444 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
1445 Dygraph
.DEFAULT_WIDTH
=480;
1446 Dygraph
.DEFAULT_HEIGHT
=320;
1447 Dygraph
.AXIS_LINE_WIDTH
=0.3;
1448 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
,sigma
:2,errorBars
:false,fractions
:false,wilsonInterval
:true,customBars
:false};
1453 Dygraph
.prototype.__old_init__
=function(div
,_84
,_85
,_86
){
1456 for(var i
=0;i
<_85
.length
;i
++){
1459 MochiKit
.Base
.update(_86
,{"labels":_87
});
1461 this.__init__(div
,_84
,_86
);
1463 Dygraph
.prototype.__init__
=function(div
,_88
,_89
){
1469 this.rollPeriod_
=_89
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
1470 this.previousVerticalX_
=-1;
1471 this.fractions_
=_89
.fractions
||false;
1472 this.dateWindow_
=_89
.dateWindow
||null;
1473 this.valueRange_
=_89
.valueRange
||null;
1474 this.wilsonInterval_
=_89
.wilsonInterval
||true;
1476 if(div
.style
.width
==""){
1477 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
1479 if(div
.style
.height
==""){
1480 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
1482 this.width_
=parseInt(div
.style
.width
,10);
1483 this.height_
=parseInt(div
.style
.height
,10);
1484 this.user_attrs_
={};
1485 MochiKit
.Base
.update(this.user_attrs_
,_89
);
1487 MochiKit
.Base
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
1488 this.labelsFromCSV_
=(this.attr_("labels")==null);
1489 this.createInterface_();
1490 this.layoutOptions_
={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
1491 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
1492 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
1493 this.layout_
=new DygraphLayout(this,this.layoutOptions_
);
1494 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
1495 MochiKit
.Base
.update(this.renderOptions_
,this.attrs_
);
1496 MochiKit
.Base
.update(this.renderOptions_
,this.user_attrs_
);
1497 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
1498 this.createStatusMessage_();
1499 this.createRollInterface_();
1500 this.createDragInterface_();
1503 Dygraph
.prototype.attr_
=function(_90
){
1504 if(typeof (this.user_attrs_
[_90
])!="undefined"){
1505 return this.user_attrs_
[_90
];
1507 if(typeof (this.attrs_
[_90
])!="undefined"){
1508 return this.attrs_
[_90
];
1514 Dygraph
.prototype.log
=function(_91
,_92
){
1515 if(typeof (console
)!="undefined"){
1518 console
.debug("dygraphs: "+_92
);
1521 console
.info("dygraphs: "+_92
);
1523 case Dygraph
.WARNING
:
1524 console
.warn("dygraphs: "+_92
);
1527 console
.error("dygraphs: "+_92
);
1532 Dygraph
.prototype.info
=function(_93
){
1533 this.log(Dygraph
.INFO
,_93
);
1535 Dygraph
.prototype.warn
=function(_94
){
1536 this.log(Dygraph
.WARNING
,_94
);
1538 Dygraph
.prototype.error
=function(_95
){
1539 this.log(Dygraph
.ERROR
,_95
);
1541 Dygraph
.prototype.rollPeriod
=function(){
1542 return this.rollPeriod_
;
1544 Dygraph
.addEvent
=function(el
,evt
,fn
){
1545 var _98
=function(e
){
1551 if(window
.addEventListener
){
1552 el
.addEventListener(evt
,_98
,false);
1554 el
.attachEvent("on"+evt
,_98
);
1557 Dygraph
.prototype.createInterface_
=function(){
1558 var _100
=this.maindiv_
;
1559 this.graphDiv
=document
.createElement("div");
1560 this.graphDiv
.style
.width
=this.width_
+"px";
1561 this.graphDiv
.style
.height
=this.height_
+"px";
1562 _100
.appendChild(this.graphDiv
);
1563 this.canvas_
=document
.createElement("canvas");
1564 this.canvas_
.style
.position
="absolute";
1565 this.canvas_
.width
=this.width_
;
1566 this.canvas_
.height
=this.height_
;
1567 this.graphDiv
.appendChild(this.canvas_
);
1568 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
1570 Dygraph
.addEvent(this.hidden_
,"mousemove",function(e
){
1573 Dygraph
.addEvent(this.hidden_
,"mouseout",function(e
){
1577 Dygraph
.prototype.createPlotKitCanvas_
=function(_102
){
1578 var h
=document
.createElement("canvas");
1579 h
.style
.position
="absolute";
1580 h
.style
.top
=_102
.style
.top
;
1581 h
.style
.left
=_102
.style
.left
;
1582 h
.width
=this.width_
;
1583 h
.height
=this.height_
;
1584 this.graphDiv
.appendChild(h
);
1587 Dygraph
.hsvToRGB
=function(hue
,_105
,_106
){
1596 var i
=Math
.floor(hue
*6);
1598 var p
=_106
*(1-_105
);
1599 var q
=_106
*(1-(_105
*f
));
1600 var t
=_106
*(1-(_105
*(1-f
)));
1635 red
=Math
.floor(255*red
+0.5);
1636 _108
=Math
.floor(255*_108
+0.5);
1637 blue
=Math
.floor(255*blue
+0.5);
1638 return "rgb("+red
+","+_108
+","+blue
+")";
1640 Dygraph
.prototype.setColors_
=function(){
1641 var num
=this.attr_("labels").length
-1;
1643 var _115
=this.attr_("colors");
1645 var sat
=this.attr_("colorSaturation")||1;
1646 var val
=this.attr_("colorValue")||0.5;
1647 for(var i
=1;i
<=num
;i
++){
1648 var hue
=(1*i
/(1+num
));
1649 this.colors_
.push(Dygraph
.hsvToRGB(hue
,sat
,val
));
1652 for(var i
=0;i
<num
;i
++){
1653 var _118
=_115
[i
%_115
.length
];
1654 this.colors_
.push(_118
);
1657 this.renderOptions_
.colorScheme
=this.colors_
;
1658 MochiKit
.Base
.update(this.plotter_
.options
,this.renderOptions_
);
1659 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
1660 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
1662 Dygraph
.findPosX
=function(obj
){
1664 if(obj
.offsetParent
){
1665 while(obj
.offsetParent
){
1666 _120
+=obj
.offsetLeft
;
1667 obj
=obj
.offsetParent
;
1676 Dygraph
.findPosY
=function(obj
){
1678 if(obj
.offsetParent
){
1679 while(obj
.offsetParent
){
1680 _121
+=obj
.offsetTop
;
1681 obj
=obj
.offsetParent
;
1690 Dygraph
.prototype.createStatusMessage_
=function(){
1691 if(!this.attr_("labelsDiv")){
1692 var _122
=this.attr_("labelsDivWidth");
1693 var _123
={"position":"absolute","fontSize":"14px","zIndex":10,"width":_122
+"px","top":"0px","left":(this.width_
-_122
-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
1694 MochiKit
.Base
.update(_123
,this.attr_("labelsDivStyles"));
1695 var div
=document
.createElement("div");
1696 for(var name
in _123
){
1697 div
.style
[name
]=_123
[name
];
1699 this.graphDiv
.appendChild(div
);
1700 this.attrs_
.labelsDiv
=div
;
1703 Dygraph
.prototype.createRollInterface_
=function(){
1704 var _125
=this.attr_("showRoller")?"block":"none";
1705 var _126
={"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_125
};
1706 var _127
=document
.createElement("input");
1709 _127
.value
=this.rollPeriod_
;
1710 for(var name
in _126
){
1711 _127
.style
[name
]=_126
[name
];
1713 var pa
=this.graphDiv
;
1714 pa
.appendChild(_127
);
1716 _127
.onchange
=function(){
1717 _129
.adjustRoll(_127
.value
);
1721 Dygraph
.pageX
=function(e
){
1723 return (!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
1726 var b
=document
.body
;
1727 return e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
1730 Dygraph
.pageY
=function(e
){
1732 return (!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
1735 var b
=document
.body
;
1736 return e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
1739 Dygraph
.prototype.createDragInterface_
=function(){
1749 var getX
=function(e
){
1750 return Dygraph
.pageX(e
)-px
;
1752 var getY
=function(e
){
1753 return Dygraph
.pageX(e
)-py
;
1755 Dygraph
.addEvent(this.hidden_
,"mousemove",function(_143
){
1759 self
.drawZoomRect_(_134
,_136
,_138
);
1763 Dygraph
.addEvent(this.hidden_
,"mousedown",function(_144
){
1765 px
=Dygraph
.findPosX(self
.canvas_
);
1766 py
=Dygraph
.findPosY(self
.canvas_
);
1770 Dygraph
.addEvent(document
,"mouseup",function(_145
){
1777 Dygraph
.addEvent(this.hidden_
,"mouseout",function(_146
){
1783 Dygraph
.addEvent(this.hidden_
,"mouseup",function(_147
){
1788 var _148
=Math
.abs(_136
-_134
);
1789 var _149
=Math
.abs(_137
-_135
);
1790 if(_148
<2&&_149
<2&&self
.attr_("clickCallback")!=null&&self
.lastx_
!=undefined
){
1791 self
.attr_("clickCallback")(_147
,new Date(self
.lastx_
));
1794 self
.doZoom_(Math
.min(_134
,_136
),Math
.max(_134
,_136
));
1796 self
.canvas_
.getContext("2d").clearRect(0,0,self
.canvas_
.width
,self
.canvas_
.height
);
1802 Dygraph
.addEvent(this.hidden_
,"dblclick",function(_150
){
1803 self
.dateWindow_
=null;
1804 self
.drawGraph_(self
.rawData_
);
1805 var _151
=self
.rawData_
[0][0];
1806 var _152
=self
.rawData_
[self
.rawData_
.length
-1][0];
1807 if(self
.attr_("zoomCallback")){
1808 self
.attr_("zoomCallback")(_151
,_152
);
1812 Dygraph
.prototype.drawZoomRect_
=function(_153
,endX
,_155
){
1813 var ctx
=this.canvas_
.getContext("2d");
1815 ctx
.clearRect(Math
.min(_153
,_155
),0,Math
.abs(_153
-_155
),this.height_
);
1818 ctx
.fillStyle
="rgba(128,128,128,0.33)";
1819 ctx
.fillRect(Math
.min(_153
,endX
),0,Math
.abs(endX
-_153
),this.height_
);
1822 Dygraph
.prototype.doZoom_
=function(lowX
,_157
){
1823 var _158
=this.layout_
.points
;
1826 for(var i
=0;i
<_158
.length
;i
++){
1827 var cx
=_158
[i
].canvasx
;
1829 if(cx
<lowX
&&(_159
==null||x
>_159
)){
1832 if(cx
>_157
&&(_160
==null||x
<_160
)){
1840 _160
=_158
[_158
.length
-1].xval
;
1842 this.dateWindow_
=[_159
,_160
];
1843 this.drawGraph_(this.rawData_
);
1844 if(this.attr_("zoomCallback")){
1845 this.attr_("zoomCallback")(_159
,_160
);
1848 Dygraph
.prototype.mouseMove_
=function(_162
){
1849 var _163
=Dygraph
.pageX(_162
)-Dygraph
.findPosX(this.hidden_
);
1850 var _164
=this.layout_
.points
;
1855 for(var i
=0;i
<_164
.length
;i
++){
1856 var dist
=Math
.abs(_164
[i
].canvasx
-_163
);
1864 _165
=_164
[idx
].xval
;
1866 if(_163
>_164
[_164
.length
-1].canvasx
){
1867 _165
=_164
[_164
.length
-1].xval
;
1870 for(var i
=0;i
<_164
.length
;i
++){
1871 if(_164
[i
].xval
==_165
){
1875 var _171
=this.attr_("highlightCircleSize");
1876 var ctx
=this.canvas_
.getContext("2d");
1877 if(this.previousVerticalX_
>=0){
1878 var px
=this.previousVerticalX_
;
1879 ctx
.clearRect(px
-_171
-1,0,2*_171
+2,this.height_
);
1881 var isOK
=function(x
){
1882 return x
&&!isNaN(x
);
1885 var _163
=_170
[0].canvasx
;
1886 var _173
=this.attr_("xValueFormatter")(_165
,this)+":";
1887 var clen
=this.colors_
.length
;
1888 for(var i
=0;i
<_170
.length
;i
++){
1889 if(!isOK(_170
[i
].canvasy
)){
1892 if(this.attr_("labelsSeparateLines")){
1896 var c
=new RGBColor(this.colors_
[i
%clen
]);
1897 _173
+=" <b><font color='"+c
.toHex()+"'>"+_175
.name
+"</font></b>:"+this.round_(_175
.yval
,2);
1899 this.attr_("labelsDiv").innerHTML
=_173
;
1902 for(var i
=0;i
<_170
.length
;i
++){
1903 if(!isOK(_170
[i
%clen
].canvasy
)){
1907 ctx
.fillStyle
=this.colors_
[i
%clen
];
1908 ctx
.arc(_163
,_170
[i
%clen
].canvasy
,_171
,0,360,false);
1912 this.previousVerticalX_
=_163
;
1915 Dygraph
.prototype.mouseOut_
=function(_177
){
1916 var ctx
=this.canvas_
.getContext("2d");
1917 ctx
.clearRect(0,0,this.width_
,this.height_
);
1918 this.attr_("labelsDiv").innerHTML
="";
1920 Dygraph
.zeropad
=function(x
){
1927 Dygraph
.prototype.hmsString_
=function(date
){
1928 var _179
=Dygraph
.zeropad
;
1929 var d
=new Date(date
);
1931 return _179(d
.getHours())+":"+_179(d
.getMinutes())+":"+_179(d
.getSeconds());
1934 return _179(d
.getHours())+":"+_179(d
.getMinutes());
1936 return _179(d
.getHours());
1940 Dygraph
.dateString_
=function(date
,self
){
1941 var _181
=Dygraph
.zeropad
;
1942 var d
=new Date(date
);
1943 var year
=""+d
.getFullYear();
1944 var _183
=_181(d
.getMonth()+1);
1945 var day
=_181(d
.getDate());
1947 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
1949 ret
=" "+self
.hmsString_(date
);
1951 return year
+"/"+_183+"/"+day
+ret
;
1953 Dygraph
.prototype.round_
=function(num
,_187
){
1954 var _188
=Math
.pow(10,_187
);
1955 return Math
.round(num
*_188
)/_188
;
1957 Dygraph
.prototype.loadedEvent_
=function(data
){
1958 this.rawData_
=this.parseCSV_(data
);
1959 this.drawGraph_(this.rawData_
);
1961 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
1962 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
1963 Dygraph
.prototype.addXTicks_
=function(){
1965 if(this.dateWindow_
){
1966 _190
=this.dateWindow_
[0];
1967 endDate
=this.dateWindow_
[1];
1969 _190
=this.rawData_
[0][0];
1970 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
1972 var _191
=this.attr_("xTicker")(_190
,endDate
,this);
1973 this.layout_
.updateOptions({xTicks
:_191
});
1976 Dygraph
.TEN_SECONDLY
=1;
1977 Dygraph
.THIRTY_SECONDLY
=2;
1979 Dygraph
.TEN_MINUTELY
=4;
1980 Dygraph
.THIRTY_MINUTELY
=5;
1982 Dygraph
.SIX_HOURLY
=7;
1986 Dygraph
.QUARTERLY
=11;
1987 Dygraph
.BIANNUAL
=12;
1990 Dygraph
.NUM_GRANULARITIES
=15;
1991 Dygraph
.SHORT_SPACINGS
=[];
1992 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
1993 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
1994 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
1995 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
1996 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
1997 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
1998 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
1999 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600*6;
2000 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
2001 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
2002 Dygraph
.prototype.NumXTicks
=function(_192
,_193
,_194
){
2003 if(_194
<Dygraph
.MONTHLY
){
2004 var _195
=Dygraph
.SHORT_SPACINGS
[_194
];
2005 return Math
.floor(0.5+1*(_193
-_192
)/_195
);
2009 if(_194
==Dygraph
.QUARTERLY
){
2012 if(_194
==Dygraph
.BIANNUAL
){
2015 if(_194
==Dygraph
.ANNUAL
){
2018 if(_194
==Dygraph
.DECADAL
){
2022 var _198
=365.2524*24*3600*1000;
2023 var _199
=1*(_193
-_192
)/_198
;
2024 return Math
.floor(0.5+1*_199
*_197
/_196
);
2027 Dygraph
.prototype.GetXAxis
=function(_200
,_201
,_202
){
2029 if(_202
<Dygraph
.MONTHLY
){
2030 var _204
=Dygraph
.SHORT_SPACINGS
[_202
];
2032 if(_202
<Dygraph
.HOURLY
){
2033 _200
=_204
*Math
.floor(0.5+_200
/_204
);
2035 for(var t
=_200
;t
<=_201
;t
+=_204
){
2037 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
2038 if(frac
==0||_202
>=Dygraph
.DAILY
){
2039 _203
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_205
)});
2041 _203
.push({v
:t
,label
:this.hmsString_(t
)});
2047 if(_202
==Dygraph
.MONTHLY
){
2048 _206
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
2050 if(_202
==Dygraph
.QUARTERLY
){
2053 if(_202
==Dygraph
.BIANNUAL
){
2056 if(_202
==Dygraph
.ANNUAL
){
2059 if(_202
==Dygraph
.DECADAL
){
2067 var _208
=new Date(_200
).getFullYear();
2068 var _209
=new Date(_201
).getFullYear();
2069 var _210
=Dygraph
.zeropad
;
2070 for(var i
=_208
;i
<=_209
;i
++){
2074 for(var j
=0;j
<_206
.length
;j
++){
2075 var _211
=i
+"/"+_210(1+_206[j])+"/01";
2076 var t
=Date
.parse(_211
);
2080 _203
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
2086 Dygraph
.dateTicker
=function(_212
,_213
,self
){
2088 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
2089 var _215
=self
.NumXTicks(_212
,_213
,i
);
2090 if(self
.width_
/_215
>=self
.attr_("pixelsPerXLabel")){
2096 return self
.GetXAxis(_212
,_213
,_214
);
2100 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
2102 var _219
,low_val
,high_val
,nTicks
;
2103 var _220
=self
.attr_("pixelsPerYLabel");
2104 for(var i
=-10;i
<50;i
++){
2105 var _221
=Math
.pow(10,i
);
2106 for(var j
=0;j
<_218
.length
;j
++){
2108 low_val
=Math
.floor(minV
/_219
)*_219
;
2109 high_val
=Math
.ceil(maxV
/_219
)*_219
;
2110 nTicks
=(high_val
-low_val
)/_219
;
2111 var _222
=self
.height_
/nTicks
;
2121 for(var i
=0;i
<nTicks
;i
++){
2122 var _224
=low_val
+i
*_219
;
2123 var _225
=self
.round_(_224
,2);
2124 if(self
.attr_("labelsKMB")){
2127 _225
=self
.round_(_224
/(k
*k
*k
),1)+"B";
2130 _225
=self
.round_(_224
/(k
*k
),1)+"M";
2133 _225
=self
.round_(_224
/k
,1)+"K";
2138 _223
.push({label
:_225
,v
:_224
});
2142 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
2143 var _229
=Dygraph
.numericTicks(minY
,maxY
,this);
2144 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_229
});
2146 Dygraph
.prototype.extremeValues_
=function(_230
){
2147 var minY
=null,maxY
=null;
2148 var bars
=this.attr_("errorBars")||this.attr_("customBars");
2150 for(var j
=0;j
<_230
.length
;j
++){
2151 var y
=_230
[j
][1][0];
2155 var low
=y
-_230
[j
][1][1];
2156 var high
=y
+_230
[j
][1][2];
2163 if(maxY
==null||high
>maxY
){
2166 if(minY
==null||low
<minY
){
2171 for(var j
=0;j
<_230
.length
;j
++){
2176 if(maxY
==null||y
>maxY
){
2179 if(minY
==null||y
<minY
){
2186 Dygraph
.prototype.drawGraph_
=function(data
){
2187 var minY
=null,maxY
=null;
2188 this.layout_
.removeAllDatasets();
2190 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
2191 for(var i
=1;i
<data
[0].length
;i
++){
2193 for(var j
=0;j
<data
.length
;j
++){
2194 var date
=data
[j
][0];
2195 _234
[j
]=[date
,data
[j
][i
]];
2197 _234
=this.rollingAverage(_234
,this.rollPeriod_
);
2198 var bars
=this.attr_("errorBars")||this.attr_("customBars");
2199 if(this.dateWindow_
){
2200 var low
=this.dateWindow_
[0];
2201 var high
=this.dateWindow_
[1];
2203 for(var k
=0;k
<_234
.length
;k
++){
2204 if(_234
[k
][0]>=low
&&_234
[k
][0]<=high
){
2210 var _236
=this.extremeValues_(_234
);
2213 if(!minY
||_237
<minY
){
2216 if(!maxY
||_238
>maxY
){
2221 for(var j
=0;j
<_234
.length
;j
++){
2222 vals
[j
]=[_234
[j
][0],_234
[j
][1][0],_234
[j
][1][1],_234
[j
][1][2]];
2224 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
2226 this.layout_
.addDataset(this.attr_("labels")[i
],_234
);
2229 if(this.valueRange_
!=null){
2230 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
2233 var _241
=maxY
+0.1*span
;
2234 var _242
=minY
-0.1*span
;
2235 if(_242
<0&&minY
>=0){
2238 if(_241
>0&&maxY
<=0){
2241 if(this.attr_("includeZero")){
2249 this.addYTicks_(_242
,_241
);
2252 this.layout_
.evaluateWithError();
2253 this.plotter_
.clear();
2254 this.plotter_
.render();
2255 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
2257 Dygraph
.prototype.rollingAverage
=function(_243
,_244
){
2261 var _244
=Math
.min(_244
,_243
.length
-1);
2263 var _246
=this.attr_("sigma");
2264 if(this.fractions_
){
2268 for(var i
=0;i
<_243
.length
;i
++){
2272 num
-=_243
[i
-_244
][1][0];
2273 den
-=_243
[i
-_244
][1][1];
2275 var date
=_243
[i
][0];
2276 var _249
=den
?num
/den
:0;
2277 if(this.attr_("errorBars")){
2278 if(this.wilsonInterval_
){
2280 var p
=_249
<0?0:_249
,n
=den
;
2281 var pm
=_246
*Math
.sqrt(p
*(1-p
)/n+_246*_246/(4*n
*n
));
2282 var _251
=1+_246
*_246
/den
;
2283 var low
=(p
+_246
*_246
/(2*den)-pm)/_251
;
2284 var high
=(p
+_246
*_246
/(2*den)+pm)/_251
;
2285 _245
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
2287 _245
[i
]=[date
,[0,0,0]];
2290 var _252
=den
?_246
*Math
.sqrt(_249
*(1-_249
)/den
):1;
2291 _245
[i
]=[date
,[mult
*_249
,mult
*_252
,mult
*_252
]];
2294 _245
[i
]=[date
,mult
*_249
];
2298 if(this.attr_("customBars")){
2303 for(var i
=0;i
<_243
.length
;i
++){
2304 var data
=_243
[i
][1];
2306 _245
[i
]=[_243
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
2312 var prev
=_243
[i
-_244
];
2318 _245
[i
]=[_243
[i
][0],[1*mid
/_254,1*(mid-low)/_254
,1*(high
-mid
)/_254
]];
2321 var _256
=Math
.min(_244
-1,_243
.length
-2);
2322 if(!this.attr_("errorBars")){
2326 for(var i
=0;i
<_243
.length
;i
++){
2329 for(var j
=Math
.max(0,i
-_244
+1);j
<i
+1;j
++){
2338 _245
[i
]=[_243
[i
][0],sum
/_258
];
2340 _245
[i
]=[_243
[i
][0],null];
2344 for(var i
=0;i
<_243
.length
;i
++){
2348 for(var j
=Math
.max(0,i
-_244
+1);j
<i
+1;j
++){
2349 var y
=_243
[j
][1][0];
2355 _259
+=Math
.pow(_243
[j
][1][1],2);
2358 var _252
=Math
.sqrt(_259
)/_258
;
2359 _245
[i
]=[_243
[i
][0],[sum
/_258
,_246
*_252
,_246
*_252
]];
2361 _245
[i
]=[_243
[i
][0],[null,null,null]];
2369 Dygraph
.dateParser
=function(_260
,self
){
2372 if(_260
.length
==10&&_260
.search("-")!=-1){
2373 _261
=_260
.replace("-","/","g");
2374 while(_261
.search("-")!=-1){
2375 _261
=_261
.replace("-","/");
2380 _261
=_260
.substr(0,4)+"/"+_260.substr(4,2)+"/"+_260
.substr(6,2);
2387 self
.error("Couldn't parse "+_260
+" as a date");
2391 Dygraph
.prototype.detectTypeFromString_
=function(str
){
2393 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
2396 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
2401 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
2402 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
2403 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
2405 this.attrs_
.xValueFormatter
=function(x
){
2408 this.attrs_
.xValueParser
=function(x
){
2409 return parseFloat(x
);
2411 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
2414 Dygraph
.prototype.parseCSV_
=function(data
){
2416 var _264
=data
.split("\n");
2418 if(this.labelsFromCSV_
){
2420 this.attrs_
.labels
=_264
[0].split(",");
2424 var _268
=this.attr_("labels").length
;
2425 for(var i
=_265
;i
<_264
.length
;i
++){
2430 var _270
=line
.split(",");
2436 this.detectTypeFromString_(_270
[0]);
2437 _266
=this.attr_("xValueParser");
2440 _271
[0]=_266(_270
[0],this);
2441 if(this.fractions_
){
2442 for(var j
=1;j
<_270
.length
;j
++){
2443 var vals
=_270
[j
].split("/");
2444 _271
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
2447 if(this.attr_("errorBars")){
2448 for(var j
=1;j
<_270
.length
;j
+=2){
2449 _271
[(j
+1)/2]=[parseFloat(_270
[j
]),parseFloat(_270
[j
+1])];
2452 if(this.attr_("customBars")){
2453 for(var j
=1;j
<_270
.length
;j
++){
2454 var vals
=_270
[j
].split(";");
2455 _271
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
2458 for(var j
=1;j
<_270
.length
;j
++){
2459 _271
[j
]=parseFloat(_270
[j
]);
2465 if(_271
.length
!=_268
){
2466 this.error("Number of columns in line "+i
+" ("+_271
.length
+") does not agree with number of labels ("+_268
+") "+line
);
2471 Dygraph
.prototype.parseArray_
=function(data
){
2473 this.error("Can't plot empty data set");
2476 if(data
[0].length
==0){
2477 this.error("Data set cannot contain an empty row");
2480 if(this.attr_("labels")==null){
2481 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
2482 this.attrs_
.labels
=["X"];
2483 for(var i
=1;i
<data
[0].length
;i
++){
2484 this.attrs_
.labels
.push("Y"+i
);
2487 if(MochiKit
.Base
.isDateLike(data
[0][0])){
2488 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
2489 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
2490 var _272
=MochiKit
.Base
.clone(data
);
2491 for(var i
=0;i
<data
.length
;i
++){
2492 if(_272
[i
].length
==0){
2493 this.error("Row "<<(1+i
)<<" of data is empty");
2496 if(_272
[i
][0]==null||typeof (_272
[i
][0].getTime
)!="function"){
2497 this.error("x value in row "<<(1+i
)<<" is not a Date");
2500 _272
[i
][0]=_272
[i
][0].getTime();
2504 this.attrs_
.xValueFormatter
=function(x
){
2507 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
2511 Dygraph
.prototype.parseDataTable_
=function(data
){
2512 var cols
=data
.getNumberOfColumns();
2513 var rows
=data
.getNumberOfRows();
2515 for(var i
=0;i
<cols
;i
++){
2516 _275
.push(data
.getColumnLabel(i
));
2518 this.attrs_
.labels
=_275
;
2519 var _276
=data
.getColumnType(0);
2521 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
2522 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
2523 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
2526 this.attrs_
.xValueFormatter
=function(x
){
2529 this.attrs_
.xValueParser
=function(x
){
2530 return parseFloat(x
);
2532 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
2534 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_276
+"')");
2539 for(var i
=0;i
<rows
;i
++){
2541 if(!data
.getValue(i
,0)){
2545 row
.push(data
.getValue(i
,0).getTime());
2547 row
.push(data
.getValue(i
,0));
2549 for(var j
=1;j
<cols
;j
++){
2550 row
.push(data
.getValue(i
,j
));
2556 Dygraph
.prototype.start_
=function(){
2557 if(typeof this.file_
=="function"){
2558 this.loadedEvent_(this.file_());
2560 if(MochiKit
.Base
.isArrayLike(this.file_
)){
2561 this.rawData_
=this.parseArray_(this.file_
);
2562 this.drawGraph_(this.rawData_
);
2564 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
2565 this.rawData_
=this.parseDataTable_(this.file_
);
2566 this.drawGraph_(this.rawData_
);
2568 if(typeof this.file_
=="string"){
2569 if(this.file_
.indexOf("\n")>=0){
2570 this.loadedEvent_(this.file_
);
2572 var req
=new XMLHttpRequest();
2574 req
.onreadystatechange
=function(){
2575 if(req
.readyState
==4){
2576 if(req
.status
==200){
2577 _279
.loadedEvent_(req
.responseText
);
2581 req
.open("GET",this.file_
,true);
2585 this.error("Unknown data format: "+(typeof this.file_
));
2591 Dygraph
.prototype.updateOptions
=function(_280
){
2592 if(_280
.rollPeriod
){
2593 this.rollPeriod_
=_280
.rollPeriod
;
2595 if(_280
.dateWindow
){
2596 this.dateWindow_
=_280
.dateWindow
;
2598 if(_280
.valueRange
){
2599 this.valueRange_
=_280
.valueRange
;
2601 MochiKit
.Base
.update(this.user_attrs_
,_280
);
2602 this.labelsFromCSV_
=(this.attr_("labels")==null);
2603 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
2604 if(_280
["file"]&&_280
["file"]!=this.file_
){
2605 this.file_
=_280
["file"];
2608 this.drawGraph_(this.rawData_
);
2611 Dygraph
.prototype.adjustRoll
=function(_281
){
2612 this.rollPeriod_
=_281
;
2613 this.drawGraph_(this.rawData_
);
2615 Dygraph
.GVizChart
=function(_282
){
2616 this.container
=_282
;
2618 Dygraph
.GVizChart
.prototype.draw
=function(data
,_283
){
2619 this.container
.innerHTML
="";
2620 this.date_graph
=new Dygraph(this.container
,data
,_283
);
2623 function RGBColor(_284
){
2625 if(_284
.charAt(0)=="#"){
2626 _284
=_284
.substr(1,6);
2628 _284
=_284
.replace(/ /g,"");
2629 _284
=_284
.toLowerCase();
2630 var _285
={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"};
2631 for(var key
in _285
){
2636 var _287
=[{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
){
2637 return [parseInt(bits
[1]),parseInt(bits
[2]),parseInt(bits
[3])];
2638 }},{re
:/^(\w{2})(\w{2})(\w{2})$/,example
:["#00ff00","336699"],process
:function(bits
){
2639 return [parseInt(bits
[1],16),parseInt(bits
[2],16),parseInt(bits
[3],16)];
2640 }},{re
:/^(\w{1})(\w{1})(\w{1})$/,example
:["#fb0","f0f"],process
:function(bits
){
2641 return [parseInt(bits
[1]+bits
[1],16),parseInt(bits
[2]+bits
[2],16),parseInt(bits
[3]+bits
[3],16)];
2643 for(var i
=0;i
<_287
.length
;i
++){
2645 var _290
=_287
[i
].process
;
2646 var bits
=re
.exec(_284
);
2648 channels
=_290(bits
);
2655 this.r
=(this.r
<0||isNaN(this.r
))?0:((this.r
>255)?255:this.r
);
2656 this.g
=(this.g
<0||isNaN(this.g
))?0:((this.g
>255)?255:this.g
);
2657 this.b
=(this.b
<0||isNaN(this.b
))?0:((this.b
>255)?255:this.b
);
2658 this.toRGB
=function(){
2659 return "rgb("+this.r
+", "+this.g
+", "+this.b
+")";
2661 this.toHex
=function(){
2662 var r
=this.r
.toString(16);
2663 var g
=this.g
.toString(16);
2664 var b
=this.b
.toString(16);