start removing Color dependence
[dygraphs.git] / dygraph-combined.js
CommitLineData
6a1aa64f
DV
1/***
2
3 MochiKit.MochiKit 1.4 : PACKED VERSION
4
5 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6 diff against the source tree, not this file.
7
8 See <http://mochikit.com/> for documentation, downloads, license, etc.
9
10 (c) 2005 Bob Ippolito. All rights Reserved.
11
12***/
13
14if(typeof (dojo)!="undefined"){
15dojo.provide("MochiKit.Base");
16}
17if(typeof (MochiKit)=="undefined"){
18MochiKit={};
19}
20if(typeof (MochiKit.Base)=="undefined"){
21MochiKit.Base={};
22}
23if(typeof (MochiKit.__export__)=="undefined"){
24MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined"));
25}
26MochiKit.Base.VERSION="1.4";
27MochiKit.Base.NAME="MochiKit.Base";
28MochiKit.Base.update=function(_1,_2){
29if(_1===null){
30_1={};
31}
32for(var i=1;i<arguments.length;i++){
33var o=arguments[i];
34if(typeof (o)!="undefined"&&o!==null){
35for(var k in o){
36_1[k]=o[k];
37}
38}
39}
40return _1;
41};
42MochiKit.Base.update(MochiKit.Base,{__repr__:function(){
43return "["+this.NAME+" "+this.VERSION+"]";
44},toString:function(){
45return this.__repr__();
46},camelize:function(_6){
47var _7=_6.split("-");
48var cc=_7[0];
49for(var i=1;i<_7.length;i++){
50cc+=_7[i].charAt(0).toUpperCase()+_7[i].substring(1);
51}
52return cc;
53},counter:function(n){
54if(arguments.length===0){
55n=1;
56}
57return function(){
58return n++;
59};
60},clone:function(_b){
61var me=arguments.callee;
62if(arguments.length==1){
63me.prototype=_b;
64return new me();
65}
66},_flattenArray:function(_d,_e){
67for(var i=0;i<_e.length;i++){
68var o=_e[i];
69if(o instanceof Array){
70arguments.callee(_d,o);
71}else{
72_d.push(o);
73}
74}
75return _d;
76},flattenArray:function(lst){
77return MochiKit.Base._flattenArray([],lst);
78},flattenArguments:function(lst){
79var res=[];
80var m=MochiKit.Base;
81var _15=m.extend(null,arguments);
82while(_15.length){
83var o=_15.shift();
84if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
85for(var i=o.length-1;i>=0;i--){
86_15.unshift(o[i]);
87}
88}else{
89res.push(o);
90}
91}
92return res;
93},extend:function(_18,obj,_1a){
94if(!_1a){
95_1a=0;
96}
97if(obj){
98var l=obj.length;
99if(typeof (l)!="number"){
100if(typeof (MochiKit.Iter)!="undefined"){
101obj=MochiKit.Iter.list(obj);
102l=obj.length;
103}else{
104throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
105}
106}
107if(!_18){
108_18=[];
109}
110for(var i=_1a;i<l;i++){
111_18.push(obj[i]);
112}
113}
114return _18;
115},updatetree:function(_1d,obj){
116if(_1d===null){
117_1d={};
118}
119for(var i=1;i<arguments.length;i++){
120var o=arguments[i];
121if(typeof (o)!="undefined"&&o!==null){
122for(var k in o){
123var v=o[k];
124if(typeof (_1d[k])=="object"&&typeof (v)=="object"){
125arguments.callee(_1d[k],v);
126}else{
127_1d[k]=v;
128}
129}
130}
131}
132return _1d;
133},setdefault:function(_23,obj){
134if(_23===null){
135_23={};
136}
137for(var i=1;i<arguments.length;i++){
138var o=arguments[i];
139for(var k in o){
140if(!(k in _23)){
141_23[k]=o[k];
142}
143}
144}
145return _23;
146},keys:function(obj){
147var _29=[];
148for(var _2a in obj){
149_29.push(_2a);
150}
151return _29;
152},values:function(obj){
153var _2c=[];
154for(var _2d in obj){
155_2c.push(obj[_2d]);
156}
157return _2c;
158},items:function(obj){
159var _2f=[];
160var e;
161for(var _31 in obj){
162var v;
163try{
164v=obj[_31];
165}
166catch(e){
167continue;
168}
169_2f.push([_31,v]);
170}
171return _2f;
172},_newNamedError:function(_33,_34,_35){
173_35.prototype=new MochiKit.Base.NamedError(_33.NAME+"."+_34);
174_33[_34]=_35;
175},operator:{truth:function(a){
176return !!a;
177},lognot:function(a){
178return !a;
179},identity:function(a){
180return a;
181},not:function(a){
182return ~a;
183},neg:function(a){
184return -a;
185},add:function(a,b){
186return a+b;
187},sub:function(a,b){
188return a-b;
189},div:function(a,b){
190return a/b;
191},mod:function(a,b){
192return a%b;
193},mul:function(a,b){
194return a*b;
195},and:function(a,b){
196return a&b;
197},or:function(a,b){
198return a|b;
199},xor:function(a,b){
200return a^b;
201},lshift:function(a,b){
202return a<<b;
203},rshift:function(a,b){
204return a>>b;
205},zrshift:function(a,b){
206return a>>>b;
207},eq:function(a,b){
208return a==b;
209},ne:function(a,b){
210return a!=b;
211},gt:function(a,b){
212return a>b;
213},ge:function(a,b){
214return a>=b;
215},lt:function(a,b){
216return a<b;
217},le:function(a,b){
218return a<=b;
219},seq:function(a,b){
220return a===b;
221},sne:function(a,b){
222return a!==b;
223},ceq:function(a,b){
224return MochiKit.Base.compare(a,b)===0;
225},cne:function(a,b){
226return MochiKit.Base.compare(a,b)!==0;
227},cgt:function(a,b){
228return MochiKit.Base.compare(a,b)==1;
229},cge:function(a,b){
230return MochiKit.Base.compare(a,b)!=-1;
231},clt:function(a,b){
232return MochiKit.Base.compare(a,b)==-1;
233},cle:function(a,b){
234return MochiKit.Base.compare(a,b)!=1;
235},logand:function(a,b){
236return a&&b;
237},logor:function(a,b){
238return a||b;
239},contains:function(a,b){
240return b in a;
241}},forwardCall:function(_73){
242return function(){
243return this[_73].apply(this,arguments);
244};
245},itemgetter:function(_74){
246return function(arg){
247return arg[_74];
248};
249},typeMatcher:function(){
250var _76={};
251for(var i=0;i<arguments.length;i++){
252var typ=arguments[i];
253_76[typ]=typ;
254}
255return function(){
256for(var i=0;i<arguments.length;i++){
257if(!(typeof (arguments[i]) in _76)){
258return false;
259}
260}
261return true;
262};
263},isNull:function(){
264for(var i=0;i<arguments.length;i++){
265if(arguments[i]!==null){
266return false;
267}
268}
269return true;
270},isUndefinedOrNull:function(){
271for(var i=0;i<arguments.length;i++){
272var o=arguments[i];
273if(!(typeof (o)=="undefined"||o===null)){
274return false;
275}
276}
277return true;
278},isEmpty:function(obj){
279return !MochiKit.Base.isNotEmpty.apply(this,arguments);
280},isNotEmpty:function(obj){
281for(var i=0;i<arguments.length;i++){
282var o=arguments[i];
283if(!(o&&o.length)){
284return false;
285}
286}
287return true;
288},isArrayLike:function(){
289for(var i=0;i<arguments.length;i++){
290var o=arguments[i];
291var typ=typeof (o);
292if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o===null||typeof (o.length)!="number"||o.nodeType===3){
293return false;
294}
295}
296return true;
297},isDateLike:function(){
298for(var i=0;i<arguments.length;i++){
299var o=arguments[i];
300if(typeof (o)!="object"||o===null||typeof (o.getTime)!="function"){
301return false;
302}
303}
304return true;
305},xmap:function(fn){
306if(fn===null){
307return MochiKit.Base.extend(null,arguments,1);
308}
309var _87=[];
310for(var i=1;i<arguments.length;i++){
311_87.push(fn(arguments[i]));
312}
313return _87;
314},map:function(fn,lst){
315var m=MochiKit.Base;
316var itr=MochiKit.Iter;
317var _8d=m.isArrayLike;
318if(arguments.length<=2){
319if(!_8d(lst)){
320if(itr){
321lst=itr.list(lst);
322if(fn===null){
323return lst;
324}
325}else{
326throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
327}
328}
329if(fn===null){
330return m.extend(null,lst);
331}
332var _8e=[];
333for(var i=0;i<lst.length;i++){
334_8e.push(fn(lst[i]));
335}
336return _8e;
337}else{
338if(fn===null){
339fn=Array;
340}
341var _90=null;
342for(i=1;i<arguments.length;i++){
343if(!_8d(arguments[i])){
344if(itr){
345return itr.list(itr.imap.apply(null,arguments));
346}else{
347throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
348}
349}
350var l=arguments[i].length;
351if(_90===null||_90>l){
352_90=l;
353}
354}
355_8e=[];
356for(i=0;i<_90;i++){
357var _92=[];
358for(var j=1;j<arguments.length;j++){
359_92.push(arguments[j][i]);
360}
361_8e.push(fn.apply(this,_92));
362}
363return _8e;
364}
365},xfilter:function(fn){
366var _95=[];
367if(fn===null){
368fn=MochiKit.Base.operator.truth;
369}
370for(var i=1;i<arguments.length;i++){
371var o=arguments[i];
372if(fn(o)){
373_95.push(o);
374}
375}
376return _95;
377},filter:function(fn,lst,_9a){
378var _9b=[];
379var m=MochiKit.Base;
380if(!m.isArrayLike(lst)){
381if(MochiKit.Iter){
382lst=MochiKit.Iter.list(lst);
383}else{
384throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
385}
386}
387if(fn===null){
388fn=m.operator.truth;
389}
390if(typeof (Array.prototype.filter)=="function"){
391return Array.prototype.filter.call(lst,fn,_9a);
392}else{
393if(typeof (_9a)=="undefined"||_9a===null){
394for(var i=0;i<lst.length;i++){
395var o=lst[i];
396if(fn(o)){
397_9b.push(o);
398}
399}
400}else{
401for(i=0;i<lst.length;i++){
402o=lst[i];
403if(fn.call(_9a,o)){
404_9b.push(o);
405}
406}
407}
408}
409return _9b;
410},_wrapDumbFunction:function(_9f){
411return function(){
412switch(arguments.length){
413case 0:
414return _9f();
415case 1:
416return _9f(arguments[0]);
417case 2:
418return _9f(arguments[0],arguments[1]);
419case 3:
420return _9f(arguments[0],arguments[1],arguments[2]);
421}
422var _a0=[];
423for(var i=0;i<arguments.length;i++){
424_a0.push("arguments["+i+"]");
425}
426return eval("(func("+_a0.join(",")+"))");
427};
428},methodcaller:function(_a2){
429var _a3=MochiKit.Base.extend(null,arguments,1);
430if(typeof (_a2)=="function"){
431return function(obj){
432return _a2.apply(obj,_a3);
433};
434}else{
435return function(obj){
436return obj[_a2].apply(obj,_a3);
437};
438}
439},method:function(_a6,_a7){
440var m=MochiKit.Base;
441return m.bind.apply(this,m.extend([_a7,_a6],arguments,2));
442},compose:function(f1,f2){
443var _ab=[];
444var m=MochiKit.Base;
445if(arguments.length===0){
446throw new TypeError("compose() requires at least one argument");
447}
448for(var i=0;i<arguments.length;i++){
449var fn=arguments[i];
450if(typeof (fn)!="function"){
451throw new TypeError(m.repr(fn)+" is not a function");
452}
453_ab.push(fn);
454}
455return function(){
456var _af=arguments;
457for(var i=_ab.length-1;i>=0;i--){
458_af=[_ab[i].apply(this,_af)];
459}
460return _af[0];
461};
462},bind:function(_b1,_b2){
463if(typeof (_b1)=="string"){
464_b1=_b2[_b1];
465}
466var _b3=_b1.im_func;
467var _b4=_b1.im_preargs;
468var _b5=_b1.im_self;
469var m=MochiKit.Base;
470if(typeof (_b1)=="function"&&typeof (_b1.apply)=="undefined"){
471_b1=m._wrapDumbFunction(_b1);
472}
473if(typeof (_b3)!="function"){
474_b3=_b1;
475}
476if(typeof (_b2)!="undefined"){
477_b5=_b2;
478}
479if(typeof (_b4)=="undefined"){
480_b4=[];
481}else{
482_b4=_b4.slice();
483}
484m.extend(_b4,arguments,2);
485var _b7=function(){
486var _b8=arguments;
487var me=arguments.callee;
488if(me.im_preargs.length>0){
489_b8=m.concat(me.im_preargs,_b8);
490}
491var _ba=me.im_self;
492if(!_ba){
493_ba=this;
494}
495return me.im_func.apply(_ba,_b8);
496};
497_b7.im_self=_b5;
498_b7.im_func=_b3;
499_b7.im_preargs=_b4;
500return _b7;
501},bindMethods:function(_bb){
502var _bc=MochiKit.Base.bind;
503for(var k in _bb){
504var _be=_bb[k];
505if(typeof (_be)=="function"){
506_bb[k]=_bc(_be,_bb);
507}
508}
509},registerComparator:function(_bf,_c0,_c1,_c2){
510MochiKit.Base.comparatorRegistry.register(_bf,_c0,_c1,_c2);
511},_primitives:{"boolean":true,"string":true,"number":true},compare:function(a,b){
512if(a==b){
513return 0;
514}
515var _c5=(typeof (a)=="undefined"||a===null);
516var _c6=(typeof (b)=="undefined"||b===null);
517if(_c5&&_c6){
518return 0;
519}else{
520if(_c5){
521return -1;
522}else{
523if(_c6){
524return 1;
525}
526}
527}
528var m=MochiKit.Base;
529var _c8=m._primitives;
530if(!(typeof (a) in _c8&&typeof (b) in _c8)){
531try{
532return m.comparatorRegistry.match(a,b);
533}
534catch(e){
535if(e!=m.NotFound){
536throw e;
537}
538}
539}
540if(a<b){
541return -1;
542}else{
543if(a>b){
544return 1;
545}
546}
547var _c9=m.repr;
548throw new TypeError(_c9(a)+" and "+_c9(b)+" can not be compared");
549},compareDateLike:function(a,b){
550return MochiKit.Base.compare(a.getTime(),b.getTime());
551},compareArrayLike:function(a,b){
552var _ce=MochiKit.Base.compare;
553var _cf=a.length;
554var _d0=0;
555if(_cf>b.length){
556_d0=1;
557_cf=b.length;
558}else{
559if(_cf<b.length){
560_d0=-1;
561}
562}
563for(var i=0;i<_cf;i++){
564var cmp=_ce(a[i],b[i]);
565if(cmp){
566return cmp;
567}
568}
569return _d0;
570},registerRepr:function(_d3,_d4,_d5,_d6){
571MochiKit.Base.reprRegistry.register(_d3,_d4,_d5,_d6);
572},repr:function(o){
573if(typeof (o)=="undefined"){
574return "undefined";
575}else{
576if(o===null){
577return "null";
578}
579}
580try{
581if(typeof (o.__repr__)=="function"){
582return o.__repr__();
583}else{
584if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){
585return o.repr();
586}
587}
588return MochiKit.Base.reprRegistry.match(o);
589}
590catch(e){
591if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){
592return o.NAME;
593}
594}
595try{
596var _d8=(o+"");
597}
598catch(e){
599return "["+typeof (o)+"]";
600}
601if(typeof (o)=="function"){
602o=_d8.replace(/^\s+/,"");
603var idx=o.indexOf("{");
604if(idx!=-1){
605o=o.substr(0,idx)+"{...}";
606}
607}
608return _d8;
609},reprArrayLike:function(o){
610var m=MochiKit.Base;
611return "["+m.map(m.repr,o).join(", ")+"]";
612},reprString:function(o){
613return ("\""+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){
615return o+"";
616},registerJSON:function(_de,_df,_e0,_e1){
617MochiKit.Base.jsonRegistry.register(_de,_df,_e0,_e1);
618},evalJSON:function(){
619return eval("("+arguments[0]+")");
620},serializeJSON:function(o){
621var _e3=typeof (o);
622if(_e3=="number"||_e3=="boolean"){
623return o+"";
624}else{
625if(o===null){
626return "null";
627}
628}
629var m=MochiKit.Base;
630var _e5=m.reprString;
631if(_e3=="string"){
632return _e5(o);
633}
634var me=arguments.callee;
635var _e7;
636if(typeof (o.__json__)=="function"){
637_e7=o.__json__();
638if(o!==_e7){
639return me(_e7);
640}
641}
642if(typeof (o.json)=="function"){
643_e7=o.json();
644if(o!==_e7){
645return me(_e7);
646}
647}
648if(_e3!="function"&&typeof (o.length)=="number"){
649var res=[];
650for(var i=0;i<o.length;i++){
651var val=me(o[i]);
652if(typeof (val)!="string"){
653val="undefined";
654}
655res.push(val);
656}
657return "["+res.join(", ")+"]";
658}
659try{
660_e7=m.jsonRegistry.match(o);
661if(o!==_e7){
662return me(_e7);
663}
664}
665catch(e){
666if(e!=m.NotFound){
667throw e;
668}
669}
670if(_e3=="undefined"){
671throw new TypeError("undefined can not be serialized as JSON");
672}
673if(_e3=="function"){
674return null;
675}
676res=[];
677for(var k in o){
678var _ec;
679if(typeof (k)=="number"){
680_ec="\""+k+"\"";
681}else{
682if(typeof (k)=="string"){
683_ec=_e5(k);
684}else{
685continue;
686}
687}
688val=me(o[k]);
689if(typeof (val)!="string"){
690continue;
691}
692res.push(_ec+":"+val);
693}
694return "{"+res.join(", ")+"}";
695},objEqual:function(a,b){
696return (MochiKit.Base.compare(a,b)===0);
697},arrayEqual:function(_ef,arr){
698if(_ef.length!=arr.length){
699return false;
700}
701return (MochiKit.Base.compare(_ef,arr)===0);
702},concat:function(){
703var _f1=[];
704var _f2=MochiKit.Base.extend;
705for(var i=0;i<arguments.length;i++){
706_f2(_f1,arguments[i]);
707}
708return _f1;
709},keyComparator:function(key){
710var m=MochiKit.Base;
711var _f6=m.compare;
712if(arguments.length==1){
713return function(a,b){
714return _f6(a[key],b[key]);
715};
716}
717var _f9=m.extend(null,arguments);
718return function(a,b){
719var _fc=0;
720for(var i=0;(_fc===0)&&(i<_f9.length);i++){
721var key=_f9[i];
722_fc=_f6(a[key],b[key]);
723}
724return _fc;
725};
726},reverseKeyComparator:function(key){
727var _100=MochiKit.Base.keyComparator.apply(this,arguments);
728return function(a,b){
729return _100(b,a);
730};
731},partial:function(func){
732var m=MochiKit.Base;
733return m.bind.apply(this,m.extend([func,undefined],arguments,1));
734},listMinMax:function(_105,lst){
735if(lst.length===0){
736return null;
737}
738var cur=lst[0];
739var _108=MochiKit.Base.compare;
740for(var i=1;i<lst.length;i++){
741var o=lst[i];
742if(_108(o,cur)==_105){
743cur=o;
744}
745}
746return cur;
747},objMax:function(){
748return MochiKit.Base.listMinMax(1,arguments);
749},objMin:function(){
750return MochiKit.Base.listMinMax(-1,arguments);
751},findIdentical:function(lst,_10c,_10d,end){
752if(typeof (end)=="undefined"||end===null){
753end=lst.length;
754}
755if(typeof (_10d)=="undefined"||_10d===null){
756_10d=0;
757}
758for(var i=_10d;i<end;i++){
759if(lst[i]===_10c){
760return i;
761}
762}
763return -1;
764},mean:function(){
765var sum=0;
766var m=MochiKit.Base;
767var args=m.extend(null,arguments);
768var _113=args.length;
769while(args.length){
770var o=args.shift();
771if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
772_113+=o.length-1;
773for(var i=o.length-1;i>=0;i--){
774sum+=o[i];
775}
776}else{
777sum+=o;
778}
779}
780if(_113<=0){
781throw new TypeError("mean() requires at least one argument");
782}
783return sum/_113;
784},median:function(){
785var data=MochiKit.Base.flattenArguments(arguments);
786if(data.length===0){
787throw new TypeError("median() requires at least one argument");
788}
789data.sort(compare);
790if(data.length%2==0){
791var _117=data.length/2;
792return (data[_117]+data[_117-1])/2;
793}else{
794return data[(data.length-1)/2];
795}
796},findValue:function(lst,_119,_11a,end){
797if(typeof (end)=="undefined"||end===null){
798end=lst.length;
799}
800if(typeof (_11a)=="undefined"||_11a===null){
801_11a=0;
802}
803var cmp=MochiKit.Base.compare;
804for(var i=_11a;i<end;i++){
805if(cmp(lst[i],_119)===0){
806return i;
807}
808}
809return -1;
810},nodeWalk:function(node,_11f){
811var _120=[node];
812var _121=MochiKit.Base.extend;
813while(_120.length){
814var res=_11f(_120.shift());
815if(res){
816_121(_120,res);
817}
818}
819},nameFunctions:function(_123){
820var base=_123.NAME;
821if(typeof (base)=="undefined"){
822base="";
823}else{
824base=base+".";
825}
826for(var name in _123){
827var o=_123[name];
828if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
829try{
830o.NAME=base+name;
831}
832catch(e){
833}
834}
835}
836},queryString:function(_127,_128){
837if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_127)=="string"||(typeof (_127.nodeType)!="undefined"&&_127.nodeType>0))){
838var kv=MochiKit.DOM.formContents(_127);
839_127=kv[0];
840_128=kv[1];
841}else{
842if(arguments.length==1){
843if(typeof (_127.length)=="number"&&_127.length==2){
844return arguments.callee(_127[0],_127[1]);
845}
846var o=_127;
847_127=[];
848_128=[];
849for(var k in o){
850var v=o[k];
851if(typeof (v)=="function"){
852continue;
853}else{
854if(typeof (v)!="string"&&typeof (v.length)=="number"){
855for(var i=0;i<v.length;i++){
856_127.push(k);
857_128.push(v[i]);
858}
859}else{
860_127.push(k);
861_128.push(v);
862}
863}
864}
865}
866}
867var rval=[];
868var len=Math.min(_127.length,_128.length);
869var _130=MochiKit.Base.urlEncode;
870for(var i=0;i<len;i++){
871v=_128[i];
872if(typeof (v)!="undefined"&&v!==null){
873rval.push(_130(_127[i])+"="+_130(v));
874}
875}
876return rval.join("&");
877},parseQueryString:function(_131,_132){
878var qstr=(_131.charAt(0)=="?")?_131.substring(1):_131;
879var _134=qstr.replace(/\+/g,"%20").split(/(\&amp\;|\&\#38\;|\&#x26;|\&)/);
880var o={};
881var _136;
882if(typeof (decodeURIComponent)!="undefined"){
883_136=decodeURIComponent;
884}else{
885_136=unescape;
886}
887if(_132){
888for(var i=0;i<_134.length;i++){
889var pair=_134[i].split("=");
890var name=_136(pair.shift());
891if(!name){
892continue;
893}
894var arr=o[name];
895if(!(arr instanceof Array)){
896arr=[];
897o[name]=arr;
898}
899arr.push(_136(pair.join("=")));
900}
901}else{
902for(i=0;i<_134.length;i++){
903pair=_134[i].split("=");
904var name=pair.shift();
905if(!name){
906continue;
907}
908o[_136(name)]=_136(pair.join("="));
909}
910}
911return o;
912}});
913MochiKit.Base.AdapterRegistry=function(){
914this.pairs=[];
915};
916MochiKit.Base.AdapterRegistry.prototype={register:function(name,_13c,wrap,_13e){
917if(_13e){
918this.pairs.unshift([name,_13c,wrap]);
919}else{
920this.pairs.push([name,_13c,wrap]);
921}
922},match:function(){
923for(var i=0;i<this.pairs.length;i++){
924var pair=this.pairs[i];
925if(pair[1].apply(this,arguments)){
926return pair[2].apply(this,arguments);
927}
928}
929throw MochiKit.Base.NotFound;
930},unregister:function(name){
931for(var i=0;i<this.pairs.length;i++){
932var pair=this.pairs[i];
933if(pair[0]==name){
934this.pairs.splice(i,1);
935return true;
936}
937}
938return false;
939}};
940MochiKit.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"];
941MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
942MochiKit.Base._exportSymbols=function(_144,_145){
943if(!MochiKit.__export__){
944return;
945}
946var all=_145.EXPORT_TAGS[":all"];
947for(var i=0;i<all.length;i++){
948_144[all[i]]=_145[all[i]];
949}
950};
951MochiKit.Base.__new__=function(){
952var m=this;
953m.noop=m.operator.identity;
954m.forward=m.forwardCall;
955m.find=m.findValue;
956if(typeof (encodeURIComponent)!="undefined"){
957m.urlEncode=function(_149){
958return encodeURIComponent(_149).replace(/\'/g,"%27");
959};
960}else{
961m.urlEncode=function(_14a){
962return escape(_14a).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27");
963};
964}
965m.NamedError=function(name){
966this.message=name;
967this.name=name;
968};
969m.NamedError.prototype=new Error();
970m.update(m.NamedError.prototype,{repr:function(){
971if(this.message&&this.message!=this.name){
972return this.name+"("+m.repr(this.message)+")";
973}else{
974return this.name+"()";
975}
976},toString:m.forwardCall("repr")});
977m.NotFound=new m.NamedError("MochiKit.Base.NotFound");
978m.listMax=m.partial(m.listMinMax,1);
979m.listMin=m.partial(m.listMinMax,-1);
980m.isCallable=m.typeMatcher("function");
981m.isUndefined=m.typeMatcher("undefined");
982m.merge=m.partial(m.update,null);
983m.zip=m.partial(m.map,null);
984m.average=m.mean;
985m.comparatorRegistry=new m.AdapterRegistry();
986m.registerComparator("dateLike",m.isDateLike,m.compareDateLike);
987m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike);
988m.reprRegistry=new m.AdapterRegistry();
989m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike);
990m.registerRepr("string",m.typeMatcher("string"),m.reprString);
991m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber);
992m.jsonRegistry=new m.AdapterRegistry();
993var all=m.concat(m.EXPORT,m.EXPORT_OK);
994m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all};
995m.nameFunctions(this);
996};
997MochiKit.Base.__new__();
998if(MochiKit.__export__){
999compare=MochiKit.Base.compare;
1000compose=MochiKit.Base.compose;
1001serializeJSON=MochiKit.Base.serializeJSON;
1002}
1003MochiKit.Base._exportSymbols(this,MochiKit.Base);
1004if(typeof (dojo)!="undefined"){
b0c3b730 1005dojo.provide("MochiKit.Color");
5fb1199a
DV
1006dojo.require("MochiKit.Base");
1007}
1008if(typeof (JSAN)!="undefined"){
1009JSAN.use("MochiKit.Base",[]);
1010}
1011try{
1012if(typeof (MochiKit.Base)=="undefined"){
1013throw "";
1014}
1015}
1016catch(e){
b0c3b730 1017throw "MochiKit.Color depends on MochiKit.Base";
5fb1199a 1018}
b0c3b730
DV
1019if(typeof (MochiKit.Color)=="undefined"){
1020MochiKit.Color={};
5fb1199a 1021}
b0c3b730
DV
1022MochiKit.Color.NAME="MochiKit.Color";
1023MochiKit.Color.VERSION="1.4";
1024MochiKit.Color.__repr__=function(){
5fb1199a 1025return "["+this.NAME+" "+this.VERSION+"]";
b0c3b730
DV
1026};
1027MochiKit.Color.toString=function(){
5fb1199a 1028return this.__repr__();
b0c3b730
DV
1029};
1030MochiKit.Color.Color=function(red,_14e,blue,_150){
1031if(typeof (_150)=="undefined"||_150===null){
1032_150=1;
5fb1199a 1033}
b0c3b730
DV
1034this.rgb={r:red,g:_14e,b:blue,a:_150};
1035};
1036MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_151){
1037var rgb=this.rgb;
1038var m=MochiKit.Color;
1039return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_151);
1040},colorWithHue:function(hue){
1041var hsl=this.asHSL();
1042hsl.h=hue;
1043var m=MochiKit.Color;
1044return m.Color.fromHSL(hsl);
1045},colorWithSaturation:function(_157){
1046var hsl=this.asHSL();
1047hsl.s=_157;
1048var m=MochiKit.Color;
1049return m.Color.fromHSL(hsl);
1050},colorWithLightness:function(_15a){
1051var hsl=this.asHSL();
1052hsl.l=_15a;
1053var m=MochiKit.Color;
1054return m.Color.fromHSL(hsl);
1055},darkerColorWithLevel:function(_15d){
1056var hsl=this.asHSL();
1057hsl.l=Math.max(hsl.l-_15d,0);
1058var m=MochiKit.Color;
1059return m.Color.fromHSL(hsl);
1060},lighterColorWithLevel:function(_160){
1061var hsl=this.asHSL();
1062hsl.l=Math.min(hsl.l+_160,1);
1063var m=MochiKit.Color;
1064return m.Color.fromHSL(hsl);
1065},blendedColor:function(_163,_164){
1066if(typeof (_164)=="undefined"||_164===null){
1067_164=0.5;
5fb1199a 1068}
b0c3b730
DV
1069var sf=1-_164;
1070var s=this.rgb;
1071var d=_163.rgb;
1072var df=_164;
1073return 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){
1075var a=this.asRGB();
1076var b=_169.asRGB();
1077return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]);
1078},isLight:function(){
1079return this.asHSL().b>0.5;
1080},isDark:function(){
1081return (!this.isLight());
1082},toHSLString:function(){
1083var c=this.asHSL();
1084var ccc=MochiKit.Color.clampColorComponent;
1085var rval=this._hslString;
1086if(!rval){
1087var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%");
1088var a=c.a;
1089if(a>=1){
1090a=1;
1091rval="hsl("+mid+")";
1092}else{
1093if(a<=0){
1094a=0;
5fb1199a 1095}
b0c3b730 1096rval="hsla("+mid+","+a+")";
5fb1199a 1097}
b0c3b730 1098this._hslString=rval;
5fb1199a 1099}
5fb1199a 1100return rval;
b0c3b730
DV
1101},toRGBString:function(){
1102var c=this.rgb;
1103var ccc=MochiKit.Color.clampColorComponent;
1104var rval=this._rgbString;
1105if(!rval){
1106var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0));
1107if(c.a!=1){
1108rval="rgba("+mid+","+c.a+")";
5fb1199a 1109}else{
b0c3b730 1110rval="rgb("+mid+")";
5fb1199a 1111}
b0c3b730 1112this._rgbString=rval;
5fb1199a 1113}
5fb1199a 1114return rval;
b0c3b730
DV
1115},asRGB:function(){
1116return MochiKit.Base.clone(this.rgb);
1117},toHexString:function(){
1118var m=MochiKit.Color;
1119var c=this.rgb;
1120var ccc=MochiKit.Color.clampColorComponent;
1121var rval=this._hexString;
1122if(!rval){
1123rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255)));
1124this._hexString=rval;
5fb1199a 1125}
5fb1199a 1126return rval;
b0c3b730
DV
1127},asHSV:function(){
1128var hsv=this.hsv;
1129var c=this.rgb;
1130if(typeof (hsv)=="undefined"||hsv===null){
1131hsv=MochiKit.Color.rgbToHSV(this.rgb);
1132this.hsv=hsv;
5fb1199a 1133}
b0c3b730
DV
1134return MochiKit.Base.clone(hsv);
1135},asHSL:function(){
1136var hsl=this.hsl;
1137var c=this.rgb;
1138if(typeof (hsl)=="undefined"||hsl===null){
1139hsl=MochiKit.Color.rgbToHSL(this.rgb);
1140this.hsl=hsl;
5fb1199a 1141}
b0c3b730
DV
1142return MochiKit.Base.clone(hsl);
1143},toString:function(){
1144return this.toRGBString();
1145},repr:function(){
1146var c=this.rgb;
1147var col=[c.r,c.g,c.b,c.a];
1148return this.__class__.NAME+"("+col.join(", ")+")";
5fb1199a 1149}};
b0c3b730
DV
1150MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_180,blue,_182){
1151var _183=MochiKit.Color.Color;
5fb1199a 1152if(arguments.length==1){
b0c3b730
DV
1153var rgb=red;
1154red=rgb.r;
1155_180=rgb.g;
1156blue=rgb.b;
1157if(typeof (rgb.a)=="undefined"){
1158_182=undefined;
1159}else{
1160_182=rgb.a;
5fb1199a 1161}
5fb1199a 1162}
b0c3b730
DV
1163return new _183(red,_180,blue,_182);
1164},fromHSL:function(hue,_186,_187,_188){
1165var m=MochiKit.Color;
1166return m.Color.fromRGB(m.hslToRGB.apply(m,arguments));
1167},fromHSV:function(hue,_18b,_18c,_18d){
1168var m=MochiKit.Color;
1169return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments));
1170},fromName:function(name){
1171var _190=MochiKit.Color.Color;
1172if(name.charAt(0)=="\""){
1173name=name.substr(1,name.length-2);
5fb1199a 1174}
b0c3b730
DV
1175var _191=_190._namedColors[name.toLowerCase()];
1176if(typeof (_191)=="string"){
1177return _190.fromHexString(_191);
5fb1199a 1178}else{
b0c3b730
DV
1179if(name=="transparent"){
1180return _190.transparentColor();
5fb1199a 1181}
5fb1199a 1182}
b0c3b730
DV
1183return null;
1184},fromString:function(_192){
1185var self=MochiKit.Color.Color;
1186var _194=_192.substr(0,3);
1187if(_194=="rgb"){
1188return self.fromRGBString(_192);
1189}else{
1190if(_194=="hsl"){
1191return self.fromHSLString(_192);
1192}else{
1193if(_192.charAt(0)=="#"){
1194return self.fromHexString(_192);
5fb1199a 1195}
5fb1199a 1196}
5fb1199a 1197}
b0c3b730
DV
1198return self.fromName(_192);
1199},fromHexString:function(_195){
1200if(_195.charAt(0)=="#"){
1201_195=_195.substring(1);
5fb1199a 1202}
b0c3b730
DV
1203var _196=[];
1204var i,hex;
1205if(_195.length==3){
1206for(i=0;i<3;i++){
1207hex=_195.substr(i,1);
1208_196.push(parseInt(hex+hex,16)/255);
5fb1199a 1209}
b0c3b730
DV
1210}else{
1211for(i=0;i<6;i+=2){
1212hex=_195.substr(i,2);
1213_196.push(parseInt(hex,16)/255);
5fb1199a 1214}
5fb1199a 1215}
b0c3b730
DV
1216var _199=MochiKit.Color.Color;
1217return _199.fromRGB.apply(_199,_196);
1218},_fromColorString:function(pre,_19b,_19c,_19d){
1219if(_19d.indexOf(pre)===0){
1220_19d=_19d.substring(_19d.indexOf("(",3)+1,_19d.length-1);
5fb1199a 1221}
b0c3b730
DV
1222var _19e=_19d.split(/\s*,\s*/);
1223var _19f=[];
1224for(var i=0;i<_19e.length;i++){
1225var c=_19e[i];
1226var val;
1227var _1a3=c.substring(c.length-3);
1228if(c.charAt(c.length-1)=="%"){
1229val=0.01*parseFloat(c.substring(0,c.length-1));
1230}else{
1231if(_1a3=="deg"){
1232val=parseFloat(c)/360;
1233}else{
1234if(_1a3=="rad"){
1235val=parseFloat(c)/(Math.PI*2);
1236}else{
1237val=_19c[i]*parseFloat(c);
5fb1199a 1238}
5fb1199a 1239}
5fb1199a 1240}
b0c3b730 1241_19f.push(val);
5fb1199a 1242}
b0c3b730
DV
1243return this[_19b].apply(this,_19f);
1244},fromBackground:function(elem){
1245var cls=MochiKit.Color.Color;
1246return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor();
1247},fromText:function(elem){
1248var cls=MochiKit.Color.Color;
1249return cls.fromComputedStyle(elem,"color","color")||cls.blackColor();
1250},namedColors:function(){
1251return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
1252}});
1253MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_1a9){
1254v*=_1a9;
1255if(v<0){
1256return 0;
1257}else{
1258if(v>_1a9){
1259return _1a9;
1260}else{
1261return v;
5fb1199a
DV
1262}
1263}
b0c3b730
DV
1264},_hslValue:function(n1,n2,hue){
1265if(hue>6){
1266hue-=6;
1267}else{
1268if(hue<0){
1269hue+=6;
5fb1199a
DV
1270}
1271}
b0c3b730
DV
1272var val;
1273if(hue<1){
1274val=n1+(n2-n1)*hue;
5fb1199a 1275}else{
b0c3b730
DV
1276if(hue<3){
1277val=n2;
5fb1199a 1278}else{
b0c3b730
DV
1279if(hue<4){
1280val=n1+(n2-n1)*(4-hue);
5fb1199a 1281}else{
b0c3b730 1282val=n1;
5fb1199a 1283}
5fb1199a 1284}
5fb1199a 1285}
b0c3b730
DV
1286return val;
1287},hsvToRGB:function(hue,_1af,_1b0,_1b1){
1288if(arguments.length==1){
1289var hsv=hue;
1290hue=hsv.h;
1291_1af=hsv.s;
1292_1b0=hsv.v;
1293_1b1=hsv.a;
5fb1199a 1294}
b0c3b730
DV
1295var red;
1296var _1b4;
1297var blue;
1298if(_1af===0){
1299red=_1b0;
1300_1b4=_1b0;
1301blue=_1b0;
5fb1199a 1302}else{
b0c3b730
DV
1303var i=Math.floor(hue*6);
1304var f=(hue*6)-i;
1305var p=_1b0*(1-_1af);
1306var q=_1b0*(1-(_1af*f));
1307var t=_1b0*(1-(_1af*(1-f)));
1308switch(i){
1309case 1:
1310red=q;
1311_1b4=_1b0;
1312blue=p;
1313break;
1314case 2:
1315red=p;
1316_1b4=_1b0;
1317blue=t;
1318break;
1319case 3:
1320red=p;
1321_1b4=q;
1322blue=_1b0;
1323break;
1324case 4:
1325red=t;
1326_1b4=p;
1327blue=_1b0;
1328break;
1329case 5:
1330red=_1b0;
1331_1b4=p;
1332blue=q;
1333break;
1334case 6:
1335case 0:
1336red=_1b0;
1337_1b4=t;
1338blue=p;
1339break;
5fb1199a 1340}
5fb1199a 1341}
b0c3b730
DV
1342return {r:red,g:_1b4,b:blue,a:_1b1};
1343},hslToRGB:function(hue,_1bc,_1bd,_1be){
5fb1199a 1344if(arguments.length==1){
b0c3b730
DV
1345var hsl=hue;
1346hue=hsl.h;
1347_1bc=hsl.s;
1348_1bd=hsl.l;
1349_1be=hsl.a;
5fb1199a 1350}
b0c3b730
DV
1351var red;
1352var _1c1;
1353var blue;
1354if(_1bc===0){
1355red=_1bd;
1356_1c1=_1bd;
1357blue=_1bd;
5fb1199a 1358}else{
b0c3b730
DV
1359var m2;
1360if(_1bd<=0.5){
1361m2=_1bd*(1+_1bc);
1362}else{
1363m2=_1bd+_1bc-(_1bd*_1bc);
5fb1199a 1364}
b0c3b730
DV
1365var m1=(2*_1bd)-m2;
1366var f=MochiKit.Color._hslValue;
1367var h6=hue*6;
1368red=f(m1,m2,h6+2);
1369_1c1=f(m1,m2,h6);
1370blue=f(m1,m2,h6-2);
5fb1199a 1371}
b0c3b730
DV
1372return {r:red,g:_1c1,b:blue,a:_1be};
1373},rgbToHSV:function(red,_1c8,blue,_1ca){
1374if(arguments.length==1){
1375var rgb=red;
1376red=rgb.r;
1377_1c8=rgb.g;
1378blue=rgb.b;
1379_1ca=rgb.a;
5fb1199a 1380}
b0c3b730
DV
1381var max=Math.max(Math.max(red,_1c8),blue);
1382var min=Math.min(Math.min(red,_1c8),blue);
1383var hue;
1384var _1cf;
1385var _1d0=max;
1386if(min==max){
1387hue=0;
1388_1cf=0;
1389}else{
1390var _1d1=(max-min);
1391_1cf=_1d1/max;
1392if(red==max){
1393hue=(_1c8-blue)/_1d1;
1394}else{
1395if(_1c8==max){
1396hue=2+((blue-red)/_1d1);
1397}else{
1398hue=4+((red-_1c8)/_1d1);
5fb1199a 1399}
5fb1199a 1400}
b0c3b730
DV
1401hue/=6;
1402if(hue<0){
1403hue+=1;
5fb1199a 1404}
b0c3b730
DV
1405if(hue>1){
1406hue-=1;
5fb1199a 1407}
5fb1199a 1408}
b0c3b730
DV
1409return {h:hue,s:_1cf,v:_1d0,a:_1ca};
1410},rgbToHSL:function(red,_1d3,blue,_1d5){
1411if(arguments.length==1){
1412var rgb=red;
1413red=rgb.r;
1414_1d3=rgb.g;
1415blue=rgb.b;
1416_1d5=rgb.a;
5fb1199a 1417}
b0c3b730
DV
1418var max=Math.max(red,Math.max(_1d3,blue));
1419var min=Math.min(red,Math.min(_1d3,blue));
1420var hue;
5fb1199a 1421var _1da;
b0c3b730
DV
1422var _1db=(max+min)/2;
1423var _1dc=max-min;
1424if(_1dc===0){
1425hue=0;
1426_1da=0;
1427}else{
1428if(_1db<=0.5){
1429_1da=_1dc/(max+min);
1430}else{
1431_1da=_1dc/(2-max-min);
5fb1199a 1432}
b0c3b730
DV
1433if(red==max){
1434hue=(_1d3-blue)/_1dc;
1435}else{
1436if(_1d3==max){
1437hue=2+((blue-red)/_1dc);
1438}else{
1439hue=4+((red-_1d3)/_1dc);
5fb1199a 1440}
5fb1199a 1441}
b0c3b730
DV
1442hue/=6;
1443if(hue<0){
1444hue+=1;
5fb1199a 1445}
b0c3b730
DV
1446if(hue>1){
1447hue-=1;
5fb1199a 1448}
5fb1199a 1449}
b0c3b730
DV
1450return {h:hue,s:_1da,l:_1db,a:_1d5};
1451},toColorPart:function(num){
1452num=Math.round(num);
1453var _1de=num.toString(16);
1454if(num<16){
1455return "0"+_1de;
5fb1199a 1456}
b0c3b730
DV
1457return _1de;
1458},__new__:function(){
5fb1199a 1459var m=MochiKit.Base;
b0c3b730
DV
1460this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]);
1461this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]);
1462var _1e0=1/3;
1463var _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]};
1464var _1e2=function(name,r,g,b,a){
1465var rval=this.fromRGB(r,g,b,a);
1466this[name]=function(){
1467return rval;
5fb1199a 1468};
b0c3b730
DV
1469return rval;
1470};
1471for(var k in _1e1){
1472var name=k+"Color";
1473var _1eb=m.concat([_1e2,this.Color,name],_1e1[k]);
1474this.Color[name]=m.bind.apply(null,_1eb);
1475}
1476var _1ec=function(){
1477for(var i=0;i<arguments.length;i++){
1478if(!(arguments[i] instanceof Color)){
1479return false;
1480}
5fb1199a 1481}
b0c3b730
DV
1482return true;
1483};
1484var _1ee=function(a,b){
1485return a.compareRGB(b);
1486};
1487m.nameFunctions(this);
1488m.registerComparator(this.Color.NAME,_1ec,_1ee);
1489this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
1490}});
1491MochiKit.Color.EXPORT=["Color"];
1492MochiKit.Color.EXPORT_OK=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
1493MochiKit.Color.__new__();
1494MochiKit.Base._exportSymbols(this,MochiKit.Color);
1495MochiKit.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"};
6a1aa64f
DV
1496
1497
6219c9d6 1498Date.ext={};Date.ext.util={};Date.ext.util.xPad=function(x,pad,r){if(typeof (r)=="undefined"){r=10}for(;parseInt(x,10)<r&&r>1;r/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(d){return Date.ext.util.xPad(parseInt(Date.ext.util.G(d)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date.ext.util.xPad(doy,0,100)},m:function(d){return Date.ext.util.xPad(d.getMonth()+1,0)},M:["getMinutes","0"],p:function(d){return Date.ext.locales[d.locale].p[d.getHours()>=12?1:0]},P:function(d){return Date.ext.locales[d.locale].P[d.getHours()>=12?1:0]},S:["getSeconds","0"],u:function(d){var dow=d.getDay();return dow===0?7:dow},U:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=6-d.getDay();var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0,10)},y:function(d){return Date.ext.util.xPad(d.getFullYear()%100,0)},Y:"getFullYear",z:function(d){var o=d.getTimezoneOffset();var H=Date.ext.util.xPad(parseInt(Math.abs(o/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a-zA-Z]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a-zA-Z]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY%])/g,function(m0,m1){var f=Date.ext.formats[m1];if(typeof (f)=="string"){return d[f]()}else{if(typeof (f)=="function"){return f.call(d,d)}else{if(typeof (f)=="object"&&typeof (f[0])=="string"){return Date.ext.util.xPad(d[f[0]](),f[1])}else{return m1}}}});d=null;return str};
efe0829a
DV
1499DygraphLayout=function(_1,_2){
1500this.dygraph_=_1;
1501this.options={};
1502MochiKit.Base.update(this.options,_2?_2:{});
1503this.datasets=new Array();
1504};
1505DygraphLayout.prototype.attr_=function(_3){
1506return this.dygraph_.attr_(_3);
1507};
1508DygraphLayout.prototype.addDataset=function(_4,_5){
1509this.datasets[_4]=_5;
1510};
1511DygraphLayout.prototype.evaluate=function(){
1512this._evaluateLimits();
1513this._evaluateLineCharts();
1514this._evaluateLineTicks();
1515};
1516DygraphLayout.prototype._evaluateLimits=function(){
1517this.minxval=this.maxxval=null;
1518for(var _6 in this.datasets){
1519var _7=this.datasets[_6];
1520var x1=_7[0][0];
1521if(!this.minxval||x1<this.minxval){
1522this.minxval=x1;
1523}
1524var x2=_7[_7.length-1][0];
1525if(!this.maxxval||x2>this.maxxval){
1526this.maxxval=x2;
1527}
1528}
1529this.xrange=this.maxxval-this.minxval;
1530this.xscale=(this.xrange!=0?1/this.xrange:1);
1531this.minyval=this.options.yAxis[0];
1532this.maxyval=this.options.yAxis[1];
1533this.yrange=this.maxyval-this.minyval;
1534this.yscale=(this.yrange!=0?1/this.yrange:1);
1535};
1536DygraphLayout.prototype._evaluateLineCharts=function(){
1537this.points=new Array();
1538for(var _10 in this.datasets){
1539var _11=this.datasets[_10];
1540for(var j=0;j<_11.length;j++){
1541var _13=_11[j];
1542var _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};
1543if(_14.y<=0){
1544_14.y=0;
1545}
1546if(_14.y>=1){
1547_14.y=1;
1548}
1549if((_14.x>=0)&&(_14.x<=1)){
1550this.points.push(_14);
1551}
1552}
1553}
1554};
1555DygraphLayout.prototype._evaluateLineTicks=function(){
1556this.xticks=new Array();
1557for(var i=0;i<this.options.xTicks.length;i++){
1558var _16=this.options.xTicks[i];
1559var _17=_16.label;
1560var pos=this.xscale*(_16.v-this.minxval);
1561if((pos>=0)&&(pos<=1)){
1562this.xticks.push([pos,_17]);
1563}
1564}
1565this.yticks=new Array();
1566for(var i=0;i<this.options.yTicks.length;i++){
1567var _16=this.options.yTicks[i];
1568var _17=_16.label;
1569var pos=1-(this.yscale*(_16.v-this.minyval));
1570if((pos>=0)&&(pos<=1)){
1571this.yticks.push([pos,_17]);
1572}
1573}
6a1aa64f 1574};
285a6bda 1575DygraphLayout.prototype.evaluateWithError=function(){
b2a516b8
DV
1576this.evaluate();
1577if(!this.options.errorBars){
1578return;
1579}
1580var i=0;
efe0829a 1581for(var _19 in this.datasets){
b2a516b8 1582var j=0;
efe0829a 1583var _20=this.datasets[_19];
efe0829a
DV
1584for(var j=0;j<_20.length;j++,i++){
1585var _21=_20[j];
1586var xv=parseFloat(_21[0]);
1587var yv=parseFloat(_21[1]);
b2a516b8 1588if(xv==this.points[i].xval&&yv==this.points[i].yval){
efe0829a
DV
1589this.points[i].errorMinus=parseFloat(_21[2]);
1590this.points[i].errorPlus=parseFloat(_21[3]);
b2a516b8
DV
1591}
1592}
1593}
6a1aa64f 1594};
285a6bda 1595DygraphLayout.prototype.removeAllDatasets=function(){
b2a516b8
DV
1596delete this.datasets;
1597this.datasets=new Array();
6a1aa64f 1598};
efe0829a
DV
1599DygraphLayout.prototype.updateOptions=function(_24){
1600MochiKit.Base.update(this.options,_24?_24:{});
b2a516b8 1601};
efe0829a 1602DygraphCanvasRenderer=function(_25,_26,_27,_28){
efe0829a 1603this.dygraph_=_25;
fbe31dc8 1604this.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()};
efe0829a 1605MochiKit.Base.update(this.options,_28);
fbe31dc8 1606this.layout=_27;
b0c3b730 1607this.element=_26;
fbe31dc8 1608this.container=this.element.parentNode;
3df0ccf0 1609this.isIE=(/MSIE/.test(navigator.userAgent)&&!window.opera);
fbe31dc8
DV
1610if(this.isIE&&!isNil(G_vmlCanvasManager)){
1611this.IEDelay=0.5;
1612this.maxTries=5;
1613this.renderDelay=null;
1614this.clearDelay=null;
1615this.element=G_vmlCanvasManager.initElement(this.element);
1616}
1617this.height=this.element.height;
1618this.width=this.element.width;
1619if(!this.isIE&&!(DygraphCanvasRenderer.isSupported(this.element))){
1620throw "Canvas is not supported.";
1621}
1622this.xlabels=new Array();
1623this.ylabels=new Array();
1624this.area={x:this.options.yAxisLabelWidth+2*this.options.axisTickSize,y:0};
1625this.area.w=this.width-this.area.x-this.options.rightGap;
1626this.area.h=this.height-this.options.axisLabelFontSize-2*this.options.axisTickSize;
b0c3b730
DV
1627this.container.style.position="relative";
1628this.container.style.width=this.width+"px";
fbe31dc8
DV
1629};
1630DygraphCanvasRenderer.prototype.clear=function(){
1631if(this.isIE){
1632try{
1633if(this.clearDelay){
1634this.clearDelay.cancel();
1635this.clearDelay=null;
1636}
1637var _29=this.element.getContext("2d");
1638}
1639catch(e){
1640this.clearDelay=MochiKit.Async.wait(this.IEDelay);
1641this.clearDelay.addCallback(bind(this.clear,this));
1642return;
1643}
1644}
1645var _29=this.element.getContext("2d");
1646_29.clearRect(0,0,this.width,this.height);
2160ed4a 1647for(var i=0;i<this.xlabels.length;i++){
b0c3b730
DV
1648var el=this.xlabels[i];
1649el.parentNode.removeChild(el);
2160ed4a
DV
1650}
1651for(var i=0;i<this.ylabels.length;i++){
b0c3b730
DV
1652var el=this.ylabels[i];
1653el.parentNode.removeChild(el);
2160ed4a 1654}
fbe31dc8
DV
1655this.xlabels=new Array();
1656this.ylabels=new Array();
1657};
b0c3b730
DV
1658DygraphCanvasRenderer.isSupported=function(_31){
1659var _32=null;
fbe31dc8 1660try{
b0c3b730
DV
1661if(MochiKit.Base.isUndefinedOrNull(_31)){
1662_32=document.createElement("canvas");
fbe31dc8 1663}else{
b0c3b730 1664_32=_31;
fbe31dc8 1665}
b0c3b730 1666var _33=_32.getContext("2d");
fbe31dc8
DV
1667}
1668catch(e){
1669var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
b0c3b730
DV
1670var _35=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
1671if((!ie)||(ie[1]<6)||(_35)){
fbe31dc8
DV
1672return false;
1673}
1674return true;
1675}
1676return true;
b2a516b8 1677};
285a6bda 1678DygraphCanvasRenderer.prototype.render=function(){
b2a516b8
DV
1679var ctx=this.element.getContext("2d");
1680if(this.options.drawYGrid){
b0c3b730 1681var _37=this.layout.yticks;
b2a516b8
DV
1682ctx.save();
1683ctx.strokeStyle=this.options.gridLineColor.toRGBString();
1684ctx.lineWidth=this.options.axisLineWidth;
b0c3b730 1685for(var i=0;i<_37.length;i++){
b2a516b8 1686var x=this.area.x;
b0c3b730 1687var y=this.area.y+_37[i][0]*this.area.h;
b2a516b8
DV
1688ctx.beginPath();
1689ctx.moveTo(x,y);
1690ctx.lineTo(x+this.area.w,y);
1691ctx.closePath();
1692ctx.stroke();
1693}
1694}
1695if(this.options.drawXGrid){
b0c3b730 1696var _37=this.layout.xticks;
b2a516b8
DV
1697ctx.save();
1698ctx.strokeStyle=this.options.gridLineColor.toRGBString();
1699ctx.lineWidth=this.options.axisLineWidth;
b0c3b730
DV
1700for(var i=0;i<_37.length;i++){
1701var x=this.area.x+_37[i][0]*this.area.w;
b2a516b8
DV
1702var y=this.area.y+this.area.h;
1703ctx.beginPath();
1704ctx.moveTo(x,y);
1705ctx.lineTo(x,this.area.y);
1706ctx.closePath();
1707ctx.stroke();
1708}
1709}
2ce09b19 1710this._renderLineChart();
fbe31dc8 1711this._renderAxis();
b2a516b8 1712};
fbe31dc8
DV
1713DygraphCanvasRenderer.prototype._renderAxis=function(){
1714if(!this.options.drawXAxis&&!this.options.drawYAxis){
1715return;
1716}
b0c3b730 1717var _40=this.element.getContext("2d");
bd597afc
DV
1718var _41={"position":"absolute","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"};
1719var _42=function(txt){
1720var div=document.createElement("div");
1721for(var _45 in _41){
1722div.style[_45]=_41[_45];
1723}
1724div.appendChild(document.createTextNode(txt));
1725return div;
1726};
b0c3b730
DV
1727_40.save();
1728_40.strokeStyle=this.options.axisLineColor.toRGBString();
1729_40.lineWidth=this.options.axisLineWidth;
fbe31dc8
DV
1730if(this.options.drawYAxis){
1731if(this.layout.yticks){
2160ed4a 1732for(var i=0;i<this.layout.yticks.length;i++){
bd597afc
DV
1733var _46=this.layout.yticks[i];
1734if(typeof (_46)=="function"){
fbe31dc8
DV
1735return;
1736}
1737var x=this.area.x;
bd597afc 1738var y=this.area.y+_46[0]*this.area.h;
b0c3b730
DV
1739_40.beginPath();
1740_40.moveTo(x,y);
1741_40.lineTo(x-this.options.axisTickSize,y);
1742_40.closePath();
1743_40.stroke();
bd597afc 1744var _47=_42(_46[1]);
fbe31dc8
DV
1745var top=(y-this.options.axisLabelFontSize/2);
1746if(top<0){
1747top=0;
1748}
1749if(top+this.options.axisLabelFontSize+3>this.height){
bd597afc 1750_47.style.bottom="0px";
fbe31dc8 1751}else{
bd597afc 1752_47.style.top=top+"px";
fbe31dc8 1753}
bd597afc
DV
1754_47.style.left="0px";
1755_47.style.textAlign="right";
1756_47.style.width=this.options.yAxisLabelWidth+"px";
1757this.container.appendChild(_47);
1758this.ylabels.push(_47);
2160ed4a 1759}
bd597afc
DV
1760var _49=this.ylabels[0];
1761var _50=this.options.axisLabelFontSize;
1762var _51=parseInt(_49.style.top)+_50;
1763if(_51>this.height-_50){
1764_49.style.top=(parseInt(_49.style.top)-_50/2)+"px";
fbe31dc8
DV
1765}
1766}
b0c3b730
DV
1767_40.beginPath();
1768_40.moveTo(this.area.x,this.area.y);
1769_40.lineTo(this.area.x,this.area.y+this.area.h);
1770_40.closePath();
1771_40.stroke();
fbe31dc8
DV
1772}
1773if(this.options.drawXAxis){
1774if(this.layout.xticks){
2160ed4a 1775for(var i=0;i<this.layout.xticks.length;i++){
bd597afc 1776var _46=this.layout.xticks[i];
fbe31dc8
DV
1777if(typeof (dataset)=="function"){
1778return;
1779}
bd597afc 1780var x=this.area.x+_46[0]*this.area.w;
fbe31dc8 1781var y=this.area.y+this.area.h;
b0c3b730
DV
1782_40.beginPath();
1783_40.moveTo(x,y);
1784_40.lineTo(x,y+this.options.axisTickSize);
1785_40.closePath();
1786_40.stroke();
bd597afc
DV
1787var _47=_42(_46[1]);
1788_47.style.textAlign="center";
1789_47.style.bottom="0px";
1790var _52=(x-this.options.axisLabelWidth/2);
1791if(_52+this.options.axisLabelWidth>this.width){
1792_52=this.width-this.options.xAxisLabelWidth;
1793_47.style.textAlign="right";
b0c3b730 1794}
bd597afc
DV
1795if(_52<0){
1796_52=0;
1797_47.style.textAlign="left";
b0c3b730 1798}
bd597afc
DV
1799_47.style.left=_52+"px";
1800_47.style.width=this.options.xAxisLabelWidth+"px";
1801this.container.appendChild(_47);
1802this.xlabels.push(_47);
b0c3b730
DV
1803}
1804}
1805_40.beginPath();
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);
1808_40.closePath();
1809_40.stroke();
1810}
1811_40.restore();
efe0829a 1812};
fbe31dc8 1813DygraphCanvasRenderer.prototype._renderLineChart=function(){
bd597afc
DV
1814var _53=this.element.getContext("2d");
1815var _54=this.options.colorScheme.length;
1816var _55=this.options.colorScheme;
1817var _56=MochiKit.Base.keys(this.layout.datasets);
1818var _57=this.layout.options.errorBars;
1819var _58=_56.length;
1820var _59=MochiKit.Base.bind;
1821var _60=MochiKit.Base.partial;
2160ed4a 1822for(var i=0;i<this.layout.points.length;i++){
bd597afc
DV
1823var _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;
2160ed4a 1826}
bd597afc 1827var _62=function(x){
9317362d
DV
1828return x&&!isNaN(x);
1829};
bd597afc
DV
1830var _63=function(ctx){
1831for(var i=0;i<_58;i++){
1832var _64=_56[i];
1833var _65=_55[i%_54];
1834var _66=this.options.strokeColorTransform;
1835_53.save();
1836_53.strokeStyle=_65.toRGBString();
1837_53.lineWidth=this.options.strokeWidth;
1838var _61=this.layout.points[0];
1839var _67=this.dygraph_.attr_("pointSize");
1840var _68=null,prevY=null;
1841var _69=this.dygraph_.attr_("drawPoints");
1842var _70=this.layout.points;
1843for(var j=0;j<_70.length;j++){
1844var _61=_70[j];
1845if(_61.name==_64){
1846if(!_62(_61.canvasy)){
1847_68=prevY=null;
1848}else{
1849var _71=(!_68&&(j==_70.length-1||!_62(_70[j+1].canvasy)));
1850if(!_68){
1851_68=_61.canvasx;
1852prevY=_61.canvasy;
b2a516b8 1853}else{
9317362d 1854ctx.beginPath();
bd597afc
DV
1855ctx.moveTo(_68,prevY);
1856_68=_61.canvasx;
1857prevY=_61.canvasy;
1858ctx.lineTo(_68,prevY);
9317362d
DV
1859ctx.stroke();
1860}
bd597afc 1861if(_69||_71){
9317362d 1862ctx.beginPath();
bd597afc
DV
1863ctx.fillStyle=_65.toRGBString();
1864ctx.arc(_61.canvasx,_61.canvasy,_67,0,360,false);
9317362d
DV
1865ctx.fill();
1866}
b2a516b8 1867}
648acd28 1868}
b2a516b8 1869}
b2a516b8
DV
1870}
1871};
bd597afc
DV
1872var _72=function(ctx){
1873for(var i=0;i<_58;i++){
1874var _73=_56[i];
1875var _74=_55[i%_54];
1876var _75=this.options.strokeColorTransform;
1877_53.save();
1878_53.strokeStyle=_74.toRGBString();
1879_53.lineWidth=this.options.strokeWidth;
1880var _76=-1;
1881var _77=[-1,-1];
1882var _78=0;
1883var _79=this.layout.yscale;
1884var _80=_74.colorWithAlpha(0.15);
1885ctx.fillStyle=_80.toRGBString();
5fb1199a
DV
1886ctx.beginPath();
1887for(var j=0;j<this.layout.points.length;j++){
bd597afc
DV
1888var _81=this.layout.points[j];
1889_78++;
1890if(_81.name==_73){
1891if(!_81.y||isNaN(_81.y)){
1892_76=-1;
648acd28
DV
1893return;
1894}
bd597afc
DV
1895var _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;
1898if(_76>=0){
1899ctx.moveTo(_76,_77[0]);
1900ctx.lineTo(_81.canvasx,_82[0]);
1901ctx.lineTo(_81.canvasx,_82[1]);
1902ctx.lineTo(_76,_77[1]);
5fb1199a
DV
1903ctx.closePath();
1904}
bd597afc
DV
1905_77[0]=_82[0];
1906_77[1]=_82[1];
1907_76=_81.canvasx;
b2a516b8 1908}
b2a516b8 1909}
b2a516b8
DV
1910ctx.fill();
1911}
6a1aa64f 1912};
bd597afc
DV
1913if(_57){
1914_59(_72,this)(_53);
b2a516b8 1915}
bd597afc
DV
1916_59(_63,this)(_53);
1917_53.restore();
6a1aa64f 1918};
bd597afc 1919Dygraph=function(div,_83,_84){
b2a516b8 1920if(arguments.length>0){
285a6bda
DV
1921if(arguments.length==4){
1922this.warn("Using deprecated four-argument dygraph constructor");
bd597afc 1923this.__old_init__(div,_83,arguments[2],arguments[3]);
285a6bda 1924}else{
bd597afc 1925this.__init__(div,_83,_84);
285a6bda 1926}
b2a516b8 1927}
6a1aa64f 1928};
285a6bda
DV
1929Dygraph.NAME="Dygraph";
1930Dygraph.VERSION="1.2";
1931Dygraph.__repr__=function(){
b2a516b8 1932return "["+this.NAME+" "+this.VERSION+"]";
6a1aa64f 1933};
285a6bda 1934Dygraph.toString=function(){
b2a516b8 1935return this.__repr__();
6a1aa64f 1936};
285a6bda
DV
1937Dygraph.DEFAULT_ROLL_PERIOD=1;
1938Dygraph.DEFAULT_WIDTH=480;
1939Dygraph.DEFAULT_HEIGHT=320;
1940Dygraph.AXIS_LINE_WIDTH=0.3;
8846615a 1941Dygraph.DEFAULT_ATTRS={highlightCircleSize:3,pixelsPerXLabel:60,pixelsPerYLabel:30,labelsDivWidth:250,labelsDivStyles:{},labelsSeparateLines:false,labelsKMB:false,strokeWidth:1,axisTickSize:3,axisLabelFontSize:14,xAxisLabelWidth:50,yAxisLabelWidth:50,rightGap:5,showRoller:false,xValueFormatter:Dygraph.dateString_,xValueParser:Dygraph.dateParser,xTicker:Dygraph.dateTicker,sigma:2,errorBars:false,fractions:false,wilsonInterval:true,customBars:false};
285a6bda
DV
1942Dygraph.DEBUG=1;
1943Dygraph.INFO=2;
1944Dygraph.WARNING=3;
1945Dygraph.ERROR=3;
bd597afc
DV
1946Dygraph.prototype.__old_init__=function(div,_85,_86,_87){
1947if(_86!=null){
1948var _88=["Date"];
1949for(var i=0;i<_86.length;i++){
1950_88.push(_86[i]);
285a6bda 1951}
bd597afc 1952MochiKit.Base.update(_87,{"labels":_88});
285a6bda 1953}
bd597afc 1954this.__init__(div,_85,_87);
285a6bda 1955};
bd597afc
DV
1956Dygraph.prototype.__init__=function(div,_89,_90){
1957if(_90==null){
1958_90={};
285a6bda 1959}
b2a516b8 1960this.maindiv_=div;
bd597afc
DV
1961this.file_=_89;
1962this.rollPeriod_=_90.rollPeriod||Dygraph.DEFAULT_ROLL_PERIOD;
b2a516b8 1963this.previousVerticalX_=-1;
bd597afc
DV
1964this.fractions_=_90.fractions||false;
1965this.dateWindow_=_90.dateWindow||null;
1966this.valueRange_=_90.valueRange||null;
1967this.wilsonInterval_=_90.wilsonInterval||true;
caf49918 1968div.innerHTML="";
285a6bda
DV
1969if(div.style.width==""){
1970div.style.width=Dygraph.DEFAULT_WIDTH+"px";
1971}
1972if(div.style.height==""){
1973div.style.height=Dygraph.DEFAULT_HEIGHT+"px";
1974}
b2a516b8
DV
1975this.width_=parseInt(div.style.width,10);
1976this.height_=parseInt(div.style.height,10);
285a6bda 1977this.user_attrs_={};
bd597afc 1978MochiKit.Base.update(this.user_attrs_,_90);
b8339f6e 1979this.attrs_={};
285a6bda
DV
1980MochiKit.Base.update(this.attrs_,Dygraph.DEFAULT_ATTRS);
1981this.labelsFromCSV_=(this.attr_("labels")==null);
b2a516b8 1982this.createInterface_();
b64a4f1a 1983this.layoutOptions_={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
285a6bda
DV
1984MochiKit.Base.update(this.layoutOptions_,this.attrs_);
1985MochiKit.Base.update(this.layoutOptions_,this.user_attrs_);
efe0829a 1986this.layout_=new DygraphLayout(this,this.layoutOptions_);
8846615a 1987this.renderOptions_={colorScheme:this.colors_,strokeColor:null,axisLineWidth:Dygraph.AXIS_LINE_WIDTH};
285a6bda
DV
1988MochiKit.Base.update(this.renderOptions_,this.attrs_);
1989MochiKit.Base.update(this.renderOptions_,this.user_attrs_);
9317362d 1990this.plotter_=new DygraphCanvasRenderer(this,this.hidden_,this.layout_,this.renderOptions_);
b2a516b8
DV
1991this.createStatusMessage_();
1992this.createRollInterface_();
1993this.createDragInterface_();
b2a516b8 1994this.start_();
6a1aa64f 1995};
bd597afc
DV
1996Dygraph.prototype.attr_=function(_91){
1997if(typeof (this.user_attrs_[_91])!="undefined"){
1998return this.user_attrs_[_91];
285a6bda 1999}else{
bd597afc
DV
2000if(typeof (this.attrs_[_91])!="undefined"){
2001return this.attrs_[_91];
285a6bda
DV
2002}else{
2003return null;
2004}
2005}
2006};
bd597afc 2007Dygraph.prototype.log=function(_92,_93){
285a6bda 2008if(typeof (console)!="undefined"){
bd597afc 2009switch(_92){
285a6bda 2010case Dygraph.DEBUG:
bd597afc 2011console.debug("dygraphs: "+_93);
285a6bda
DV
2012break;
2013case Dygraph.INFO:
bd597afc 2014console.info("dygraphs: "+_93);
285a6bda
DV
2015break;
2016case Dygraph.WARNING:
bd597afc 2017console.warn("dygraphs: "+_93);
285a6bda
DV
2018break;
2019case Dygraph.ERROR:
bd597afc 2020console.error("dygraphs: "+_93);
285a6bda
DV
2021break;
2022}
2023}
2024};
bd597afc
DV
2025Dygraph.prototype.info=function(_94){
2026this.log(Dygraph.INFO,_94);
285a6bda 2027};
bd597afc
DV
2028Dygraph.prototype.warn=function(_95){
2029this.log(Dygraph.WARNING,_95);
285a6bda 2030};
bd597afc
DV
2031Dygraph.prototype.error=function(_96){
2032this.log(Dygraph.ERROR,_96);
285a6bda
DV
2033};
2034Dygraph.prototype.rollPeriod=function(){
b2a516b8
DV
2035return this.rollPeriod_;
2036};
76171648 2037Dygraph.addEvent=function(el,evt,fn){
bd597afc 2038var _99=function(e){
76171648
DV
2039if(!e){
2040var e=window.event;
2041}
2042fn(e);
2043};
2044if(window.addEventListener){
bd597afc 2045el.addEventListener(evt,_99,false);
76171648 2046}else{
bd597afc 2047el.attachEvent("on"+evt,_99);
76171648
DV
2048}
2049};
285a6bda 2050Dygraph.prototype.createInterface_=function(){
bd597afc 2051var _101=this.maindiv_;
b0c3b730
DV
2052this.graphDiv=document.createElement("div");
2053this.graphDiv.style.width=this.width_+"px";
2054this.graphDiv.style.height=this.height_+"px";
bd597afc 2055_101.appendChild(this.graphDiv);
b0c3b730
DV
2056this.canvas_=document.createElement("canvas");
2057this.canvas_.style.position="absolute";
2058this.canvas_.width=this.width_;
2059this.canvas_.height=this.height_;
2060this.graphDiv.appendChild(this.canvas_);
b2a516b8 2061this.hidden_=this.createPlotKitCanvas_(this.canvas_);
bd597afc 2062var _102=this;
76171648 2063Dygraph.addEvent(this.hidden_,"mousemove",function(e){
bd597afc 2064_102.mouseMove_(e);
b2a516b8 2065});
76171648 2066Dygraph.addEvent(this.hidden_,"mouseout",function(e){
bd597afc 2067_102.mouseOut_(e);
b2a516b8 2068});
6a1aa64f 2069};
bd597afc 2070Dygraph.prototype.createPlotKitCanvas_=function(_103){
b2a516b8
DV
2071var h=document.createElement("canvas");
2072h.style.position="absolute";
bd597afc
DV
2073h.style.top=_103.style.top;
2074h.style.left=_103.style.left;
b2a516b8
DV
2075h.width=this.width_;
2076h.height=this.height_;
b0c3b730 2077this.graphDiv.appendChild(h);
b2a516b8
DV
2078return h;
2079};
285a6bda
DV
2080Dygraph.prototype.setColors_=function(){
2081var num=this.attr_("labels").length-1;
b2a516b8 2082this.colors_=[];
bd597afc
DV
2083var _106=this.attr_("colors");
2084if(!_106){
285a6bda
DV
2085var sat=this.attr_("colorSaturation")||1;
2086var val=this.attr_("colorValue")||0.5;
b2a516b8
DV
2087for(var i=1;i<=num;i++){
2088var hue=(1*i/(1+num));
2089this.colors_.push(MochiKit.Color.Color.fromHSV(hue,sat,val));
2090}
2091}else{
2092for(var i=0;i<num;i++){
bd597afc
DV
2093var _110=_106[i%_106.length];
2094this.colors_.push(MochiKit.Color.Color.fromString(_110));
b2a516b8 2095}
b2a516b8 2096}
285a6bda
DV
2097this.renderOptions_.colorScheme=this.colors_;
2098MochiKit.Base.update(this.plotter_.options,this.renderOptions_);
2099MochiKit.Base.update(this.layoutOptions_,this.user_attrs_);
2100MochiKit.Base.update(this.layoutOptions_,this.attrs_);
b2a516b8 2101};
3df0ccf0 2102Dygraph.findPosX=function(obj){
bd597afc 2103var _112=0;
3df0ccf0
DV
2104if(obj.offsetParent){
2105while(obj.offsetParent){
bd597afc 2106_112+=obj.offsetLeft;
3df0ccf0
DV
2107obj=obj.offsetParent;
2108}
2109}else{
2110if(obj.x){
bd597afc 2111_112+=obj.x;
3df0ccf0
DV
2112}
2113}
bd597afc 2114return _112;
3df0ccf0
DV
2115};
2116Dygraph.findPosY=function(obj){
bd597afc 2117var _113=0;
3df0ccf0
DV
2118if(obj.offsetParent){
2119while(obj.offsetParent){
bd597afc 2120_113+=obj.offsetTop;
3df0ccf0
DV
2121obj=obj.offsetParent;
2122}
2123}else{
2124if(obj.y){
bd597afc 2125_113+=obj.y;
3df0ccf0
DV
2126}
2127}
bd597afc 2128return _113;
3df0ccf0 2129};
285a6bda
DV
2130Dygraph.prototype.createStatusMessage_=function(){
2131if(!this.attr_("labelsDiv")){
bd597afc
DV
2132var _114=this.attr_("labelsDivWidth");
2133var _115={"position":"absolute","fontSize":"14px","zIndex":10,"width":_114+"px","top":"0px","left":(this.width_-_114-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
2134MochiKit.Base.update(_115,this.attr_("labelsDivStyles"));
b0c3b730 2135var div=document.createElement("div");
bd597afc
DV
2136for(var name in _115){
2137div.style[name]=_115[name];
b0c3b730
DV
2138}
2139this.graphDiv.appendChild(div);
285a6bda
DV
2140this.attrs_.labelsDiv=div;
2141}
2142};
2143Dygraph.prototype.createRollInterface_=function(){
bd597afc
DV
2144var _117=this.attr_("showRoller")?"block":"none";
2145var _118={"position":"absolute","zIndex":10,"top":(this.plotter_.area.h-25)+"px","left":(this.plotter_.area.x+1)+"px","display":_117};
2146var _119=document.createElement("input");
2147_119.type="text";
2148_119.size="2";
2149_119.value=this.rollPeriod_;
2150for(var name in _118){
2151_119.style[name]=_118[name];
b0c3b730 2152}
b2a516b8 2153var pa=this.graphDiv;
bd597afc
DV
2154pa.appendChild(_119);
2155var _121=this;
2156_119.onchange=function(){
2157_121.adjustRoll(_119.value);
76171648 2158};
bd597afc 2159return _119;
76171648
DV
2160};
2161Dygraph.pageX=function(e){
2162if(e.pageX){
2163return (!e.pageX||e.pageX<0)?0:e.pageX;
2164}else{
2165var de=document;
2166var b=document.body;
2167return e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
2168}
2169};
2170Dygraph.pageY=function(e){
2171if(e.pageY){
2172return (!e.pageY||e.pageY<0)?0:e.pageY;
2173}else{
2174var de=document;
2175var b=document.body;
2176return e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
2177}
285a6bda
DV
2178};
2179Dygraph.prototype.createDragInterface_=function(){
fbe31dc8 2180var self=this;
bd597afc 2181var _125=false;
76171648
DV
2182var _126=null;
2183var _127=null;
bd597afc
DV
2184var _128=null;
2185var _129=null;
2186var _130=null;
353a0294
DV
2187var px=0;
2188var py=0;
efe0829a 2189var getX=function(e){
76171648 2190return Dygraph.pageX(e)-px;
b2a516b8 2191};
efe0829a 2192var getY=function(e){
76171648 2193return Dygraph.pageX(e)-py;
b2a516b8 2194};
bd597afc
DV
2195Dygraph.addEvent(this.hidden_,"mousemove",function(_135){
2196if(_125){
2197_128=getX(_135);
2198_129=getY(_135);
2199self.drawZoomRect_(_126,_128,_130);
2200_130=_128;
6a1aa64f 2201}
b2a516b8 2202});
bd597afc
DV
2203Dygraph.addEvent(this.hidden_,"mousedown",function(_136){
2204_125=true;
3df0ccf0
DV
2205px=Dygraph.findPosX(self.canvas_);
2206py=Dygraph.findPosY(self.canvas_);
bd597afc
DV
2207_126=getX(_136);
2208_127=getY(_136);
b2a516b8 2209});
bd597afc
DV
2210Dygraph.addEvent(document,"mouseup",function(_137){
2211if(_125){
2212_125=false;
2213_126=null;
2214_127=null;
6a1aa64f 2215}
b2a516b8 2216});
bd597afc
DV
2217Dygraph.addEvent(this.hidden_,"mouseout",function(_138){
2218if(_125){
2219_128=null;
2220_129=null;
6a1aa64f 2221}
b2a516b8 2222});
bd597afc
DV
2223Dygraph.addEvent(this.hidden_,"mouseup",function(_139){
2224if(_125){
2225_125=false;
2226_128=getX(_139);
2227_129=getY(_139);
2228var _140=Math.abs(_128-_126);
2229var _141=Math.abs(_129-_127);
2230if(_140<2&&_141<2&&self.attr_("clickCallback")!=null&&self.lastx_!=undefined){
2231self.attr_("clickCallback")(_139,new Date(self.lastx_));
2232}
2233if(_140>=10){
2234self.doZoom_(Math.min(_126,_128),Math.max(_126,_128));
b2a516b8 2235}else{
fbe31dc8 2236self.canvas_.getContext("2d").clearRect(0,0,self.canvas_.width,self.canvas_.height);
b2a516b8 2237}
bd597afc
DV
2238_126=null;
2239_127=null;
b2a516b8
DV
2240}
2241});
bd597afc 2242Dygraph.addEvent(this.hidden_,"dblclick",function(_142){
fbe31dc8
DV
2243self.dateWindow_=null;
2244self.drawGraph_(self.rawData_);
bd597afc
DV
2245var _143=self.rawData_[0][0];
2246var _144=self.rawData_[self.rawData_.length-1][0];
fbe31dc8 2247if(self.attr_("zoomCallback")){
bd597afc 2248self.attr_("zoomCallback")(_143,_144);
67e650dc 2249}
b2a516b8 2250});
6a1aa64f 2251};
bd597afc 2252Dygraph.prototype.drawZoomRect_=function(_145,endX,_147){
b2a516b8 2253var ctx=this.canvas_.getContext("2d");
bd597afc
DV
2254if(_147){
2255ctx.clearRect(Math.min(_145,_147),0,Math.abs(_145-_147),this.height_);
b2a516b8 2256}
bd597afc 2257if(endX&&_145){
b2a516b8 2258ctx.fillStyle="rgba(128,128,128,0.33)";
bd597afc 2259ctx.fillRect(Math.min(_145,endX),0,Math.abs(endX-_145),this.height_);
b2a516b8
DV
2260}
2261};
bd597afc
DV
2262Dygraph.prototype.doZoom_=function(lowX,_149){
2263var _150=this.layout_.points;
2264var _151=null;
2265var _152=null;
2266for(var i=0;i<_150.length;i++){
2267var cx=_150[i].canvasx;
2268var x=_150[i].xval;
2269if(cx<lowX&&(_151==null||x>_151)){
2270_151=x;
b2a516b8 2271}
bd597afc
DV
2272if(cx>_149&&(_152==null||x<_152)){
2273_152=x;
b2a516b8 2274}
b2a516b8 2275}
bd597afc
DV
2276if(_151==null){
2277_151=_150[0].xval;
b2a516b8 2278}
bd597afc
DV
2279if(_152==null){
2280_152=_150[_150.length-1].xval;
b0c3b730 2281}
bd597afc 2282this.dateWindow_=[_151,_152];
b2a516b8 2283this.drawGraph_(this.rawData_);
285a6bda 2284if(this.attr_("zoomCallback")){
bd597afc 2285this.attr_("zoomCallback")(_151,_152);
67e650dc 2286}
b2a516b8 2287};
bd597afc
DV
2288Dygraph.prototype.mouseMove_=function(_154){
2289var _155=Dygraph.pageX(_154)-Dygraph.findPosX(this.hidden_);
2290var _156=this.layout_.points;
2291var _157=-1;
2292var _158=-1;
2293var _159=1e+100;
b2a516b8 2294var idx=-1;
bd597afc
DV
2295for(var i=0;i<_156.length;i++){
2296var dist=Math.abs(_156[i].canvasx-_155);
2297if(dist>_159){
b2a516b8
DV
2298break;
2299}
bd597afc 2300_159=dist;
b2a516b8
DV
2301idx=i;
2302}
2303if(idx>=0){
bd597afc 2304_157=_156[idx].xval;
b2a516b8 2305}
bd597afc
DV
2306if(_155>_156[_156.length-1].canvasx){
2307_157=_156[_156.length-1].xval;
b2a516b8 2308}
bd597afc
DV
2309var _162=[];
2310for(var i=0;i<_156.length;i++){
2311if(_156[i].xval==_157){
2312_162.push(_156[i]);
b2a516b8
DV
2313}
2314}
bd597afc 2315var _163=this.attr_("highlightCircleSize");
b2a516b8
DV
2316var ctx=this.canvas_.getContext("2d");
2317if(this.previousVerticalX_>=0){
2318var px=this.previousVerticalX_;
bd597afc 2319ctx.clearRect(px-_163-1,0,2*_163+2,this.height_);
b2a516b8 2320}
648acd28
DV
2321var isOK=function(x){
2322return x&&!isNaN(x);
2323};
bd597afc
DV
2324if(_162.length>0){
2325var _155=_162[0].canvasx;
2326var _165=this.attr_("xValueFormatter")(_157,this)+":";
b2a516b8 2327var clen=this.colors_.length;
bd597afc
DV
2328for(var i=0;i<_162.length;i++){
2329if(!isOK(_162[i].canvasy)){
648acd28
DV
2330continue;
2331}
285a6bda 2332if(this.attr_("labelsSeparateLines")){
bd597afc 2333_165+="<br/>";
b2a516b8 2334}
bd597afc
DV
2335var _167=_162[i];
2336_165+=" <b><font color='"+this.colors_[i%clen].toHexString()+"'>"+_167.name+"</font></b>:"+this.round_(_167.yval,2);
b2a516b8 2337}
bd597afc
DV
2338this.attr_("labelsDiv").innerHTML=_165;
2339this.lastx_=_157;
b2a516b8 2340ctx.save();
bd597afc
DV
2341for(var i=0;i<_162.length;i++){
2342if(!isOK(_162[i%clen].canvasy)){
648acd28
DV
2343continue;
2344}
b2a516b8
DV
2345ctx.beginPath();
2346ctx.fillStyle=this.colors_[i%clen].toRGBString();
bd597afc 2347ctx.arc(_155,_162[i%clen].canvasy,_163,0,360,false);
b2a516b8
DV
2348ctx.fill();
2349}
2350ctx.restore();
bd597afc 2351this.previousVerticalX_=_155;
b2a516b8 2352}
6a1aa64f 2353};
bd597afc 2354Dygraph.prototype.mouseOut_=function(_168){
b2a516b8
DV
2355var ctx=this.canvas_.getContext("2d");
2356ctx.clearRect(0,0,this.width_,this.height_);
285a6bda 2357this.attr_("labelsDiv").innerHTML="";
6a1aa64f 2358};
285a6bda 2359Dygraph.zeropad=function(x){
6372d433
DV
2360if(x<10){
2361return "0"+x;
2362}else{
2363return ""+x;
2364}
2365};
285a6bda 2366Dygraph.prototype.hmsString_=function(date){
bd597afc 2367var _170=Dygraph.zeropad;
6372d433
DV
2368var d=new Date(date);
2369if(d.getSeconds()){
bd597afc 2370return _170(d.getHours())+":"+_170(d.getMinutes())+":"+_170(d.getSeconds());
6372d433
DV
2371}else{
2372if(d.getMinutes()){
bd597afc 2373return _170(d.getHours())+":"+_170(d.getMinutes());
6372d433 2374}else{
bd597afc 2375return _170(d.getHours());
6372d433
DV
2376}
2377}
2378};
285a6bda 2379Dygraph.dateString_=function(date,self){
bd597afc 2380var _172=Dygraph.zeropad;
b2a516b8
DV
2381var d=new Date(date);
2382var year=""+d.getFullYear();
bd597afc
DV
2383var _174=_172(d.getMonth()+1);
2384var day=_172(d.getDate());
6372d433
DV
2385var ret="";
2386var frac=d.getHours()*3600+d.getMinutes()*60+d.getSeconds();
2387if(frac){
285a6bda 2388ret=" "+self.hmsString_(date);
b2a516b8 2389}
bd597afc 2390return year+"/"+_174+"/"+day+ret;
6a1aa64f 2391};
bd597afc
DV
2392Dygraph.prototype.round_=function(num,_178){
2393var _179=Math.pow(10,_178);
2394return Math.round(num*_179)/_179;
6a1aa64f 2395};
285a6bda 2396Dygraph.prototype.loadedEvent_=function(data){
b2a516b8
DV
2397this.rawData_=this.parseCSV_(data);
2398this.drawGraph_(this.rawData_);
6a1aa64f 2399};
285a6bda
DV
2400Dygraph.prototype.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
2401Dygraph.prototype.quarters=["Jan","Apr","Jul","Oct"];
2402Dygraph.prototype.addXTicks_=function(){
bd597afc 2403var _181,endDate;
b2a516b8 2404if(this.dateWindow_){
bd597afc 2405_181=this.dateWindow_[0];
b2a516b8
DV
2406endDate=this.dateWindow_[1];
2407}else{
bd597afc 2408_181=this.rawData_[0][0];
b2a516b8
DV
2409endDate=this.rawData_[this.rawData_.length-1][0];
2410}
bd597afc
DV
2411var _182=this.attr_("xTicker")(_181,endDate,this);
2412this.layout_.updateOptions({xTicks:_182});
285a6bda
DV
2413};
2414Dygraph.SECONDLY=0;
2415Dygraph.TEN_SECONDLY=1;
2416Dygraph.THIRTY_SECONDLY=2;
2417Dygraph.MINUTELY=3;
2418Dygraph.TEN_MINUTELY=4;
2419Dygraph.THIRTY_MINUTELY=5;
2420Dygraph.HOURLY=6;
2421Dygraph.SIX_HOURLY=7;
2422Dygraph.DAILY=8;
2423Dygraph.WEEKLY=9;
2424Dygraph.MONTHLY=10;
2425Dygraph.QUARTERLY=11;
2426Dygraph.BIANNUAL=12;
2427Dygraph.ANNUAL=13;
2428Dygraph.DECADAL=14;
2429Dygraph.NUM_GRANULARITIES=15;
2430Dygraph.SHORT_SPACINGS=[];
2431Dygraph.SHORT_SPACINGS[Dygraph.SECONDLY]=1000*1;
2432Dygraph.SHORT_SPACINGS[Dygraph.TEN_SECONDLY]=1000*10;
2433Dygraph.SHORT_SPACINGS[Dygraph.THIRTY_SECONDLY]=1000*30;
2434Dygraph.SHORT_SPACINGS[Dygraph.MINUTELY]=1000*60;
2435Dygraph.SHORT_SPACINGS[Dygraph.TEN_MINUTELY]=1000*60*10;
2436Dygraph.SHORT_SPACINGS[Dygraph.THIRTY_MINUTELY]=1000*60*30;
2437Dygraph.SHORT_SPACINGS[Dygraph.HOURLY]=1000*3600;
2438Dygraph.SHORT_SPACINGS[Dygraph.HOURLY]=1000*3600*6;
2439Dygraph.SHORT_SPACINGS[Dygraph.DAILY]=1000*86400;
2440Dygraph.SHORT_SPACINGS[Dygraph.WEEKLY]=1000*604800;
bd597afc
DV
2441Dygraph.prototype.NumXTicks=function(_183,_184,_185){
2442if(_185<Dygraph.MONTHLY){
2443var _186=Dygraph.SHORT_SPACINGS[_185];
2444return Math.floor(0.5+1*(_184-_183)/_186);
285a6bda 2445}else{
bd597afc
DV
2446var _187=1;
2447var _188=12;
2448if(_185==Dygraph.QUARTERLY){
2449_188=3;
285a6bda 2450}
bd597afc
DV
2451if(_185==Dygraph.BIANNUAL){
2452_188=2;
285a6bda 2453}
bd597afc
DV
2454if(_185==Dygraph.ANNUAL){
2455_188=1;
285a6bda 2456}
bd597afc
DV
2457if(_185==Dygraph.DECADAL){
2458_188=1;
2459_187=10;
285a6bda 2460}
bd597afc
DV
2461var _189=365.2524*24*3600*1000;
2462var _190=1*(_184-_183)/_189;
2463return Math.floor(0.5+1*_190*_188/_187);
285a6bda
DV
2464}
2465};
bd597afc
DV
2466Dygraph.prototype.GetXAxis=function(_191,_192,_193){
2467var _194=[];
2468if(_193<Dygraph.MONTHLY){
2469var _195=Dygraph.SHORT_SPACINGS[_193];
2470var _196="%d%b";
2471if(_193<Dygraph.HOURLY){
2472_191=_195*Math.floor(0.5+_191/_195);
2473}
2474for(var t=_191;t<=_192;t+=_195){
36615faf
DV
2475var d=new Date(t);
2476var frac=d.getHours()*3600+d.getMinutes()*60+d.getSeconds();
bd597afc
DV
2477if(frac==0||_193>=Dygraph.DAILY){
2478_194.push({v:t,label:new Date(t+3600*1000).strftime(_196)});
b2a516b8 2479}else{
bd597afc 2480_194.push({v:t,label:this.hmsString_(t)});
36615faf
DV
2481}
2482}
b2a516b8 2483}else{
bd597afc
DV
2484var _198;
2485var _199=1;
2486if(_193==Dygraph.MONTHLY){
2487_198=[0,1,2,3,4,5,6,7,8,9,10,11,12];
b2a516b8 2488}else{
bd597afc
DV
2489if(_193==Dygraph.QUARTERLY){
2490_198=[0,3,6,9];
b2a516b8 2491}else{
bd597afc
DV
2492if(_193==Dygraph.BIANNUAL){
2493_198=[0,6];
b2a516b8 2494}else{
bd597afc
DV
2495if(_193==Dygraph.ANNUAL){
2496_198=[0];
6372d433 2497}else{
bd597afc
DV
2498if(_193==Dygraph.DECADAL){
2499_198=[0];
2500_199=10;
b2a516b8
DV
2501}
2502}
2503}
2504}
6372d433 2505}
bd597afc
DV
2506var _200=new Date(_191).getFullYear();
2507var _201=new Date(_192).getFullYear();
2508var _202=Dygraph.zeropad;
2509for(var i=_200;i<=_201;i++){
2510if(i%_199!=0){
36615faf 2511continue;
6372d433 2512}
bd597afc
DV
2513for(var j=0;j<_198.length;j++){
2514var _203=i+"/"+_202(1+_198[j])+"/01";
2515var t=Date.parse(_203);
2516if(t<_191||t>_192){
b2a516b8
DV
2517continue;
2518}
bd597afc 2519_194.push({v:t,label:new Date(t).strftime("%b %y")});
b2a516b8
DV
2520}
2521}
b2a516b8 2522}
bd597afc 2523return _194;
36615faf 2524};
bd597afc
DV
2525Dygraph.dateTicker=function(_204,_205,self){
2526var _206=-1;
285a6bda 2527for(var i=0;i<Dygraph.NUM_GRANULARITIES;i++){
bd597afc
DV
2528var _207=self.NumXTicks(_204,_205,i);
2529if(self.width_/_207>=self.attr_("pixelsPerXLabel")){
2530_206=i;
36615faf
DV
2531break;
2532}
b2a516b8 2533}
bd597afc
DV
2534if(_206>=0){
2535return self.GetXAxis(_204,_205,_206);
36615faf 2536}else{
6372d433 2537}
6a1aa64f 2538};
285a6bda 2539Dygraph.numericTicks=function(minV,maxV,self){
bd597afc
DV
2540var _210=[1,2,5];
2541var _211,low_val,high_val,nTicks;
2542var _212=self.attr_("pixelsPerYLabel");
2ce09b19 2543for(var i=-10;i<50;i++){
bd597afc
DV
2544var _213=Math.pow(10,i);
2545for(var j=0;j<_210.length;j++){
2546_211=_213*_210[j];
2547low_val=Math.floor(minV/_211)*_211;
2548high_val=Math.ceil(maxV/_211)*_211;
2549nTicks=(high_val-low_val)/_211;
2550var _214=self.height_/nTicks;
2551if(_214>_212){
2ce09b19 2552break;
6a1aa64f 2553}
b2a516b8 2554}
bd597afc 2555if(_214>_212){
2ce09b19 2556break;
b2a516b8 2557}
2ce09b19 2558}
bd597afc 2559var _215=[];
2ce09b19 2560for(var i=0;i<nTicks;i++){
bd597afc
DV
2561var _216=low_val+i*_211;
2562var _217=self.round_(_216,2);
285a6bda 2563if(self.attr_("labelsKMB")){
b2a516b8 2564var k=1000;
bd597afc
DV
2565if(_216>=k*k*k){
2566_217=self.round_(_216/(k*k*k),1)+"B";
b2a516b8 2567}else{
bd597afc
DV
2568if(_216>=k*k){
2569_217=self.round_(_216/(k*k),1)+"M";
b2a516b8 2570}else{
bd597afc
DV
2571if(_216>=k){
2572_217=self.round_(_216/k,1)+"K";
b2a516b8
DV
2573}
2574}
2575}
2576}
bd597afc 2577_215.push({label:_217,v:_216});
b2a516b8 2578}
bd597afc 2579return _215;
6a1aa64f 2580};
285a6bda 2581Dygraph.prototype.addYTicks_=function(minY,maxY){
bd597afc
DV
2582var _221=Dygraph.numericTicks(minY,maxY,this);
2583this.layout_.updateOptions({yAxis:[minY,maxY],yTicks:_221});
6a1aa64f 2584};
bd597afc 2585Dygraph.prototype.extremeValues_=function(_222){
e4007107 2586var minY=null,maxY=null;
b64a4f1a 2587var bars=this.attr_("errorBars")||this.attr_("customBars");
648acd28 2588if(bars){
bd597afc
DV
2589for(var j=0;j<_222.length;j++){
2590var y=_222[j][1][0];
648acd28
DV
2591if(!y){
2592continue;
e4007107 2593}
bd597afc
DV
2594var low=y-_222[j][1][1];
2595var high=y+_222[j][1][2];
648acd28
DV
2596if(low>y){
2597low=y;
b2a516b8 2598}
648acd28
DV
2599if(high<y){
2600high=y;
b2a516b8 2601}
648acd28
DV
2602if(maxY==null||high>maxY){
2603maxY=high;
285a6bda 2604}
648acd28
DV
2605if(minY==null||low<minY){
2606minY=low;
e4007107 2607}
285a6bda 2608}
b2a516b8 2609}else{
bd597afc
DV
2610for(var j=0;j<_222.length;j++){
2611var y=_222[j][1];
648acd28
DV
2612if(!y){
2613continue;
285a6bda 2614}
b2a516b8 2615if(maxY==null||y>maxY){
285a6bda
DV
2616maxY=y;
2617}
e4007107
DV
2618if(minY==null||y<minY){
2619minY=y;
2620}
b2a516b8
DV
2621}
2622}
648acd28
DV
2623return [minY,maxY];
2624};
2625Dygraph.prototype.drawGraph_=function(data){
2626var minY=null,maxY=null;
2627this.layout_.removeAllDatasets();
2628this.setColors_();
9317362d 2629this.attrs_["pointSize"]=0.5*this.attr_("highlightCircleSize");
648acd28 2630for(var i=1;i<data[0].length;i++){
bd597afc 2631var _226=[];
648acd28
DV
2632for(var j=0;j<data.length;j++){
2633var date=data[j][0];
bd597afc 2634_226[j]=[date,data[j][i]];
648acd28 2635}
bd597afc 2636_226=this.rollingAverage(_226,this.rollPeriod_);
b64a4f1a 2637var bars=this.attr_("errorBars")||this.attr_("customBars");
648acd28
DV
2638if(this.dateWindow_){
2639var low=this.dateWindow_[0];
2640var high=this.dateWindow_[1];
bd597afc
DV
2641var _227=[];
2642for(var k=0;k<_226.length;k++){
2643if(_226[k][0]>=low&&_226[k][0]<=high){
2644_227.push(_226[k]);
648acd28
DV
2645}
2646}
bd597afc 2647_226=_227;
648acd28 2648}
bd597afc
DV
2649var _228=this.extremeValues_(_226);
2650var _229=_228[0];
2651var _230=_228[1];
2652if(!minY||_229<minY){
2653minY=_229;
648acd28 2654}
bd597afc
DV
2655if(!maxY||_230>maxY){
2656maxY=_230;
b2a516b8
DV
2657}
2658if(bars){
2659var vals=[];
bd597afc
DV
2660for(var j=0;j<_226.length;j++){
2661vals[j]=[_226[j][0],_226[j][1][0],_226[j][1][1],_226[j][1][2]];
b2a516b8 2662}
285a6bda 2663this.layout_.addDataset(this.attr_("labels")[i],vals);
b2a516b8 2664}else{
bd597afc 2665this.layout_.addDataset(this.attr_("labels")[i],_226);
b2a516b8
DV
2666}
2667}
2668if(this.valueRange_!=null){
2669this.addYTicks_(this.valueRange_[0],this.valueRange_[1]);
2670}else{
e4007107 2671var span=maxY-minY;
bd597afc
DV
2672var _233=maxY+0.1*span;
2673var _234=minY-0.1*span;
2674if(_234<0&&minY>=0){
2675_234=0;
e4007107 2676}
bd597afc
DV
2677if(_233>0&&maxY<=0){
2678_233=0;
e4007107
DV
2679}
2680if(this.attr_("includeZero")){
2681if(maxY<0){
bd597afc 2682_233=0;
e4007107
DV
2683}
2684if(minY>0){
bd597afc 2685_234=0;
e4007107 2686}
b2a516b8 2687}
bd597afc 2688this.addYTicks_(_234,_233);
b2a516b8
DV
2689}
2690this.addXTicks_();
2691this.layout_.evaluateWithError();
2692this.plotter_.clear();
2693this.plotter_.render();
2694this.canvas_.getContext("2d").clearRect(0,0,this.canvas_.width,this.canvas_.height);
6a1aa64f 2695};
bd597afc
DV
2696Dygraph.prototype.rollingAverage=function(_235,_236){
2697if(_235.length<2){
2698return _235;
b2a516b8 2699}
bd597afc
DV
2700var _236=Math.min(_236,_235.length-1);
2701var _237=[];
2702var _238=this.attr_("sigma");
b2a516b8
DV
2703if(this.fractions_){
2704var num=0;
2705var den=0;
2706var mult=100;
bd597afc
DV
2707for(var i=0;i<_235.length;i++){
2708num+=_235[i][1][0];
2709den+=_235[i][1][1];
2710if(i-_236>=0){
2711num-=_235[i-_236][1][0];
2712den-=_235[i-_236][1][1];
2713}
2714var date=_235[i][0];
2715var _241=den?num/den:0;
285a6bda 2716if(this.attr_("errorBars")){
b2a516b8
DV
2717if(this.wilsonInterval_){
2718if(den){
bd597afc
DV
2719var p=_241<0?0:_241,n=den;
2720var pm=_238*Math.sqrt(p*(1-p)/n+_238*_238/(4*n*n));
2721var _244=1+_238*_238/den;
2722var low=(p+_238*_238/(2*den)-pm)/_244;
2723var high=(p+_238*_238/(2*den)+pm)/_244;
2724_237[i]=[date,[p*mult,(p-low)*mult,(high-p)*mult]];
b2a516b8 2725}else{
bd597afc 2726_237[i]=[date,[0,0,0]];
b2a516b8
DV
2727}
2728}else{
bd597afc
DV
2729var _245=den?_238*Math.sqrt(_241*(1-_241)/den):1;
2730_237[i]=[date,[mult*_241,mult*_245,mult*_245]];
b2a516b8
DV
2731}
2732}else{
bd597afc 2733_237[i]=[date,mult*_241];
b2a516b8
DV
2734}
2735}
2736}else{
b64a4f1a 2737if(this.attr_("customBars")){
6372d433
DV
2738var low=0;
2739var mid=0;
2740var high=0;
bd597afc
DV
2741var _247=0;
2742for(var i=0;i<_235.length;i++){
2743var data=_235[i][1];
b2a516b8 2744var y=data[1];
bd597afc 2745_237[i]=[_235[i][0],[y,y-data[0],data[2]-y]];
6372d433
DV
2746low+=data[0];
2747mid+=y;
2748high+=data[2];
bd597afc
DV
2749_247+=1;
2750if(i-_236>=0){
2751var prev=_235[i-_236];
6372d433
DV
2752low-=prev[1][0];
2753mid-=prev[1][1];
2754high-=prev[1][2];
bd597afc 2755_247-=1;
6372d433 2756}
bd597afc 2757_237[i]=[_235[i][0],[1*mid/_247,1*(mid-low)/_247,1*(high-mid)/_247]];
6372d433
DV
2758}
2759}else{
bd597afc 2760var _249=Math.min(_236-1,_235.length-2);
285a6bda 2761if(!this.attr_("errorBars")){
bd597afc
DV
2762if(_236==1){
2763return _235;
648acd28 2764}
bd597afc 2765for(var i=0;i<_235.length;i++){
b2a516b8 2766var sum=0;
bd597afc
DV
2767var _251=0;
2768for(var j=Math.max(0,i-_236+1);j<i+1;j++){
2769var y=_235[j][1];
648acd28
DV
2770if(!y||isNaN(y)){
2771continue;
b2a516b8 2772}
bd597afc
DV
2773_251++;
2774sum+=_235[j][1];
648acd28 2775}
bd597afc
DV
2776if(_251){
2777_237[i]=[_235[i][0],sum/_251];
648acd28 2778}else{
bd597afc 2779_237[i]=[_235[i][0],null];
b2a516b8 2780}
648acd28 2781}
2847c1cf 2782}else{
bd597afc 2783for(var i=0;i<_235.length;i++){
b2a516b8 2784var sum=0;
bd597afc
DV
2785var _252=0;
2786var _251=0;
2787for(var j=Math.max(0,i-_236+1);j<i+1;j++){
2788var y=_235[j][1][0];
648acd28
DV
2789if(!y||isNaN(y)){
2790continue;
b2a516b8 2791}
bd597afc
DV
2792_251++;
2793sum+=_235[j][1][0];
2794_252+=Math.pow(_235[j][1][1],2);
b2a516b8 2795}
bd597afc
DV
2796if(_251){
2797var _245=Math.sqrt(_252)/_251;
2798_237[i]=[_235[i][0],[sum/_251,_238*_245,_238*_245]];
648acd28 2799}else{
bd597afc 2800_237[i]=[_235[i][0],[null,null,null]];
b2a516b8
DV
2801}
2802}
2803}
648acd28
DV
2804}
2805}
bd597afc 2806return _237;
6a1aa64f 2807};
bd597afc
DV
2808Dygraph.dateParser=function(_253,self){
2809var _254;
285a6bda 2810var d;
bd597afc
DV
2811if(_253.length==10&&_253.search("-")!=-1){
2812_254=_253.replace("-","/","g");
2813while(_254.search("-")!=-1){
2814_254=_254.replace("-","/");
353a0294 2815}
bd597afc 2816d=Date.parse(_254);
b2a516b8 2817}else{
bd597afc
DV
2818if(_253.length==8){
2819_254=_253.substr(0,4)+"/"+_253.substr(4,2)+"/"+_253.substr(6,2);
2820d=Date.parse(_254);
8846615a 2821}else{
bd597afc 2822d=Date.parse(_253);
285a6bda 2823}
b2a516b8 2824}
285a6bda 2825if(!d||isNaN(d)){
bd597afc 2826self.error("Couldn't parse "+_253+" as a date");
b2a516b8 2827}
285a6bda 2828return d;
6a1aa64f 2829};
285a6bda 2830Dygraph.prototype.detectTypeFromString_=function(str){
bd597afc 2831var _256=false;
285a6bda 2832if(str.indexOf("-")>=0||str.indexOf("/")>=0||isNaN(parseFloat(str))){
bd597afc 2833_256=true;
285a6bda
DV
2834}else{
2835if(str.length==8&&str>"19700101"&&str<"20371231"){
bd597afc 2836_256=true;
285a6bda
DV
2837}
2838}
bd597afc 2839if(_256){
285a6bda
DV
2840this.attrs_.xValueFormatter=Dygraph.dateString_;
2841this.attrs_.xValueParser=Dygraph.dateParser;
2842this.attrs_.xTicker=Dygraph.dateTicker;
2843}else{
2844this.attrs_.xValueFormatter=function(x){
2845return x;
2846};
2847this.attrs_.xValueParser=function(x){
2848return parseFloat(x);
2849};
2850this.attrs_.xTicker=Dygraph.numericTicks;
2851}
2852};
2853Dygraph.prototype.parseCSV_=function(data){
b2a516b8 2854var ret=[];
bd597afc
DV
2855var _257=data.split("\n");
2856var _258=0;
b2a516b8 2857if(this.labelsFromCSV_){
bd597afc
DV
2858_258=1;
2859this.attrs_.labels=_257[0].split(",");
2860}
2861var _259;
2862var _260=false;
2863var _261=this.attr_("labels").length;
2864for(var i=_258;i<_257.length;i++){
2865var line=_257[i];
b2a516b8
DV
2866if(line.length==0){
2867continue;
2868}
bd597afc
DV
2869var _263=line.split(",");
2870if(_263.length<2){
b2a516b8
DV
2871continue;
2872}
bd597afc
DV
2873var _264=[];
2874if(!_260){
2875this.detectTypeFromString_(_263[0]);
2876_259=this.attr_("xValueParser");
2877_260=true;
285a6bda 2878}
bd597afc 2879_264[0]=_259(_263[0],this);
b2a516b8 2880if(this.fractions_){
bd597afc
DV
2881for(var j=1;j<_263.length;j++){
2882var vals=_263[j].split("/");
2883_264[j]=[parseFloat(vals[0]),parseFloat(vals[1])];
b2a516b8
DV
2884}
2885}else{
285a6bda 2886if(this.attr_("errorBars")){
bd597afc
DV
2887for(var j=1;j<_263.length;j+=2){
2888_264[(j+1)/2]=[parseFloat(_263[j]),parseFloat(_263[j+1])];
b2a516b8
DV
2889}
2890}else{
b64a4f1a 2891if(this.attr_("customBars")){
bd597afc
DV
2892for(var j=1;j<_263.length;j++){
2893var vals=_263[j].split(";");
2894_264[j]=[parseFloat(vals[0]),parseFloat(vals[1]),parseFloat(vals[2])];
b2a516b8
DV
2895}
2896}else{
bd597afc
DV
2897for(var j=1;j<_263.length;j++){
2898_264[j]=parseFloat(_263[j]);
285a6bda 2899}
b2a516b8
DV
2900}
2901}
2902}
bd597afc
DV
2903ret.push(_264);
2904if(_264.length!=_261){
2905this.error("Number of columns in line "+i+" ("+_264.length+") does not agree with number of labels ("+_261+") "+line);
b2a516b8 2906}
b2a516b8
DV
2907}
2908return ret;
6a1aa64f 2909};
285a6bda
DV
2910Dygraph.prototype.parseArray_=function(data){
2911if(data.length==0){
2912this.error("Can't plot empty data set");
2913return null;
2914}
2915if(data[0].length==0){
2916this.error("Data set cannot contain an empty row");
2917return null;
2918}
2919if(this.attr_("labels")==null){
2920this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
2921this.attrs_.labels=["X"];
2922for(var i=1;i<data[0].length;i++){
2923this.attrs_.labels.push("Y"+i);
2924}
2925}
2926if(MochiKit.Base.isDateLike(data[0][0])){
2927this.attrs_.xValueFormatter=Dygraph.dateString_;
2928this.attrs_.xTicker=Dygraph.dateTicker;
bd597afc 2929var _265=MochiKit.Base.clone(data);
285a6bda 2930for(var i=0;i<data.length;i++){
bd597afc 2931if(_265[i].length==0){
285a6bda
DV
2932this.error("Row "<<(1+i)<<" of data is empty");
2933return null;
2934}
bd597afc 2935if(_265[i][0]==null||typeof (_265[i][0].getTime)!="function"){
285a6bda
DV
2936this.error("x value in row "<<(1+i)<<" is not a Date");
2937return null;
2938}
bd597afc 2939_265[i][0]=_265[i][0].getTime();
285a6bda 2940}
bd597afc 2941return _265;
285a6bda
DV
2942}else{
2943this.attrs_.xValueFormatter=function(x){
2944return x;
2945};
2946this.attrs_.xTicker=Dygraph.numericTicks;
2947return data;
2948}
2949};
2950Dygraph.prototype.parseDataTable_=function(data){
6219c9d6
DV
2951var cols=data.getNumberOfColumns();
2952var rows=data.getNumberOfRows();
bd597afc 2953var _268=[];
6219c9d6 2954for(var i=0;i<cols;i++){
bd597afc 2955_268.push(data.getColumnLabel(i));
6219c9d6 2956}
bd597afc
DV
2957this.attrs_.labels=_268;
2958var _269=data.getColumnType(0);
2959if(_269=="date"){
285a6bda
DV
2960this.attrs_.xValueFormatter=Dygraph.dateString_;
2961this.attrs_.xValueParser=Dygraph.dateParser;
2962this.attrs_.xTicker=Dygraph.dateTicker;
2963}else{
bd597afc 2964if(_269=="number"){
285a6bda
DV
2965this.attrs_.xValueFormatter=function(x){
2966return x;
2967};
2968this.attrs_.xValueParser=function(x){
2969return parseFloat(x);
2970};
2971this.attrs_.xTicker=Dygraph.numericTicks;
2972}else{
bd597afc 2973this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_269+"')");
6219c9d6
DV
2974return null;
2975}
285a6bda 2976}
6219c9d6
DV
2977var ret=[];
2978for(var i=0;i<rows;i++){
2979var row=[];
b3b20e24
DV
2980if(!data.getValue(i,0)){
2981continue;
2982}
bd597afc 2983if(_269=="date"){
6219c9d6 2984row.push(data.getValue(i,0).getTime());
36615faf
DV
2985}else{
2986row.push(data.getValue(i,0));
2987}
6219c9d6
DV
2988for(var j=1;j<cols;j++){
2989row.push(data.getValue(i,j));
2990}
2991ret.push(row);
2992}
2993return ret;
2994};
285a6bda 2995Dygraph.prototype.start_=function(){
b2a516b8
DV
2996if(typeof this.file_=="function"){
2997this.loadedEvent_(this.file_());
2998}else{
285a6bda
DV
2999if(MochiKit.Base.isArrayLike(this.file_)){
3000this.rawData_=this.parseArray_(this.file_);
3001this.drawGraph_(this.rawData_);
3002}else{
6219c9d6
DV
3003if(typeof this.file_=="object"&&typeof this.file_.getColumnRange=="function"){
3004this.rawData_=this.parseDataTable_(this.file_);
3005this.drawGraph_(this.rawData_);
3006}else{
285a6bda
DV
3007if(typeof this.file_=="string"){
3008if(this.file_.indexOf("\n")>=0){
3009this.loadedEvent_(this.file_);
3010}else{
b2a516b8 3011var req=new XMLHttpRequest();
bd597afc 3012var _272=this;
b2a516b8
DV
3013req.onreadystatechange=function(){
3014if(req.readyState==4){
3015if(req.status==200){
bd597afc 3016_272.loadedEvent_(req.responseText);
b2a516b8
DV
3017}
3018}
6a1aa64f 3019};
b2a516b8
DV
3020req.open("GET",this.file_,true);
3021req.send(null);
3022}
285a6bda
DV
3023}else{
3024this.error("Unknown data format: "+(typeof this.file_));
6219c9d6 3025}
b2a516b8 3026}
b2a516b8 3027}
b2a516b8 3028}
285a6bda 3029};
bd597afc
DV
3030Dygraph.prototype.updateOptions=function(_273){
3031if(_273.rollPeriod){
3032this.rollPeriod_=_273.rollPeriod;
b2a516b8 3033}
bd597afc
DV
3034if(_273.dateWindow){
3035this.dateWindow_=_273.dateWindow;
b2a516b8 3036}
bd597afc
DV
3037if(_273.valueRange){
3038this.valueRange_=_273.valueRange;
b2a516b8 3039}
bd597afc 3040MochiKit.Base.update(this.user_attrs_,_273);
285a6bda
DV
3041this.labelsFromCSV_=(this.attr_("labels")==null);
3042this.layout_.updateOptions({"errorBars":this.attr_("errorBars")});
bd597afc
DV
3043if(_273["file"]&&_273["file"]!=this.file_){
3044this.file_=_273["file"];
b2a516b8
DV
3045this.start_();
3046}else{
3047this.drawGraph_(this.rawData_);
3048}
6a1aa64f 3049};
bd597afc
DV
3050Dygraph.prototype.adjustRoll=function(_274){
3051this.rollPeriod_=_274;
b2a516b8 3052this.drawGraph_(this.rawData_);
6a1aa64f 3053};
bd597afc
DV
3054Dygraph.GVizChart=function(_275){
3055this.container=_275;
6219c9d6 3056};
bd597afc 3057Dygraph.GVizChart.prototype.draw=function(data,_276){
6219c9d6 3058this.container.innerHTML="";
bd597afc 3059this.date_graph=new Dygraph(this.container,data,_276);
6219c9d6 3060};
285a6bda 3061DateGraph=Dygraph;
b2a516b8 3062