946e587399d5cc1775e782ebdde11a49aa1060f8
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
);
1004 if(typeof (dojo
)!="undefined"){
1005 dojo
.provide("MochiKit.Color");
1006 dojo
.require("MochiKit.Base");
1008 if(typeof (JSAN
)!="undefined"){
1009 JSAN
.use("MochiKit.Base",[]);
1012 if(typeof (MochiKit
.Base
)=="undefined"){
1017 throw "MochiKit.Color depends on MochiKit.Base";
1019 if(typeof (MochiKit
.Color
)=="undefined"){
1022 MochiKit
.Color
.NAME
="MochiKit.Color";
1023 MochiKit
.Color
.VERSION
="1.4";
1024 MochiKit
.Color
.__repr__
=function(){
1025 return "["+this.NAME
+" "+this.VERSION
+"]";
1027 MochiKit
.Color
.toString
=function(){
1028 return this.__repr__();
1030 MochiKit
.Color
.Color
=function(red
,_14e
,blue
,_150
){
1031 if(typeof (_150
)=="undefined"||_150
===null){
1034 this.rgb
={r
:red
,g
:_14e
,b
:blue
,a
:_150
};
1036 MochiKit
.Color
.Color
.prototype={__class__
:MochiKit
.Color
.Color
,colorWithAlpha
:function(_151
){
1038 var m
=MochiKit
.Color
;
1039 return m
.Color
.fromRGB(rgb
.r
,rgb
.g
,rgb
.b
,_151
);
1040 },colorWithHue
:function(hue
){
1041 var hsl
=this.asHSL();
1043 var m
=MochiKit
.Color
;
1044 return m
.Color
.fromHSL(hsl
);
1045 },colorWithSaturation
:function(_157
){
1046 var hsl
=this.asHSL();
1048 var m
=MochiKit
.Color
;
1049 return m
.Color
.fromHSL(hsl
);
1050 },colorWithLightness
:function(_15a
){
1051 var hsl
=this.asHSL();
1053 var m
=MochiKit
.Color
;
1054 return m
.Color
.fromHSL(hsl
);
1055 },darkerColorWithLevel
:function(_15d
){
1056 var hsl
=this.asHSL();
1057 hsl
.l
=Math
.max(hsl
.l
-_15d
,0);
1058 var m
=MochiKit
.Color
;
1059 return m
.Color
.fromHSL(hsl
);
1060 },lighterColorWithLevel
:function(_160
){
1061 var hsl
=this.asHSL();
1062 hsl
.l
=Math
.min(hsl
.l
+_160
,1);
1063 var m
=MochiKit
.Color
;
1064 return m
.Color
.fromHSL(hsl
);
1065 },blendedColor
:function(_163
,_164
){
1066 if(typeof (_164
)=="undefined"||_164
===null){
1073 return MochiKit
.Color
.Color
.fromRGB((s
.r
*sf
)+(d
.r
*df
),(s
.g
*sf
)+(d
.g
*df
),(s
.b
*sf
)+(d
.b
*df
),(s
.a
*sf
)+(d
.a
*df
));
1074 },compareRGB
:function(_169
){
1077 return MochiKit
.Base
.compare([a
.r
,a
.g
,a
.b
,a
.a
],[b
.r
,b
.g
,b
.b
,b
.a
]);
1078 },isLight
:function(){
1079 return this.asHSL().b
>0.5;
1080 },isDark
:function(){
1081 return (!this.isLight());
1082 },toHSLString
:function(){
1084 var ccc
=MochiKit
.Color
.clampColorComponent
;
1085 var rval
=this._hslString
;
1087 var mid
=(ccc(c
.h
,360).toFixed(0)+","+ccc(c
.s
,100).toPrecision(4)+"%"+","+ccc(c
.l
,100).toPrecision(4)+"%");
1091 rval
="hsl("+mid
+")";
1096 rval
="hsla("+mid
+","+a
+")";
1098 this._hslString
=rval
;
1101 },toRGBString
:function(){
1103 var ccc
=MochiKit
.Color
.clampColorComponent
;
1104 var rval
=this._rgbString
;
1106 var mid
=(ccc(c
.r
,255).toFixed(0)+","+ccc(c
.g
,255).toFixed(0)+","+ccc(c
.b
,255).toFixed(0));
1108 rval
="rgba("+mid
+","+c
.a
+")";
1110 rval
="rgb("+mid
+")";
1112 this._rgbString
=rval
;
1116 return MochiKit
.Base
.clone(this.rgb
);
1117 },toHexString
:function(){
1118 var m
=MochiKit
.Color
;
1120 var ccc
=MochiKit
.Color
.clampColorComponent
;
1121 var rval
=this._hexString
;
1123 rval
=("#"+m
.toColorPart(ccc(c
.r
,255))+m
.toColorPart(ccc(c
.g
,255))+m
.toColorPart(ccc(c
.b
,255)));
1124 this._hexString
=rval
;
1130 if(typeof (hsv
)=="undefined"||hsv
===null){
1131 hsv
=MochiKit
.Color
.rgbToHSV(this.rgb
);
1134 return MochiKit
.Base
.clone(hsv
);
1138 if(typeof (hsl
)=="undefined"||hsl
===null){
1139 hsl
=MochiKit
.Color
.rgbToHSL(this.rgb
);
1142 return MochiKit
.Base
.clone(hsl
);
1143 },toString
:function(){
1144 return this.toRGBString();
1147 var col
=[c
.r
,c
.g
,c
.b
,c
.a
];
1148 return this.__class__
.NAME
+"("+col
.join(", ")+")";
1150 MochiKit
.Base
.update(MochiKit
.Color
.Color
,{fromRGB
:function(red
,_180
,blue
,_182
){
1151 var _183
=MochiKit
.Color
.Color
;
1152 if(arguments
.length
==1){
1157 if(typeof (rgb
.a
)=="undefined"){
1163 return new _183(red
,_180
,blue
,_182
);
1164 },fromHSL
:function(hue
,_186
,_187
,_188
){
1165 var m
=MochiKit
.Color
;
1166 return m
.Color
.fromRGB(m
.hslToRGB
.apply(m
,arguments
));
1167 },fromHSV
:function(hue
,_18b
,_18c
,_18d
){
1168 var m
=MochiKit
.Color
;
1169 return m
.Color
.fromRGB(m
.hsvToRGB
.apply(m
,arguments
));
1170 },fromName
:function(name
){
1171 var _190
=MochiKit
.Color
.Color
;
1172 if(name
.charAt(0)=="\""){
1173 name
=name
.substr(1,name
.length
-2);
1175 var _191
=_190
._namedColors
[name
.toLowerCase()];
1176 if(typeof (_191
)=="string"){
1177 return _190
.fromHexString(_191
);
1179 if(name
=="transparent"){
1180 return _190
.transparentColor();
1184 },fromString
:function(_192
){
1185 var self
=MochiKit
.Color
.Color
;
1186 var _194
=_192
.substr(0,3);
1188 return self
.fromRGBString(_192
);
1191 return self
.fromHSLString(_192
);
1193 if(_192
.charAt(0)=="#"){
1194 return self
.fromHexString(_192
);
1198 return self
.fromName(_192
);
1199 },fromHexString
:function(_195
){
1200 if(_195
.charAt(0)=="#"){
1201 _195
=_195
.substring(1);
1207 hex
=_195
.substr(i
,1);
1208 _196
.push(parseInt(hex
+hex
,16)/255);
1212 hex
=_195
.substr(i
,2);
1213 _196
.push(parseInt(hex
,16)/255);
1216 var _199
=MochiKit
.Color
.Color
;
1217 return _199
.fromRGB
.apply(_199
,_196
);
1218 },_fromColorString
:function(pre
,_19b
,_19c
,_19d
){
1219 if(_19d
.indexOf(pre
)===0){
1220 _19d
=_19d
.substring(_19d
.indexOf("(",3)+1,_19d
.length
-1);
1222 var _19e
=_19d
.split(/\s*,\s*/);
1224 for(var i
=0;i
<_19e
.length
;i
++){
1227 var _1a3
=c
.substring(c
.length
-3);
1228 if(c
.charAt(c
.length
-1)=="%"){
1229 val
=0.01*parseFloat(c
.substring(0,c
.length
-1));
1232 val
=parseFloat(c
)/360;
1235 val
=parseFloat(c
)/(Math
.PI
*2);
1237 val
=_19c
[i
]*parseFloat(c
);
1243 return this[_19b
].apply(this,_19f
);
1244 },fromBackground
:function(elem
){
1245 var cls
=MochiKit
.Color
.Color
;
1246 return cls
.fromComputedStyle(elem
,"backgroundColor","background-color")||cls
.whiteColor();
1247 },fromText
:function(elem
){
1248 var cls
=MochiKit
.Color
.Color
;
1249 return cls
.fromComputedStyle(elem
,"color","color")||cls
.blackColor();
1250 },namedColors
:function(){
1251 return MochiKit
.Base
.clone(MochiKit
.Color
.Color
._namedColors
);
1253 MochiKit
.Base
.update(MochiKit
.Color
,{clampColorComponent
:function(v
,_1a9
){
1264 },_hslValue
:function(n1
,n2
,hue
){
1280 val
=n1
+(n2
-n1
)*(4-hue
);
1287 },hsvToRGB
:function(hue
,_1af
,_1b0
,_1b1
){
1288 if(arguments
.length
==1){
1303 var i
=Math
.floor(hue
*6);
1305 var p
=_1b0
*(1-_1af
);
1306 var q
=_1b0
*(1-(_1af
*f
));
1307 var t
=_1b0
*(1-(_1af
*(1-f
)));
1342 return {r
:red
,g
:_1b4
,b
:blue
,a
:_1b1
};
1343 },hslToRGB
:function(hue
,_1bc
,_1bd
,_1be
){
1344 if(arguments
.length
==1){
1363 m2
=_1bd
+_1bc
-(_1bd
*_1bc
);
1366 var f
=MochiKit
.Color
._hslValue
;
1372 return {r
:red
,g
:_1c1
,b
:blue
,a
:_1be
};
1373 },rgbToHSV
:function(red
,_1c8
,blue
,_1ca
){
1374 if(arguments
.length
==1){
1381 var max
=Math
.max(Math
.max(red
,_1c8
),blue
);
1382 var min
=Math
.min(Math
.min(red
,_1c8
),blue
);
1393 hue
=(_1c8
-blue
)/_1d1
;
1396 hue
=2+((blue
-red
)/_1d1
);
1398 hue
=4+((red
-_1c8
)/_1d1
);
1409 return {h
:hue
,s
:_1cf
,v
:_1d0
,a
:_1ca
};
1410 },rgbToHSL
:function(red
,_1d3
,blue
,_1d5
){
1411 if(arguments
.length
==1){
1418 var max
=Math
.max(red
,Math
.max(_1d3
,blue
));
1419 var min
=Math
.min(red
,Math
.min(_1d3
,blue
));
1422 var _1db
=(max
+min
)/2;
1429 _1da
=_1dc
/(max
+min
);
1431 _1da
=_1dc
/(2-max
-min
);
1434 hue
=(_1d3
-blue
)/_1dc
;
1437 hue
=2+((blue
-red
)/_1dc
);
1439 hue
=4+((red
-_1d3
)/_1dc
);
1450 return {h
:hue
,s
:_1da
,l
:_1db
,a
:_1d5
};
1451 },toColorPart
:function(num
){
1452 num
=Math
.round(num
);
1453 var _1de
=num
.toString(16);
1458 },__new__
:function(){
1459 var m
=MochiKit
.Base
;
1460 this.Color
.fromRGBString
=m
.bind(this.Color
._fromColorString
,this.Color
,"rgb","fromRGB",[1/255,1/255,1/255,1]);
1461 this.Color
.fromHSLString
=m
.bind(this.Color
._fromColorString
,this.Color
,"hsl","fromHSL",[1/360,0.01,0.01,1]);
1463 var _1e1
={black
:[0,0,0],blue
:[0,0,1],brown
:[0.6,0.4,0.2],cyan
:[0,1,1],darkGray
:[_1e0
,_1e0
,_1e0
],gray
:[0.5,0.5,0.5],green
:[0,1,0],lightGray
:[2*_1e0
,2*_1e0
,2*_1e0
],magenta
:[1,0,1],orange
:[1,0.5,0],purple
:[0.5,0,0.5],red
:[1,0,0],transparent
:[0,0,0,0],white
:[1,1,1],yellow
:[1,1,0]};
1464 var _1e2
=function(name
,r
,g
,b
,a
){
1465 var rval
=this.fromRGB(r
,g
,b
,a
);
1466 this[name
]=function(){
1473 var _1eb
=m
.concat([_1e2
,this.Color
,name
],_1e1
[k
]);
1474 this.Color
[name
]=m
.bind
.apply(null,_1eb
);
1476 var _1ec
=function(){
1477 for(var i
=0;i
<arguments
.length
;i
++){
1478 if(!(arguments
[i
] instanceof Color
)){
1484 var _1ee
=function(a
,b
){
1485 return a
.compareRGB(b
);
1487 m
.nameFunctions(this);
1488 m
.registerComparator(this.Color
.NAME
,_1ec
,_1ee
);
1489 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
1491 MochiKit
.Color
.EXPORT
=["Color"];
1492 MochiKit
.Color
.EXPORT_OK
=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
1493 MochiKit
.Color
.__new__();
1494 MochiKit
.Base
._exportSymbols(this,MochiKit
.Color
);
1495 MochiKit
.Color
.Color
._namedColors
={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",darkgrey
:"#a9a9a9",darkkhaki
:"#bdb76b",darkmagenta
:"#8b008b",darkolivegreen
:"#556b2f",darkorange
:"#ff8c00",darkorchid
:"#9932cc",darkred
:"#8b0000",darksalmon
:"#e9967a",darkseagreen
:"#8fbc8f",darkslateblue
:"#483d8b",darkslategray
:"#2f4f4f",darkslategrey
:"#2f4f4f",darkturquoise
:"#00ced1",darkviolet
:"#9400d3",deeppink
:"#ff1493",deepskyblue
:"#00bfff",dimgray
:"#696969",dimgrey
:"#696969",dodgerblue
:"#1e90ff",firebrick
:"#b22222",floralwhite
:"#fffaf0",forestgreen
:"#228b22",fuchsia
:"#ff00ff",gainsboro
:"#dcdcdc",ghostwhite
:"#f8f8ff",gold
:"#ffd700",goldenrod
:"#daa520",gray
:"#808080",green
:"#008000",greenyellow
:"#adff2f",grey
:"#808080",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",lightgray
:"#d3d3d3",lightgreen
:"#90ee90",lightgrey
:"#d3d3d3",lightpink
:"#ffb6c1",lightsalmon
:"#ffa07a",lightseagreen
:"#20b2aa",lightskyblue
:"#87cefa",lightslategray
:"#778899",lightslategrey
:"#778899",lightsteelblue
:"#b0c4de",lightyellow
:"#ffffe0",lime
:"#00ff00",limegreen
:"#32cd32",linen
:"#faf0e6",magenta
:"#ff00ff",maroon
:"#800000",mediumaquamarine
:"#66cdaa",mediumblue
:"#0000cd",mediumorchid
:"#ba55d3",mediumpurple
:"#9370db",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
:"#db7093",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",slategrey
:"#708090",snow
:"#fffafa",springgreen
:"#00ff7f",steelblue
:"#4682b4",tan
:"#d2b48c",teal
:"#008080",thistle
:"#d8bfd8",tomato
:"#ff6347",turquoise
:"#40e0d0",violet
:"#ee82ee",wheat
:"#f5deb3",white
:"#ffffff",whitesmoke
:"#f5f5f5",yellow
:"#ffff00",yellowgreen
:"#9acd32"};
1498 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
};
1499 DygraphLayout
=function(_1
,_2
){
1502 MochiKit
.Base
.update(this.options
,_2
?_2
:{});
1503 this.datasets
=new Array();
1505 DygraphLayout
.prototype.attr_
=function(_3
){
1506 return this.dygraph_
.attr_(_3
);
1508 DygraphLayout
.prototype.addDataset
=function(_4
,_5
){
1509 this.datasets
[_4
]=_5
;
1511 DygraphLayout
.prototype.evaluate
=function(){
1512 this._evaluateLimits();
1513 this._evaluateLineCharts();
1514 this._evaluateLineTicks();
1516 DygraphLayout
.prototype._evaluateLimits
=function(){
1517 this.minxval
=this.maxxval
=null;
1518 for(var _6
in this.datasets
){
1519 var _7
=this.datasets
[_6
];
1521 if(!this.minxval
||x1
<this.minxval
){
1524 var x2
=_7
[_7
.length
-1][0];
1525 if(!this.maxxval
||x2
>this.maxxval
){
1529 this.xrange
=this.maxxval
-this.minxval
;
1530 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
1531 this.minyval
=this.options
.yAxis
[0];
1532 this.maxyval
=this.options
.yAxis
[1];
1533 this.yrange
=this.maxyval
-this.minyval
;
1534 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
1536 DygraphLayout
.prototype._evaluateLineCharts
=function(){
1537 this.points
=new Array();
1538 for(var _10
in this.datasets
){
1539 var _11
=this.datasets
[_10
];
1540 for(var j
=0;j
<_11
.length
;j
++){
1542 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
};
1549 if((_14
.x
>=0)&&(_14
.x
<=1)){
1550 this.points
.push(_14
);
1555 DygraphLayout
.prototype._evaluateLineTicks
=function(){
1556 this.xticks
=new Array();
1557 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
1558 var _16
=this.options
.xTicks
[i
];
1560 var pos
=this.xscale
*(_16
.v
-this.minxval
);
1561 if((pos
>=0)&&(pos
<=1)){
1562 this.xticks
.push([pos
,_17
]);
1565 this.yticks
=new Array();
1566 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
1567 var _16
=this.options
.yTicks
[i
];
1569 var pos
=1-(this.yscale
*(_16
.v
-this.minyval
));
1570 if((pos
>=0)&&(pos
<=1)){
1571 this.yticks
.push([pos
,_17
]);
1575 DygraphLayout
.prototype.evaluateWithError
=function(){
1577 if(!this.options
.errorBars
){
1581 for(var _19
in this.datasets
){
1583 var _20
=this.datasets
[_19
];
1584 for(var j
=0;j
<_20
.length
;j
++,i
++){
1586 var xv
=parseFloat(_21
[0]);
1587 var yv
=parseFloat(_21
[1]);
1588 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
1589 this.points
[i
].errorMinus
=parseFloat(_21
[2]);
1590 this.points
[i
].errorPlus
=parseFloat(_21
[3]);
1595 DygraphLayout
.prototype.removeAllDatasets
=function(){
1596 delete this.datasets
;
1597 this.datasets
=new Array();
1599 DygraphLayout
.prototype.updateOptions
=function(_24
){
1600 MochiKit
.Base
.update(this.options
,_24
?_24
:{});
1602 DygraphCanvasRenderer
=function(_25
,_26
,_27
,_28
){
1604 this.options
={"strokeWidth":0.5,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"drawYGrid":true,"drawXGrid":true,"gridLineColor":MochiKit
.Color
.Color
.grayColor()};
1605 MochiKit
.Base
.update(this.options
,_28
);
1608 this.container
=this.element
.parentNode
;
1609 this.isIE
=(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
);
1610 if(this.isIE
&&!isNil(G_vmlCanvasManager
)){
1613 this.renderDelay
=null;
1614 this.clearDelay
=null;
1615 this.element
=G_vmlCanvasManager
.initElement(this.element
);
1617 this.height
=this.element
.height
;
1618 this.width
=this.element
.width
;
1619 if(!this.isIE
&&!(DygraphCanvasRenderer
.isSupported(this.element
))){
1620 throw "Canvas is not supported.";
1622 this.xlabels
=new Array();
1623 this.ylabels
=new Array();
1624 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
1625 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
1626 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
1627 this.container
.style
.position
="relative";
1628 this.container
.style
.width
=this.width
+"px";
1630 DygraphCanvasRenderer
.prototype.clear
=function(){
1633 if(this.clearDelay
){
1634 this.clearDelay
.cancel();
1635 this.clearDelay
=null;
1637 var _29
=this.element
.getContext("2d");
1640 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
1641 this.clearDelay
.addCallback(bind(this.clear
,this));
1645 var _29
=this.element
.getContext("2d");
1646 _29
.clearRect(0,0,this.width
,this.height
);
1647 for(var i
=0;i
<this.xlabels
.length
;i
++){
1648 var el
=this.xlabels
[i
];
1649 el
.parentNode
.removeChild(el
);
1651 for(var i
=0;i
<this.ylabels
.length
;i
++){
1652 var el
=this.ylabels
[i
];
1653 el
.parentNode
.removeChild(el
);
1655 this.xlabels
=new Array();
1656 this.ylabels
=new Array();
1658 DygraphCanvasRenderer
.isSupported
=function(_31
){
1661 if(MochiKit
.Base
.isUndefinedOrNull(_31
)){
1662 _32
=document
.createElement("canvas");
1666 var _33
=_32
.getContext("2d");
1669 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
1670 var _35
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
1671 if((!ie
)||(ie
[1]<6)||(_35
)){
1678 DygraphCanvasRenderer
.prototype.render
=function(){
1679 var ctx
=this.element
.getContext("2d");
1680 if(this.options
.drawYGrid
){
1681 var _37
=this.layout
.yticks
;
1683 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
1684 ctx
.lineWidth
=this.options
.axisLineWidth
;
1685 for(var i
=0;i
<_37
.length
;i
++){
1687 var y
=this.area
.y
+_37
[i
][0]*this.area
.h
;
1690 ctx
.lineTo(x
+this.area
.w
,y
);
1695 if(this.options
.drawXGrid
){
1696 var _37
=this.layout
.xticks
;
1698 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
1699 ctx
.lineWidth
=this.options
.axisLineWidth
;
1700 for(var i
=0;i
<_37
.length
;i
++){
1701 var x
=this.area
.x
+_37
[i
][0]*this.area
.w
;
1702 var y
=this.area
.y
+this.area
.h
;
1705 ctx
.lineTo(x
,this.area
.y
);
1710 this._renderLineChart();
1713 DygraphCanvasRenderer
.prototype._renderAxis
=function(){
1714 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
1717 var _40
=this.element
.getContext("2d");
1718 var _41
={"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"};
1719 var _42
=function(txt
){
1720 var div
=document
.createElement("div");
1721 for(var _45
in _41
){
1722 div
.style
[_45
]=_41
[_45
];
1724 div
.appendChild(document
.createTextNode(txt
));
1728 _40
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
1729 _40
.lineWidth
=this.options
.axisLineWidth
;
1730 if(this.options
.drawYAxis
){
1731 if(this.layout
.yticks
){
1732 for(var i
=0;i
<this.layout
.yticks
.length
;i
++){
1733 var _46
=this.layout
.yticks
[i
];
1734 if(typeof (_46
)=="function"){
1738 var y
=this.area
.y
+_46
[0]*this.area
.h
;
1741 _40
.lineTo(x
-this.options
.axisTickSize
,y
);
1744 var _47
=_42(_46
[1]);
1745 var top
=(y
-this.options
.axisLabelFontSize
/2);
1749 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
1750 _47
.style
.bottom
="0px";
1752 _47
.style
.top
=top
+"px";
1754 _47
.style
.left
="0px";
1755 _47
.style
.textAlign
="right";
1756 _47
.style
.width
=this.options
.yAxisLabelWidth
+"px";
1757 this.container
.appendChild(_47
);
1758 this.ylabels
.push(_47
);
1760 var _49
=this.ylabels
[0];
1761 var _50
=this.options
.axisLabelFontSize
;
1762 var _51
=parseInt(_49
.style
.top
)+_50
;
1763 if(_51
>this.height
-_50
){
1764 _49
.style
.top
=(parseInt(_49
.style
.top
)-_50
/2)+"px";
1768 _40
.moveTo(this.area
.x
,this.area
.y
);
1769 _40
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
1773 if(this.options
.drawXAxis
){
1774 if(this.layout
.xticks
){
1775 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
1776 var _46
=this.layout
.xticks
[i
];
1777 if(typeof (dataset
)=="function"){
1780 var x
=this.area
.x
+_46
[0]*this.area
.w
;
1781 var y
=this.area
.y
+this.area
.h
;
1784 _40
.lineTo(x
,y
+this.options
.axisTickSize
);
1787 var _47
=_42(_46
[1]);
1788 _47
.style
.textAlign
="center";
1789 _47
.style
.bottom
="0px";
1790 var _52
=(x
-this.options
.axisLabelWidth
/2);
1791 if(_52
+this.options
.axisLabelWidth
>this.width
){
1792 _52
=this.width
-this.options
.xAxisLabelWidth
;
1793 _47
.style
.textAlign
="right";
1797 _47
.style
.textAlign
="left";
1799 _47
.style
.left
=_52
+"px";
1800 _47
.style
.width
=this.options
.xAxisLabelWidth
+"px";
1801 this.container
.appendChild(_47
);
1802 this.xlabels
.push(_47
);
1806 _40
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
1807 _40
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
1813 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
1814 var _53
=this.element
.getContext("2d");
1815 var _54
=this.options
.colorScheme
.length
;
1816 var _55
=this.options
.colorScheme
;
1817 var _56
=MochiKit
.Base
.keys(this.layout
.datasets
);
1818 var _57
=this.layout
.options
.errorBars
;
1820 var _59
=MochiKit
.Base
.bind
;
1821 var _60
=MochiKit
.Base
.partial
;
1822 for(var i
=0;i
<this.layout
.points
.length
;i
++){
1823 var _61
=this.layout
.points
[i
];
1824 _61
.canvasx
=this.area
.w
*_61
.x
+this.area
.x
;
1825 _61
.canvasy
=this.area
.h
*_61
.y
+this.area
.y
;
1827 var _62
=function(x
){
1828 return x
&&!isNaN(x
);
1830 var _63
=function(ctx
){
1831 for(var i
=0;i
<_58
;i
++){
1834 var _66
=this.options
.strokeColorTransform
;
1836 _53
.strokeStyle
=_65
.toRGBString();
1837 _53
.lineWidth
=this.options
.strokeWidth
;
1838 var _61
=this.layout
.points
[0];
1839 var _67
=this.dygraph_
.attr_("pointSize");
1840 var _68
=null,prevY
=null;
1841 var _69
=this.dygraph_
.attr_("drawPoints");
1842 var _70
=this.layout
.points
;
1843 for(var j
=0;j
<_70
.length
;j
++){
1846 if(!_62(_61
.canvasy
)){
1849 var _71
=(!_68
&&(j
==_70
.length
-1||!_62(_70
[j
+1].canvasy
)));
1855 ctx
.moveTo(_68
,prevY
);
1858 ctx
.lineTo(_68
,prevY
);
1863 ctx
.fillStyle
=_65
.toRGBString();
1864 ctx
.arc(_61
.canvasx
,_61
.canvasy
,_67
,0,360,false);
1872 var _72
=function(ctx
){
1873 for(var i
=0;i
<_58
;i
++){
1876 var _75
=this.options
.strokeColorTransform
;
1878 _53
.strokeStyle
=_74
.toRGBString();
1879 _53
.lineWidth
=this.options
.strokeWidth
;
1883 var _79
=this.layout
.yscale
;
1884 var _80
=_74
.colorWithAlpha(0.15);
1885 ctx
.fillStyle
=_80
.toRGBString();
1887 for(var j
=0;j
<this.layout
.points
.length
;j
++){
1888 var _81
=this.layout
.points
[j
];
1891 if(!_81
.y
||isNaN(_81
.y
)){
1895 var _82
=[_81
.y
-_81
.errorPlus
*_79
,_81
.y
+_81
.errorMinus
*_79
];
1896 _82
[0]=this.area
.h
*_82
[0]+this.area
.y
;
1897 _82
[1]=this.area
.h
*_82
[1]+this.area
.y
;
1899 ctx
.moveTo(_76
,_77
[0]);
1900 ctx
.lineTo(_81
.canvasx
,_82
[0]);
1901 ctx
.lineTo(_81
.canvasx
,_82
[1]);
1902 ctx
.lineTo(_76
,_77
[1]);
1919 Dygraph
=function(div
,_83
,_84
){
1920 if(arguments
.length
>0){
1921 if(arguments
.length
==4){
1922 this.warn("Using deprecated four-argument dygraph constructor");
1923 this.__old_init__(div
,_83
,arguments
[2],arguments
[3]);
1925 this.__init__(div
,_83
,_84
);
1929 Dygraph
.NAME
="Dygraph";
1930 Dygraph
.VERSION
="1.2";
1931 Dygraph
.__repr__
=function(){
1932 return "["+this.NAME
+" "+this.VERSION
+"]";
1934 Dygraph
.toString
=function(){
1935 return this.__repr__();
1937 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
1938 Dygraph
.DEFAULT_WIDTH
=480;
1939 Dygraph
.DEFAULT_HEIGHT
=320;
1940 Dygraph
.AXIS_LINE_WIDTH
=0.3;
1941 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};
1946 Dygraph
.prototype.__old_init__
=function(div
,_85
,_86
,_87
){
1949 for(var i
=0;i
<_86
.length
;i
++){
1952 MochiKit
.Base
.update(_87
,{"labels":_88
});
1954 this.__init__(div
,_85
,_87
);
1956 Dygraph
.prototype.__init__
=function(div
,_89
,_90
){
1962 this.rollPeriod_
=_90
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
1963 this.previousVerticalX_
=-1;
1964 this.fractions_
=_90
.fractions
||false;
1965 this.dateWindow_
=_90
.dateWindow
||null;
1966 this.valueRange_
=_90
.valueRange
||null;
1967 this.wilsonInterval_
=_90
.wilsonInterval
||true;
1969 if(div
.style
.width
==""){
1970 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
1972 if(div
.style
.height
==""){
1973 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
1975 this.width_
=parseInt(div
.style
.width
,10);
1976 this.height_
=parseInt(div
.style
.height
,10);
1977 this.user_attrs_
={};
1978 MochiKit
.Base
.update(this.user_attrs_
,_90
);
1980 MochiKit
.Base
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
1981 this.labelsFromCSV_
=(this.attr_("labels")==null);
1982 this.createInterface_();
1983 this.layoutOptions_
={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
1984 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
1985 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
1986 this.layout_
=new DygraphLayout(this,this.layoutOptions_
);
1987 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
1988 MochiKit
.Base
.update(this.renderOptions_
,this.attrs_
);
1989 MochiKit
.Base
.update(this.renderOptions_
,this.user_attrs_
);
1990 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
1991 this.createStatusMessage_();
1992 this.createRollInterface_();
1993 this.createDragInterface_();
1996 Dygraph
.prototype.attr_
=function(_91
){
1997 if(typeof (this.user_attrs_
[_91
])!="undefined"){
1998 return this.user_attrs_
[_91
];
2000 if(typeof (this.attrs_
[_91
])!="undefined"){
2001 return this.attrs_
[_91
];
2007 Dygraph
.prototype.log
=function(_92
,_93
){
2008 if(typeof (console
)!="undefined"){
2011 console
.debug("dygraphs: "+_93
);
2014 console
.info("dygraphs: "+_93
);
2016 case Dygraph
.WARNING
:
2017 console
.warn("dygraphs: "+_93
);
2020 console
.error("dygraphs: "+_93
);
2025 Dygraph
.prototype.info
=function(_94
){
2026 this.log(Dygraph
.INFO
,_94
);
2028 Dygraph
.prototype.warn
=function(_95
){
2029 this.log(Dygraph
.WARNING
,_95
);
2031 Dygraph
.prototype.error
=function(_96
){
2032 this.log(Dygraph
.ERROR
,_96
);
2034 Dygraph
.prototype.rollPeriod
=function(){
2035 return this.rollPeriod_
;
2037 Dygraph
.addEvent
=function(el
,evt
,fn
){
2038 var _99
=function(e
){
2044 if(window
.addEventListener
){
2045 el
.addEventListener(evt
,_99
,false);
2047 el
.attachEvent("on"+evt
,_99
);
2050 Dygraph
.prototype.createInterface_
=function(){
2051 var _101
=this.maindiv_
;
2052 this.graphDiv
=document
.createElement("div");
2053 this.graphDiv
.style
.width
=this.width_
+"px";
2054 this.graphDiv
.style
.height
=this.height_
+"px";
2055 _101
.appendChild(this.graphDiv
);
2056 this.canvas_
=document
.createElement("canvas");
2057 this.canvas_
.style
.position
="absolute";
2058 this.canvas_
.width
=this.width_
;
2059 this.canvas_
.height
=this.height_
;
2060 this.graphDiv
.appendChild(this.canvas_
);
2061 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
2063 Dygraph
.addEvent(this.hidden_
,"mousemove",function(e
){
2066 Dygraph
.addEvent(this.hidden_
,"mouseout",function(e
){
2070 Dygraph
.prototype.createPlotKitCanvas_
=function(_103
){
2071 var h
=document
.createElement("canvas");
2072 h
.style
.position
="absolute";
2073 h
.style
.top
=_103
.style
.top
;
2074 h
.style
.left
=_103
.style
.left
;
2075 h
.width
=this.width_
;
2076 h
.height
=this.height_
;
2077 this.graphDiv
.appendChild(h
);
2080 Dygraph
.prototype.setColors_
=function(){
2081 var num
=this.attr_("labels").length
-1;
2083 var _106
=this.attr_("colors");
2085 var sat
=this.attr_("colorSaturation")||1;
2086 var val
=this.attr_("colorValue")||0.5;
2087 for(var i
=1;i
<=num
;i
++){
2088 var hue
=(1*i
/(1+num
));
2089 this.colors_
.push(MochiKit
.Color
.Color
.fromHSV(hue
,sat
,val
));
2092 for(var i
=0;i
<num
;i
++){
2093 var _110
=_106
[i
%_106
.length
];
2094 this.colors_
.push(MochiKit
.Color
.Color
.fromString(_110
));
2097 this.renderOptions_
.colorScheme
=this.colors_
;
2098 MochiKit
.Base
.update(this.plotter_
.options
,this.renderOptions_
);
2099 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
2100 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
2102 Dygraph
.findPosX
=function(obj
){
2104 if(obj
.offsetParent
){
2105 while(obj
.offsetParent
){
2106 _112
+=obj
.offsetLeft
;
2107 obj
=obj
.offsetParent
;
2116 Dygraph
.findPosY
=function(obj
){
2118 if(obj
.offsetParent
){
2119 while(obj
.offsetParent
){
2120 _113
+=obj
.offsetTop
;
2121 obj
=obj
.offsetParent
;
2130 Dygraph
.prototype.createStatusMessage_
=function(){
2131 if(!this.attr_("labelsDiv")){
2132 var _114
=this.attr_("labelsDivWidth");
2133 var _115
={"position":"absolute","fontSize":"14px","zIndex":10,"width":_114
+"px","top":"0px","left":(this.width_
-_114
-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
2134 MochiKit
.Base
.update(_115
,this.attr_("labelsDivStyles"));
2135 var div
=document
.createElement("div");
2136 for(var name
in _115
){
2137 div
.style
[name
]=_115
[name
];
2139 this.graphDiv
.appendChild(div
);
2140 this.attrs_
.labelsDiv
=div
;
2143 Dygraph
.prototype.createRollInterface_
=function(){
2144 var _117
=this.attr_("showRoller")?"block":"none";
2145 var _118
={"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_117
};
2146 var _119
=document
.createElement("input");
2149 _119
.value
=this.rollPeriod_
;
2150 for(var name
in _118
){
2151 _119
.style
[name
]=_118
[name
];
2153 var pa
=this.graphDiv
;
2154 pa
.appendChild(_119
);
2156 _119
.onchange
=function(){
2157 _121
.adjustRoll(_119
.value
);
2161 Dygraph
.pageX
=function(e
){
2163 return (!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
2166 var b
=document
.body
;
2167 return e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
2170 Dygraph
.pageY
=function(e
){
2172 return (!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
2175 var b
=document
.body
;
2176 return e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
2179 Dygraph
.prototype.createDragInterface_
=function(){
2189 var getX
=function(e
){
2190 return Dygraph
.pageX(e
)-px
;
2192 var getY
=function(e
){
2193 return Dygraph
.pageX(e
)-py
;
2195 Dygraph
.addEvent(this.hidden_
,"mousemove",function(_135
){
2199 self
.drawZoomRect_(_126
,_128
,_130
);
2203 Dygraph
.addEvent(this.hidden_
,"mousedown",function(_136
){
2205 px
=Dygraph
.findPosX(self
.canvas_
);
2206 py
=Dygraph
.findPosY(self
.canvas_
);
2210 Dygraph
.addEvent(document
,"mouseup",function(_137
){
2217 Dygraph
.addEvent(this.hidden_
,"mouseout",function(_138
){
2223 Dygraph
.addEvent(this.hidden_
,"mouseup",function(_139
){
2228 var _140
=Math
.abs(_128
-_126
);
2229 var _141
=Math
.abs(_129
-_127
);
2230 if(_140
<2&&_141
<2&&self
.attr_("clickCallback")!=null&&self
.lastx_
!=undefined
){
2231 self
.attr_("clickCallback")(_139
,new Date(self
.lastx_
));
2234 self
.doZoom_(Math
.min(_126
,_128
),Math
.max(_126
,_128
));
2236 self
.canvas_
.getContext("2d").clearRect(0,0,self
.canvas_
.width
,self
.canvas_
.height
);
2242 Dygraph
.addEvent(this.hidden_
,"dblclick",function(_142
){
2243 self
.dateWindow_
=null;
2244 self
.drawGraph_(self
.rawData_
);
2245 var _143
=self
.rawData_
[0][0];
2246 var _144
=self
.rawData_
[self
.rawData_
.length
-1][0];
2247 if(self
.attr_("zoomCallback")){
2248 self
.attr_("zoomCallback")(_143
,_144
);
2252 Dygraph
.prototype.drawZoomRect_
=function(_145
,endX
,_147
){
2253 var ctx
=this.canvas_
.getContext("2d");
2255 ctx
.clearRect(Math
.min(_145
,_147
),0,Math
.abs(_145
-_147
),this.height_
);
2258 ctx
.fillStyle
="rgba(128,128,128,0.33)";
2259 ctx
.fillRect(Math
.min(_145
,endX
),0,Math
.abs(endX
-_145
),this.height_
);
2262 Dygraph
.prototype.doZoom_
=function(lowX
,_149
){
2263 var _150
=this.layout_
.points
;
2266 for(var i
=0;i
<_150
.length
;i
++){
2267 var cx
=_150
[i
].canvasx
;
2269 if(cx
<lowX
&&(_151
==null||x
>_151
)){
2272 if(cx
>_149
&&(_152
==null||x
<_152
)){
2280 _152
=_150
[_150
.length
-1].xval
;
2282 this.dateWindow_
=[_151
,_152
];
2283 this.drawGraph_(this.rawData_
);
2284 if(this.attr_("zoomCallback")){
2285 this.attr_("zoomCallback")(_151
,_152
);
2288 Dygraph
.prototype.mouseMove_
=function(_154
){
2289 var _155
=Dygraph
.pageX(_154
)-Dygraph
.findPosX(this.hidden_
);
2290 var _156
=this.layout_
.points
;
2295 for(var i
=0;i
<_156
.length
;i
++){
2296 var dist
=Math
.abs(_156
[i
].canvasx
-_155
);
2304 _157
=_156
[idx
].xval
;
2306 if(_155
>_156
[_156
.length
-1].canvasx
){
2307 _157
=_156
[_156
.length
-1].xval
;
2310 for(var i
=0;i
<_156
.length
;i
++){
2311 if(_156
[i
].xval
==_157
){
2315 var _163
=this.attr_("highlightCircleSize");
2316 var ctx
=this.canvas_
.getContext("2d");
2317 if(this.previousVerticalX_
>=0){
2318 var px
=this.previousVerticalX_
;
2319 ctx
.clearRect(px
-_163
-1,0,2*_163
+2,this.height_
);
2321 var isOK
=function(x
){
2322 return x
&&!isNaN(x
);
2325 var _155
=_162
[0].canvasx
;
2326 var _165
=this.attr_("xValueFormatter")(_157
,this)+":";
2327 var clen
=this.colors_
.length
;
2328 for(var i
=0;i
<_162
.length
;i
++){
2329 if(!isOK(_162
[i
].canvasy
)){
2332 if(this.attr_("labelsSeparateLines")){
2336 _165
+=" <b><font color='"+this.colors_
[i
%clen
].toHexString()+"'>"+_167
.name
+"</font></b>:"+this.round_(_167
.yval
,2);
2338 this.attr_("labelsDiv").innerHTML
=_165
;
2341 for(var i
=0;i
<_162
.length
;i
++){
2342 if(!isOK(_162
[i
%clen
].canvasy
)){
2346 ctx
.fillStyle
=this.colors_
[i
%clen
].toRGBString();
2347 ctx
.arc(_155
,_162
[i
%clen
].canvasy
,_163
,0,360,false);
2351 this.previousVerticalX_
=_155
;
2354 Dygraph
.prototype.mouseOut_
=function(_168
){
2355 var ctx
=this.canvas_
.getContext("2d");
2356 ctx
.clearRect(0,0,this.width_
,this.height_
);
2357 this.attr_("labelsDiv").innerHTML
="";
2359 Dygraph
.zeropad
=function(x
){
2366 Dygraph
.prototype.hmsString_
=function(date
){
2367 var _170
=Dygraph
.zeropad
;
2368 var d
=new Date(date
);
2370 return _170(d
.getHours())+":"+_170(d
.getMinutes())+":"+_170(d
.getSeconds());
2373 return _170(d
.getHours())+":"+_170(d
.getMinutes());
2375 return _170(d
.getHours());
2379 Dygraph
.dateString_
=function(date
,self
){
2380 var _172
=Dygraph
.zeropad
;
2381 var d
=new Date(date
);
2382 var year
=""+d
.getFullYear();
2383 var _174
=_172(d
.getMonth()+1);
2384 var day
=_172(d
.getDate());
2386 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
2388 ret
=" "+self
.hmsString_(date
);
2390 return year
+"/"+_174+"/"+day
+ret
;
2392 Dygraph
.prototype.round_
=function(num
,_178
){
2393 var _179
=Math
.pow(10,_178
);
2394 return Math
.round(num
*_179
)/_179
;
2396 Dygraph
.prototype.loadedEvent_
=function(data
){
2397 this.rawData_
=this.parseCSV_(data
);
2398 this.drawGraph_(this.rawData_
);
2400 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
2401 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
2402 Dygraph
.prototype.addXTicks_
=function(){
2404 if(this.dateWindow_
){
2405 _181
=this.dateWindow_
[0];
2406 endDate
=this.dateWindow_
[1];
2408 _181
=this.rawData_
[0][0];
2409 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
2411 var _182
=this.attr_("xTicker")(_181
,endDate
,this);
2412 this.layout_
.updateOptions({xTicks
:_182
});
2415 Dygraph
.TEN_SECONDLY
=1;
2416 Dygraph
.THIRTY_SECONDLY
=2;
2418 Dygraph
.TEN_MINUTELY
=4;
2419 Dygraph
.THIRTY_MINUTELY
=5;
2421 Dygraph
.SIX_HOURLY
=7;
2425 Dygraph
.QUARTERLY
=11;
2426 Dygraph
.BIANNUAL
=12;
2429 Dygraph
.NUM_GRANULARITIES
=15;
2430 Dygraph
.SHORT_SPACINGS
=[];
2431 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
2432 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
2433 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
2434 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
2435 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
2436 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
2437 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
2438 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600*6;
2439 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
2440 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
2441 Dygraph
.prototype.NumXTicks
=function(_183
,_184
,_185
){
2442 if(_185
<Dygraph
.MONTHLY
){
2443 var _186
=Dygraph
.SHORT_SPACINGS
[_185
];
2444 return Math
.floor(0.5+1*(_184
-_183
)/_186
);
2448 if(_185
==Dygraph
.QUARTERLY
){
2451 if(_185
==Dygraph
.BIANNUAL
){
2454 if(_185
==Dygraph
.ANNUAL
){
2457 if(_185
==Dygraph
.DECADAL
){
2461 var _189
=365.2524*24*3600*1000;
2462 var _190
=1*(_184
-_183
)/_189
;
2463 return Math
.floor(0.5+1*_190
*_188
/_187
);
2466 Dygraph
.prototype.GetXAxis
=function(_191
,_192
,_193
){
2468 if(_193
<Dygraph
.MONTHLY
){
2469 var _195
=Dygraph
.SHORT_SPACINGS
[_193
];
2471 if(_193
<Dygraph
.HOURLY
){
2472 _191
=_195
*Math
.floor(0.5+_191
/_195
);
2474 for(var t
=_191
;t
<=_192
;t
+=_195
){
2476 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
2477 if(frac
==0||_193
>=Dygraph
.DAILY
){
2478 _194
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_196
)});
2480 _194
.push({v
:t
,label
:this.hmsString_(t
)});
2486 if(_193
==Dygraph
.MONTHLY
){
2487 _198
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
2489 if(_193
==Dygraph
.QUARTERLY
){
2492 if(_193
==Dygraph
.BIANNUAL
){
2495 if(_193
==Dygraph
.ANNUAL
){
2498 if(_193
==Dygraph
.DECADAL
){
2506 var _200
=new Date(_191
).getFullYear();
2507 var _201
=new Date(_192
).getFullYear();
2508 var _202
=Dygraph
.zeropad
;
2509 for(var i
=_200
;i
<=_201
;i
++){
2513 for(var j
=0;j
<_198
.length
;j
++){
2514 var _203
=i
+"/"+_202(1+_198[j])+"/01";
2515 var t
=Date
.parse(_203
);
2519 _194
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
2525 Dygraph
.dateTicker
=function(_204
,_205
,self
){
2527 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
2528 var _207
=self
.NumXTicks(_204
,_205
,i
);
2529 if(self
.width_
/_207
>=self
.attr_("pixelsPerXLabel")){
2535 return self
.GetXAxis(_204
,_205
,_206
);
2539 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
2541 var _211
,low_val
,high_val
,nTicks
;
2542 var _212
=self
.attr_("pixelsPerYLabel");
2543 for(var i
=-10;i
<50;i
++){
2544 var _213
=Math
.pow(10,i
);
2545 for(var j
=0;j
<_210
.length
;j
++){
2547 low_val
=Math
.floor(minV
/_211
)*_211
;
2548 high_val
=Math
.ceil(maxV
/_211
)*_211
;
2549 nTicks
=(high_val
-low_val
)/_211
;
2550 var _214
=self
.height_
/nTicks
;
2560 for(var i
=0;i
<nTicks
;i
++){
2561 var _216
=low_val
+i
*_211
;
2562 var _217
=self
.round_(_216
,2);
2563 if(self
.attr_("labelsKMB")){
2566 _217
=self
.round_(_216
/(k
*k
*k
),1)+"B";
2569 _217
=self
.round_(_216
/(k
*k
),1)+"M";
2572 _217
=self
.round_(_216
/k
,1)+"K";
2577 _215
.push({label
:_217
,v
:_216
});
2581 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
2582 var _221
=Dygraph
.numericTicks(minY
,maxY
,this);
2583 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_221
});
2585 Dygraph
.prototype.extremeValues_
=function(_222
){
2586 var minY
=null,maxY
=null;
2587 var bars
=this.attr_("errorBars")||this.attr_("customBars");
2589 for(var j
=0;j
<_222
.length
;j
++){
2590 var y
=_222
[j
][1][0];
2594 var low
=y
-_222
[j
][1][1];
2595 var high
=y
+_222
[j
][1][2];
2602 if(maxY
==null||high
>maxY
){
2605 if(minY
==null||low
<minY
){
2610 for(var j
=0;j
<_222
.length
;j
++){
2615 if(maxY
==null||y
>maxY
){
2618 if(minY
==null||y
<minY
){
2625 Dygraph
.prototype.drawGraph_
=function(data
){
2626 var minY
=null,maxY
=null;
2627 this.layout_
.removeAllDatasets();
2629 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
2630 for(var i
=1;i
<data
[0].length
;i
++){
2632 for(var j
=0;j
<data
.length
;j
++){
2633 var date
=data
[j
][0];
2634 _226
[j
]=[date
,data
[j
][i
]];
2636 _226
=this.rollingAverage(_226
,this.rollPeriod_
);
2637 var bars
=this.attr_("errorBars")||this.attr_("customBars");
2638 if(this.dateWindow_
){
2639 var low
=this.dateWindow_
[0];
2640 var high
=this.dateWindow_
[1];
2642 for(var k
=0;k
<_226
.length
;k
++){
2643 if(_226
[k
][0]>=low
&&_226
[k
][0]<=high
){
2649 var _228
=this.extremeValues_(_226
);
2652 if(!minY
||_229
<minY
){
2655 if(!maxY
||_230
>maxY
){
2660 for(var j
=0;j
<_226
.length
;j
++){
2661 vals
[j
]=[_226
[j
][0],_226
[j
][1][0],_226
[j
][1][1],_226
[j
][1][2]];
2663 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
2665 this.layout_
.addDataset(this.attr_("labels")[i
],_226
);
2668 if(this.valueRange_
!=null){
2669 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
2672 var _233
=maxY
+0.1*span
;
2673 var _234
=minY
-0.1*span
;
2674 if(_234
<0&&minY
>=0){
2677 if(_233
>0&&maxY
<=0){
2680 if(this.attr_("includeZero")){
2688 this.addYTicks_(_234
,_233
);
2691 this.layout_
.evaluateWithError();
2692 this.plotter_
.clear();
2693 this.plotter_
.render();
2694 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
2696 Dygraph
.prototype.rollingAverage
=function(_235
,_236
){
2700 var _236
=Math
.min(_236
,_235
.length
-1);
2702 var _238
=this.attr_("sigma");
2703 if(this.fractions_
){
2707 for(var i
=0;i
<_235
.length
;i
++){
2711 num
-=_235
[i
-_236
][1][0];
2712 den
-=_235
[i
-_236
][1][1];
2714 var date
=_235
[i
][0];
2715 var _241
=den
?num
/den
:0;
2716 if(this.attr_("errorBars")){
2717 if(this.wilsonInterval_
){
2719 var p
=_241
<0?0:_241
,n
=den
;
2720 var pm
=_238
*Math
.sqrt(p
*(1-p
)/n+_238*_238/(4*n
*n
));
2721 var _244
=1+_238
*_238
/den
;
2722 var low
=(p
+_238
*_238
/(2*den)-pm)/_244
;
2723 var high
=(p
+_238
*_238
/(2*den)+pm)/_244
;
2724 _237
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
2726 _237
[i
]=[date
,[0,0,0]];
2729 var _245
=den
?_238
*Math
.sqrt(_241
*(1-_241
)/den
):1;
2730 _237
[i
]=[date
,[mult
*_241
,mult
*_245
,mult
*_245
]];
2733 _237
[i
]=[date
,mult
*_241
];
2737 if(this.attr_("customBars")){
2742 for(var i
=0;i
<_235
.length
;i
++){
2743 var data
=_235
[i
][1];
2745 _237
[i
]=[_235
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
2751 var prev
=_235
[i
-_236
];
2757 _237
[i
]=[_235
[i
][0],[1*mid
/_247,1*(mid-low)/_247
,1*(high
-mid
)/_247
]];
2760 var _249
=Math
.min(_236
-1,_235
.length
-2);
2761 if(!this.attr_("errorBars")){
2765 for(var i
=0;i
<_235
.length
;i
++){
2768 for(var j
=Math
.max(0,i
-_236
+1);j
<i
+1;j
++){
2777 _237
[i
]=[_235
[i
][0],sum
/_251
];
2779 _237
[i
]=[_235
[i
][0],null];
2783 for(var i
=0;i
<_235
.length
;i
++){
2787 for(var j
=Math
.max(0,i
-_236
+1);j
<i
+1;j
++){
2788 var y
=_235
[j
][1][0];
2794 _252
+=Math
.pow(_235
[j
][1][1],2);
2797 var _245
=Math
.sqrt(_252
)/_251
;
2798 _237
[i
]=[_235
[i
][0],[sum
/_251
,_238
*_245
,_238
*_245
]];
2800 _237
[i
]=[_235
[i
][0],[null,null,null]];
2808 Dygraph
.dateParser
=function(_253
,self
){
2811 if(_253
.length
==10&&_253
.search("-")!=-1){
2812 _254
=_253
.replace("-","/","g");
2813 while(_254
.search("-")!=-1){
2814 _254
=_254
.replace("-","/");
2819 _254
=_253
.substr(0,4)+"/"+_253.substr(4,2)+"/"+_253
.substr(6,2);
2826 self
.error("Couldn't parse "+_253
+" as a date");
2830 Dygraph
.prototype.detectTypeFromString_
=function(str
){
2832 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
2835 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
2840 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
2841 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
2842 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
2844 this.attrs_
.xValueFormatter
=function(x
){
2847 this.attrs_
.xValueParser
=function(x
){
2848 return parseFloat(x
);
2850 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
2853 Dygraph
.prototype.parseCSV_
=function(data
){
2855 var _257
=data
.split("\n");
2857 if(this.labelsFromCSV_
){
2859 this.attrs_
.labels
=_257
[0].split(",");
2863 var _261
=this.attr_("labels").length
;
2864 for(var i
=_258
;i
<_257
.length
;i
++){
2869 var _263
=line
.split(",");
2875 this.detectTypeFromString_(_263
[0]);
2876 _259
=this.attr_("xValueParser");
2879 _264
[0]=_259(_263
[0],this);
2880 if(this.fractions_
){
2881 for(var j
=1;j
<_263
.length
;j
++){
2882 var vals
=_263
[j
].split("/");
2883 _264
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
2886 if(this.attr_("errorBars")){
2887 for(var j
=1;j
<_263
.length
;j
+=2){
2888 _264
[(j
+1)/2]=[parseFloat(_263
[j
]),parseFloat(_263
[j
+1])];
2891 if(this.attr_("customBars")){
2892 for(var j
=1;j
<_263
.length
;j
++){
2893 var vals
=_263
[j
].split(";");
2894 _264
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
2897 for(var j
=1;j
<_263
.length
;j
++){
2898 _264
[j
]=parseFloat(_263
[j
]);
2904 if(_264
.length
!=_261
){
2905 this.error("Number of columns in line "+i
+" ("+_264
.length
+") does not agree with number of labels ("+_261
+") "+line
);
2910 Dygraph
.prototype.parseArray_
=function(data
){
2912 this.error("Can't plot empty data set");
2915 if(data
[0].length
==0){
2916 this.error("Data set cannot contain an empty row");
2919 if(this.attr_("labels")==null){
2920 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
2921 this.attrs_
.labels
=["X"];
2922 for(var i
=1;i
<data
[0].length
;i
++){
2923 this.attrs_
.labels
.push("Y"+i
);
2926 if(MochiKit
.Base
.isDateLike(data
[0][0])){
2927 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
2928 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
2929 var _265
=MochiKit
.Base
.clone(data
);
2930 for(var i
=0;i
<data
.length
;i
++){
2931 if(_265
[i
].length
==0){
2932 this.error("Row "<<(1+i
)<<" of data is empty");
2935 if(_265
[i
][0]==null||typeof (_265
[i
][0].getTime
)!="function"){
2936 this.error("x value in row "<<(1+i
)<<" is not a Date");
2939 _265
[i
][0]=_265
[i
][0].getTime();
2943 this.attrs_
.xValueFormatter
=function(x
){
2946 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
2950 Dygraph
.prototype.parseDataTable_
=function(data
){
2951 var cols
=data
.getNumberOfColumns();
2952 var rows
=data
.getNumberOfRows();
2954 for(var i
=0;i
<cols
;i
++){
2955 _268
.push(data
.getColumnLabel(i
));
2957 this.attrs_
.labels
=_268
;
2958 var _269
=data
.getColumnType(0);
2960 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
2961 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
2962 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
2965 this.attrs_
.xValueFormatter
=function(x
){
2968 this.attrs_
.xValueParser
=function(x
){
2969 return parseFloat(x
);
2971 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
2973 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_269
+"')");
2978 for(var i
=0;i
<rows
;i
++){
2980 if(!data
.getValue(i
,0)){
2984 row
.push(data
.getValue(i
,0).getTime());
2986 row
.push(data
.getValue(i
,0));
2988 for(var j
=1;j
<cols
;j
++){
2989 row
.push(data
.getValue(i
,j
));
2995 Dygraph
.prototype.start_
=function(){
2996 if(typeof this.file_
=="function"){
2997 this.loadedEvent_(this.file_());
2999 if(MochiKit
.Base
.isArrayLike(this.file_
)){
3000 this.rawData_
=this.parseArray_(this.file_
);
3001 this.drawGraph_(this.rawData_
);
3003 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
3004 this.rawData_
=this.parseDataTable_(this.file_
);
3005 this.drawGraph_(this.rawData_
);
3007 if(typeof this.file_
=="string"){
3008 if(this.file_
.indexOf("\n")>=0){
3009 this.loadedEvent_(this.file_
);
3011 var req
=new XMLHttpRequest();
3013 req
.onreadystatechange
=function(){
3014 if(req
.readyState
==4){
3015 if(req
.status
==200){
3016 _272
.loadedEvent_(req
.responseText
);
3020 req
.open("GET",this.file_
,true);
3024 this.error("Unknown data format: "+(typeof this.file_
));
3030 Dygraph
.prototype.updateOptions
=function(_273
){
3031 if(_273
.rollPeriod
){
3032 this.rollPeriod_
=_273
.rollPeriod
;
3034 if(_273
.dateWindow
){
3035 this.dateWindow_
=_273
.dateWindow
;
3037 if(_273
.valueRange
){
3038 this.valueRange_
=_273
.valueRange
;
3040 MochiKit
.Base
.update(this.user_attrs_
,_273
);
3041 this.labelsFromCSV_
=(this.attr_("labels")==null);
3042 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
3043 if(_273
["file"]&&_273
["file"]!=this.file_
){
3044 this.file_
=_273
["file"];
3047 this.drawGraph_(this.rawData_
);
3050 Dygraph
.prototype.adjustRoll
=function(_274
){
3051 this.rollPeriod_
=_274
;
3052 this.drawGraph_(this.rawData_
);
3054 Dygraph
.GVizChart
=function(_275
){
3055 this.container
=_275
;
3057 Dygraph
.GVizChart
.prototype.draw
=function(data
,_276
){
3058 this.container
.innerHTML
="";
3059 this.date_graph
=new Dygraph(this.container
,data
,_276
);