From 078d1d29424f0590cb9f1b7b2925bbbefadf0896 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Tue, 18 Aug 2009 23:46:02 +0000 Subject: [PATCH] add docs --- docs/arrow.gif | Bin 0 -> 206 bytes docs/data.js | 63 + docs/dygraph-combined.js | 10375 +++++++++++++++++++++++++++++++++++++++++++++ docs/excanvas.js | 876 ++++ docs/index.html | 407 ++ docs/temperatures.csv | 367 ++ docs/temperatures.txt | 367 ++ docs/twonormals.csv | 366 ++ 8 files changed, 12821 insertions(+) create mode 100644 docs/arrow.gif create mode 100644 docs/data.js create mode 100644 docs/dygraph-combined.js create mode 100644 docs/excanvas.js create mode 100644 docs/index.html create mode 100644 docs/temperatures.csv create mode 100644 docs/temperatures.txt create mode 100644 docs/twonormals.csv diff --git a/docs/arrow.gif b/docs/arrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..f8138f9b064a6645f56d438947941894121f0f09 GIT binary patch literal 206 zcmV;<05ShZNk%w1VL$*t0HFW?|Ns90fB*mh0RR90A^8LW00093EC2ui06+jh0007? zoR6u??GK}zwAzca-n{z{hT=$;=82~2%C_zc$MQ_q_Khz>?g%@t^8pn;;qc%K7(K)@ihWM0Ou_aG4vWXrA}2{stHI_B0KJZ<+Zed~9;RFD_&&8t!RIH}lp#2% zR*3QDg-ED(ktK<>1z9(V=~QNElcWgbbYu`J%E<$G6d=0F+UoiW8!J0YTWfoZo2$Fa I8&UuOJE~z`d;kCd literal 0 HcmV?d00001 diff --git a/docs/data.js b/docs/data.js new file mode 100644 index 0000000..232bc24 --- /dev/null +++ b/docs/data.js @@ -0,0 +1,63 @@ +function StubbedData() { +return "" + +"Date,A,B\n" + +"20061001,3.01953818828,0.7212041046,2.18487394958,0.599318549691\n" + +"20061002,3.63321799308,0.778297234566,1.69491525424,0.531417655826\n" + +"20061003,2.44328097731,0.644967734352,2.51256281407,0.640539070386\n" + +"20061004,3.52733686067,0.774700921683,2.68456375839,0.66207105053\n" + +"20061005,3.28719723183,0.741636245748,2.35294117647,0.621407707226\n" + +"20061006,1.58450704225,0.523967868159,3.78657487091,0.791868460623\n" + +"20061007,5.32859680284,0.946589405904,4.0404040404,0.807910739509\n" + +"20061008,2.64084507042,0.672799548916,2.37288135593,0.626609885481\n" + +"20061009,2.26480836237,0.620990945917,3.5413153457,0.75897176848\n" + +"20061010,3.29289428076,0.74289969528,2.02702702703,0.579191340004\n" + +"20061011,2.7633851468,0.681234043829,1.1744966443,0.4413034044\n" + +"20061012,3.28719723183,0.741636245748,3.37268128162,0.741327769578\n" + +"20061013,1.77304964539,0.55569466381,1.85810810811,0.555011329732\n" + +"20061014,3.39892665474,0.7664008338,1.67224080268,0.524368852929\n" + +"20061015,2.65017667845,0.675144574777,3.35570469799,0.737661045752\n" + +"20061016,3.63951473137,0.779620631266,2.34899328859,0.620377617453\n" + +"20061017,2.25694444444,0.618859623032,1.68067226891,0.526990133716\n" + +"20061018,4.47504302926,0.857766274964,2.51677852349,0.641599927369\n" + +"20061019,2.44755244755,0.646081155692,1.68067226891,0.526990133716\n" + +"20061020,3.67775831874,0.787656442774,3.066439523,0.711598843969\n" + +"20061021,3.94265232975,0.823839169829,3.85906040268,0.788990618726\n" + +"20061022,2.59067357513,0.660187558973,3.71621621622,0.777438794254\n" + +"20061023,4.33275563258,0.847570482324,3.85906040268,0.788990618726\n" + +"20061024,3.10344827586,0.720049610821,2.84280936455,0.679611549697\n" + +"20061025,1.40350877193,0.492720767725,2.7027027027,0.666482380968\n" + +"20061026,1.95035460993,0.582291234145,2.36486486486,0.624518599275\n" + +"20061027,2.30905861456,0.632980642182,2.03045685279,0.580161203819\n" + +"20061028,4.09252669039,0.835706590809,2.87648054146,0.68754192469\n" + +"20061029,2.66903914591,0.679883997626,2.02360876897,0.578224712918\n" + +"20061030,4.74516695958,0.89127787497,4.36241610738,0.836670992529\n" + +"20061031,2.78260869565,0.685905251933,3.20945945946,0.724388507178\n" + +"20061101,1.5873015873,0.524884521441,1.51260504202,0.500373860545\n" + +"20061102,2.78745644599,0.687083077461,2.0202020202,0.57726130639\n" + +"20061103,5.11463844797,0.925157232782,2.68907563025,0.663168401088\n" + +"20061104,4.9001814882,0.919644816432,3.07692307692,0.713993047527\n" + +"20061105,5.13274336283,0.928343545136,3.55329949239,0.761492892041\n" + +"20061106,1.92644483363,0.575222935029,2.35294117647,0.621407707226\n" + +"20061107,2.46478873239,0.650573541306,1.52027027027,0.502889967904\n" + +"20061108,2.13523131673,0.609772022763,2.6981450253,0.665374048085\n" + +"20061109,3.88007054674,0.811026422222,2.72572402044,0.672079879106\n" + +"20061110,2.63620386643,0.671633132526,3.71621621622,0.777438794254\n" + +"20061111,3.69718309859,0.791736755355,3.0303030303,0.703344064467\n" + +"20061112,3.83944153578,0.802703592906,4.05405405405,0.81058250986\n" + +"20061113,2.47787610619,0.653984033555,2.20338983051,0.604340313133\n" + +"20061114,1.77304964539,0.55569466381,2.22222222222,0.60944692682\n" + +"20061115,2.30088495575,0.630766388737,0.843170320405,0.375484163785\n" + +"20061116,1.57894736842,0.522144132232,2.19594594595,0.602321544724\n" + +"20061118,2.45183887916,0.647198426991,1.69491525424,0.531417655826\n" + +"20061119,3.52733686067,0.774700921683,1.85185185185,0.55316023504\n" + +"20061120,2.97723292469,0.711254751484,2.6981450253,0.665374048085\n" + +"20061121,2.29681978799,0.629665059963,2.01680672269,0.576301104352\n" + +"20061122,3.01418439716,0.719945245328,2.5466893039,0.649125445325\n" + +"20061123,3.78378378378,0.809917534069,2.6936026936,0.664269394219\n" + +"20061124,3.18584070796,0.738851643987,2.01005025126,0.57439025002\n" + +"20061125,2.83185840708,0.697868332879,3.066439523,0.711598843969\n" + +"20061126,3.01953818828,0.7212041046,2.53378378378,0.645878720149\n" + +"20061127,2.81195079086,0.693033387099,1.51006711409,0.499540743312\n" + +"20061128,2.97723292469,0.711254751484,2.54237288136,0.648039583782\n" + +"20061129,1.41093474427,0.495309102312,3.02013422819,0.701020603129"; +} diff --git a/docs/dygraph-combined.js b/docs/dygraph-combined.js new file mode 100644 index 0000000..d0c243a --- /dev/null +++ b/docs/dygraph-combined.js @@ -0,0 +1,10375 @@ +/*** + + MochiKit.MochiKit 1.4 : PACKED VERSION + + THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please + diff against the source tree, not this file. + + See for documentation, downloads, license, etc. + + (c) 2005 Bob Ippolito. All rights Reserved. + +***/ + +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.Base"); +} +if(typeof (MochiKit)=="undefined"){ +MochiKit={}; +} +if(typeof (MochiKit.Base)=="undefined"){ +MochiKit.Base={}; +} +if(typeof (MochiKit.__export__)=="undefined"){ +MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")); +} +MochiKit.Base.VERSION="1.4"; +MochiKit.Base.NAME="MochiKit.Base"; +MochiKit.Base.update=function(_1,_2){ +if(_1===null){ +_1={}; +} +for(var i=1;i=0;i--){ +_15.unshift(o[i]); +} +}else{ +res.push(o); +} +} +return res; +},extend:function(_18,obj,_1a){ +if(!_1a){ +_1a=0; +} +if(obj){ +var l=obj.length; +if(typeof (l)!="number"){ +if(typeof (MochiKit.Iter)!="undefined"){ +obj=MochiKit.Iter.list(obj); +l=obj.length; +}else{ +throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); +} +} +if(!_18){ +_18=[]; +} +for(var i=_1a;i>b; +},zrshift:function(a,b){ +return a>>>b; +},eq:function(a,b){ +return a==b; +},ne:function(a,b){ +return a!=b; +},gt:function(a,b){ +return a>b; +},ge:function(a,b){ +return a>=b; +},lt:function(a,b){ +return al){ +_90=l; +} +} +_8e=[]; +for(i=0;i<_90;i++){ +var _92=[]; +for(var j=1;j=0;i--){ +_af=[_ab[i].apply(this,_af)]; +} +return _af[0]; +}; +},bind:function(_b1,_b2){ +if(typeof (_b1)=="string"){ +_b1=_b2[_b1]; +} +var _b3=_b1.im_func; +var _b4=_b1.im_preargs; +var _b5=_b1.im_self; +var m=MochiKit.Base; +if(typeof (_b1)=="function"&&typeof (_b1.apply)=="undefined"){ +_b1=m._wrapDumbFunction(_b1); +} +if(typeof (_b3)!="function"){ +_b3=_b1; +} +if(typeof (_b2)!="undefined"){ +_b5=_b2; +} +if(typeof (_b4)=="undefined"){ +_b4=[]; +}else{ +_b4=_b4.slice(); +} +m.extend(_b4,arguments,2); +var _b7=function(){ +var _b8=arguments; +var me=arguments.callee; +if(me.im_preargs.length>0){ +_b8=m.concat(me.im_preargs,_b8); +} +var _ba=me.im_self; +if(!_ba){ +_ba=this; +} +return me.im_func.apply(_ba,_b8); +}; +_b7.im_self=_b5; +_b7.im_func=_b3; +_b7.im_preargs=_b4; +return _b7; +},bindMethods:function(_bb){ +var _bc=MochiKit.Base.bind; +for(var k in _bb){ +var _be=_bb[k]; +if(typeof (_be)=="function"){ +_bb[k]=_bc(_be,_bb); +} +} +},registerComparator:function(_bf,_c0,_c1,_c2){ +MochiKit.Base.comparatorRegistry.register(_bf,_c0,_c1,_c2); +},_primitives:{"boolean":true,"string":true,"number":true},compare:function(a,b){ +if(a==b){ +return 0; +} +var _c5=(typeof (a)=="undefined"||a===null); +var _c6=(typeof (b)=="undefined"||b===null); +if(_c5&&_c6){ +return 0; +}else{ +if(_c5){ +return -1; +}else{ +if(_c6){ +return 1; +} +} +} +var m=MochiKit.Base; +var _c8=m._primitives; +if(!(typeof (a) in _c8&&typeof (b) in _c8)){ +try{ +return m.comparatorRegistry.match(a,b); +} +catch(e){ +if(e!=m.NotFound){ +throw e; +} +} +} +if(ab){ +return 1; +} +} +var _c9=m.repr; +throw new TypeError(_c9(a)+" and "+_c9(b)+" can not be compared"); +},compareDateLike:function(a,b){ +return MochiKit.Base.compare(a.getTime(),b.getTime()); +},compareArrayLike:function(a,b){ +var _ce=MochiKit.Base.compare; +var _cf=a.length; +var _d0=0; +if(_cf>b.length){ +_d0=1; +_cf=b.length; +}else{ +if(_cf=0;i--){ +sum+=o[i]; +} +}else{ +sum+=o; +} +} +if(_113<=0){ +throw new TypeError("mean() requires at least one argument"); +} +return sum/_113; +},median:function(){ +var data=MochiKit.Base.flattenArguments(arguments); +if(data.length===0){ +throw new TypeError("median() requires at least one argument"); +} +data.sort(compare); +if(data.length%2==0){ +var _117=data.length/2; +return (data[_117]+data[_117-1])/2; +}else{ +return data[(data.length-1)/2]; +} +},findValue:function(lst,_119,_11a,end){ +if(typeof (end)=="undefined"||end===null){ +end=lst.length; +} +if(typeof (_11a)=="undefined"||_11a===null){ +_11a=0; +} +var cmp=MochiKit.Base.compare; +for(var i=_11a;i0))){ +var kv=MochiKit.DOM.formContents(_127); +_127=kv[0]; +_128=kv[1]; +}else{ +if(arguments.length==1){ +if(typeof (_127.length)=="number"&&_127.length==2){ +return arguments.callee(_127[0],_127[1]); +} +var o=_127; +_127=[]; +_128=[]; +for(var k in o){ +var v=o[k]; +if(typeof (v)=="function"){ +continue; +}else{ +if(typeof (v)!="string"&&typeof (v.length)=="number"){ +for(var i=0;i=stop){ +throw self.StopIteration; +} +_174+=step; +return rval; +}}; +},imap:function(fun,p,q){ +var m=MochiKit.Base; +var self=MochiKit.Iter; +var _17e=m.map(self.iter,m.extend(null,arguments,1)); +var map=m.map; +var next=self.next; +return {repr:function(){ +return "imap(...)"; +},toString:m.forwardCall("repr"),next:function(){ +return fun.apply(this,map(next,_17e)); +}}; +},applymap:function(fun,seq,self){ +seq=MochiKit.Iter.iter(seq); +var m=MochiKit.Base; +return {repr:function(){ +return "applymap(...)"; +},toString:m.forwardCall("repr"),next:function(){ +return fun.apply(self,seq.next()); +}}; +},chain:function(p,q){ +var self=MochiKit.Iter; +var m=MochiKit.Base; +if(arguments.length==1){ +return self.iter(arguments[0]); +} +var _189=m.map(self.iter,arguments); +return {repr:function(){ +return "chain(...)"; +},toString:m.forwardCall("repr"),next:function(){ +while(_189.length>1){ +try{ +return _189[0].next(); +} +catch(e){ +if(e!=self.StopIteration){ +throw e; +} +_189.shift(); +} +} +if(_189.length==1){ +var arg=_189.shift(); +this.next=m.bind("next",arg); +return this.next(); +} +throw self.StopIteration; +}}; +},takewhile:function(pred,seq){ +var self=MochiKit.Iter; +seq=self.iter(seq); +return {repr:function(){ +return "takewhile(...)"; +},toString:MochiKit.Base.forwardCall("repr"),next:function(){ +var rval=seq.next(); +if(!pred(rval)){ +this.next=function(){ +throw self.StopIteration; +}; +this.next(); +} +return rval; +}}; +},dropwhile:function(pred,seq){ +seq=MochiKit.Iter.iter(seq); +var m=MochiKit.Base; +var bind=m.bind; +return {"repr":function(){ +return "dropwhile(...)"; +},"toString":m.forwardCall("repr"),"next":function(){ +while(true){ +var rval=seq.next(); +if(!pred(rval)){ +break; +} +} +this.next=bind("next",seq); +return rval; +}}; +},_tee:function(_194,sync,_196){ +sync.pos[_194]=-1; +var m=MochiKit.Base; +var _198=m.listMin; +return {repr:function(){ +return "tee("+_194+", ...)"; +},toString:m.forwardCall("repr"),next:function(){ +var rval; +var i=sync.pos[_194]; +if(i==sync.max){ +rval=_196.next(); +sync.deque.push(rval); +sync.max+=1; +sync.pos[_194]+=1; +}else{ +rval=sync.deque[i-sync.min]; +sync.pos[_194]+=1; +if(i==sync.min&&_198(sync.pos)!=sync.min){ +sync.min+=1; +sync.deque.shift(); +} +} +return rval; +}}; +},tee:function(_19b,n){ +var rval=[]; +var sync={"pos":[],"deque":[],"max":-1,"min":-1}; +if(arguments.length==1||typeof (n)=="undefined"||n===null){ +n=2; +} +var self=MochiKit.Iter; +_19b=self.iter(_19b); +var _tee=self._tee; +for(var i=0;i0&&_1ac>=stop)||(step<0&&_1ac<=stop)){ +throw MochiKit.Iter.StopIteration; +} +var rval=_1ac; +_1ac+=step; +return rval; +},repr:function(){ +return "range("+[_1ac,stop,step].join(", ")+")"; +},toString:MochiKit.Base.forwardCall("repr")}; +},sum:function(_1b0,_1b1){ +if(typeof (_1b1)=="undefined"||_1b1===null){ +_1b1=0; +} +var x=_1b1; +var self=MochiKit.Iter; +_1b0=self.iter(_1b0); +try{ +while(true){ +x+=_1b0.next(); +} +} +catch(e){ +if(e!=self.StopIteration){ +throw e; +} +} +return x; +},exhaust:function(_1b4){ +var self=MochiKit.Iter; +_1b4=self.iter(_1b4); +try{ +while(true){ +_1b4.next(); +} +} +catch(e){ +if(e!=self.StopIteration){ +throw e; +} +} +},forEach:function(_1b6,func,self){ +var m=MochiKit.Base; +if(arguments.length>2){ +func=m.bind(func,self); +} +if(m.isArrayLike(_1b6)){ +try{ +for(var i=0;i<_1b6.length;i++){ +func(_1b6[i]); +} +} +catch(e){ +if(e!=MochiKit.Iter.StopIteration){ +throw e; +} +} +}else{ +self=MochiKit.Iter; +self.exhaust(self.imap(func,_1b6)); +} +},every:function(_1bb,func){ +var self=MochiKit.Iter; +try{ +self.ifilterfalse(func,_1bb).next(); +return false; +} +catch(e){ +if(e!=self.StopIteration){ +throw e; +} +return true; +} +},sorted:function(_1be,cmp){ +var rval=MochiKit.Iter.list(_1be); +if(arguments.length==1){ +cmp=MochiKit.Base.compare; +} +rval.sort(cmp); +return rval; +},reversed:function(_1c1){ +var rval=MochiKit.Iter.list(_1c1); +rval.reverse(); +return rval; +},some:function(_1c3,func){ +var self=MochiKit.Iter; +try{ +self.ifilter(func,_1c3).next(); +return true; +} +catch(e){ +if(e!=self.StopIteration){ +throw e; +} +return false; +} +},iextend:function(lst,_1c7){ +if(MochiKit.Base.isArrayLike(_1c7)){ +for(var i=0;i<_1c7.length;i++){ +lst.push(_1c7[i]); +} +}else{ +var self=MochiKit.Iter; +_1c7=self.iter(_1c7); +try{ +while(true){ +lst.push(_1c7.next()); +} +} +catch(e){ +if(e!=self.StopIteration){ +throw e; +} +} +} +return lst; +},groupby:function(_1ca,_1cb){ +var m=MochiKit.Base; +var self=MochiKit.Iter; +if(arguments.length<2){ +_1cb=m.operator.identity; +} +_1ca=self.iter(_1ca); +var pk=undefined; +var k=undefined; +var v; +function fetch(){ +v=_1ca.next(); +k=_1cb(v); +} +function eat(){ +var ret=v; +v=undefined; +return ret; +} +var _1d2=true; +var _1d3=m.compare; +return {repr:function(){ +return "groupby(...)"; +},next:function(){ +while(_1d3(k,pk)===0){ +fetch(); +if(_1d2){ +_1d2=false; +break; +} +} +pk=k; +return [k,{next:function(){ +if(v==undefined){ +fetch(); +} +if(_1d3(k,pk)!==0){ +throw self.StopIteration; +} +return eat(); +}}]; +}}; +},groupby_as_array:function(_1d4,_1d5){ +var m=MochiKit.Base; +var self=MochiKit.Iter; +if(arguments.length<2){ +_1d5=m.operator.identity; +} +_1d4=self.iter(_1d4); +var _1d8=[]; +var _1d9=true; +var _1da; +var _1db=m.compare; +while(true){ +try{ +var _1dc=_1d4.next(); +var key=_1d5(_1dc); +} +catch(e){ +if(e==self.StopIteration){ +break; +} +throw e; +} +if(_1d9||_1db(key,_1da)!==0){ +var _1de=[]; +_1d8.push([key,_1de]); +} +_1de.push(_1dc); +_1d9=false; +_1da=key; +} +return _1d8; +},arrayLikeIter:function(_1df){ +var i=0; +return {repr:function(){ +return "arrayLikeIter(...)"; +},toString:MochiKit.Base.forwardCall("repr"),next:function(){ +if(i>=_1df.length){ +throw MochiKit.Iter.StopIteration; +} +return _1df[i++]; +}}; +},hasIterateNext:function(_1e1){ +return (_1e1&&typeof (_1e1.iterateNext)=="function"); +},iterateNextIter:function(_1e2){ +return {repr:function(){ +return "iterateNextIter(...)"; +},toString:MochiKit.Base.forwardCall("repr"),next:function(){ +var rval=_1e2.iterateNext(); +if(rval===null||rval===undefined){ +throw MochiKit.Iter.StopIteration; +} +return rval; +}}; +}}); +MochiKit.Iter.EXPORT_OK=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",]; +MochiKit.Iter.EXPORT=["StopIteration","registerIteratorFactory","iter","count","cycle","repeat","next","izip","ifilter","ifilterfalse","islice","imap","applymap","chain","takewhile","dropwhile","tee","list","reduce","range","sum","exhaust","forEach","every","sorted","reversed","some","iextend","groupby","groupby_as_array"]; +MochiKit.Iter.__new__=function(){ +var m=MochiKit.Base; +if(typeof (StopIteration)!="undefined"){ +this.StopIteration=StopIteration; +}else{ +this.StopIteration=new m.NamedError("StopIteration"); +} +this.iteratorRegistry=new m.AdapterRegistry(); +this.registerIteratorFactory("arrayLike",m.isArrayLike,this.arrayLikeIter); +this.registerIteratorFactory("iterateNext",this.hasIterateNext,this.iterateNextIter); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +m.nameFunctions(this); +}; +MochiKit.Iter.__new__(); +if(MochiKit.__export__){ +reduce=MochiKit.Iter.reduce; +} +MochiKit.Base._exportSymbols(this,MochiKit.Iter); +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.Logging"); +dojo.require("MochiKit.Base"); +} +if(typeof (JSAN)!="undefined"){ +JSAN.use("MochiKit.Base",[]); +} +try{ +if(typeof (MochiKit.Base)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Logging depends on MochiKit.Base!"; +} +if(typeof (MochiKit.Logging)=="undefined"){ +MochiKit.Logging={}; +} +MochiKit.Logging.NAME="MochiKit.Logging"; +MochiKit.Logging.VERSION="1.4"; +MochiKit.Logging.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.Logging.toString=function(){ +return this.__repr__(); +}; +MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"]; +MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"]; +MochiKit.Logging.LogMessage=function(num,_1e6,info){ +this.num=num; +this.level=_1e6; +this.info=info; +this.timestamp=new Date(); +}; +MochiKit.Logging.LogMessage.prototype={repr:function(){ +var m=MochiKit.Base; +return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")"; +},toString:MochiKit.Base.forwardCall("repr")}; +MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_1e9){ +var self=MochiKit.Logging; +if(typeof (_1e9)=="string"){ +_1e9=self.LogLevel[_1e9]; +} +return function(msg){ +var _1ec=msg.level; +if(typeof (_1ec)=="string"){ +_1ec=self.LogLevel[_1ec]; +} +return _1ec>=_1e9; +}; +},isLogMessage:function(){ +var _1ed=MochiKit.Logging.LogMessage; +for(var i=0;i=0&&this._messages.length>this.maxSize){ +this._messages.shift(); +} +},getMessages:function(_1ff){ +var _200=0; +if(!(typeof (_1ff)=="undefined"||_1ff===null)){ +_200=Math.max(0,this._messages.length-_1ff); +} +return this._messages.slice(_200); +},getMessageText:function(_201){ +if(typeof (_201)=="undefined"||_201===null){ +_201=30; +} +var _202=this.getMessages(_201); +if(_202.length){ +var lst=map(function(m){ +return "\n ["+m.num+"] "+m.level+": "+m.info.join(" "); +},_202); +lst.unshift("LAST "+_202.length+" MESSAGES:"); +return lst.join(""); +} +return ""; +},debuggingBookmarklet:function(_205){ +if(typeof (MochiKit.LoggingPane)=="undefined"){ +alert(this.getMessageText()); +}else{ +MochiKit.LoggingPane.createLoggingPane(_205||false); +} +}}; +MochiKit.Logging.__new__=function(){ +this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10}; +var m=MochiKit.Base; +m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage); +var _207=m.partial; +var _208=this.Logger; +var _209=_208.prototype.baseLog; +m.update(this.Logger.prototype,{debug:_207(_209,"DEBUG"),log:_207(_209,"INFO"),error:_207(_209,"ERROR"),fatal:_207(_209,"FATAL"),warning:_207(_209,"WARNING")}); +var self=this; +var _20b=function(name){ +return function(){ +self.logger[name].apply(self.logger,arguments); +}; +}; +this.log=_20b("log"); +this.logError=_20b("error"); +this.logDebug=_20b("debug"); +this.logFatal=_20b("fatal"); +this.logWarning=_20b("warning"); +this.logger=new _208(); +this.logger.useNativeConsole=true; +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +m.nameFunctions(this); +}; +if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){ +printfire=function(){ +printfire.args=arguments; +var ev=document.createEvent("Events"); +ev.initEvent("printfire",false,true); +dispatchEvent(ev); +}; +} +MochiKit.Logging.__new__(); +MochiKit.Base._exportSymbols(this,MochiKit.Logging); +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.DateTime"); +} +if(typeof (MochiKit)=="undefined"){ +MochiKit={}; +} +if(typeof (MochiKit.DateTime)=="undefined"){ +MochiKit.DateTime={}; +} +MochiKit.DateTime.NAME="MochiKit.DateTime"; +MochiKit.DateTime.VERSION="1.4"; +MochiKit.DateTime.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.DateTime.toString=function(){ +return this.__repr__(); +}; +MochiKit.DateTime.isoDate=function(str){ +str=str+""; +if(typeof (str)!="string"||str.length===0){ +return null; +} +var iso=str.split("-"); +if(iso.length===0){ +return null; +} +return new Date(iso[0],iso[1]-1,iso[2]); +}; +MochiKit.DateTime._isoRegexp=/(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/; +MochiKit.DateTime.isoTimestamp=function(str){ +str=str+""; +if(typeof (str)!="string"||str.length===0){ +return null; +} +var res=str.match(MochiKit.DateTime._isoRegexp); +if(typeof (res)=="undefined"||res===null){ +return null; +} +var year,_213,day,hour,min,sec,msec; +year=parseInt(res[1],10); +if(typeof (res[2])=="undefined"||res[2]===""){ +return new Date(year); +} +_213=parseInt(res[2],10)-1; +day=parseInt(res[3],10); +if(typeof (res[4])=="undefined"||res[4]===""){ +return new Date(year,_213,day); +} +hour=parseInt(res[4],10); +min=parseInt(res[5],10); +sec=(typeof (res[6])!="undefined"&&res[6]!=="")?parseInt(res[6],10):0; +if(typeof (res[7])!="undefined"&&res[7]!==""){ +msec=Math.round(1000*parseFloat("0."+res[7])); +}else{ +msec=0; +} +if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){ +return new Date(year,_213,day,hour,min,sec,msec); +} +var ofs; +if(typeof (res[9])!="undefined"&&res[9]!==""){ +ofs=parseInt(res[10],10)*3600000; +if(typeof (res[11])!="undefined"&&res[11]!==""){ +ofs+=parseInt(res[11],10)*60000; +} +if(res[9]=="-"){ +ofs=-ofs; +} +}else{ +ofs=0; +} +return new Date(Date.UTC(year,_213,day,hour,min,sec,msec)-ofs); +}; +MochiKit.DateTime.toISOTime=function(date,_21b){ +if(typeof (date)=="undefined"||date===null){ +return null; +} +var hh=date.getHours(); +var mm=date.getMinutes(); +var ss=date.getSeconds(); +var lst=[((_21b&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)]; +return lst.join(":"); +}; +MochiKit.DateTime.toISOTimestamp=function(date,_221){ +if(typeof (date)=="undefined"||date===null){ +return null; +} +var sep=_221?"T":" "; +var foot=_221?"Z":""; +if(_221){ +date=new Date(date.getTime()+(date.getTimezoneOffset()*60000)); +} +return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_221)+foot; +}; +MochiKit.DateTime.toISODate=function(date){ +if(typeof (date)=="undefined"||date===null){ +return null; +} +var _225=MochiKit.DateTime._padTwo; +return [date.getFullYear(),_225(date.getMonth()+1),_225(date.getDate())].join("-"); +}; +MochiKit.DateTime.americanDate=function(d){ +d=d+""; +if(typeof (d)!="string"||d.length===0){ +return null; +} +var a=d.split("/"); +return new Date(a[2],a[0]-1,a[1]); +}; +MochiKit.DateTime._padTwo=function(n){ +return (n>9)?n:"0"+n; +}; +MochiKit.DateTime.toPaddedAmericanDate=function(d){ +if(typeof (d)=="undefined"||d===null){ +return null; +} +var _22a=MochiKit.DateTime._padTwo; +return [_22a(d.getMonth()+1),_22a(d.getDate()),d.getFullYear()].join("/"); +}; +MochiKit.DateTime.toAmericanDate=function(d){ +if(typeof (d)=="undefined"||d===null){ +return null; +} +return [d.getMonth()+1,d.getDate(),d.getFullYear()].join("/"); +}; +MochiKit.DateTime.EXPORT=["isoDate","isoTimestamp","toISOTime","toISOTimestamp","toISODate","americanDate","toPaddedAmericanDate","toAmericanDate"]; +MochiKit.DateTime.EXPORT_OK=[]; +MochiKit.DateTime.EXPORT_TAGS={":common":MochiKit.DateTime.EXPORT,":all":MochiKit.DateTime.EXPORT}; +MochiKit.DateTime.__new__=function(){ +var base=this.NAME+"."; +for(var k in this){ +var o=this[k]; +if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ +try{ +o.NAME=base+k; +} +catch(e){ +} +} +} +}; +MochiKit.DateTime.__new__(); +if(typeof (MochiKit.Base)!="undefined"){ +MochiKit.Base._exportSymbols(this,MochiKit.DateTime); +}else{ +(function(_22f,_230){ +if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){ +var all=_230.EXPORT_TAGS[":all"]; +for(var i=0;i_23a){ +var i=_242.length-_23a; +res=fmt.separator+_242.substring(i,_242.length)+res; +_242=_242.substring(0,i); +} +} +res=_242+res; +if(_238>0){ +while(frac.length<_23b){ +frac=frac+"0"; +} +res=res+fmt.decimal+frac; +} +return _23d+res+_23e; +}; +}; +MochiKit.Format.numberFormatter=function(_246,_247,_248){ +if(typeof (_247)=="undefined"){ +_247=""; +} +var _249=_246.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/); +if(!_249){ +throw TypeError("Invalid pattern"); +} +var _24a=_246.substr(0,_249.index); +var _24b=_246.substr(_249.index+_249[0].length); +if(_24a.search(/-/)==-1){ +_24a=_24a+"-"; +} +var _24c=_249[1]; +var frac=(typeof (_249[2])=="string"&&_249[2]!="")?_249[2]:""; +var _24e=(typeof (_249[3])=="string"&&_249[3]!=""); +var tmp=_24c.split(/,/); +var _250; +if(typeof (_248)=="undefined"){ +_248="default"; +} +if(tmp.length==1){ +_250=null; +}else{ +_250=tmp[1].length; +} +var _251=_24c.length-_24c.replace(/0/g,"").length; +var _252=frac.length-frac.replace(/0/g,"").length; +var _253=frac.length; +var rval=MochiKit.Format._numberFormatter(_247,_24a,_24b,_248,_24e,_253,_251,_250,_252); +var m=MochiKit.Base; +if(m){ +var fn=arguments.callee; +var args=m.concat(arguments); +rval.repr=function(){ +return [self.NAME,"(",map(m.repr,args).join(", "),")"].join(""); +}; +} +return rval; +}; +MochiKit.Format.formatLocale=function(_258){ +if(typeof (_258)=="undefined"||_258===null){ +_258="default"; +} +if(typeof (_258)=="string"){ +var rval=MochiKit.Format.LOCALE[_258]; +if(typeof (rval)=="string"){ +rval=arguments.callee(rval); +MochiKit.Format.LOCALE[_258]=rval; +} +return rval; +}else{ +return _258; +} +}; +MochiKit.Format.twoDigitAverage=function(_25a,_25b){ +if(_25b){ +var res=_25a/_25b; +if(!isNaN(res)){ +return MochiKit.Format.twoDigitFloat(_25a/_25b); +} +} +return "0"; +}; +MochiKit.Format.twoDigitFloat=function(_25d){ +var sign=(_25d<0?"-":""); +var s=Math.floor(Math.abs(_25d)*100).toString(); +if(s=="0"){ +return s; +} +if(s.length<3){ +while(s.charAt(s.length-1)=="0"){ +s=s.substring(0,s.length-1); +} +return sign+"0."+s; +} +var head=sign+s.substring(0,s.length-2); +var tail=s.substring(s.length-2,s.length); +if(tail=="00"){ +return head; +}else{ +if(tail.charAt(1)=="0"){ +return head+"."+tail.charAt(0); +}else{ +return head+"."+tail; +} +} +}; +MochiKit.Format.lstrip=function(str,_263){ +str=str+""; +if(typeof (str)!="string"){ +return null; +} +if(!_263){ +return str.replace(/^\s+/,""); +}else{ +return str.replace(new RegExp("^["+_263+"]+"),""); +} +}; +MochiKit.Format.rstrip=function(str,_265){ +str=str+""; +if(typeof (str)!="string"){ +return null; +} +if(!_265){ +return str.replace(/\s+$/,""); +}else{ +return str.replace(new RegExp("["+_265+"]+$"),""); +} +}; +MochiKit.Format.strip=function(str,_267){ +var self=MochiKit.Format; +return self.rstrip(self.lstrip(str,_267),_267); +}; +MochiKit.Format.truncToFixed=function(_269,_26a){ +_269=Math.floor(_269*Math.pow(10,_26a)); +var res=(_269*Math.pow(10,-_26a)).toFixed(_26a); +if(res.charAt(0)=="."){ +res="0"+res; +} +return res; +}; +MochiKit.Format.roundToFixed=function(_26c,_26d){ +return MochiKit.Format.truncToFixed(_26c+0.5*Math.pow(10,-_26d),_26d); +}; +MochiKit.Format.percentFormat=function(_26e){ +return MochiKit.Format.twoDigitFloat(100*_26e)+"%"; +}; +MochiKit.Format.EXPORT=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"]; +MochiKit.Format.LOCALE={en_US:{separator:",",decimal:".",percent:"%"},de_DE:{separator:".",decimal:",",percent:"%"},fr_FR:{separator:" ",decimal:",",percent:"%"},"default":"en_US"}; +MochiKit.Format.EXPORT_OK=[]; +MochiKit.Format.EXPORT_TAGS={":all":MochiKit.Format.EXPORT,":common":MochiKit.Format.EXPORT}; +MochiKit.Format.__new__=function(){ +var base=this.NAME+"."; +var k,v,o; +for(k in this.LOCALE){ +o=this.LOCALE[k]; +if(typeof (o)=="object"){ +o.repr=function(){ +return this.NAME; +}; +o.NAME=base+"LOCALE."+k; +} +} +for(k in this){ +o=this[k]; +if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ +try{ +o.NAME=base+k; +} +catch(e){ +} +} +} +}; +MochiKit.Format.__new__(); +if(typeof (MochiKit.Base)!="undefined"){ +MochiKit.Base._exportSymbols(this,MochiKit.Format); +}else{ +(function(_273,_274){ +if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){ +var all=_274.EXPORT_TAGS[":all"]; +for(var i=0;i1){ +fn=MochiKit.Base.partial.apply(null,arguments); +} +return this.addCallbacks(fn,fn); +},addCallback:function(fn){ +if(arguments.length>1){ +fn=MochiKit.Base.partial.apply(null,arguments); +} +return this.addCallbacks(fn,null); +},addErrback:function(fn){ +if(arguments.length>1){ +fn=MochiKit.Base.partial.apply(null,arguments); +} +return this.addCallbacks(null,fn); +},addCallbacks:function(cb,eb){ +if(this.chained){ +throw new Error("Chained Deferreds can not be re-used"); +} +this.chain.push([cb,eb]); +if(this.fired>=0){ +this._fire(); +} +return this; +},_fire:function(){ +var _283=this.chain; +var _284=this.fired; +var res=this.results[_284]; +var self=this; +var cb=null; +while(_283.length>0&&this.paused===0){ +var pair=_283.shift(); +var f=pair[_284]; +if(f===null){ +continue; +} +try{ +res=f(res); +_284=((res instanceof Error)?1:0); +if(res instanceof MochiKit.Async.Deferred){ +cb=function(res){ +self._resback(res); +self.paused--; +if((self.paused===0)&&(self.fired>=0)){ +self._fire(); +} +}; +this.paused++; +} +} +catch(err){ +_284=1; +if(!(err instanceof Error)){ +err=new MochiKit.Async.GenericError(err); +} +res=err; +} +} +this.fired=_284; +this.results[_284]=res; +if(cb&&this.paused){ +res.addBoth(cb); +res.chained=true; +} +}}; +MochiKit.Base.update(MochiKit.Async,{evalJSONRequest:function(){ +return eval("("+arguments[0].responseText+")"); +},succeed:function(_28b){ +var d=new MochiKit.Async.Deferred(); +d.callback.apply(d,arguments); +return d; +},fail:function(_28d){ +var d=new MochiKit.Async.Deferred(); +d.errback.apply(d,arguments); +return d; +},getXMLHttpRequest:function(){ +var self=arguments.callee; +if(!self.XMLHttpRequest){ +var _290=[function(){ +return new XMLHttpRequest(); +},function(){ +return new ActiveXObject("Msxml2.XMLHTTP"); +},function(){ +return new ActiveXObject("Microsoft.XMLHTTP"); +},function(){ +return new ActiveXObject("Msxml2.XMLHTTP.4.0"); +},function(){ +throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest"); +}]; +for(var i=0;i<_290.length;i++){ +var func=_290[i]; +try{ +self.XMLHttpRequest=func; +return func(); +} +catch(e){ +} +} +} +return self.XMLHttpRequest(); +},_xhr_onreadystatechange:function(d){ +var m=MochiKit.Base; +if(this.readyState==4){ +try{ +this.onreadystatechange=null; +} +catch(e){ +try{ +this.onreadystatechange=m.noop; +} +catch(e){ +} +} +var _295=null; +try{ +_295=this.status; +if(!_295&&m.isNotEmpty(this.responseText)){ +_295=304; +} +} +catch(e){ +} +if(_295==200||_295==201||_295==204||_295==304||_295==1223){ +d.callback(this); +}else{ +var err=new MochiKit.Async.XMLHttpRequestError(this,"Request failed"); +if(err.number){ +d.errback(err); +}else{ +d.errback(err); +} +} +} +},_xhr_canceller:function(req){ +try{ +req.onreadystatechange=null; +} +catch(e){ +try{ +req.onreadystatechange=MochiKit.Base.noop; +} +catch(e){ +} +} +req.abort(); +},sendXMLHttpRequest:function(req,_299){ +if(typeof (_299)=="undefined"||_299===null){ +_299=""; +} +var m=MochiKit.Base; +var self=MochiKit.Async; +var d=new self.Deferred(m.partial(self._xhr_canceller,req)); +try{ +req.onreadystatechange=m.bind(self._xhr_onreadystatechange,req,d); +req.send(_299); +} +catch(e){ +try{ +req.onreadystatechange=null; +} +catch(ignore){ +} +d.errback(e); +} +return d; +},doXHR:function(url,opts){ +var self=MochiKit.Async; +return self.callLater(0,self._doXHR,url,opts); +},_doXHR:function(url,opts){ +var m=MochiKit.Base; +opts=m.update({method:"GET",sendContent:""},opts); +var self=MochiKit.Async; +var req=self.getXMLHttpRequest(); +if(opts.queryString){ +var qs=m.queryString(opts.queryString); +if(qs){ +url+="?"+qs; +} +} +if("username" in opts){ +req.open(opts.method,url,true,opts.username,opts.password); +}else{ +req.open(opts.method,url,true); +} +if(req.overrideMimeType&&opts.mimeType){ +req.overrideMimeType(opts.mimeType); +} +if(opts.headers){ +var _2a6=opts.headers; +if(!m.isArrayLike(_2a6)){ +_2a6=m.items(_2a6); +} +for(var i=0;i<_2a6.length;i++){ +var _2a8=_2a6[i]; +var name=_2a8[0]; +var _2aa=_2a8[1]; +req.setRequestHeader(name,_2aa); +} +} +return self.sendXMLHttpRequest(req,opts.sendContent); +},_buildURL:function(url){ +if(arguments.length>1){ +var m=MochiKit.Base; +var qs=m.queryString.apply(null,m.extend(null,arguments,1)); +if(qs){ +return url+"?"+qs; +} +} +return url; +},doSimpleXMLHttpRequest:function(url){ +var self=MochiKit.Async; +url=self._buildURL.apply(self,arguments); +return self.doXHR(url); +},loadJSONDoc:function(url){ +var self=MochiKit.Async; +url=self._buildURL.apply(self,arguments); +var d=self.doXHR(url,{"mimeType":"text/plain","headers":[["Accept","application/json"]]}); +d=d.addCallback(self.evalJSONRequest); +return d; +},wait:function(_2b3,_2b4){ +var d=new MochiKit.Async.Deferred(); +var m=MochiKit.Base; +if(typeof (_2b4)!="undefined"){ +d.addCallback(function(){ +return _2b4; +}); +} +var _2b7=setTimeout(m.bind("callback",d),Math.floor(_2b3*1000)); +d.canceller=function(){ +try{ +clearTimeout(_2b7); +} +catch(e){ +} +}; +return d; +},callLater:function(_2b8,func){ +var m=MochiKit.Base; +var _2bb=m.partial.apply(m,m.extend(null,arguments,1)); +return MochiKit.Async.wait(_2b8).addCallback(function(res){ +return _2bb(); +}); +}}); +MochiKit.Async.DeferredLock=function(){ +this.waiting=[]; +this.locked=false; +this.id=this._nextId(); +}; +MochiKit.Async.DeferredLock.prototype={__class__:MochiKit.Async.DeferredLock,acquire:function(){ +var d=new MochiKit.Async.Deferred(); +if(this.locked){ +this.waiting.push(d); +}else{ +this.locked=true; +d.callback(this); +} +return d; +},release:function(){ +if(!this.locked){ +throw TypeError("Tried to release an unlocked DeferredLock"); +} +this.locked=false; +if(this.waiting.length>0){ +this.locked=true; +this.waiting.shift().callback(this); +} +},_nextId:MochiKit.Base.counter(),repr:function(){ +var _2be; +if(this.locked){ +_2be="locked, "+this.waiting.length+" waiting"; +}else{ +_2be="unlocked"; +} +return "DeferredLock("+this.id+", "+_2be+")"; +},toString:MochiKit.Base.forwardCall("repr")}; +MochiKit.Async.DeferredList=function(list,_2c0,_2c1,_2c2,_2c3){ +MochiKit.Async.Deferred.apply(this,[_2c3]); +this.list=list; +var _2c4=[]; +this.resultList=_2c4; +this.finishedCount=0; +this.fireOnOneCallback=_2c0; +this.fireOnOneErrback=_2c1; +this.consumeErrors=_2c2; +var cb=MochiKit.Base.bind(this._cbDeferred,this); +for(var i=0;i=0){ +var opt=elem.options[elem.selectedIndex]; +var v=opt.value; +if(!v){ +var h=opt.outerHTML; +if(h&&!h.match(/^[^>]+\svalue\s*=/i)){ +v=opt.text; +} +} +_2e3.push(name); +_2e4.push(v); +return null; +} +_2e3.push(name); +_2e4.push(""); +return null; +}else{ +var opts=elem.options; +if(!opts.length){ +_2e3.push(name); +_2e4.push(""); +return null; +} +for(var i=0;i]+\svalue\s*=/i)){ +v=opt.text; +} +} +_2e3.push(name); +_2e4.push(v); +} +return null; +} +} +if(_2e9==="FORM"||_2e9==="P"||_2e9==="SPAN"||_2e9==="DIV"){ +return elem.childNodes; +} +_2e3.push(name); +_2e4.push(elem.value||""); +return null; +} +return elem.childNodes; +}); +return [_2e3,_2e4]; +},withDocument:function(doc,func){ +var self=MochiKit.DOM; +var _2f2=self._document; +var rval; +try{ +self._document=doc; +rval=func(); +} +catch(e){ +self._document=_2f2; +throw e; +} +self._document=_2f2; +return rval; +},registerDOMConverter:function(name,_2f5,wrap,_2f7){ +MochiKit.DOM.domConverters.register(name,_2f5,wrap,_2f7); +},coerceToDOM:function(node,ctx){ +var m=MochiKit.Base; +var im=MochiKit.Iter; +var self=MochiKit.DOM; +if(im){ +var iter=im.iter; +var _2fe=im.repeat; +var map=m.map; +} +var _300=self.domConverters; +var _301=arguments.callee; +var _302=m.NotFound; +while(true){ +if(typeof (node)=="undefined"||node===null){ +return null; +} +if(typeof (node)=="function"&&typeof (node.length)=="number"&&!(node instanceof Function)){ +node=im.list(node); +} +if(typeof (node.nodeType)!="undefined"&&node.nodeType>0){ +return node; +} +if(typeof (node)=="number"||typeof (node)=="boolean"){ +node=node.toString(); +} +if(typeof (node)=="string"){ +return self._document.createTextNode(node); +} +if(typeof (node.__dom__)=="function"){ +node=node.__dom__(ctx); +continue; +} +if(typeof (node.dom)=="function"){ +node=node.dom(ctx); +continue; +} +if(typeof (node)=="function"){ +node=node.apply(ctx,[ctx]); +continue; +} +if(im){ +var _303=null; +try{ +_303=iter(node); +} +catch(e){ +} +if(_303){ +return map(_301,_303,_2fe(ctx)); +} +} +try{ +node=_300.match(node,ctx); +continue; +} +catch(e){ +if(e!=_302){ +throw e; +} +} +return self._document.createTextNode(node.toString()); +} +return undefined; +},isChildNode:function(node,_305){ +var self=MochiKit.DOM; +if(typeof (node)=="string"){ +node=self.getElement(node); +} +if(typeof (_305)=="string"){ +_305=self.getElement(_305); +} +if(node===_305){ +return true; +} +while(node&&node.tagName.toUpperCase()!="BODY"){ +node=node.parentNode; +if(node===_305){ +return true; +} +} +return false; +},setNodeAttribute:function(node,attr,_309){ +var o={}; +o[attr]=_309; +try{ +return MochiKit.DOM.updateNodeAttributes(node,o); +} +catch(e){ +} +return null; +},getNodeAttribute:function(node,attr){ +var self=MochiKit.DOM; +var _30e=self.attributeArray.renames[attr]; +node=self.getElement(node); +try{ +if(_30e){ +return node[_30e]; +} +return node.getAttribute(attr); +} +catch(e){ +} +return null; +},removeNodeAttribute:function(node,attr){ +var self=MochiKit.DOM; +var _312=self.attributeArray.renames[attr]; +node=self.getElement(node); +try{ +if(_312){ +return node[_312]; +} +return node.removeAttribute(attr); +} +catch(e){ +} +return null; +},updateNodeAttributes:function(node,_314){ +var elem=node; +var self=MochiKit.DOM; +if(typeof (node)=="string"){ +elem=self.getElement(node); +} +if(_314){ +var _317=MochiKit.Base.updatetree; +if(self.attributeArray.compliant){ +for(var k in _314){ +var v=_314[k]; +if(typeof (v)=="object"&&typeof (elem[k])=="object"){ +if(k=="style"&&MochiKit.Style){ +MochiKit.Style.setStyle(elem,v); +}else{ +_317(elem[k],v); +} +}else{ +if(k.substring(0,2)=="on"){ +if(typeof (v)=="string"){ +v=new Function(v); +} +elem[k]=v; +}else{ +elem.setAttribute(k,v); +} +} +} +}else{ +var _31a=self.attributeArray.renames; +for(var k in _314){ +v=_314[k]; +var _31b=_31a[k]; +if(k=="style"&&typeof (v)=="string"){ +elem.style.cssText=v; +}else{ +if(typeof (_31b)=="string"){ +elem[_31b]=v; +}else{ +if(typeof (elem[k])=="object"&&typeof (v)=="object"){ +if(k=="style"&&MochiKit.Style){ +MochiKit.Style.setStyle(elem,v); +}else{ +_317(elem[k],v); +} +}else{ +if(k.substring(0,2)=="on"){ +if(typeof (v)=="string"){ +v=new Function(v); +} +elem[k]=v; +}else{ +elem.setAttribute(k,v); +} +} +} +} +} +} +} +return elem; +},appendChildNodes:function(node){ +var elem=node; +var self=MochiKit.DOM; +if(typeof (node)=="string"){ +elem=self.getElement(node); +} +var _31f=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; +var _320=MochiKit.Base.concat; +while(_31f.length){ +var n=_31f.shift(); +if(typeof (n)=="undefined"||n===null){ +}else{ +if(typeof (n.nodeType)=="number"){ +elem.appendChild(n); +}else{ +_31f=_320(n,_31f); +} +} +} +return elem; +},insertSiblingNodesBefore:function(node){ +var elem=node; +var self=MochiKit.DOM; +if(typeof (node)=="string"){ +elem=self.getElement(node); +} +var _325=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; +var _326=elem.parentNode; +var _327=MochiKit.Base.concat; +while(_325.length){ +var n=_325.shift(); +if(typeof (n)=="undefined"||n===null){ +}else{ +if(typeof (n.nodeType)=="number"){ +_326.insertBefore(n,elem); +}else{ +_325=_327(n,_325); +} +} +} +return _326; +},insertSiblingNodesAfter:function(node){ +var elem=node; +var self=MochiKit.DOM; +if(typeof (node)=="string"){ +elem=self.getElement(node); +} +var _32c=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; +if(elem.nextSibling){ +return self.insertSiblingNodesBefore(elem.nextSibling,_32c); +}else{ +return self.appendChildNodes(elem.parentNode,_32c); +} +},replaceChildNodes:function(node){ +var elem=node; +var self=MochiKit.DOM; +if(typeof (node)=="string"){ +elem=self.getElement(node); +arguments[0]=elem; +} +var _330; +while((_330=elem.firstChild)){ +elem.removeChild(_330); +} +if(arguments.length<2){ +return elem; +}else{ +return self.appendChildNodes.apply(this,arguments); +} +},createDOM:function(name,_332){ +var elem; +var self=MochiKit.DOM; +var m=MochiKit.Base; +if(typeof (_332)=="string"||typeof (_332)=="number"){ +var args=m.extend([name,null],arguments,1); +return arguments.callee.apply(this,args); +} +if(typeof (name)=="string"){ +var _337=self._xhtml; +if(_332&&!self.attributeArray.compliant){ +var _338=""; +if("name" in _332){ +_338+=" name=\""+self.escapeHTML(_332.name)+"\""; +} +if(name=="input"&&"type" in _332){ +_338+=" type=\""+self.escapeHTML(_332.type)+"\""; +} +if(_338){ +name="<"+name+_338+">"; +_337=false; +} +} +var d=self._document; +if(_337&&d===document){ +elem=d.createElementNS("http://www.w3.org/1999/xhtml",name); +}else{ +elem=d.createElement(name); +} +}else{ +elem=name; +} +if(_332){ +self.updateNodeAttributes(elem,_332); +} +if(arguments.length<=2){ +return elem; +}else{ +var args=m.extend([elem],arguments,2); +return self.appendChildNodes.apply(this,args); +} +},createDOMFunc:function(){ +var m=MochiKit.Base; +return m.partial.apply(this,m.extend([MochiKit.DOM.createDOM],arguments)); +},removeElement:function(elem){ +var e=MochiKit.DOM.getElement(elem); +e.parentNode.removeChild(e); +return e; +},swapDOM:function(dest,src){ +var self=MochiKit.DOM; +dest=self.getElement(dest); +var _340=dest.parentNode; +if(src){ +src=self.getElement(src); +_340.replaceChild(src,dest); +}else{ +_340.removeChild(dest); +} +return src; +},getElement:function(id){ +var self=MochiKit.DOM; +if(arguments.length==1){ +return ((typeof (id)=="string")?self._document.getElementById(id):id); +}else{ +return MochiKit.Base.map(self.getElement,arguments); +} +},getElementsByTagAndClassName:function(_343,_344,_345){ +var self=MochiKit.DOM; +if(typeof (_343)=="undefined"||_343===null){ +_343="*"; +} +if(typeof (_345)=="undefined"||_345===null){ +_345=self._document; +} +_345=self.getElement(_345); +var _347=(_345.getElementsByTagName(_343)||self._document.all); +if(typeof (_344)=="undefined"||_344===null){ +return MochiKit.Base.extend(null,_347); +} +var _348=[]; +for(var i=0;i<_347.length;i++){ +var _34a=_347[i]; +var cls=_34a.className; +if(!cls){ +continue; +} +var _34c=cls.split(" "); +for(var j=0;j<_34c.length;j++){ +if(_34c[j]==_344){ +_348.push(_34a); +break; +} +} +} +return _348; +},_newCallStack:function(path,once){ +var rval=function(){ +var _351=arguments.callee.callStack; +for(var i=0;i<_351.length;i++){ +if(_351[i].apply(this,arguments)===false){ +break; +} +} +if(once){ +try{ +this[path]=null; +} +catch(e){ +} +} +}; +rval.callStack=[]; +return rval; +},addToCallStack:function(_353,path,func,once){ +var self=MochiKit.DOM; +var _358=_353[path]; +var _359=_358; +if(!(typeof (_358)=="function"&&typeof (_358.callStack)=="object"&&_358.callStack!==null)){ +_359=self._newCallStack(path,once); +if(typeof (_358)=="function"){ +_359.callStack.push(_358); +} +_353[path]=_359; +} +_359.callStack.push(func); +},addLoadEvent:function(func){ +var self=MochiKit.DOM; +self.addToCallStack(self._window,"onload",func,true); +},focusOnLoad:function(_35c){ +var self=MochiKit.DOM; +self.addLoadEvent(function(){ +_35c=self.getElement(_35c); +if(_35c){ +_35c.focus(); +} +}); +},setElementClass:function(_35e,_35f){ +var self=MochiKit.DOM; +var obj=self.getElement(_35e); +if(self.attributeArray.compliant){ +obj.setAttribute("class",_35f); +}else{ +obj.setAttribute("className",_35f); +} +},toggleElementClass:function(_362){ +var self=MochiKit.DOM; +for(var i=1;i/g,">"); +},toHTML:function(dom){ +return MochiKit.DOM.emitHTML(dom).join(""); +},emitHTML:function(dom,lst){ +if(typeof (lst)=="undefined"||lst===null){ +lst=[]; +} +var _385=[dom]; +var self=MochiKit.DOM; +var _387=self.escapeHTML; +var _388=self.attributeArray; +while(_385.length){ +dom=_385.pop(); +if(typeof (dom)=="string"){ +lst.push(dom); +}else{ +if(dom.nodeType==1){ +lst.push("<"+dom.tagName.toLowerCase()); +var _389=[]; +var _38a=_388(dom); +for(var i=0;i<_38a.length;i++){ +var a=_38a[i]; +_389.push([" ",a.name,"=\"",_387(a.value),"\""]); +} +_389.sort(); +for(i=0;i<_389.length;i++){ +var _38d=_389[i]; +for(var j=0;j<_38d.length;j++){ +lst.push(_38d[j]); +} +} +if(dom.hasChildNodes()){ +lst.push(">"); +_385.push(""); +var _38f=dom.childNodes; +for(i=_38f.length-1;i>=0;i--){ +_385.push(_38f[i]); +} +}else{ +lst.push("/>"); +} +}else{ +if(dom.nodeType==3){ +lst.push(_387(dom.nodeValue)); +} +} +} +} +return lst; +},scrapeText:function(node,_391){ +var rval=[]; +(function(node){ +var cn=node.childNodes; +if(cn){ +for(var i=0;i0){ +var _3b8=m.filter; +_3b7=function(node){ +return _3b8(_3b7.ignoreAttrFilter,node.attributes); +}; +_3b7.ignoreAttr={}; +var _3ba=_3b6.attributes; +var _3bb=_3b7.ignoreAttr; +for(var i=0;i<_3ba.length;i++){ +var a=_3ba[i]; +_3bb[a.name]=a.value; +} +_3b7.ignoreAttrFilter=function(a){ +return (_3b7.ignoreAttr[a.name]!=a.value); +}; +_3b7.compliant=false; +_3b7.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"}; +}else{ +_3b7=function(node){ +return node.attributes; +}; +_3b7.compliant=true; +_3b7.renames={}; +} +this.attributeArray=_3b7; +var _3c0=function(_3c1,arr){ +var _3c3=arr[1].split("."); +var str=""; +var obj={}; +str+="if (!MochiKit."+_3c3[1]+") { throw new Error(\""; +str+="This function has been deprecated and depends on MochiKit."; +str+=_3c3[1]+".\");}"; +str+="return MochiKit."+_3c3[1]+"."+arr[0]; +str+=".apply(this, arguments);"; +obj[_3c3[2]]=new Function(str); +MochiKit.Base.update(MochiKit[_3c1],obj); +}; +for(var i;i0){ +abort(repr(expr)); +} +},buildMatchExpression:function(){ +var repr=MochiKit.Base.repr; +var _3d1=this.params; +var _3d2=[]; +var _3d3,i; +function childElements(_3d5){ +return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, "+_3d5+".childNodes)"; +} +if(_3d1.wildcard){ +_3d2.push("true"); +} +if(_3d3=_3d1.id){ +_3d2.push("element.id == "+repr(_3d3)); +} +if(_3d3=_3d1.tagName){ +_3d2.push("element.tagName.toUpperCase() == "+repr(_3d3)); +} +if((_3d3=_3d1.classNames).length>0){ +for(i=0;i<_3d3.length;i++){ +_3d2.push("MochiKit.DOM.hasElementClass(element, "+repr(_3d3[i])+")"); +} +} +if((_3d3=_3d1.pseudoClassNames).length>0){ +for(i=0;i<_3d3.length;i++){ +var _3d6=_3d3[i].match(/^([^(]+)(?:\((.*)\))?$/); +var _3d7=_3d6[1]; +var _3d8=_3d6[2]; +switch(_3d7){ +case "root": +_3d2.push("element.nodeType == 9 || element === element.ownerDocument.documentElement"); +break; +case "nth-child": +case "nth-last-child": +case "nth-of-type": +case "nth-last-of-type": +_3d6=_3d8.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/); +if(!_3d6){ +throw "Invalid argument to pseudo element nth-child: "+_3d8; +} +var a,b; +if(_3d6[0]=="odd"){ +a=2; +b=1; +}else{ +if(_3d6[0]=="even"){ +a=2; +b=0; +}else{ +a=_3d6[2]&&parseInt(_3d6)||null; +b=parseInt(_3d6[3]); +} +} +_3d2.push("this.nthChild(element,"+a+","+b+","+!!_3d7.match("^nth-last")+","+!!_3d7.match("of-type$")+")"); +break; +case "first-child": +_3d2.push("this.nthChild(element, null, 1)"); +break; +case "last-child": +_3d2.push("this.nthChild(element, null, 1, true)"); +break; +case "first-of-type": +_3d2.push("this.nthChild(element, null, 1, false, true)"); +break; +case "last-of-type": +_3d2.push("this.nthChild(element, null, 1, true, true)"); +break; +case "only-child": +_3d2.push(childElements("element.parentNode")+".length == 1"); +break; +case "only-of-type": +_3d2.push("MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, "+childElements("element.parentNode")+").length == 1"); +break; +case "empty": +_3d2.push("element.childNodes.length == 0"); +break; +case "enabled": +_3d2.push("(this.isUIElement(element) && element.disabled === false)"); +break; +case "disabled": +_3d2.push("(this.isUIElement(element) && element.disabled === true)"); +break; +case "checked": +_3d2.push("(this.isUIElement(element) && element.checked === true)"); +break; +case "not": +var _3db=new MochiKit.Selector.Selector(_3d8); +_3d2.push("!( "+_3db.buildMatchExpression()+")"); +break; +} +} +} +if(_3d3=_3d1.attributes){ +MochiKit.Base.map(function(_3dc){ +var _3dd="MochiKit.DOM.getNodeAttribute(element, "+repr(_3dc.name)+")"; +var _3de=function(_3df){ +return _3dd+".split("+repr(_3df)+")"; +}; +switch(_3dc.operator){ +case "=": +_3d2.push(_3dd+" == "+repr(_3dc.value)); +break; +case "~=": +_3d2.push(_3dd+" && MochiKit.Base.findValue("+_3de(" ")+", "+repr(_3dc.value)+") > -1"); +break; +case "^=": +_3d2.push(_3dd+".substring(0, "+_3dc.value.length+") == "+repr(_3dc.value)); +break; +case "$=": +_3d2.push(_3dd+".substring("+_3dd+".length - "+_3dc.value.length+") == "+repr(_3dc.value)); +break; +case "*=": +_3d2.push(_3dd+".match("+repr(_3dc.value)+")"); +break; +case "|=": +_3d2.push(_3dd+" && "+_3de("-")+"[0].toUpperCase() == "+repr(_3dc.value.toUpperCase())); +break; +case "!=": +_3d2.push(_3dd+" != "+repr(_3dc.value)); +break; +case "": +case undefined: +_3d2.push(_3dd+" != null"); +break; +default: +throw "Unknown operator "+_3dc.operator+" in selector"; +} +},_3d3); +} +return _3d2.join(" && "); +},compileMatcher:function(){ +this.match=new Function("element","if (!element.tagName) return false; return "+this.buildMatchExpression()); +},nthChild:function(_3e0,a,b,_3e3,_3e4){ +var _3e5=MochiKit.Base.filter(function(node){ +return node.nodeType==1; +},_3e0.parentNode.childNodes); +if(_3e4){ +_3e5=MochiKit.Base.filter(function(node){ +return node.tagName==_3e0.tagName; +},_3e5); +} +if(_3e3){ +_3e5=MochiKit.Iter.reversed(_3e5); +} +if(a){ +var _3e8=MochiKit.Base.findIdentical(_3e5,_3e0); +return ((_3e8+1-b)/a)%1==0; +}else{ +return b==MochiKit.Base.findIdentical(_3e5,_3e0)+1; +} +},isUIElement:function(_3e9){ +return MochiKit.Base.findValue(["input","button","select","option","textarea","object"],_3e9.tagName.toLowerCase())>-1; +},findElements:function(_3ea,axis){ +var _3ec; +if(axis==undefined){ +axis=""; +} +function inScope(_3ed,_3ee){ +if(axis==""){ +return MochiKit.DOM.isChildNode(_3ed,_3ee); +}else{ +if(axis==">"){ +return _3ed.parentNode==_3ee; +}else{ +if(axis=="+"){ +return _3ed==nextSiblingElement(_3ee); +}else{ +if(axis=="~"){ +var _3ef=_3ee; +while(_3ef=nextSiblingElement(_3ef)){ +if(_3ed==_3ef){ +return true; +} +} +return false; +}else{ +throw "Invalid axis: "+axis; +} +} +} +} +} +if(_3ec=MochiKit.DOM.getElement(this.params.id)){ +if(this.match(_3ec)){ +if(!_3ea||inScope(_3ec,_3ea)){ +return [_3ec]; +} +} +} +function nextSiblingElement(node){ +node=node.nextSibling; +while(node&&node.nodeType!=1){ +node=node.nextSibling; +} +return node; +} +if(axis==""){ +_3ea=(_3ea||MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName||"*"); +}else{ +if(axis==">"){ +if(!_3ea){ +throw "> combinator not allowed without preceeding expression"; +} +_3ea=MochiKit.Base.filter(function(node){ +return node.nodeType==1; +},_3ea.childNodes); +}else{ +if(axis=="+"){ +if(!_3ea){ +throw "+ combinator not allowed without preceeding expression"; +} +_3ea=nextSiblingElement(_3ea)&&[nextSiblingElement(_3ea)]; +}else{ +if(axis=="~"){ +if(!_3ea){ +throw "~ combinator not allowed without preceeding expression"; +} +var _3f2=[]; +while(nextSiblingElement(_3ea)){ +_3ea=nextSiblingElement(_3ea); +_3f2.push(_3ea); +} +_3ea=_3f2; +} +} +} +} +if(!_3ea){ +return []; +} +var _3f3=MochiKit.Base.filter(MochiKit.Base.bind(function(_3f4){ +return this.match(_3f4); +},this),_3ea); +return _3f3; +},repr:function(){ +return "Selector("+this.expression+")"; +},toString:MochiKit.Base.forwardCall("repr")}; +MochiKit.Base.update(MochiKit.Selector,{findChildElements:function(_3f5,_3f6){ +return MochiKit.Base.flattenArray(MochiKit.Base.map(function(_3f7){ +var _3f8=""; +return MochiKit.Iter.reduce(function(_3f9,expr){ +if(match=expr.match(/^[>+~]$/)){ +_3f8=match[0]; +return _3f9; +}else{ +var _3fb=new MochiKit.Selector.Selector(expr); +var _3fc=MochiKit.Iter.reduce(function(_3fd,_3fe){ +return MochiKit.Base.extend(_3fd,_3fb.findElements(_3fe||_3f5,_3f8)); +},_3f9,[]); +_3f8=""; +return _3fc; +} +},_3f7.replace(/(^\s+|\s+$)/g,"").split(/\s+/),[null]); +},_3f6)); +},findDocElements:function(){ +return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(),arguments); +},__new__:function(){ +var m=MochiKit.Base; +this.$$=this.findDocElements; +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +m.nameFunctions(this); +}}); +MochiKit.Selector.__new__(); +MochiKit.Base._exportSymbols(this,MochiKit.Selector); +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.Style"); +dojo.require("MochiKit.Base"); +dojo.require("MochiKit.DOM"); +} +if(typeof (JSAN)!="undefined"){ +JSAN.use("MochiKit.Base",[]); +JSAN.use("MochiKit.DOM",[]); +} +try{ +if(typeof (MochiKit.Base)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Style depends on MochiKit.Base!"; +} +try{ +if(typeof (MochiKit.DOM)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Style depends on MochiKit.DOM!"; +} +if(typeof (MochiKit.Style)=="undefined"){ +MochiKit.Style={}; +} +MochiKit.Style.NAME="MochiKit.Style"; +MochiKit.Style.VERSION="1.4"; +MochiKit.Style.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.Style.toString=function(){ +return this.__repr__(); +}; +MochiKit.Style.EXPORT_OK=[]; +MochiKit.Style.EXPORT=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"]; +MochiKit.Style.Dimensions=function(w,h){ +this.w=w; +this.h=h; +}; +MochiKit.Style.Dimensions.prototype.__repr__=function(){ +var repr=MochiKit.Base.repr; +return "{w: "+repr(this.w)+", h: "+repr(this.h)+"}"; +}; +MochiKit.Style.Dimensions.prototype.toString=function(){ +return this.__repr__(); +}; +MochiKit.Style.Coordinates=function(x,y){ +this.x=x; +this.y=y; +}; +MochiKit.Style.Coordinates.prototype.__repr__=function(){ +var repr=MochiKit.Base.repr; +return "{x: "+repr(this.x)+", y: "+repr(this.y)+"}"; +}; +MochiKit.Style.Coordinates.prototype.toString=function(){ +return this.__repr__(); +}; +MochiKit.Base.update(MochiKit.Style,{getStyle:function(elem,_407){ +var dom=MochiKit.DOM; +var d=dom._document; +elem=dom.getElement(elem); +_407=MochiKit.Base.camelize(_407); +if(!elem||elem==d){ +return undefined; +} +if(_407=="opacity"&&elem.filters){ +var _40a=(MochiKit.Style.getStyle(elem,"filter")||"").match(/alpha\(opacity=(.*)\)/); +if(_40a&&_40a[1]){ +return parseFloat(_40a[1])/100; +} +return 1; +} +var _40b=elem.style?elem.style[_407]:null; +if(!_40b){ +if(d.defaultView&&d.defaultView.getComputedStyle){ +var css=d.defaultView.getComputedStyle(elem,null); +_407=_407.replace(/([A-Z])/g,"-$1").toLowerCase(); +_40b=css?css.getPropertyValue(_407):null; +}else{ +if(elem.currentStyle){ +_40b=elem.currentStyle[_407]; +} +} +} +if(_407=="opacity"){ +_40b=parseFloat(_40b); +} +if(/Opera/.test(navigator.userAgent)&&(MochiKit.Base.find(["left","top","right","bottom"],_407)!=-1)){ +if(MochiKit.Style.getStyle(elem,"position")=="static"){ +_40b="auto"; +} +} +return _40b=="auto"?null:_40b; +},setStyle:function(elem,_40e){ +elem=MochiKit.DOM.getElement(elem); +for(var name in _40e){ +if(name=="opacity"){ +MochiKit.Style.setOpacity(elem,_40e[name]); +}else{ +elem.style[MochiKit.Base.camelize(name)]=_40e[name]; +} +} +},setOpacity:function(elem,o){ +elem=MochiKit.DOM.getElement(elem); +var self=MochiKit.Style; +if(o==1){ +var _413=/Gecko/.test(navigator.userAgent)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent)); +elem.style["opacity"]=_413?0.999999:1; +if(/MSIE/.test(navigator.userAgent)){ +elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,""); +} +}else{ +if(o<0.00001){ +o=0; +} +elem.style["opacity"]=o; +if(/MSIE/.test(navigator.userAgent)){ +elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o*100+")"; +} +} +},getElementPosition:function(elem,_415){ +var self=MochiKit.Style; +var dom=MochiKit.DOM; +elem=dom.getElement(elem); +if(!elem||(!(elem.x&&elem.y)&&(!elem.parentNode===null||self.getStyle(elem,"display")=="none"))){ +return undefined; +} +var c=new self.Coordinates(0,0); +var box=null; +var _41a=null; +var d=MochiKit.DOM._document; +var de=d.documentElement; +var b=d.body; +if(!elem.parentNode&&elem.x&&elem.y){ +c.x+=elem.x||0; +c.y+=elem.y||0; +}else{ +if(elem.getBoundingClientRect){ +box=elem.getBoundingClientRect(); +c.x+=box.left+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0); +c.y+=box.top+(de.scrollTop||b.scrollTop)-(de.clientTop||0); +}else{ +if(elem.offsetParent){ +c.x+=elem.offsetLeft; +c.y+=elem.offsetTop; +_41a=elem.offsetParent; +if(_41a!=elem){ +while(_41a){ +c.x+=_41a.offsetLeft; +c.y+=_41a.offsetTop; +_41a=_41a.offsetParent; +} +} +var ua=navigator.userAgent.toLowerCase(); +if((typeof (opera)!="undefined"&&parseFloat(opera.version())<9)||(ua.indexOf("AppleWebKit")!=-1&&self.getStyle(elem,"position")=="absolute")){ +c.x-=b.offsetLeft; +c.y-=b.offsetTop; +} +} +} +} +if(typeof (_415)!="undefined"){ +_415=arguments.callee(_415); +if(_415){ +c.x-=(_415.x||0); +c.y-=(_415.y||0); +} +} +if(elem.parentNode){ +_41a=elem.parentNode; +}else{ +_41a=null; +} +while(_41a){ +var _41f=_41a.tagName.toUpperCase(); +if(_41f==="BODY"||_41f==="HTML"){ +break; +} +var disp=self.getStyle(_41a,"display"); +if(disp!="inline"&&disp!="table-row"){ +c.x-=_41a.scrollLeft; +c.y-=_41a.scrollTop; +} +if(_41a.parentNode){ +_41a=_41a.parentNode; +}else{ +_41a=null; +} +} +return c; +},setElementPosition:function(elem,_422,_423){ +elem=MochiKit.DOM.getElement(elem); +if(typeof (_423)=="undefined"){ +_423="px"; +} +var _424={}; +var _425=MochiKit.Base.isUndefinedOrNull; +if(!_425(_422.x)){ +_424["left"]=_422.x+_423; +} +if(!_425(_422.y)){ +_424["top"]=_422.y+_423; +} +MochiKit.DOM.updateNodeAttributes(elem,{"style":_424}); +},getElementDimensions:function(elem){ +var self=MochiKit.Style; +var dom=MochiKit.DOM; +if(typeof (elem.w)=="number"||typeof (elem.h)=="number"){ +return new self.Dimensions(elem.w||0,elem.h||0); +} +elem=dom.getElement(elem); +if(!elem){ +return undefined; +} +var disp=self.getStyle(elem,"display"); +if(disp!="none"&&disp!==""&&typeof (disp)!="undefined"){ +return new self.Dimensions(elem.offsetWidth||0,elem.offsetHeight||0); +} +var s=elem.style; +var _42b=s.visibility; +var _42c=s.position; +s.visibility="hidden"; +s.position="absolute"; +s.display=""; +var _42d=elem.offsetWidth; +var _42e=elem.offsetHeight; +s.display="none"; +s.position=_42c; +s.visibility=_42b; +return new self.Dimensions(_42d,_42e); +},setElementDimensions:function(elem,_430,_431){ +elem=MochiKit.DOM.getElement(elem); +if(typeof (_431)=="undefined"){ +_431="px"; +} +var _432={}; +var _433=MochiKit.Base.isUndefinedOrNull; +if(!_433(_430.w)){ +_432["width"]=_430.w+_431; +} +if(!_433(_430.h)){ +_432["height"]=_430.h+_431; +} +MochiKit.DOM.updateNodeAttributes(elem,{"style":_432}); +},setDisplayForElement:function(_434,_435){ +var _436=MochiKit.Base.extend(null,arguments,1); +var _437=MochiKit.DOM.getElement; +for(var i=0;i<_436.length;i++){ +_435=_437(_436[i]); +if(_435){ +_435.style.display=_434; +} +} +},getViewportDimensions:function(){ +var d=new MochiKit.Style.Dimensions(); +var w=MochiKit.DOM._window; +var b=MochiKit.DOM._document.body; +if(w.innerWidth){ +d.w=w.innerWidth; +d.h=w.innerHeight; +}else{ +if(b.parentElement.clientWidth){ +d.w=b.parentElement.clientWidth; +d.h=b.parentElement.clientHeight; +}else{ +if(b&&b.clientWidth){ +d.w=b.clientWidth; +d.h=b.clientHeight; +} +} +} +return d; +},getViewportPosition:function(){ +var c=new MochiKit.Style.Coordinates(0,0); +var d=MochiKit.DOM._document; +var de=d.documentElement; +var db=d.body; +if(de&&(de.scrollTop||de.scrollLeft)){ +c.x=de.scrollLeft; +c.y=de.scrollTop; +}else{ +if(db){ +c.x=db.scrollLeft; +c.y=db.scrollTop; +} +} +return c; +},__new__:function(){ +var m=MochiKit.Base; +this.elementPosition=this.getElementPosition; +this.elementDimensions=this.getElementDimensions; +this.hideElement=m.partial(this.setDisplayForElement,"none"); +this.showElement=m.partial(this.setDisplayForElement,"block"); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +m.nameFunctions(this); +}}); +MochiKit.Style.__new__(); +MochiKit.Base._exportSymbols(this,MochiKit.Style); +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.LoggingPane"); +dojo.require("MochiKit.Logging"); +dojo.require("MochiKit.Base"); +} +if(typeof (JSAN)!="undefined"){ +JSAN.use("MochiKit.Logging",[]); +JSAN.use("MochiKit.Base",[]); +} +try{ +if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.Logging)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!"; +} +if(typeof (MochiKit.LoggingPane)=="undefined"){ +MochiKit.LoggingPane={}; +} +MochiKit.LoggingPane.NAME="MochiKit.LoggingPane"; +MochiKit.LoggingPane.VERSION="1.4"; +MochiKit.LoggingPane.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.LoggingPane.toString=function(){ +return this.__repr__(); +}; +MochiKit.LoggingPane.createLoggingPane=function(_441){ +var m=MochiKit.LoggingPane; +_441=!(!_441); +if(m._loggingPane&&m._loggingPane.inline!=_441){ +m._loggingPane.closePane(); +m._loggingPane=null; +} +if(!m._loggingPane||m._loggingPane.closed){ +m._loggingPane=new m.LoggingPane(_441,MochiKit.Logging.logger); +} +return m._loggingPane; +}; +MochiKit.LoggingPane.LoggingPane=function(_443,_444){ +if(typeof (_444)=="undefined"||_444===null){ +_444=MochiKit.Logging.logger; +} +this.logger=_444; +var _445=MochiKit.Base.update; +var _446=MochiKit.Base.updatetree; +var bind=MochiKit.Base.bind; +var _448=MochiKit.Base.clone; +var win=window; +var uid="_MochiKit_LoggingPane"; +if(typeof (MochiKit.DOM)!="undefined"){ +win=MochiKit.DOM.currentWindow(); +} +if(!_443){ +var url=win.location.href.split("?")[0].replace(/[#:\/.><&-]/g,"_"); +var name=uid+"_"+url; +var nwin=win.open("",name,"dependent,resizable,height=200"); +if(!nwin){ +alert("Not able to open debugging window due to pop-up blocking."); +return undefined; +} +nwin.document.write(""+"[MochiKit.LoggingPane]"+""); +nwin.document.close(); +nwin.document.title+=" "+win.document.title; +win=nwin; +} +var doc=win.document; +this.doc=doc; +var _44f=doc.getElementById(uid); +var _450=!!_44f; +if(_44f&&typeof (_44f.loggingPane)!="undefined"){ +_44f.loggingPane.logger=this.logger; +_44f.loggingPane.buildAndApplyFilter(); +return _44f.loggingPane; +} +if(_450){ +var _451; +while((_451=_44f.firstChild)){ +_44f.removeChild(_451); +} +}else{ +_44f=doc.createElement("div"); +_44f.id=uid; +} +_44f.loggingPane=this; +var _452=doc.createElement("input"); +var _453=doc.createElement("input"); +var _454=doc.createElement("button"); +var _455=doc.createElement("button"); +var _456=doc.createElement("button"); +var _457=doc.createElement("button"); +var _458=doc.createElement("div"); +var _459=doc.createElement("div"); +var _45a=uid+"_Listener"; +this.colorTable=_448(this.colorTable); +var _45b=[]; +var _45c=null; +var _45d=function(msg){ +var _45f=msg.level; +if(typeof (_45f)=="number"){ +_45f=MochiKit.Logging.LogLevel[_45f]; +} +return _45f; +}; +var _460=function(msg){ +return msg.info.join(" "); +}; +var _462=bind(function(msg){ +var _464=_45d(msg); +var text=_460(msg); +var c=this.colorTable[_464]; +var p=doc.createElement("span"); +p.className="MochiKit-LogMessage MochiKit-LogLevel-"+_464; +p.style.cssText="margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: "+c; +p.appendChild(doc.createTextNode(_464+": "+text)); +_459.appendChild(p); +_459.appendChild(doc.createElement("br")); +if(_458.offsetHeight>_458.scrollHeight){ +_458.scrollTop=0; +}else{ +_458.scrollTop=_458.scrollHeight; +} +},this); +var _468=function(msg){ +_45b[_45b.length]=msg; +_462(msg); +}; +var _46a=function(){ +var _46b,_46c; +try{ +_46b=new RegExp(_452.value); +_46c=new RegExp(_453.value); +} +catch(e){ +logDebug("Error in filter regex: "+e.message); +return null; +} +return function(msg){ +return (_46b.test(_45d(msg))&&_46c.test(_460(msg))); +}; +}; +var _46e=function(){ +while(_459.firstChild){ +_459.removeChild(_459.firstChild); +} +}; +var _46f=function(){ +_45b=[]; +_46e(); +}; +var _470=bind(function(){ +if(this.closed){ +return; +} +this.closed=true; +if(MochiKit.LoggingPane._loggingPane==this){ +MochiKit.LoggingPane._loggingPane=null; +} +this.logger.removeListener(_45a); +try{ +try{ +_44f.loggingPane=null; +} +catch(e){ +logFatal("Bookmarklet was closed incorrectly."); +} +if(_443){ +_44f.parentNode.removeChild(_44f); +}else{ +this.win.close(); +} +} +catch(e){ +} +},this); +var _471=function(){ +_46e(); +for(var i=0;i<_45b.length;i++){ +var msg=_45b[i]; +if(_45c===null||_45c(msg)){ +_462(msg); +} +} +}; +this.buildAndApplyFilter=function(){ +_45c=_46a(); +_471(); +this.logger.removeListener(_45a); +this.logger.addListener(_45a,_45c,_468); +}; +var _474=bind(function(){ +_45b=this.logger.getMessages(); +_471(); +},this); +var _475=bind(function(_476){ +_476=_476||window.event; +key=_476.which||_476.keyCode; +if(key==13){ +this.buildAndApplyFilter(); +} +},this); +var _477="display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: "+this.logFont; +if(_443){ +_477+="; height: 10em; border-top: 2px solid black"; +}else{ +_477+="; height: 100%;"; +} +_44f.style.cssText=_477; +if(!_450){ +doc.body.appendChild(_44f); +} +_477={"cssText":"width: 33%; display: inline; font: "+this.logFont}; +_446(_452,{"value":"FATAL|ERROR|WARNING|INFO|DEBUG","onkeypress":_475,"style":_477}); +_44f.appendChild(_452); +_446(_453,{"value":".*","onkeypress":_475,"style":_477}); +_44f.appendChild(_453); +_477="width: 8%; display:inline; font: "+this.logFont; +_454.appendChild(doc.createTextNode("Filter")); +_454.onclick=bind("buildAndApplyFilter",this); +_454.style.cssText=_477; +_44f.appendChild(_454); +_455.appendChild(doc.createTextNode("Load")); +_455.onclick=_474; +_455.style.cssText=_477; +_44f.appendChild(_455); +_456.appendChild(doc.createTextNode("Clear")); +_456.onclick=_46f; +_456.style.cssText=_477; +_44f.appendChild(_456); +_457.appendChild(doc.createTextNode("Close")); +_457.onclick=_470; +_457.style.cssText=_477; +_44f.appendChild(_457); +_458.style.cssText="overflow: auto; width: 100%"; +_459.style.cssText="width: 100%; height: "+(_443?"8em":"100%"); +_458.appendChild(_459); +_44f.appendChild(_458); +this.buildAndApplyFilter(); +_474(); +if(_443){ +this.win=undefined; +}else{ +this.win=win; +} +this.inline=_443; +this.closePane=_470; +this.closed=false; +return this; +}; +MochiKit.LoggingPane.LoggingPane.prototype={"logFont":"8pt Verdana,sans-serif","colorTable":{"ERROR":"red","FATAL":"darkred","WARNING":"blue","INFO":"black","DEBUG":"green"}}; +MochiKit.LoggingPane.EXPORT_OK=["LoggingPane"]; +MochiKit.LoggingPane.EXPORT=["createLoggingPane"]; +MochiKit.LoggingPane.__new__=function(){ +this.EXPORT_TAGS={":common":this.EXPORT,":all":MochiKit.Base.concat(this.EXPORT,this.EXPORT_OK)}; +MochiKit.Base.nameFunctions(this); +MochiKit.LoggingPane._loggingPane=null; +}; +MochiKit.LoggingPane.__new__(); +MochiKit.Base._exportSymbols(this,MochiKit.LoggingPane); +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.Color"); +dojo.require("MochiKit.Base"); +dojo.require("MochiKit.DOM"); +dojo.require("MochiKit.Style"); +} +if(typeof (JSAN)!="undefined"){ +JSAN.use("MochiKit.Base",[]); +JSAN.use("MochiKit.DOM",[]); +JSAN.use("MochiKit.Style",[]); +} +try{ +if(typeof (MochiKit.Base)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Color depends on MochiKit.Base"; +} +try{ +if(typeof (MochiKit.DOM)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Color depends on MochiKit.DOM"; +} +try{ +if(typeof (MochiKit.Style)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Color depends on MochiKit.Style"; +} +if(typeof (MochiKit.Color)=="undefined"){ +MochiKit.Color={}; +} +MochiKit.Color.NAME="MochiKit.Color"; +MochiKit.Color.VERSION="1.4"; +MochiKit.Color.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.Color.toString=function(){ +return this.__repr__(); +}; +MochiKit.Color.Color=function(red,_479,blue,_47b){ +if(typeof (_47b)=="undefined"||_47b===null){ +_47b=1; +} +this.rgb={r:red,g:_479,b:blue,a:_47b}; +}; +MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_47c){ +var rgb=this.rgb; +var m=MochiKit.Color; +return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_47c); +},colorWithHue:function(hue){ +var hsl=this.asHSL(); +hsl.h=hue; +var m=MochiKit.Color; +return m.Color.fromHSL(hsl); +},colorWithSaturation:function(_482){ +var hsl=this.asHSL(); +hsl.s=_482; +var m=MochiKit.Color; +return m.Color.fromHSL(hsl); +},colorWithLightness:function(_485){ +var hsl=this.asHSL(); +hsl.l=_485; +var m=MochiKit.Color; +return m.Color.fromHSL(hsl); +},darkerColorWithLevel:function(_488){ +var hsl=this.asHSL(); +hsl.l=Math.max(hsl.l-_488,0); +var m=MochiKit.Color; +return m.Color.fromHSL(hsl); +},lighterColorWithLevel:function(_48b){ +var hsl=this.asHSL(); +hsl.l=Math.min(hsl.l+_48b,1); +var m=MochiKit.Color; +return m.Color.fromHSL(hsl); +},blendedColor:function(_48e,_48f){ +if(typeof (_48f)=="undefined"||_48f===null){ +_48f=0.5; +} +var sf=1-_48f; +var s=this.rgb; +var d=_48e.rgb; +var df=_48f; +return MochiKit.Color.Color.fromRGB((s.r*sf)+(d.r*df),(s.g*sf)+(d.g*df),(s.b*sf)+(d.b*df),(s.a*sf)+(d.a*df)); +},compareRGB:function(_494){ +var a=this.asRGB(); +var b=_494.asRGB(); +return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]); +},isLight:function(){ +return this.asHSL().b>0.5; +},isDark:function(){ +return (!this.isLight()); +},toHSLString:function(){ +var c=this.asHSL(); +var ccc=MochiKit.Color.clampColorComponent; +var rval=this._hslString; +if(!rval){ +var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%"); +var a=c.a; +if(a>=1){ +a=1; +rval="hsl("+mid+")"; +}else{ +if(a<=0){ +a=0; +} +rval="hsla("+mid+","+a+")"; +} +this._hslString=rval; +} +return rval; +},toRGBString:function(){ +var c=this.rgb; +var ccc=MochiKit.Color.clampColorComponent; +var rval=this._rgbString; +if(!rval){ +var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0)); +if(c.a!=1){ +rval="rgba("+mid+","+c.a+")"; +}else{ +rval="rgb("+mid+")"; +} +this._rgbString=rval; +} +return rval; +},asRGB:function(){ +return MochiKit.Base.clone(this.rgb); +},toHexString:function(){ +var m=MochiKit.Color; +var c=this.rgb; +var ccc=MochiKit.Color.clampColorComponent; +var rval=this._hexString; +if(!rval){ +rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255))); +this._hexString=rval; +} +return rval; +},asHSV:function(){ +var hsv=this.hsv; +var c=this.rgb; +if(typeof (hsv)=="undefined"||hsv===null){ +hsv=MochiKit.Color.rgbToHSV(this.rgb); +this.hsv=hsv; +} +return MochiKit.Base.clone(hsv); +},asHSL:function(){ +var hsl=this.hsl; +var c=this.rgb; +if(typeof (hsl)=="undefined"||hsl===null){ +hsl=MochiKit.Color.rgbToHSL(this.rgb); +this.hsl=hsl; +} +return MochiKit.Base.clone(hsl); +},toString:function(){ +return this.toRGBString(); +},repr:function(){ +var c=this.rgb; +var col=[c.r,c.g,c.b,c.a]; +return this.__class__.NAME+"("+col.join(", ")+")"; +}}; +MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_4ab,blue,_4ad){ +var _4ae=MochiKit.Color.Color; +if(arguments.length==1){ +var rgb=red; +red=rgb.r; +_4ab=rgb.g; +blue=rgb.b; +if(typeof (rgb.a)=="undefined"){ +_4ad=undefined; +}else{ +_4ad=rgb.a; +} +} +return new _4ae(red,_4ab,blue,_4ad); +},fromHSL:function(hue,_4b1,_4b2,_4b3){ +var m=MochiKit.Color; +return m.Color.fromRGB(m.hslToRGB.apply(m,arguments)); +},fromHSV:function(hue,_4b6,_4b7,_4b8){ +var m=MochiKit.Color; +return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments)); +},fromName:function(name){ +var _4bb=MochiKit.Color.Color; +if(name.charAt(0)=="\""){ +name=name.substr(1,name.length-2); +} +var _4bc=_4bb._namedColors[name.toLowerCase()]; +if(typeof (_4bc)=="string"){ +return _4bb.fromHexString(_4bc); +}else{ +if(name=="transparent"){ +return _4bb.transparentColor(); +} +} +return null; +},fromString:function(_4bd){ +var self=MochiKit.Color.Color; +var _4bf=_4bd.substr(0,3); +if(_4bf=="rgb"){ +return self.fromRGBString(_4bd); +}else{ +if(_4bf=="hsl"){ +return self.fromHSLString(_4bd); +}else{ +if(_4bd.charAt(0)=="#"){ +return self.fromHexString(_4bd); +} +} +} +return self.fromName(_4bd); +},fromHexString:function(_4c0){ +if(_4c0.charAt(0)=="#"){ +_4c0=_4c0.substring(1); +} +var _4c1=[]; +var i,hex; +if(_4c0.length==3){ +for(i=0;i<3;i++){ +hex=_4c0.substr(i,1); +_4c1.push(parseInt(hex+hex,16)/255); +} +}else{ +for(i=0;i<6;i+=2){ +hex=_4c0.substr(i,2); +_4c1.push(parseInt(hex,16)/255); +} +} +var _4c4=MochiKit.Color.Color; +return _4c4.fromRGB.apply(_4c4,_4c1); +},_fromColorString:function(pre,_4c6,_4c7,_4c8){ +if(_4c8.indexOf(pre)===0){ +_4c8=_4c8.substring(_4c8.indexOf("(",3)+1,_4c8.length-1); +} +var _4c9=_4c8.split(/\s*,\s*/); +var _4ca=[]; +for(var i=0;i<_4c9.length;i++){ +var c=_4c9[i]; +var val; +var _4ce=c.substring(c.length-3); +if(c.charAt(c.length-1)=="%"){ +val=0.01*parseFloat(c.substring(0,c.length-1)); +}else{ +if(_4ce=="deg"){ +val=parseFloat(c)/360; +}else{ +if(_4ce=="rad"){ +val=parseFloat(c)/(Math.PI*2); +}else{ +val=_4c7[i]*parseFloat(c); +} +} +} +_4ca.push(val); +} +return this[_4c6].apply(this,_4ca); +},fromComputedStyle:function(elem,_4d0){ +var d=MochiKit.DOM; +var cls=MochiKit.Color.Color; +for(elem=d.getElement(elem);elem;elem=elem.parentNode){ +var _4d3=MochiKit.Style.getStyle.apply(d,arguments); +if(!_4d3){ +continue; +} +var _4d4=cls.fromString(_4d3); +if(!_4d4){ +break; +} +if(_4d4.asRGB().a>0){ +return _4d4; +} +} +return null; +},fromBackground:function(elem){ +var cls=MochiKit.Color.Color; +return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor(); +},fromText:function(elem){ +var cls=MochiKit.Color.Color; +return cls.fromComputedStyle(elem,"color","color")||cls.blackColor(); +},namedColors:function(){ +return MochiKit.Base.clone(MochiKit.Color.Color._namedColors); +}}); +MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_4da){ +v*=_4da; +if(v<0){ +return 0; +}else{ +if(v>_4da){ +return _4da; +}else{ +return v; +} +} +},_hslValue:function(n1,n2,hue){ +if(hue>6){ +hue-=6; +}else{ +if(hue<0){ +hue+=6; +} +} +var val; +if(hue<1){ +val=n1+(n2-n1)*hue; +}else{ +if(hue<3){ +val=n2; +}else{ +if(hue<4){ +val=n1+(n2-n1)*(4-hue); +}else{ +val=n1; +} +} +} +return val; +},hsvToRGB:function(hue,_4e0,_4e1,_4e2){ +if(arguments.length==1){ +var hsv=hue; +hue=hsv.h; +_4e0=hsv.s; +_4e1=hsv.v; +_4e2=hsv.a; +} +var red; +var _4e5; +var blue; +if(_4e0===0){ +red=_4e1; +_4e5=_4e1; +blue=_4e1; +}else{ +var i=Math.floor(hue*6); +var f=(hue*6)-i; +var p=_4e1*(1-_4e0); +var q=_4e1*(1-(_4e0*f)); +var t=_4e1*(1-(_4e0*(1-f))); +switch(i){ +case 1: +red=q; +_4e5=_4e1; +blue=p; +break; +case 2: +red=p; +_4e5=_4e1; +blue=t; +break; +case 3: +red=p; +_4e5=q; +blue=_4e1; +break; +case 4: +red=t; +_4e5=p; +blue=_4e1; +break; +case 5: +red=_4e1; +_4e5=p; +blue=q; +break; +case 6: +case 0: +red=_4e1; +_4e5=t; +blue=p; +break; +} +} +return {r:red,g:_4e5,b:blue,a:_4e2}; +},hslToRGB:function(hue,_4ed,_4ee,_4ef){ +if(arguments.length==1){ +var hsl=hue; +hue=hsl.h; +_4ed=hsl.s; +_4ee=hsl.l; +_4ef=hsl.a; +} +var red; +var _4f2; +var blue; +if(_4ed===0){ +red=_4ee; +_4f2=_4ee; +blue=_4ee; +}else{ +var m2; +if(_4ee<=0.5){ +m2=_4ee*(1+_4ed); +}else{ +m2=_4ee+_4ed-(_4ee*_4ed); +} +var m1=(2*_4ee)-m2; +var f=MochiKit.Color._hslValue; +var h6=hue*6; +red=f(m1,m2,h6+2); +_4f2=f(m1,m2,h6); +blue=f(m1,m2,h6-2); +} +return {r:red,g:_4f2,b:blue,a:_4ef}; +},rgbToHSV:function(red,_4f9,blue,_4fb){ +if(arguments.length==1){ +var rgb=red; +red=rgb.r; +_4f9=rgb.g; +blue=rgb.b; +_4fb=rgb.a; +} +var max=Math.max(Math.max(red,_4f9),blue); +var min=Math.min(Math.min(red,_4f9),blue); +var hue; +var _500; +var _501=max; +if(min==max){ +hue=0; +_500=0; +}else{ +var _502=(max-min); +_500=_502/max; +if(red==max){ +hue=(_4f9-blue)/_502; +}else{ +if(_4f9==max){ +hue=2+((blue-red)/_502); +}else{ +hue=4+((red-_4f9)/_502); +} +} +hue/=6; +if(hue<0){ +hue+=1; +} +if(hue>1){ +hue-=1; +} +} +return {h:hue,s:_500,v:_501,a:_4fb}; +},rgbToHSL:function(red,_504,blue,_506){ +if(arguments.length==1){ +var rgb=red; +red=rgb.r; +_504=rgb.g; +blue=rgb.b; +_506=rgb.a; +} +var max=Math.max(red,Math.max(_504,blue)); +var min=Math.min(red,Math.min(_504,blue)); +var hue; +var _50b; +var _50c=(max+min)/2; +var _50d=max-min; +if(_50d===0){ +hue=0; +_50b=0; +}else{ +if(_50c<=0.5){ +_50b=_50d/(max+min); +}else{ +_50b=_50d/(2-max-min); +} +if(red==max){ +hue=(_504-blue)/_50d; +}else{ +if(_504==max){ +hue=2+((blue-red)/_50d); +}else{ +hue=4+((red-_504)/_50d); +} +} +hue/=6; +if(hue<0){ +hue+=1; +} +if(hue>1){ +hue-=1; +} +} +return {h:hue,s:_50b,l:_50c,a:_506}; +},toColorPart:function(num){ +num=Math.round(num); +var _50f=num.toString(16); +if(num<16){ +return "0"+_50f; +} +return _50f; +},__new__:function(){ +var m=MochiKit.Base; +this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]); +this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]); +var _511=1/3; +var _512={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_511,_511,_511],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_511,2*_511,2*_511],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]}; +var _513=function(name,r,g,b,a){ +var rval=this.fromRGB(r,g,b,a); +this[name]=function(){ +return rval; +}; +return rval; +}; +for(var k in _512){ +var name=k+"Color"; +var _51c=m.concat([_513,this.Color,name],_512[k]); +this.Color[name]=m.bind.apply(null,_51c); +} +var _51d=function(){ +for(var i=0;i1){ +var src=MochiKit.DOM.getElement(arguments[0]); +var sig=arguments[1]; +var obj=arguments[2]; +var func=arguments[3]; +for(var i=_55f.length-1;i>=0;i--){ +var o=_55f[i]; +if(o.source===src&&o.signal===sig&&o.objOrFunc===obj&&o.funcOrStr===func){ +self._disconnect(o); +if(!self._lock){ +_55f.splice(i,1); +}else{ +self._dirty=true; +} +return true; +} +} +}else{ +var idx=m.findIdentical(_55f,_55d); +if(idx>=0){ +self._disconnect(_55d); +if(!self._lock){ +_55f.splice(idx,1); +}else{ +self._dirty=true; +} +return true; +} +} +return false; +},disconnectAllTo:function(_568,_569){ +var self=MochiKit.Signal; +var _56b=self._observers; +var _56c=self._disconnect; +var _56d=self._lock; +var _56e=self._dirty; +if(typeof (_569)==="undefined"){ +_569=null; +} +for(var i=_56b.length-1;i>=0;i--){ +var _570=_56b[i]; +if(_570.objOrFunc===_568&&(_569===null||_570.funcOrStr===_569)){ +_56c(_570); +if(_56d){ +_56e=true; +}else{ +_56b.splice(i,1); +} +} +} +self._dirty=_56e; +},disconnectAll:function(src,sig){ +src=MochiKit.DOM.getElement(src); +var m=MochiKit.Base; +var _574=m.flattenArguments(m.extend(null,arguments,1)); +var self=MochiKit.Signal; +var _576=self._disconnect; +var _577=self._observers; +var i,_579; +var _57a=self._lock; +var _57b=self._dirty; +if(_574.length===0){ +for(i=_577.length-1;i>=0;i--){ +_579=_577[i]; +if(_579.source===src){ +_576(_579); +if(!_57a){ +_577.splice(i,1); +}else{ +_57b=true; +} +} +} +}else{ +var sigs={}; +for(i=0;i<_574.length;i++){ +sigs[_574[i]]=true; +} +for(i=_577.length-1;i>=0;i--){ +_579=_577[i]; +if(_579.source===src&&_579.signal in sigs){ +_576(_579); +if(!_57a){ +_577.splice(i,1); +}else{ +_57b=true; +} +} +} +} +self._dirty=_57b; +},signal:function(src,sig){ +var self=MochiKit.Signal; +var _580=self._observers; +src=MochiKit.DOM.getElement(src); +var args=MochiKit.Base.extend(null,arguments,2); +var _582=[]; +self._lock=true; +for(var i=0;i<_580.length;i++){ +var _584=_580[i]; +if(_584.source===src&&_584.signal===sig){ +try{ +_584.listener.apply(src,args); +} +catch(e){ +_582.push(e); +} +} +} +self._lock=false; +if(self._dirty){ +self._dirty=false; +for(var i=_580.length-1;i>=0;i--){ +if(!_580[i].connected){ +_580.splice(i,1); +} +} +} +if(_582.length==1){ +throw _582[0]; +}else{ +if(_582.length>1){ +var e=new Error("Multiple errors thrown in handling 'sig', see errors property"); +e.errors=_582; +throw e; +} +} +}}); +MochiKit.Signal.EXPORT_OK=[]; +MochiKit.Signal.EXPORT=["connect","disconnect","signal","disconnectAll","disconnectAllTo"]; +MochiKit.Signal.__new__=function(win){ +var m=MochiKit.Base; +this._document=document; +this._window=win; +this._lock=false; +this._dirty=false; +try{ +this.connect(window,"onunload",this._unloadCache); +} +catch(e){ +} +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +m.nameFunctions(this); +}; +MochiKit.Signal.__new__(this); +if(MochiKit.__export__){ +connect=MochiKit.Signal.connect; +disconnect=MochiKit.Signal.disconnect; +disconnectAll=MochiKit.Signal.disconnectAll; +signal=MochiKit.Signal.signal; +} +MochiKit.Base._exportSymbols(this,MochiKit.Signal); +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.Position"); +dojo.require("MochiKit.Base"); +dojo.require("MochiKit.DOM"); +dojo.require("MochiKit.Style"); +} +if(typeof (JSAN)!="undefined"){ +JSAN.use("MochiKit.Base",[]); +JSAN.use("MochiKit.DOM",[]); +JSAN.use("MochiKit.Style",[]); +} +try{ +if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.Style)=="undefined"||typeof (MochiKit.DOM)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "MochiKit.Style depends on MochiKit.Base, MochiKit.DOM, and MochiKit.Style!"; +} +if(typeof (MochiKit.Position)=="undefined"){ +MochiKit.Position={}; +} +MochiKit.Position.NAME="MochiKit.Position"; +MochiKit.Position.VERSION="1.4"; +MochiKit.Position.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.Position.toString=function(){ +return this.__repr__(); +}; +MochiKit.Position.EXPORT_OK=[]; +MochiKit.Position.EXPORT=[]; +MochiKit.Base.update(MochiKit.Position,{includeScrollOffsets:false,prepare:function(){ +var _588=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0; +var _589=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0; +this.windowOffset=new MochiKit.Style.Coordinates(_588,_589); +},cumulativeOffset:function(_58a){ +var _58b=0; +var _58c=0; +do{ +_58b+=_58a.offsetTop||0; +_58c+=_58a.offsetLeft||0; +_58a=_58a.offsetParent; +}while(_58a); +return new MochiKit.Style.Coordinates(_58c,_58b); +},realOffset:function(_58d){ +var _58e=0; +var _58f=0; +do{ +_58e+=_58d.scrollTop||0; +_58f+=_58d.scrollLeft||0; +_58d=_58d.parentNode; +}while(_58d); +return new MochiKit.Style.Coordinates(_58f,_58e); +},within:function(_590,x,y){ +if(this.includeScrollOffsets){ +return this.withinIncludingScrolloffsets(_590,x,y); +} +this.xcomp=x; +this.ycomp=y; +this.offset=this.cumulativeOffset(_590); +if(_590.style.position=="fixed"){ +this.offset.x+=this.windowOffset.x; +this.offset.y+=this.windowOffset.y; +} +return (y>=this.offset.y&&y=this.offset.x&&x=this.offset.y&&this.ycomp=this.offset.x&&this.xcomp"+el.innerHTML+""; +},_roundTopCorners:function(el,_5c2,_5c3){ +var _5c4=this._createCorner(_5c3); +for(var i=0;i=0;i--){ +_5c9.appendChild(this._createCornerSlice(_5c7,_5c8,i,"bottom")); +} +el.style.paddingBottom=0; +el.appendChild(_5c9); +},_createCorner:function(_5cb){ +var dom=MochiKit.DOM; +return dom.DIV({style:{backgroundColor:_5cb.toString()}}); +},_createCornerSlice:function(_5cd,_5ce,n,_5d0){ +var _5d1=MochiKit.DOM.SPAN(); +var _5d2=_5d1.style; +_5d2.backgroundColor=_5cd.toString(); +_5d2.display="block"; +_5d2.height="1px"; +_5d2.overflow="hidden"; +_5d2.fontSize="1px"; +var _5d3=this._borderColor(_5cd,_5ce); +if(this.options.border&&n===0){ +_5d2.borderTopStyle="solid"; +_5d2.borderTopWidth="1px"; +_5d2.borderLeftWidth="0px"; +_5d2.borderRightWidth="0px"; +_5d2.borderBottomWidth="0px"; +_5d2.height="0px"; +_5d2.borderColor=_5d3.toString(); +}else{ +if(_5d3){ +_5d2.borderColor=_5d3.toString(); +_5d2.borderStyle="solid"; +_5d2.borderWidth="0px 1px"; +} +} +if(!this.options.compact&&(n==(this.options.numSlices-1))){ +_5d2.height="2px"; +} +this._setMargin(_5d1,n,_5d0); +this._setBorder(_5d1,n,_5d0); +return _5d1; +},_setOptions:function(_5d4){ +this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false,__unstable__wrapElement:false}; +MochiKit.Base.update(this.options,_5d4); +this.options.numSlices=(this.options.compact?2:4); +},_whichSideTop:function(){ +var _5d5=this.options.corners; +if(this._hasString(_5d5,"all","top")){ +return ""; +} +var _5d6=(_5d5.indexOf("tl")!=-1); +var _5d7=(_5d5.indexOf("tr")!=-1); +if(_5d6&&_5d7){ +return ""; +} +if(_5d6){ +return "left"; +} +if(_5d7){ +return "right"; +} +return ""; +},_whichSideBottom:function(){ +var _5d8=this.options.corners; +if(this._hasString(_5d8,"all","bottom")){ +return ""; +} +var _5d9=(_5d8.indexOf("bl")!=-1); +var _5da=(_5d8.indexOf("br")!=-1); +if(_5d9&&_5da){ +return ""; +} +if(_5d9){ +return "left"; +} +if(_5da){ +return "right"; +} +return ""; +},_borderColor:function(_5db,_5dc){ +if(_5db=="transparent"){ +return _5dc; +}else{ +if(this.options.border){ +return this.options.border; +}else{ +if(this.options.blend){ +return _5dc.blendedColor(_5db); +} +} +} +return ""; +},_setMargin:function(el,n,_5df){ +var _5e0=this._marginSize(n)+"px"; +var _5e1=(_5df=="top"?this._whichSideTop():this._whichSideBottom()); +var _5e2=el.style; +if(_5e1=="left"){ +_5e2.marginLeft=_5e0; +_5e2.marginRight="0px"; +}else{ +if(_5e1=="right"){ +_5e2.marginRight=_5e0; +_5e2.marginLeft="0px"; +}else{ +_5e2.marginLeft=_5e0; +_5e2.marginRight=_5e0; +} +} +},_setBorder:function(el,n,_5e5){ +var _5e6=this._borderSize(n)+"px"; +var _5e7=(_5e5=="top"?this._whichSideTop():this._whichSideBottom()); +var _5e8=el.style; +if(_5e7=="left"){ +_5e8.borderLeftWidth=_5e6; +_5e8.borderRightWidth="0px"; +}else{ +if(_5e7=="right"){ +_5e8.borderRightWidth=_5e6; +_5e8.borderLeftWidth="0px"; +}else{ +_5e8.borderLeftWidth=_5e6; +_5e8.borderRightWidth=_5e6; +} +} +},_marginSize:function(n){ +if(this.isTransparent){ +return 0; +} +var o=this.options; +if(o.compact&&o.blend){ +var _5eb=[1,0]; +return _5eb[n]; +}else{ +if(o.compact){ +var _5ec=[2,1]; +return _5ec[n]; +}else{ +if(o.blend){ +var _5ed=[3,2,1,0]; +return _5ed[n]; +}else{ +var _5ee=[5,3,2,1]; +return _5ee[n]; +} +} +} +},_borderSize:function(n){ +var o=this.options; +var _5f1; +if(o.compact&&(o.blend||this.isTransparent)){ +return 1; +}else{ +if(o.compact){ +_5f1=[1,0]; +}else{ +if(o.blend){ +_5f1=[2,1,1,1]; +}else{ +if(o.border){ +_5f1=[0,2,0,0]; +}else{ +if(this.isTransparent){ +_5f1=[5,3,2,1]; +}else{ +return 0; +} +} +} +} +} +return _5f1[n]; +},_hasString:function(str){ +for(var i=1;i=(_61c||i)){ +_61c=i; +} +},this.effects); +_618=_61c||_618; +break; +case "break": +ma(function(e){ +e.finalize(); +},this.effects); +break; +} +_617.startOn+=_618; +_617.finishOn+=_618; +if(!_617.options.queue.limit||this.effects.length<_617.options.queue.limit){ +this.effects.push(_617); +} +if(!this.interval){ +this.interval=this.startLoop(MochiKit.Base.bind(this.loop,this),40); +} +},startLoop:function(func,_621){ +return setInterval(func,_621); +},remove:function(_622){ +this.effects=MochiKit.Base.filter(function(e){ +return e!=_622; +},this.effects); +if(!this.effects.length){ +this.stopLoop(this.interval); +this.interval=null; +} +},stopLoop:function(_624){ +clearInterval(_624); +},loop:function(){ +var _625=new Date().getTime(); +MochiKit.Base.map(function(_626){ +_626.loop(_625); +},this.effects); +}}); +MochiKit.Visual.Queues={instances:{},get:function(_627){ +if(typeof (_627)!="string"){ +return _627; +} +if(!this.instances[_627]){ +this.instances[_627]=new MochiKit.Visual.ScopedQueue(); +} +return this.instances[_627]; +}}; +MochiKit.Visual.Queue=MochiKit.Visual.Queues.get("global"); +MochiKit.Visual.DefaultOptions={transition:MochiKit.Visual.Transitions.sinoidal,duration:1,fps:25,sync:false,from:0,to:1,delay:0,queue:"parallel"}; +MochiKit.Visual.Base=function(){ +}; +MochiKit.Visual.Base.prototype={__class__:MochiKit.Visual.Base,start:function(_628){ +var v=MochiKit.Visual; +this.options=MochiKit.Base.setdefault(_628||{},v.DefaultOptions); +this.currentFrame=0; +this.state="idle"; +this.startOn=this.options.delay*1000; +this.finishOn=this.startOn+(this.options.duration*1000); +this.event("beforeStart"); +if(!this.options.sync){ +v.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).add(this); +} +},loop:function(_62a){ +if(_62a>=this.startOn){ +if(_62a>=this.finishOn){ +return this.finalize(); +} +var pos=(_62a-this.startOn)/(this.finishOn-this.startOn); +var _62c=Math.round(pos*this.options.fps*this.options.duration); +if(_62c>this.currentFrame){ +this.render(pos); +this.currentFrame=_62c; +} +} +},render:function(pos){ +if(this.state=="idle"){ +this.state="running"; +this.event("beforeSetup"); +this.setup(); +this.event("afterSetup"); +} +if(this.state=="running"){ +if(this.options.transition){ +pos=this.options.transition(pos); +} +pos*=(this.options.to-this.options.from); +pos+=this.options.from; +this.event("beforeUpdate"); +this.update(pos); +this.event("afterUpdate"); +} +},cancel:function(){ +if(!this.options.sync){ +MochiKit.Visual.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).remove(this); +} +this.state="finished"; +},finalize:function(){ +this.render(1); +this.cancel(); +this.event("beforeFinish"); +this.finish(); +this.event("afterFinish"); +},setup:function(){ +},finish:function(){ +},update:function(_62e){ +},event:function(_62f){ +if(this.options[_62f+"Internal"]){ +this.options[_62f+"Internal"](this); +} +if(this.options[_62f]){ +this.options[_62f](this); +} +},repr:function(){ +return "["+this.__class__.NAME+", options:"+MochiKit.Base.repr(this.options)+"]"; +}}; +MochiKit.Visual.Parallel=function(_630,_631){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_630,_631); +} +this.__init__(_630,_631); +}; +MochiKit.Visual.Parallel.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.Parallel.prototype,{__class__:MochiKit.Visual.Parallel,__init__:function(_633,_634){ +this.effects=_633||[]; +this.start(_634); +},update:function(_635){ +MochiKit.Base.map(function(_636){ +_636.render(_635); +},this.effects); +},finish:function(){ +MochiKit.Base.map(function(_637){ +_637.finalize(); +},this.effects); +}}); +MochiKit.Visual.Opacity=function(_638,_639){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_638,_639); +} +this.__init__(_638,_639); +}; +MochiKit.Visual.Opacity.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.Opacity.prototype,{__class__:MochiKit.Visual.Opacity,__init__:function(_63b,_63c){ +var b=MochiKit.Base; +var s=MochiKit.Style; +this.element=MochiKit.DOM.getElement(_63b); +if(this.element.currentStyle&&(!this.element.currentStyle.hasLayout)){ +s.setStyle(this.element,{zoom:1}); +} +_63c=b.update({from:s.getStyle(this.element,"opacity")||0,to:1},_63c||{}); +this.start(_63c); +},update:function(_63f){ +MochiKit.Style.setStyle(this.element,{"opacity":_63f}); +}}); +MochiKit.Visual.Move=function(_640,_641){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_640,_641); +} +this.__init__(_640,_641); +}; +MochiKit.Visual.Move.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.Move.prototype,{__class__:MochiKit.Visual.Move,__init__:function(_643,_644){ +this.element=MochiKit.DOM.getElement(_643); +_644=MochiKit.Base.update({x:0,y:0,mode:"relative"},_644||{}); +this.start(_644); +},setup:function(){ +MochiKit.DOM.makePositioned(this.element); +var s=this.element.style; +var _646=s.visibility; +var _647=s.display; +if(_647=="none"){ +s.visibility="hidden"; +s.display=""; +} +this.originalLeft=parseFloat(MochiKit.Style.getStyle(this.element,"left")||"0"); +this.originalTop=parseFloat(MochiKit.Style.getStyle(this.element,"top")||"0"); +if(this.options.mode=="absolute"){ +this.options.x-=this.originalLeft; +this.options.y-=this.originalTop; +} +if(_647=="none"){ +s.visibility=_646; +s.display=_647; +} +},update:function(_648){ +MochiKit.Style.setStyle(this.element,{left:Math.round(this.options.x*_648+this.originalLeft)+"px",top:Math.round(this.options.y*_648+this.originalTop)+"px"}); +}}); +MochiKit.Visual.Scale=function(_649,_64a,_64b){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_649,_64a,_64b); +} +this.__init__(_649,_64a,_64b); +}; +MochiKit.Visual.Scale.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.Scale.prototype,{__class__:MochiKit.Visual.Scale,__init__:function(_64d,_64e,_64f){ +this.element=MochiKit.DOM.getElement(_64d); +_64f=MochiKit.Base.update({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_64e},_64f||{}); +this.start(_64f); +},setup:function(){ +this.restoreAfterFinish=this.options.restoreAfterFinish||false; +this.elementPositioning=MochiKit.Style.getStyle(this.element,"position"); +var ma=MochiKit.Base.map; +var b=MochiKit.Base.bind; +this.originalStyle={}; +ma(b(function(k){ +this.originalStyle[k]=this.element.style[k]; +},this),["top","left","width","height","fontSize"]); +this.originalTop=this.element.offsetTop; +this.originalLeft=this.element.offsetLeft; +var _653=MochiKit.Style.getStyle(this.element,"font-size")||"100%"; +ma(b(function(_654){ +if(_653.indexOf(_654)>0){ +this.fontSize=parseFloat(_653); +this.fontSizeType=_654; +} +},this),["em","px","%"]); +this.factor=(this.options.scaleTo-this.options.scaleFrom)/100; +if(/^content/.test(this.options.scaleMode)){ +this.dims=[this.element.scrollHeight,this.element.scrollWidth]; +}else{ +if(this.options.scaleMode=="box"){ +this.dims=[this.element.offsetHeight,this.element.offsetWidth]; +}else{ +this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]; +} +} +},update:function(_655){ +var _656=(this.options.scaleFrom/100)+(this.factor*_655); +if(this.options.scaleContent&&this.fontSize){ +MochiKit.Style.setStyle(this.element,{fontSize:this.fontSize*_656+this.fontSizeType}); +} +this.setDimensions(this.dims[0]*_656,this.dims[1]*_656); +},finish:function(){ +if(this.restoreAfterFinish){ +MochiKit.Style.setStyle(this.element,this.originalStyle); +} +},setDimensions:function(_657,_658){ +var d={}; +var r=Math.round; +if(/MSIE/.test(navigator.userAgent)){ +r=Math.ceil; +} +if(this.options.scaleX){ +d.width=r(_658)+"px"; +} +if(this.options.scaleY){ +d.height=r(_657)+"px"; +} +if(this.options.scaleFromCenter){ +var topd=(_657-this.dims[0])/2; +var _65c=(_658-this.dims[1])/2; +if(this.elementPositioning=="absolute"){ +if(this.options.scaleY){ +d.top=this.originalTop-topd+"px"; +} +if(this.options.scaleX){ +d.left=this.originalLeft-_65c+"px"; +} +}else{ +if(this.options.scaleY){ +d.top=-topd+"px"; +} +if(this.options.scaleX){ +d.left=-_65c+"px"; +} +} +} +MochiKit.Style.setStyle(this.element,d); +}}); +MochiKit.Visual.Highlight=function(_65d,_65e){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_65d,_65e); +} +this.__init__(_65d,_65e); +}; +MochiKit.Visual.Highlight.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.Highlight.prototype,{__class__:MochiKit.Visual.Highlight,__init__:function(_660,_661){ +this.element=MochiKit.DOM.getElement(_660); +_661=MochiKit.Base.update({startcolor:"#ffff99"},_661||{}); +this.start(_661); +},setup:function(){ +var b=MochiKit.Base; +var s=MochiKit.Style; +if(s.getStyle(this.element,"display")=="none"){ +this.cancel(); +return; +} +this.oldStyle={backgroundImage:s.getStyle(this.element,"background-image")}; +s.setStyle(this.element,{backgroundImage:"none"}); +if(!this.options.endcolor){ +this.options.endcolor=MochiKit.Color.Color.fromBackground(this.element).toHexString(); +} +if(b.isUndefinedOrNull(this.options.restorecolor)){ +this.options.restorecolor=s.getStyle(this.element,"background-color"); +} +this._base=b.map(b.bind(function(i){ +return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16); +},this),[0,1,2]); +this._delta=b.map(b.bind(function(i){ +return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i]; +},this),[0,1,2]); +},update:function(_666){ +var m="#"; +MochiKit.Base.map(MochiKit.Base.bind(function(i){ +m+=MochiKit.Color.toColorPart(Math.round(this._base[i]+this._delta[i]*_666)); +},this),[0,1,2]); +MochiKit.Style.setStyle(this.element,{backgroundColor:m}); +},finish:function(){ +MochiKit.Style.setStyle(this.element,MochiKit.Base.update(this.oldStyle,{backgroundColor:this.options.restorecolor})); +}}); +MochiKit.Visual.ScrollTo=function(_669,_66a){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_669,_66a); +} +this.__init__(_669,_66a); +}; +MochiKit.Visual.ScrollTo.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.ScrollTo.prototype,{__class__:MochiKit.Visual.ScrollTo,__init__:function(_66c,_66d){ +this.element=MochiKit.DOM.getElement(_66c); +this.start(_66d||{}); +},setup:function(){ +var p=MochiKit.Position; +p.prepare(); +var _66f=p.cumulativeOffset(this.element); +if(this.options.offset){ +_66f.y+=this.options.offset; +} +var max; +if(window.innerHeight){ +max=window.innerHeight-window.height; +}else{ +if(document.documentElement&&document.documentElement.clientHeight){ +max=document.documentElement.clientHeight-document.body.scrollHeight; +}else{ +if(document.body){ +max=document.body.clientHeight-document.body.scrollHeight; +} +} +} +this.scrollStart=p.windowOffset.y; +this.delta=(_66f.y>max?max:_66f.y)-this.scrollStart; +},update:function(_671){ +var p=MochiKit.Position; +p.prepare(); +window.scrollTo(p.windowOffset.x,this.scrollStart+(_671*this.delta)); +}}); +MochiKit.Visual.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; +MochiKit.Visual.Morph=function(_673,_674){ +var cls=arguments.callee; +if(!(this instanceof cls)){ +return new cls(_673,_674); +} +this.__init__(_673,_674); +}; +MochiKit.Visual.Morph.prototype=new MochiKit.Visual.Base(); +MochiKit.Base.update(MochiKit.Visual.Morph.prototype,{__class__:MochiKit.Visual.Morph,__init__:function(_676,_677){ +this.element=MochiKit.DOM.getElement(_676); +this.start(_677||{}); +},setup:function(){ +var b=MochiKit.Base; +var _679=this.options.style; +this.styleStart={}; +this.styleEnd={}; +this.units={}; +var _67a,unit; +for(var s in _679){ +_67a=_679[s]; +s=b.camelize(s); +if(MochiKit.Visual.CSS_LENGTH.test(_67a)){ +var _67d=_67a.match(/^([\+\-]?[0-9\.]+)(.*)$/); +_67a=parseFloat(_67d[1]); +unit=(_67d.length==3)?_67d[2]:null; +this.styleEnd[s]=_67a; +this.units[s]=unit; +_67a=MochiKit.Style.getStyle(this.element,s); +_67d=_67a.match(/^([\+\-]?[0-9\.]+)(.*)$/); +_67a=parseFloat(_67d[1]); +this.styleStart[s]=_67a; +}else{ +var c=MochiKit.Color.Color; +_67a=c.fromString(_67a); +if(_67a){ +this.units[s]="color"; +this.styleEnd[s]=_67a.toHexString(); +_67a=MochiKit.Style.getStyle(this.element,s); +this.styleStart[s]=c.fromString(_67a).toHexString(); +this.styleStart[s]=b.map(b.bind(function(i){ +return parseInt(this.styleStart[s].slice(i*2+1,i*2+3),16); +},this),[0,1,2]); +this.styleEnd[s]=b.map(b.bind(function(i){ +return parseInt(this.styleEnd[s].slice(i*2+1,i*2+3),16); +},this),[0,1,2]); +} +} +} +},update:function(_681){ +var _682; +for(var s in this.styleStart){ +if(this.units[s]=="color"){ +var m="#"; +var _685=this.styleStart[s]; +var end=this.styleEnd[s]; +MochiKit.Base.map(MochiKit.Base.bind(function(i){ +m+=MochiKit.Color.toColorPart(Math.round(_685[i]+(end[i]-_685[i])*_681)); +},this),[0,1,2]); +this.element.style[s]=m; +}else{ +_682=this.styleStart[s]+Math.round((this.styleEnd[s]-this.styleStart[s])*_681*1000)/1000+this.units[s]; +this.element.style[s]=_682; +} +} +}}); +MochiKit.Visual.fade=function(_688,_689){ +var s=MochiKit.Style; +var _68b=s.getStyle(_688,"opacity"); +_689=MochiKit.Base.update({from:s.getStyle(_688,"opacity")||1,to:0,afterFinishInternal:function(_68c){ +if(_68c.options.to!==0){ +return; +} +s.hideElement(_68c.element); +s.setStyle(_68c.element,{"opacity":_68b}); +}},_689||{}); +return new MochiKit.Visual.Opacity(_688,_689); +}; +MochiKit.Visual.appear=function(_68d,_68e){ +var s=MochiKit.Style; +var v=MochiKit.Visual; +_68e=MochiKit.Base.update({from:(s.getStyle(_68d,"display")=="none"?0:s.getStyle(_68d,"opacity")||0),to:1,afterFinishInternal:function(_691){ +v.forceRerendering(_691.element); +},beforeSetupInternal:function(_692){ +s.setStyle(_692.element,{"opacity":_692.options.from}); +s.showElement(_692.element); +}},_68e||{}); +return new v.Opacity(_68d,_68e); +}; +MochiKit.Visual.puff=function(_693,_694){ +var s=MochiKit.Style; +var v=MochiKit.Visual; +_693=MochiKit.DOM.getElement(_693); +var _697={position:s.getStyle(_693,"position"),top:_693.style.top,left:_693.style.left,width:_693.style.width,height:_693.style.height,opacity:s.getStyle(_693,"opacity")}; +_694=MochiKit.Base.update({beforeSetupInternal:function(_698){ +MochiKit.Position.absolutize(_698.effects[0].element); +},afterFinishInternal:function(_699){ +s.hideElement(_699.effects[0].element); +s.setStyle(_699.effects[0].element,_697); +},scaleContent:true,scaleFromCenter:true},_694||{}); +return new v.Parallel([new v.Scale(_693,200,{sync:true,scaleFromCenter:_694.scaleFromCenter,scaleContent:_694.scaleContent,restoreAfterFinish:true}),new v.Opacity(_693,{sync:true,to:0})],_694); +}; +MochiKit.Visual.blindUp=function(_69a,_69b){ +var d=MochiKit.DOM; +_69a=d.getElement(_69a); +var _69d=d.makeClipping(_69a); +_69b=MochiKit.Base.update({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_69e){ +MochiKit.Style.hideElement(_69e.element); +d.undoClipping(_69e.element,_69d); +}},_69b||{}); +return new MochiKit.Visual.Scale(_69a,0,_69b); +}; +MochiKit.Visual.blindDown=function(_69f,_6a0){ +var d=MochiKit.DOM; +var s=MochiKit.Style; +_69f=d.getElement(_69f); +var _6a3=s.getElementDimensions(_69f); +var _6a4; +_6a0=MochiKit.Base.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_6a3.h,originalWidth:_6a3.w},restoreAfterFinish:true,afterSetupInternal:function(_6a5){ +_6a4=d.makeClipping(_6a5.element); +s.setStyle(_6a5.element,{height:"0px"}); +s.showElement(_6a5.element); +},afterFinishInternal:function(_6a6){ +d.undoClipping(_6a6.element,_6a4); +}},_6a0||{}); +return new MochiKit.Visual.Scale(_69f,100,_6a0); +}; +MochiKit.Visual.switchOff=function(_6a7,_6a8){ +var d=MochiKit.DOM; +_6a7=d.getElement(_6a7); +var _6aa=MochiKit.Style.getStyle(_6a7,"opacity"); +var _6ab; +_6a8=MochiKit.Base.update({duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetupInternal:function(_6ac){ +d.makePositioned(_6ac.element); +_6ab=d.makeClipping(_6ac.element); +},afterFinishInternal:function(_6ad){ +MochiKit.Style.hideElement(_6ad.element); +d.undoClipping(_6ad.element,_6ab); +d.undoPositioned(_6ad.element); +MochiKit.Style.setStyle(_6ad.element,{"opacity":_6aa}); +}},_6a8||{}); +var v=MochiKit.Visual; +return new v.appear(_6a7,{duration:0.4,from:0,transition:v.Transitions.flicker,afterFinishInternal:function(_6af){ +new v.Scale(_6af.element,1,_6a8); +}}); +}; +MochiKit.Visual.dropOut=function(_6b0,_6b1){ +var d=MochiKit.DOM; +var s=MochiKit.Style; +_6b0=d.getElement(_6b0); +var _6b4={top:s.getStyle(_6b0,"top"),left:s.getStyle(_6b0,"left"),opacity:s.getStyle(_6b0,"opacity")}; +_6b1=MochiKit.Base.update({duration:0.5,distance:100,beforeSetupInternal:function(_6b5){ +d.makePositioned(_6b5.effects[0].element); +},afterFinishInternal:function(_6b6){ +s.hideElement(_6b6.effects[0].element); +d.undoPositioned(_6b6.effects[0].element); +s.setStyle(_6b6.effects[0].element,_6b4); +}},_6b1||{}); +var v=MochiKit.Visual; +return new v.Parallel([new v.Move(_6b0,{x:0,y:_6b1.distance,sync:true}),new v.Opacity(_6b0,{sync:true,to:0})],_6b1); +}; +MochiKit.Visual.shake=function(_6b8,_6b9){ +var d=MochiKit.DOM; +var v=MochiKit.Visual; +var s=MochiKit.Style; +_6b8=d.getElement(_6b8); +_6b9=MochiKit.Base.update({x:-20,y:0,duration:0.05,afterFinishInternal:function(_6bd){ +d.undoPositioned(_6bd.element); +s.setStyle(_6bd.element,_6be); +}},_6b9||{}); +var _6be={top:s.getStyle(_6b8,"top"),left:s.getStyle(_6b8,"left")}; +return new v.Move(_6b8,{x:20,y:0,duration:0.05,afterFinishInternal:function(_6bf){ +new v.Move(_6bf.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_6c0){ +new v.Move(_6c0.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_6c1){ +new v.Move(_6c1.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_6c2){ +new v.Move(_6c2.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_6c3){ +new v.Move(_6c3.element,_6b9); +}}); +}}); +}}); +}}); +}}); +}; +MochiKit.Visual.slideDown=function(_6c4,_6c5){ +var d=MochiKit.DOM; +var b=MochiKit.Base; +var s=MochiKit.Style; +_6c4=d.getElement(_6c4); +if(!_6c4.firstChild){ +throw "MochiKit.Visual.slideDown must be used on a element with a child"; +} +d.removeEmptyTextNodes(_6c4); +var _6c9=s.getStyle(_6c4.firstChild,"bottom")||0; +var _6ca=s.getElementDimensions(_6c4); +var _6cb; +_6c5=b.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_6ca.h,originalWidth:_6ca.w},restoreAfterFinish:true,afterSetupInternal:function(_6cc){ +d.makePositioned(_6cc.element); +d.makePositioned(_6cc.element.firstChild); +if(/Opera/.test(navigator.userAgent)){ +s.setStyle(_6cc.element,{top:""}); +} +_6cb=d.makeClipping(_6cc.element); +s.setStyle(_6cc.element,{height:"0px"}); +s.showElement(_6cc.element); +},afterUpdateInternal:function(_6cd){ +s.setStyle(_6cd.element.firstChild,{bottom:(_6cd.dims[0]-_6cd.element.clientHeight)+"px"}); +},afterFinishInternal:function(_6ce){ +d.undoClipping(_6ce.element,_6cb); +if(/MSIE/.test(navigator.userAgent)){ +d.undoPositioned(_6ce.element); +d.undoPositioned(_6ce.element.firstChild); +}else{ +d.undoPositioned(_6ce.element.firstChild); +d.undoPositioned(_6ce.element); +} +s.setStyle(_6ce.element.firstChild,{bottom:_6c9}); +}},_6c5||{}); +return new MochiKit.Visual.Scale(_6c4,100,_6c5); +}; +MochiKit.Visual.slideUp=function(_6cf,_6d0){ +var d=MochiKit.DOM; +var b=MochiKit.Base; +var s=MochiKit.Style; +_6cf=d.getElement(_6cf); +if(!_6cf.firstChild){ +throw "MochiKit.Visual.slideUp must be used on a element with a child"; +} +d.removeEmptyTextNodes(_6cf); +var _6d4=s.getStyle(_6cf.firstChild,"bottom"); +var _6d5; +_6d0=b.update({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(_6d6){ +d.makePositioned(_6d6.element); +d.makePositioned(_6d6.element.firstChild); +if(/Opera/.test(navigator.userAgent)){ +s.setStyle(_6d6.element,{top:""}); +} +_6d5=d.makeClipping(_6d6.element); +s.showElement(_6d6.element); +},afterUpdateInternal:function(_6d7){ +s.setStyle(_6d7.element.firstChild,{bottom:(_6d7.dims[0]-_6d7.element.clientHeight)+"px"}); +},afterFinishInternal:function(_6d8){ +s.hideElement(_6d8.element); +d.undoClipping(_6d8.element,_6d5); +d.undoPositioned(_6d8.element.firstChild); +d.undoPositioned(_6d8.element); +s.setStyle(_6d8.element.firstChild,{bottom:_6d4}); +}},_6d0||{}); +return new MochiKit.Visual.Scale(_6cf,0,_6d0); +}; +MochiKit.Visual.squish=function(_6d9,_6da){ +var d=MochiKit.DOM; +var b=MochiKit.Base; +var _6dd; +_6da=b.update({restoreAfterFinish:true,beforeSetupInternal:function(_6de){ +_6dd=d.makeClipping(_6de.element); +},afterFinishInternal:function(_6df){ +MochiKit.Style.hideElement(_6df.element); +d.undoClipping(_6df.element,_6dd); +}},_6da||{}); +return new MochiKit.Visual.Scale(_6d9,/Opera/.test(navigator.userAgent)?1:0,_6da); +}; +MochiKit.Visual.grow=function(_6e0,_6e1){ +var d=MochiKit.DOM; +var v=MochiKit.Visual; +var s=MochiKit.Style; +_6e0=d.getElement(_6e0); +_6e1=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.full,scaleContent:true,scaleFromCenter:false},_6e1||{}); +var _6e5={top:_6e0.style.top,left:_6e0.style.left,height:_6e0.style.height,width:_6e0.style.width,opacity:s.getStyle(_6e0,"opacity")}; +var dims=s.getElementDimensions(_6e0); +var _6e7,_6e8; +var _6e9,_6ea; +switch(_6e1.direction){ +case "top-left": +_6e7=_6e8=_6e9=_6ea=0; +break; +case "top-right": +_6e7=dims.w; +_6e8=_6ea=0; +_6e9=-dims.w; +break; +case "bottom-left": +_6e7=_6e9=0; +_6e8=dims.h; +_6ea=-dims.h; +break; +case "bottom-right": +_6e7=dims.w; +_6e8=dims.h; +_6e9=-dims.w; +_6ea=-dims.h; +break; +case "center": +_6e7=dims.w/2; +_6e8=dims.h/2; +_6e9=-dims.w/2; +_6ea=-dims.h/2; +break; +} +var _6eb=MochiKit.Base.update({beforeSetupInternal:function(_6ec){ +s.setStyle(_6ec.effects[0].element,{height:"0px"}); +s.showElement(_6ec.effects[0].element); +},afterFinishInternal:function(_6ed){ +d.undoClipping(_6ed.effects[0].element); +d.undoPositioned(_6ed.effects[0].element); +s.setStyle(_6ed.effects[0].element,_6e5); +}},_6e1||{}); +return new v.Move(_6e0,{x:_6e7,y:_6e8,duration:0.01,beforeSetupInternal:function(_6ee){ +s.hideElement(_6ee.element); +d.makeClipping(_6ee.element); +d.makePositioned(_6ee.element); +},afterFinishInternal:function(_6ef){ +new v.Parallel([new v.Opacity(_6ef.element,{sync:true,to:1,from:0,transition:_6e1.opacityTransition}),new v.Move(_6ef.element,{x:_6e9,y:_6ea,sync:true,transition:_6e1.moveTransition}),new v.Scale(_6ef.element,100,{scaleMode:{originalHeight:dims.h,originalWidth:dims.w},sync:true,scaleFrom:/Opera/.test(navigator.userAgent)?1:0,transition:_6e1.scaleTransition,scaleContent:_6e1.scaleContent,scaleFromCenter:_6e1.scaleFromCenter,restoreAfterFinish:true})],_6eb); +}}); +}; +MochiKit.Visual.shrink=function(_6f0,_6f1){ +var d=MochiKit.DOM; +var v=MochiKit.Visual; +var s=MochiKit.Style; +_6f0=d.getElement(_6f0); +_6f1=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.none,scaleContent:true,scaleFromCenter:false},_6f1||{}); +var _6f5={top:_6f0.style.top,left:_6f0.style.left,height:_6f0.style.height,width:_6f0.style.width,opacity:s.getStyle(_6f0,"opacity")}; +var dims=s.getElementDimensions(_6f0); +var _6f7,_6f8; +switch(_6f1.direction){ +case "top-left": +_6f7=_6f8=0; +break; +case "top-right": +_6f7=dims.w; +_6f8=0; +break; +case "bottom-left": +_6f7=0; +_6f8=dims.h; +break; +case "bottom-right": +_6f7=dims.w; +_6f8=dims.h; +break; +case "center": +_6f7=dims.w/2; +_6f8=dims.h/2; +break; +} +var _6f9; +var _6fa=MochiKit.Base.update({beforeStartInternal:function(_6fb){ +_6f9=d.makePositioned(_6fb.effects[0].element); +d.makeClipping(_6fb.effects[0].element); +},afterFinishInternal:function(_6fc){ +s.hideElement(_6fc.effects[0].element); +d.undoClipping(_6fc.effects[0].element,_6f9); +d.undoPositioned(_6fc.effects[0].element); +s.setStyle(_6fc.effects[0].element,_6f5); +}},_6f1||{}); +return new v.Parallel([new v.Opacity(_6f0,{sync:true,to:0,from:1,transition:_6f1.opacityTransition}),new v.Scale(_6f0,/Opera/.test(navigator.userAgent)?1:0,{sync:true,transition:_6f1.scaleTransition,scaleContent:_6f1.scaleContent,scaleFromCenter:_6f1.scaleFromCenter,restoreAfterFinish:true}),new v.Move(_6f0,{x:_6f7,y:_6f8,sync:true,transition:_6f1.moveTransition})],_6fa); +}; +MochiKit.Visual.pulsate=function(_6fd,_6fe){ +var d=MochiKit.DOM; +var v=MochiKit.Visual; +var b=MochiKit.Base; +var _702=MochiKit.Style.getStyle(_6fd,"opacity"); +_6fe=b.update({duration:3,from:0,afterFinishInternal:function(_703){ +MochiKit.Style.setStyle(_703.element,{"opacity":_702}); +}},_6fe||{}); +var _704=_6fe.transition||v.Transitions.sinoidal; +var _705=b.bind(function(pos){ +return _704(1-v.Transitions.pulse(pos,_6fe.pulses)); +},_704); +b.bind(_705,_704); +return new v.Opacity(_6fd,b.update({transition:_705},_6fe)); +}; +MochiKit.Visual.fold=function(_707,_708){ +var d=MochiKit.DOM; +var v=MochiKit.Visual; +var s=MochiKit.Style; +_707=d.getElement(_707); +var _70c={top:_707.style.top,left:_707.style.left,width:_707.style.width,height:_707.style.height}; +var _70d=d.makeClipping(_707); +_708=MochiKit.Base.update({scaleContent:false,scaleX:false,afterFinishInternal:function(_70e){ +new v.Scale(_707,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_70f){ +s.hideElement(_70f.element); +d.undoClipping(_70f.element,_70d); +s.setStyle(_70f.element,_70c); +}}); +}},_708||{}); +return new v.Scale(_707,5,_708); +}; +MochiKit.Visual.Color=MochiKit.Color.Color; +MochiKit.Visual.getElementsComputedStyle=MochiKit.DOM.computedStyle; +MochiKit.Visual.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +MochiKit.Visual.EXPORT=["roundElement","roundClass","tagifyText","multiple","toggle","Parallel","Opacity","Move","Scale","Highlight","ScrollTo","Morph","fade","appear","puff","blindUp","blindDown","switchOff","dropOut","shake","slideDown","slideUp","squish","grow","shrink","pulsate","fold"]; +MochiKit.Visual.EXPORT_OK=["Base","PAIRS"]; +MochiKit.Visual.__new__(); +MochiKit.Base._exportSymbols(this,MochiKit.Visual); +if(typeof (MochiKit)=="undefined"){ +MochiKit={}; +} +if(typeof (MochiKit.MochiKit)=="undefined"){ +MochiKit.MochiKit={}; +} +MochiKit.MochiKit.NAME="MochiKit.MochiKit"; +MochiKit.MochiKit.VERSION="1.4"; +MochiKit.MochiKit.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +MochiKit.MochiKit.toString=function(){ +return this.__repr__(); +}; +MochiKit.MochiKit.SUBMODULES=["Base","Iter","Logging","DateTime","Format","Async","DOM","Selector","Style","LoggingPane","Color","Signal","Position","Visual"]; +if(typeof (JSAN)!="undefined"||typeof (dojo)!="undefined"){ +if(typeof (dojo)!="undefined"){ +dojo.provide("MochiKit.MochiKit"); +dojo.require("MochiKit.*"); +} +if(typeof (JSAN)!="undefined"){ +(function(lst){ +for(var i=0;i"); +} +} +})(); +} + + +/*** + + PlotKit.PlotKit 0.9.1 : PACKED VERSION + + THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please + diff against the source tree, not this file. + + For more information, . + + Copyright (c) 2006. Alastair Tse. + +***/ + +try{ +if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.DOM)=="undefined"||typeof (MochiKit.Color)=="undefined"||typeof (MochiKit.Format)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format}"; +} +MochiKit.Base.update(MochiKit.Color.Color.prototype,{asFillColor:function(){ +return this.lighterColorWithLevel(0.3); +},asStrokeColor:function(){ +return this.darkerColorWithLevel(0.1); +},asPointColor:function(){ +return this.lighterColorWithLevel(0.1); +}}); +if(typeof (PlotKit)=="undefined"){ +PlotKit={}; +} +PlotKit.NAME="PlotKit"; +PlotKit.VERSION="0.8"; +PlotKit.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.toString=function(){ +return this.__repr__(); +}; +if(typeof (PlotKit.Base)=="undefined"){ +PlotKit.Base={}; +} +PlotKit.Base.NAME="PlotKit.Base"; +PlotKit.Base.VERSION=PlotKit.VERSION; +PlotKit.Base.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.Base.toString=function(){ +return this.__repr__(); +}; +PlotKit.Base.usingPrototype=function(){ +try{ +return (typeof (Object.extend)=="function"); +} +catch(e){ +return false; +} +}; +MochiKit.Base.update(PlotKit.Base,{roundInterval:function(_1,_2,_3){ +var _4=MochiKit.Format.roundToFixed; +var _5=_1/_2; +return parseFloat(_4(_5,_3)); +},collapse:function(_6){ +var m=MochiKit.Base; +var _8=new Array(); +for(var i=0;i<_6.length;i++){ +_8=m.concat(_8,_6[i]); +} +if(PlotKit.Base.usingPrototype()){ +delete _8.extend; +delete _8.from; +delete _8.inspect; +} +return _8; +},uniq:function(_10){ +var m=MochiKit.Base; +if(!m.isArrayLike(_10)||(_10.length<1)){ +return new Array(); +} +var _11=new Array(); +var _12=_10[0]; +_11.push(_10[0]); +for(var i=1;i<_10.length;i++){ +if(m.compare(_10[i],_12)!=0){ +_12=_10[i]; +_11.push(_10[i]); +} +} +return _11; +},colorScheme:function(){ +var mb=MochiKit.Base; +var mc=MochiKit.Color; +var _15=["red","orange","yellow","green","cyan","blue","purple","magenta"]; +var _16=function(_17){ +return mc.Color[_17+"Color"](); +}; +return mb.map(_16,_15); +},baseDarkPrimaryColors:function(){ +var _18=MochiKit.Color.Color.fromHexString; +return [_18("#ad3f40"),_18("#ddac2c"),_18("#dfdd0c"),_18("#5276c4"),_18("#739c5a")]; +},basePrimaryColors:function(){ +var _19=MochiKit.Color.Color.fromHexString; +return [_19("#d24c4d"),_19("#f2b32f"),_19("#ece90e"),_19("#5d83da"),_19("#78a15d")]; +},baseBlueColors:function(){ +var _20=MochiKit.Color.Color.fromHexString; +return [_20("#4b6b94"),_20("#5d81b4"),_20("#acbad2")]; +},palette:function(_21,_22,_23,_24){ +var _25=MochiKit.Base.isUndefinedOrNull; +var _26=new Array(); +if(_25(_24)){ +_24=0.1; +} +if(_25(_23)){ +_23=0.4; +} +if(_25(_22)){ +_22=-0.2; +} +var _27=_22; +while(_27<=_23){ +_26.push(_27); +_27+=_24; +} +var _28=function(_29,_30){ +return _29.lighterColorWithLevel(_30); +}; +return MochiKit.Base.map(partial(_28,_21),_26); +},excanvasSupported:function(){ +if(/MSIE/.test(navigator.userAgent)&&!window.opera){ +return true; +} +return false; +},findPosX:function(obj){ +var _32=0; +if(obj.offsetParent){ +while(obj.offsetParent){ +_32+=obj.offsetLeft; +obj=obj.offsetParent; +} +}else{ +if(obj.x){ +_32+=obj.x; +} +} +return _32; +},findPosY:function(obj){ +var _33=0; +if(obj.offsetParent){ +while(obj.offsetParent){ +_33+=obj.offsetTop; +obj=obj.offsetParent; +} +}else{ +if(obj.y){ +_33+=obj.y; +} +} +return _33; +},isFuncLike:function(obj){ +return (typeof (obj)=="function"); +}}); +PlotKit.Base.map=function(fn,lst){ +if(PlotKit.Base.usingPrototype()){ +var _36=[]; +for(var x in lst){ +if(typeof (lst[x])=="function"){ +continue; +} +_36.push(fn(lst[x])); +} +return _36; +}else{ +return MochiKit.Base.map(fn,lst); +} +}; +PlotKit.Base.items=function(lst){ +if(PlotKit.Base.usingPrototype()){ +var _38=[]; +for(var x in lst){ +if(typeof (lst[x])=="function"){ +continue; +} +_38.push([x,lst[x]]); +} +return _38; +}else{ +return MochiKit.Base.items(lst); +} +}; +PlotKit.Base.keys=function(lst){ +if(PlotKit.Base.usingPrototype()){ +var _39=[]; +for(var x in lst){ +if(typeof (lst[x])=="function"){ +continue; +} +_39.push(x); +} +return _39; +}else{ +return MochiKit.Base.keys(lst); +} +}; +PlotKit.Base.baseColors=function(){ +var _40=MochiKit.Color.Color.fromHexString; +return [_40("#476fb2"),_40("#be2c2b"),_40("#85b730"),_40("#734a99"),_40("#26a1c5"),_40("#fb8707"),_40("#000000")]; +}; +PlotKit.Base.officeBaseStyle={"axisLineWidth":2,"axisLabelColor":Color.grayColor(),"axisLineColor":Color.whiteColor(),"padding":{top:5,bottom:10,left:30,right:30}}; +MochiKit.Base.update(PlotKit.Base,{officeBlue:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"backgroundColor":PlotKit.Base.baseColors()[0].lighterColorWithLevel(0.45)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +},officeRed:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"backgroundColor":PlotKit.Base.baseColors()[1].lighterColorWithLevel(0.5)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +},officeGreen:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[2]),"backgroundColor":PlotKit.Base.baseColors()[2].lighterColorWithLevel(0.5)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +},officePurple:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[3]),"backgroundColor":PlotKit.Base.baseColors()[3].lighterColorWithLevel(0.5)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +},officeCyan:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[4]),"backgroundColor":PlotKit.Base.baseColors()[4].lighterColorWithLevel(0.5)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +},officeOrange:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[5]),"backgroundColor":PlotKit.Base.baseColors()[5].lighterColorWithLevel(0.4)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +},officeBlack:function(){ +var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[6],0,0.6),"backgroundColor":PlotKit.Base.baseColors()[6].lighterColorWithLevel(0.9)}; +MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle); +return r; +}}); +PlotKit.Base.EXPORT=["baseColors","collapse","colorScheme","findPosX","findPosY","officeBaseStyle","officeBlue","officeRed","officeGreen","officePurple","officeCyan","officeOrange","officeBlack","roundInterval","uniq","isFuncLike","excanvasSupported"]; +PlotKit.Base.EXPORT_OK=[]; +PlotKit.Base.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +PlotKit.Base.__new__(); +MochiKit.Base._exportSymbols(this,PlotKit.Base); +try{ +if(typeof (PlotKit.Base)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Base"; +} +if(typeof (PlotKit.Layout)=="undefined"){ +PlotKit.Layout={}; +} +PlotKit.Layout.NAME="PlotKit.Layout"; +PlotKit.Layout.VERSION=PlotKit.VERSION; +PlotKit.Layout.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.Layout.toString=function(){ +return this.__repr__(); +}; +PlotKit.Layout.valid_styles=["bar","line","pie","point"]; +PlotKit.Layout=function(_42,_43){ +this.options={"barWidthFillFraction":0.75,"barOrientation":"vertical","xOriginIsZero":true,"yOriginIsZero":true,"xAxis":null,"yAxis":null,"xTicks":null,"yTicks":null,"xNumberOfTicks":10,"yNumberOfTicks":5,"xTickPrecision":1,"yTickPrecision":1,"pieRadius":0.4}; +this.style=_42; +MochiKit.Base.update(this.options,_43?_43:{}); +if(!MochiKit.Base.isUndefinedOrNull(this.options.xAxis)){ +this.minxval=this.options.xAxis[0]; +this.maxxval=this.options.xAxis[1]; +this.xscale=this.maxxval-this.minxval; +}else{ +this.minxval=0; +this.maxxval=null; +this.xscale=null; +} +if(!MochiKit.Base.isUndefinedOrNull(this.options.yAxis)){ +this.minyval=this.options.yAxis[0]; +this.maxyval=this.options.yAxis[1]; +this.yscale=this.maxyval-this.minyval; +}else{ +this.minyval=0; +this.maxyval=null; +this.yscale=null; +} +this.bars=new Array(); +this.points=new Array(); +this.slices=new Array(); +this.xticks=new Array(); +this.yticks=new Array(); +this.datasets=new Array(); +this.minxdelta=0; +this.xrange=1; +this.yrange=1; +this.hitTestCache={x2maxy:null}; +}; +PlotKit.Layout.prototype.addDataset=function(_44,_45){ +this.datasets[_44]=_45; +}; +PlotKit.Layout.prototype.removeDataset=function(_46,_47){ +delete this.datasets[_46]; +}; +PlotKit.Layout.prototype.addDatasetFromTable=function(_48,_49,_50,_51,_52){ +var _53=MochiKit.Base.isUndefinedOrNull; +var _54=MochiKit.DOM.scrapeText; +var _55=MochiKit.Format.strip; +if(_53(_50)){ +_50=0; +} +if(_53(_51)){ +_51=1; +} +if(_53(_52)){ +_52=-1; +} +var _56=_49.tBodies[0].rows; +var _57=new Array(); +var _58=new Array(); +if(!_53(_56)){ +for(var i=0;i<_56.length;i++){ +_57.push([parseFloat(_55(_54(_56[i].cells[_50]))),parseFloat(_55(_54(_56[i].cells[_51])))]); +if(_52>=0){ +_58.push({v:parseFloat(_55(_54(_56[i].cells[_50]))),label:_55(_54(_56[i].cells[_52]))}); +} +} +this.addDataset(_48,_57); +if(_52>=0){ +this.options.xTicks=_58; +} +return true; +} +return false; +}; +PlotKit.Layout.prototype.evaluate=function(){ +this._evaluateLimits(); +this._evaluateScales(); +if(this.style=="bar"){ +if(this.options.barOrientation=="horizontal"){ +this._evaluateHorizBarCharts(); +}else{ +this._evaluateBarCharts(); +} +this._evaluateBarTicks(); +}else{ +if(this.style=="line"){ +this._evaluateLineCharts(); +this._evaluateLineTicks(); +}else{ +if(this.style=="pie"){ +this._evaluatePieCharts(); +this._evaluatePieTicks(); +} +} +} +}; +PlotKit.Layout.prototype.hitTest=function(x,y){ +var f=MochiKit.Format.twoDigitFloat; +if((this.style=="bar")&&this.bars&&(this.bars.length>0)){ +for(var i=0;i=bar.x)&&(x<=bar.x+bar.w)&&(y>=bar.y)&&(y-bar.y<=bar.h)){ +return bar; +} +} +}else{ +if(this.style=="line"){ +if(this.hitTestCache.x2maxy==null){ +this._regenerateHitTestCache(); +} +var _62=x/this.xscale; +var _63=this.hitTestCache.xvalues; +var _64=null; +var _65=null; +for(var i=1;i<_63.length;i++){ +if(_63[i]>_62){ +_64=_63[i-1]; +_65=_63[i]; +break; +} +} +if((_64!=null)){ +var _66=this.hitTestCache.x2maxy[_64]; +var _67=this.hitTestCache.x2maxy[_65]; +var _68=(1-y)/this.yscale; +var _69=(_67-_66)/(_65-_64); +var _70=_66+_69*(_62-_64); +if(_70>=_68){ +var obj={xval:_62,yval:_68,xafter:_65,yafter:_67,xbefore:_64,ybefore:_66,yprojected:_70}; +return obj; +} +} +}else{ +if(this.style=="pie"){ +var _71=Math.sqrt((y-0.5)*(y-0.5)+(x-0.5)*(x-0.5)); +if(_71>this.options.pieRadius){ +return null; +} +var _72=Math.atan2(y-0.5,x-0.5)-Math.PI/2; +for(var i=0;i=_72){ +return _73; +} +} +} +} +} +return null; +}; +PlotKit.Layout.prototype.rectForX=function(x){ +return null; +}; +PlotKit.Layout.prototype.angleRangeForX=function(x){ +return null; +}; +PlotKit.Layout.prototype._evaluateLimits=function(){ +var map=PlotKit.Base.map; +var _75=PlotKit.Base.items; +var _76=MochiKit.Base.itemgetter; +var _77=PlotKit.Base.collapse; +var _78=MochiKit.Base.listMin; +var _79=MochiKit.Base.listMax; +var _80=MochiKit.Base.isUndefinedOrNull; +var all=_77(map(_76(1),_75(this.datasets))); +if(_80(this.options.xAxis)){ +if(this.options.xOriginIsZero){ +this.minxval=0; +}else{ +this.minxval=_78(map(parseFloat,map(_76(0),all))); +} +this.maxxval=_79(map(parseFloat,map(_76(0),all))); +}else{ +this.minxval=this.options.xAxis[0]; +this.maxxval=this.options.xAxis[1]; +this.xscale=this.maxval-this.minxval; +} +if(_80(this.options.yAxis)){ +if(this.options.yOriginIsZero){ +this.minyval=0; +}else{ +this.minyval=_78(map(parseFloat,map(_76(1),all))); +} +this.maxyval=_79(map(parseFloat,map(_76(1),all))); +}else{ +this.minyval=this.options.yAxis[0]; +this.maxyval=this.options.yAxis[1]; +this.yscale=this.maxyval-this.minyval; +} +}; +PlotKit.Layout.prototype._evaluateScales=function(){ +var _82=MochiKit.Base.isUndefinedOrNull; +this.xrange=this.maxxval-this.minxval; +if(this.xrange==0){ +this.xscale=1; +}else{ +this.xscale=1/this.xrange; +} +this.yrange=this.maxyval-this.minyval; +if(this.yrange==0){ +this.yscale=1; +}else{ +this.yscale=1/this.yrange; +} +}; +PlotKit.Layout.prototype._uniqueXValues=function(){ +var _83=PlotKit.Base.collapse; +var map=PlotKit.Base.map; +var _84=PlotKit.Base.uniq; +var _85=MochiKit.Base.itemgetter; +var _86=PlotKit.Base.items; +var _87=map(parseFloat,map(_85(0),_83(map(_85(1),_86(this.datasets))))); +_87.sort(MochiKit.Base.compare); +return _84(_87); +}; +PlotKit.Layout.prototype._evaluateBarCharts=function(){ +var _88=PlotKit.Base.items; +var _89=_88(this.datasets).length; +var _90=10000000; +var _91=this._uniqueXValues(); +for(var i=1;i<_91.length;i++){ +_90=Math.min(Math.abs(_91[i]-_91[i-1]),_90); +} +var _92=0; +var _93=0; +var _94=0; +if(_91.length==1){ +_90=1; +this.xscale=1; +this.minxval=_91[0]; +_92=1*this.options.barWidthFillFraction; +_93=_92/_89; +_94=(1-this.options.barWidthFillFraction)/2; +}else{ +if(this.xrange==1){ +this.xscale=0.5; +}else{ +if(this.xrange==2){ +this.xscale=1/3; +}else{ +this.xscale=(1-_90/this.xrange)/this.xrange; +} +} +_92=_90*this.xscale*this.options.barWidthFillFraction; +_93=_92/_89; +_94=_90*this.xscale*(1-this.options.barWidthFillFraction)/2; +} +this.minxdelta=_90; +this.bars=new Array(); +var i=0; +for(var _95 in this.datasets){ +var _96=this.datasets[_95]; +if(PlotKit.Base.isFuncLike(_96)){ +continue; +} +for(var j=0;j<_96.length;j++){ +var _98=_96[j]; +var _99={x:((parseFloat(_98[0])-this.minxval)*this.xscale)+(i*_93)+_94,y:1-((parseFloat(_98[1])-this.minyval)*this.yscale),w:_93,h:((parseFloat(_98[1])-this.minyval)*this.yscale),xval:parseFloat(_98[0]),yval:parseFloat(_98[1]),name:_95}; +if((_99.x>=0)&&(_99.x<=1)&&(_99.y>=0)&&(_99.y<=1)){ +this.bars.push(_99); +} +} +i++; +} +}; +PlotKit.Layout.prototype._evaluateHorizBarCharts=function(){ +var _100=PlotKit.Base.items; +var _101=_100(this.datasets).length; +var _102=10000000; +var _103=this._uniqueXValues(); +for(var i=1;i<_103.length;i++){ +_102=Math.min(Math.abs(_103[i]-_103[i-1]),_102); +} +var _104=0; +var _105=0; +var _106=0; +if(_103.length==1){ +_102=1; +this.xscale=1; +this.minxval=_103[0]; +_104=1*this.options.barWidthFillFraction; +_105=_104/_101; +_106=(1-this.options.barWidthFillFraction)/2; +}else{ +this.xscale=(1-_102/this.xrange)/this.xrange; +_104=_102*this.xscale*this.options.barWidthFillFraction; +_105=_104/_101; +_106=_102*this.xscale*(1-this.options.barWidthFillFraction)/2; +} +this.minxdelta=_102; +this.bars=new Array(); +var i=0; +for(var _107 in this.datasets){ +var _108=this.datasets[_107]; +if(PlotKit.Base.isFuncLike(_108)){ +continue; +} +for(var j=0;j<_108.length;j++){ +var item=_108[j]; +var rect={y:((parseFloat(item[0])-this.minxval)*this.xscale)+(i*_105)+_106,x:0,h:_105,w:((parseFloat(item[1])-this.minyval)*this.yscale),xval:parseFloat(item[0]),yval:parseFloat(item[1]),name:_107}; +if(rect.y<=0){ +rect.y=0; +} +if(rect.y>=1){ +rect.y=1; +} +if((rect.x>=0)&&(rect.x<=1)){ +this.bars.push(rect); +} +} +i++; +} +}; +PlotKit.Layout.prototype._evaluateLineCharts=function(){ +var _111=PlotKit.Base.items; +var _112=_111(this.datasets).length; +this.points=new Array(); +var i=0; +for(var _113 in this.datasets){ +var _114=this.datasets[_113]; +if(PlotKit.Base.isFuncLike(_114)){ +continue; +} +_114.sort(function(a,b){ +return compare(parseFloat(a[0]),parseFloat(b[0])); +}); +for(var j=0;j<_114.length;j++){ +var item=_114[j]; +var _117={x:((parseFloat(item[0])-this.minxval)*this.xscale),y:1-((parseFloat(item[1])-this.minyval)*this.yscale),xval:parseFloat(item[0]),yval:parseFloat(item[1]),name:_113}; +if(_117.y<=0){ +_117.y=0; +} +if(_117.y>=1){ +_117.y=1; +} +if((_117.x>=0)&&(_117.x<=1)){ +this.points.push(_117); +} +} +i++; +} +}; +PlotKit.Layout.prototype._evaluatePieCharts=function(){ +var _118=PlotKit.Base.items; +var sum=MochiKit.Iter.sum; +var _120=MochiKit.Base.itemgetter; +var _121=_118(this.datasets).length; +var _122=_118(this.datasets)[0][1]; +var _123=sum(map(_120(1),_122)); +this.slices=new Array(); +var _124=0; +for(var i=0;i<_122.length;i++){ +var _125=_122[i][1]/_123; +var _126=_124*Math.PI*2; +var _127=(_124+_125)*Math.PI*2; +var _128={fraction:_125,xval:_122[i][0],yval:_122[i][1],startAngle:_126,endAngle:_127}; +if(_122[i][1]!=0){ +this.slices.push(_128); +} +_124+=_125; +} +}; +PlotKit.Layout.prototype._evaluateLineTicksForXAxis=function(){ +var _129=MochiKit.Base.isUndefinedOrNull; +if(this.options.xTicks){ +this.xticks=new Array(); +var _130=function(tick){ +var _132=tick.label; +if(_129(_132)){ +_132=tick.v.toString(); +} +var pos=this.xscale*(tick.v-this.minxval); +if((pos>=0)&&(pos<=1)){ +this.xticks.push([pos,_132]); +} +}; +MochiKit.Iter.forEach(this.options.xTicks,bind(_130,this)); +}else{ +if(this.options.xNumberOfTicks){ +var _134=this._uniqueXValues(); +var _135=this.xrange/this.options.xNumberOfTicks; +var _136=0; +this.xticks=new Array(); +for(var i=0;i<=_134.length;i++){ +if((_134[i]-this.minxval)>=(_136*_135)){ +var pos=this.xscale*(_134[i]-this.minxval); +if((pos>1)||(pos<0)){ +continue; +} +this.xticks.push([pos,_134[i]]); +_136++; +} +if(_136>this.options.xNumberOfTicks){ +break; +} +} +} +} +}; +PlotKit.Layout.prototype._evaluateLineTicksForYAxis=function(){ +var _137=MochiKit.Base.isUndefinedOrNull; +if(this.options.yTicks){ +this.yticks=new Array(); +var _138=function(tick){ +var _139=tick.label; +if(_137(_139)){ +_139=tick.v.toString(); +} +var pos=1-(this.yscale*(tick.v-this.minyval)); +if((pos>=0)&&(pos<=1)){ +this.yticks.push([pos,_139]); +} +}; +MochiKit.Iter.forEach(this.options.yTicks,bind(_138,this)); +}else{ +if(this.options.yNumberOfTicks){ +this.yticks=new Array(); +var _140=PlotKit.Base.roundInterval; +var prec=this.options.yTickPrecision; +var _142=_140(this.yrange,this.options.yNumberOfTicks,prec); +for(var i=0;i<=this.options.yNumberOfTicks;i++){ +var yval=this.minyval+(i*_142); +var pos=1-((yval-this.minyval)*this.yscale); +if((pos>1)||(pos<0)){ +continue; +} +this.yticks.push([pos,MochiKit.Format.roundToFixed(yval,prec)]); +} +} +} +}; +PlotKit.Layout.prototype._evaluateLineTicks=function(){ +this._evaluateLineTicksForXAxis(); +this._evaluateLineTicksForYAxis(); +}; +PlotKit.Layout.prototype._evaluateBarTicks=function(){ +this._evaluateLineTicks(); +var _144=function(tick){ +return [tick[0]+(this.minxdelta*this.xscale)/2,tick[1]]; +}; +this.xticks=MochiKit.Base.map(bind(_144,this),this.xticks); +if(this.options.barOrientation=="horizontal"){ +var _145=this.xticks; +this.xticks=this.yticks; +this.yticks=_145; +var _146=function(tick){ +return [1-tick[0],tick[1]]; +}; +this.xticks=MochiKit.Base.map(_146,this.xticks); +} +}; +PlotKit.Layout.prototype._evaluatePieTicks=function(){ +var _147=MochiKit.Base.isUndefinedOrNull; +var _148=MochiKit.Format.numberFormatter("#%"); +this.xticks=new Array(); +if(this.options.xTicks){ +var _149=new Array(); +for(var i=0;i0){ +this.__init__(_158,_159,_160); +} +}; +PlotKit.CanvasRenderer.prototype.__init__=function(_161,_162,_163){ +var _164=MochiKit.Base.isUndefinedOrNull; +var _165=MochiKit.Color.Color; +this.options={"drawBackground":true,"backgroundColor":_165.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"strokeColor":_165.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_165.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_165.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true}; +MochiKit.Base.update(this.options,_163?_163:{}); +this.layout=_162; +this.element=MochiKit.DOM.getElement(_161); +this.container=this.element.parentNode; +this.isIE=PlotKit.Base.excanvasSupported(); +if(this.isIE&&!_164(G_vmlCanvasManager)){ +this.IEDelay=0.5; +this.maxTries=5; +this.renderDelay=null; +this.clearDelay=null; +this.element=G_vmlCanvasManager.initElement(this.element); +} +this.height=this.element.height; +this.width=this.element.width; +if(_164(this.element)){ +throw "CanvasRenderer() - passed canvas is not found"; +} +if(!this.isIE&&!(PlotKit.CanvasRenderer.isSupported(this.element))){ +throw "CanvasRenderer() - Canvas is not supported."; +} +if(_164(this.container)||(this.container.nodeName.toLowerCase()!="div")){ +throw "CanvasRenderer() - needs to be enclosed in
"; +} +this.xlabels=new Array(); +this.ylabels=new Array(); +this.isFirstRender=true; +this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom}; +MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}}); +}; +PlotKit.CanvasRenderer.prototype.render=function(){ +if(this.isIE){ +try{ +if(this.renderDelay){ +this.renderDelay.cancel(); +this.renderDelay=null; +} +var _166=this.element.getContext("2d"); +} +catch(e){ +this.isFirstRender=false; +if(this.maxTries-->0){ +this.renderDelay=MochiKit.Async.wait(this.IEDelay); +this.renderDelay.addCallback(bind(this.render,this)); +} +return; +} +} +if(this.options.drawBackground){ +this._renderBackground(); +} +if(this.layout.style=="bar"){ +this._renderBarChart(); +this._renderBarAxis(); +}else{ +if(this.layout.style=="pie"){ +this._renderPieChart(); +this._renderPieAxis(); +}else{ +if(this.layout.style=="line"){ +this._renderLineChart(); +this._renderLineAxis(); +} +} +} +}; +PlotKit.CanvasRenderer.prototype._renderBarChartWrap=function(data,_168){ +var _169=this.element.getContext("2d"); +var _170=this.options.colorScheme.length; +var _171=this.options.colorScheme; +var _172=MochiKit.Base.keys(this.layout.datasets); +var _173=_172.length; +for(var i=0;i<_173;i++){ +var _174=_172[i]; +var _175=_171[i%_170]; +_169.save(); +_169.fillStyle=_175.toRGBString(); +if(this.options.strokeColor){ +_169.strokeStyle=this.options.strokeColor.toRGBString(); +}else{ +if(this.options.strokeColorTransform){ +_169.strokeStyle=_175[this.options.strokeColorTransform]().toRGBString(); +} +} +_169.lineWidth=this.options.strokeWidth; +var _176=function(obj){ +if(obj.name==_174){ +_168(_169,obj); +} +}; +MochiKit.Iter.forEach(data,bind(_176,this)); +_169.restore(); +} +}; +PlotKit.CanvasRenderer.prototype._renderBarChart=function(){ +var bind=MochiKit.Base.bind; +var _178=function(_179,bar){ +var x=this.area.w*bar.x+this.area.x; +var y=this.area.h*bar.y+this.area.y; +var w=this.area.w*bar.w; +var h=this.area.h*bar.h; +if((w<1)||(h<1)){ +return; +} +if(this.options.shouldFill){ +_179.fillRect(x,y,w,h); +} +if(this.options.shouldStroke){ +_179.strokeRect(x,y,w,h); +} +}; +this._renderBarChartWrap(this.layout.bars,bind(_178,this)); +}; +PlotKit.CanvasRenderer.prototype._renderLineChart=function(){ +var _182=this.element.getContext("2d"); +var _183=this.options.colorScheme.length; +var _184=this.options.colorScheme; +var _185=MochiKit.Base.keys(this.layout.datasets); +var _186=_185.length; +var bind=MochiKit.Base.bind; +var _187=MochiKit.Base.partial; +for(var i=0;i<_186;i++){ +var _188=_185[i]; +var _189=_184[i%_183]; +var _190=this.options.strokeColorTransform; +_182.save(); +_182.fillStyle=_189.toRGBString(); +if(this.options.strokeColor){ +_182.strokeStyle=this.options.strokeColor.toRGBString(); +}else{ +if(this.options.strokeColorTransform){ +_182.strokeStyle=_189[_190]().toRGBString(); +} +} +_182.lineWidth=this.options.strokeWidth; +var _191=function(ctx){ +ctx.beginPath(); +ctx.moveTo(this.area.x,this.area.y+this.area.h); +var _193=function(ctx_,_195){ +if(_195.name==_188){ +ctx_.lineTo(this.area.w*_195.x+this.area.x,this.area.h*_195.y+this.area.y); +} +}; +MochiKit.Iter.forEach(this.layout.points,_187(_193,ctx),this); +ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y); +ctx.lineTo(this.area.x,this.area.y+this.area.h); +ctx.closePath(); +}; +if(this.options.shouldFill){ +bind(_191,this)(_182); +_182.fill(); +} +if(this.options.shouldStroke){ +bind(_191,this)(_182); +_182.stroke(); +} +_182.restore(); +} +}; +PlotKit.CanvasRenderer.prototype._renderPieChart=function(){ +var _196=this.element.getContext("2d"); +var _197=this.options.colorScheme.length; +var _198=this.layout.slices; +var _199=this.area.x+this.area.w*0.5; +var _200=this.area.y+this.area.h*0.5; +var _201=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius); +if(this.isIE){ +_199=parseInt(_199); +_200=parseInt(_200); +_201=parseInt(_201); +} +for(var i=0;i<_198.length;i++){ +var _202=this.options.colorScheme[i%_197]; +_196.save(); +_196.fillStyle=_202.toRGBString(); +var _203=function(){ +_196.beginPath(); +_196.moveTo(_199,_200); +_196.arc(_199,_200,_201,_198[i].startAngle-Math.PI/2,_198[i].endAngle-Math.PI/2,false); +_196.lineTo(_199,_200); +_196.closePath(); +}; +if(Math.abs(_198[i].startAngle-_198[i].endAngle)>0.001){ +if(this.options.shouldFill){ +_203(); +_196.fill(); +} +if(this.options.shouldStroke){ +_203(); +_196.lineWidth=this.options.strokeWidth; +if(this.options.strokeColor){ +_196.strokeStyle=this.options.strokeColor.toRGBString(); +}else{ +if(this.options.strokeColorTransform){ +_196.strokeStyle=_202[this.options.strokeColorTransform]().toRGBString(); +} +} +_196.stroke(); +} +} +_196.restore(); +} +}; +PlotKit.CanvasRenderer.prototype._renderBarAxis=function(){ +this._renderAxis(); +}; +PlotKit.CanvasRenderer.prototype._renderLineAxis=function(){ +this._renderAxis(); +}; +PlotKit.CanvasRenderer.prototype._renderAxis=function(){ +if(!this.options.drawXAxis&&!this.options.drawYAxis){ +return; +} +var _204=this.element.getContext("2d"); +var _205={"style":{"position":"absolute","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}}; +_204.save(); +_204.strokeStyle=this.options.axisLineColor.toRGBString(); +_204.lineWidth=this.options.axisLineWidth; +if(this.options.drawYAxis){ +if(this.layout.yticks){ +var _206=function(tick){ +if(typeof (tick)=="function"){ +return; +} +var x=this.area.x; +var y=this.area.y+tick[0]*this.area.h; +_204.beginPath(); +_204.moveTo(x,y); +_204.lineTo(x-this.options.axisTickSize,y); +_204.closePath(); +_204.stroke(); +var _207=DIV(_205,tick[1]); +_207.style.top=(y-this.options.axisLabelFontSize)+"px"; +_207.style.left=(x-this.options.padding.left-this.options.axisTickSize)+"px"; +_207.style.textAlign="right"; +_207.style.width=(this.options.padding.left-this.options.axisTickSize*2)+"px"; +MochiKit.DOM.appendChildNodes(this.container,_207); +this.ylabels.push(_207); +}; +MochiKit.Iter.forEach(this.layout.yticks,bind(_206,this)); +} +_204.beginPath(); +_204.moveTo(this.area.x,this.area.y); +_204.lineTo(this.area.x,this.area.y+this.area.h); +_204.closePath(); +_204.stroke(); +} +if(this.options.drawXAxis){ +if(this.layout.xticks){ +var _206=function(tick){ +if(typeof (dataset)=="function"){ +return; +} +var x=this.area.x+tick[0]*this.area.w; +var y=this.area.y+this.area.h; +_204.beginPath(); +_204.moveTo(x,y); +_204.lineTo(x,y+this.options.axisTickSize); +_204.closePath(); +_204.stroke(); +var _208=DIV(_205,tick[1]); +_208.style.top=(y+this.options.axisTickSize)+"px"; +_208.style.left=(x-this.options.axisLabelWidth/2)+"px"; +_208.style.textAlign="center"; +_208.style.width=this.options.axisLabelWidth+"px"; +MochiKit.DOM.appendChildNodes(this.container,_208); +this.xlabels.push(_208); +}; +MochiKit.Iter.forEach(this.layout.xticks,bind(_206,this)); +} +_204.beginPath(); +_204.moveTo(this.area.x,this.area.y+this.area.h); +_204.lineTo(this.area.x+this.area.w,this.area.y+this.area.h); +_204.closePath(); +_204.stroke(); +} +_204.restore(); +}; +PlotKit.CanvasRenderer.prototype._renderPieAxis=function(){ +if(!this.options.drawXAxis){ +return; +} +if(this.layout.xticks){ +var _209=new Array(); +for(var i=0;iMath.PI*2){ +_216=_216-Math.PI*2; +}else{ +if(_216<0){ +_216=_216+Math.PI*2; +} +} +var _217=_210+Math.sin(_216)*(_212+10); +var _218=_211-Math.cos(_216)*(_212+10); +var _219={"position":"absolute","zIndex":11,"width":_213+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()}; +if(_216<=Math.PI*0.5){ +_219["textAlign"]="left"; +_219["verticalAlign"]="top"; +_219["left"]=_217+"px"; +_219["top"]=(_218-this.options.axisLabelFontSize)+"px"; +}else{ +if((_216>Math.PI*0.5)&&(_216<=Math.PI)){ +_219["textAlign"]="left"; +_219["verticalAlign"]="bottom"; +_219["left"]=_217+"px"; +_219["top"]=_218+"px"; +}else{ +if((_216>Math.PI)&&(_216<=Math.PI*1.5)){ +_219["textAlign"]="right"; +_219["verticalAlign"]="bottom"; +_219["left"]=(_217-_213)+"px"; +_219["top"]=_218+"px"; +}else{ +_219["textAlign"]="right"; +_219["verticalAlign"]="bottom"; +_219["left"]=(_217-_213)+"px"; +_219["top"]=(_218-this.options.axisLabelFontSize)+"px"; +} +} +} +var _220=DIV({"style":_219},this.layout.xticks[i][1]); +this.xlabels.push(_220); +MochiKit.DOM.appendChildNodes(this.container,_220); +} +} +}; +PlotKit.CanvasRenderer.prototype._renderBackground=function(){ +var _221=this.element.getContext("2d"); +_221.save(); +_221.fillStyle=this.options.backgroundColor.toRGBString(); +_221.fillRect(0,0,this.width,this.height); +_221.restore(); +}; +PlotKit.CanvasRenderer.prototype.clear=function(){ +if(this.isIE){ +try{ +if(this.clearDelay){ +this.clearDelay.cancel(); +this.clearDelay=null; +} +var _222=this.element.getContext("2d"); +} +catch(e){ +this.isFirstRender=false; +this.clearDelay=MochiKit.Async.wait(this.IEDelay); +this.clearDelay.addCallback(bind(this.clear,this)); +return; +} +} +var _222=this.element.getContext("2d"); +_222.clearRect(0,0,this.width,this.height); +MochiKit.Iter.forEach(this.xlabels,MochiKit.DOM.removeElement); +MochiKit.Iter.forEach(this.ylabels,MochiKit.DOM.removeElement); +this.xlabels=new Array(); +this.ylabels=new Array(); +}; +PlotKit.CanvasRenderer.prototype._initialiseEvents=function(){ +var _223=MochiKit.Signal.connect; +var bind=MochiKit.Base.bind; +_223(this.element,"onclick",bind(this.onclick,this)); +}; +PlotKit.CanvasRenderer.prototype._resolveObject=function(e){ +var x=(e.mouse().page.x-PlotKit.Base.findPosX(this.element)-this.area.x)/this.area.w; +var y=(e.mouse().page.y-PlotKit.Base.findPosY(this.element)-this.area.y)/this.area.h; +var _225=this.layout.hitTest(x,y); +if(_225){ +return _225; +} +return null; +}; +PlotKit.CanvasRenderer.prototype._createEventObject=function(_226,e){ +if(_226==null){ +return null; +} +e.chart=_226; +return e; +}; +PlotKit.CanvasRenderer.prototype.onclick=function(e){ +var _227=this._resolveObject(e); +var _228=this._createEventObject(_227,e); +if(_228!=null){ +MochiKit.Signal.signal(this,"onclick",_228); +} +}; +PlotKit.CanvasRenderer.prototype.onmouseover=function(e){ +var _229=this._resolveObject(e); +var _230=this._createEventObject(_229,e); +if(_230!=null){ +signal(this,"onmouseover",_230); +} +}; +PlotKit.CanvasRenderer.prototype.onmouseout=function(e){ +var _231=this._resolveObject(e); +var _232=this._createEventObject(_231,e); +if(_232==null){ +signal(this,"onmouseout",e); +}else{ +signal(this,"onmouseout",_232); +} +}; +PlotKit.CanvasRenderer.prototype.onmousemove=function(e){ +var _233=this._resolveObject(e); +var _234=this._createEventObject(_233,e); +if((_233==null)&&(this.event_isinside==null)){ +return; +} +if((_233!=null)&&(this.event_isinside==null)){ +signal(this,"onmouseover",_234); +} +if((_233==null)&&(this.event_isinside!=null)){ +signal(this,"onmouseout",_234); +} +if((_233!=null)&&(this.event_isinside!=null)){ +signal(this,"onmousemove",_234); +} +this.event_isinside=_233; +}; +PlotKit.CanvasRenderer.isSupported=function(_235){ +var _236=null; +try{ +if(MochiKit.Base.isUndefinedOrNull(_235)){ +_236=MochiKit.DOM.CANVAS({}); +}else{ +_236=MochiKit.DOM.getElement(_235); +} +var _237=_236.getContext("2d"); +} +catch(e){ +var ie=navigator.appVersion.match(/MSIE (\d\.\d)/); +var _239=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1); +if((!ie)||(ie[1]<6)||(_239)){ +return false; +} +return true; +} +return true; +}; +PlotKit.Canvas={}; +PlotKit.Canvas.CanvasRenderer=PlotKit.CanvasRenderer; +PlotKit.Canvas.EXPORT=["CanvasRenderer"]; +PlotKit.Canvas.EXPORT_OK=["CanvasRenderer"]; +PlotKit.Canvas.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +PlotKit.Canvas.__new__(); +MochiKit.Base._exportSymbols(this,PlotKit.Canvas); +try{ +if(typeof (PlotKit.Layout)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Layout"; +} +PlotKit.SVGRenderer=function(_240,_241,_242){ +if(arguments.length>0){ +this.__init__(_240,_241,_242); +} +}; +PlotKit.SVGRenderer.NAME="PlotKit.SVGRenderer"; +PlotKit.SVGRenderer.VERSION=PlotKit.VERSION; +PlotKit.SVGRenderer.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.SVGRenderer.toString=function(){ +return this.__repr__(); +}; +PlotKit.SVGRenderer.SVGNS="http://www.w3.org/2000/svg"; +PlotKit.SVGRenderer.prototype.__init__=function(_243,_244,_245){ +var _246=MochiKit.Base.isUndefinedOrNull; +this.options={"drawBackground":true,"backgroundColor":Color.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"strokeColor":Color.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"axisLabelUseDiv":true,"pieRadius":0.4,"enableEvents":true}; +MochiKit.Base.update(this.options,_245?_245:{}); +this.layout=_244; +this.element=MochiKit.DOM.getElement(_243); +this.container=this.element.parentNode; +this.height=parseInt(this.element.getAttribute("height")); +this.width=parseInt(this.element.getAttribute("width")); +this.document=document; +this.root=this.element; +try{ +this.document=this.element.getSVGDocument(); +this.root=_246(this.document.documentElement)?this.element:this.document.documentElement; +} +catch(e){ +} +this.element.style.zIndex=1; +if(_246(this.element)){ +throw "SVGRenderer() - passed SVG object is not found"; +} +if(_246(this.container)||this.container.nodeName.toLowerCase()!="div"){ +throw "SVGRenderer() - No DIV's around the SVG."; +} +this.xlabels=new Array(); +this.ylabels=new Array(); +this.defs=this.createSVGElement("defs"); +this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom}; +MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}}); +}; +PlotKit.SVGRenderer.prototype.render=function(){ +if(this.options.drawBackground){ +this._renderBackground(); +} +if(this.layout.style=="bar"){ +this._renderBarChart(); +this._renderBarAxis(); +}else{ +if(this.layout.style=="pie"){ +this._renderPieChart(); +this._renderPieAxis(); +}else{ +if(this.layout.style=="line"){ +this._renderLineChart(); +this._renderLineAxis(); +} +} +} +}; +PlotKit.SVGRenderer.prototype._renderBarOrLine=function(data,_247,_248,_249){ +var _250=this.options.colorScheme.length; +var _251=this.options.colorScheme; +var _252=MochiKit.Base.keys(this.layout.datasets); +var _253=_252.length; +for(var i=0;i<_253;i++){ +var _254=_252[i]; +var _255=new Array(); +var _256=_251[i%_250]; +if(this.options.shouldFill){ +_255["fill"]=_256.toRGBString(); +}else{ +_255["fill"]="none"; +} +if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){ +if(this.options.strokeColor){ +_255["stroke"]=this.options.strokeColor.toRGBString(); +}else{ +if(this.options.strokeColorTransform){ +_255["stroke"]=_256[this.options.strokeColorTransform]().toRGBString(); +} +} +_255["strokeWidth"]=this.options.strokeWidth; +} +if(_248){ +_248(_255); +} +var _257=function(obj){ +if(obj.name==_254){ +_247(_255,obj); +} +}; +MochiKit.Iter.forEach(data,bind(_257,this)); +if(_249){ +_249(_255); +} +} +}; +PlotKit.SVGRenderer.prototype._renderBarChart=function(){ +var bind=MochiKit.Base.bind; +var _258=function(_259,bar){ +var x=this.area.w*bar.x+this.area.x; +var y=this.area.h*bar.y+this.area.y; +var w=this.area.w*bar.w; +var h=this.area.h*bar.h; +this._drawRect(x,y,w,h,_259); +}; +this._renderBarOrLine(this.layout.bars,bind(_258,this)); +}; +PlotKit.SVGRenderer.prototype._renderLineChart=function(){ +var bind=MochiKit.Base.bind; +var _260=function(_261,_262){ +this._tempPointsBuffer+=(this.area.w*_262.x+this.area.x)+","+(this.area.h*_262.y+this.area.y)+" "; +}; +var _263=function(_264){ +this._tempPointsBuffer=""; +this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" "; +}; +var _265=function(_266){ +this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y); +_266["points"]=this._tempPointsBuffer; +var elem=this.createSVGElement("polygon",_266); +this.root.appendChild(elem); +}; +this._renderBarOrLine(this.layout.points,bind(_260,this),bind(_263,this),bind(_265,this)); +}; +PlotKit.SVGRenderer.prototype._renderPieChart=function(){ +var _268=this.options.colorScheme.length; +var _269=this.layout.slices; +var _270=this.area.x+this.area.w*0.5; +var _271=this.area.y+this.area.h*0.5; +var _272=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius); +if(_269.length==1&&(Math.abs(_269[0].startAngle)-Math.abs(_269[0].endAngle)<0.1)){ +var _273={"cx":_270,"cy":_271,"r":_272}; +var _274=this.options.colorScheme[0]; +if(this.options.shouldFill){ +_273["fill"]=_274.toRGBString(); +}else{ +_273["fill"]="none"; +} +if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){ +if(this.options.strokeColor){ +_273["stroke"]=this.options.strokeColor.toRGBString(); +}else{ +if(this.options.strokeColorTransform){ +_273["stroke"]=_274[this.options.strokeColorTransform]().toRGBString(); +} +} +_273["style"]="stroke-width: "+this.options.strokeWidth; +} +this.root.appendChild(this.createSVGElement("circle",_273)); +return; +} +for(var i=0;i<_269.length;i++){ +var _273=new Array(); +var _274=this.options.colorScheme[i%_268]; +if(this.options.shouldFill){ +_273["fill"]=_274.toRGBString(); +}else{ +_273["fill"]="none"; +} +if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){ +if(this.options.strokeColor){ +_273["stroke"]=this.options.strokeColor.toRGBString(); +}else{ +if(this.options.strokeColorTransform){ +_273["stroke"]=_274[this.options.strokeColorTransform]().toRGBString(); +} +} +_273["style"]="stroke-width:"+this.options.strokeWidth; +} +var _275=0; +if(Math.abs(_269[i].endAngle-_269[i].startAngle)>Math.PI){ +_275=1; +} +var x1=Math.cos(_269[i].startAngle-Math.PI/2)*_272; +var y1=Math.sin(_269[i].startAngle-Math.PI/2)*_272; +var x2=Math.cos(_269[i].endAngle-Math.PI/2)*_272; +var y2=Math.sin(_269[i].endAngle-Math.PI/2)*_272; +var rx=x2-x1; +var ry=y2-y1; +var _282="M"+_270+","+_271+" "; +_282+="l"+x1+","+y1+" "; +_282+="a"+_272+","+_272+" 0 "+_275+",1 "+rx+","+ry+" z"; +_273["d"]=_282; +var elem=this.createSVGElement("path",_273); +this.root.appendChild(elem); +} +}; +PlotKit.SVGRenderer.prototype._renderBarAxis=function(){ +this._renderAxis(); +}; +PlotKit.SVGRenderer.prototype._renderLineAxis=function(){ +this._renderAxis(); +}; +PlotKit.SVGRenderer.prototype._renderAxis=function(){ +if(!this.options.drawXAxis&&!this.options.drawYAxis){ +return; +} +var _283={"style":{"position":"absolute","textAlign":"center","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}}; +var _284={"stroke":this.options.axisLineColor.toRGBString(),"strokeWidth":this.options.axisLineWidth}; +if(this.options.drawYAxis){ +if(this.layout.yticks){ +var _285=function(tick){ +var x=this.area.x; +var y=this.area.y+tick[0]*this.area.h; +this._drawLine(x,y,x-3,y,_284); +if(this.options.axisLabelUseDiv){ +var _286=DIV(_283,tick[1]); +_286.style.top=(y-this.options.axisLabelFontSize)+"px"; +_286.style.left=(x-this.options.padding.left+this.options.axisTickSize)+"px"; +_286.style.textAlign="left"; +_286.style.width=(this.options.padding.left-3)+"px"; +MochiKit.DOM.appendChildNodes(this.container,_286); +this.ylabels.push(_286); +}else{ +var _287={y:y+3,x:(x-this.options.padding.left+3),width:(this.options.padding.left-this.options.axisTickSize)+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString()}; +var _286=this.createSVGElement("text",_287); +_286.appendChild(this.document.createTextNode(tick[1])); +this.root.appendChild(_286); +} +}; +MochiKit.Iter.forEach(this.layout.yticks,bind(_285,this)); +} +this._drawLine(this.area.x,this.area.y,this.area.x,this.area.y+this.area.h,_284); +} +if(this.options.drawXAxis){ +if(this.layout.xticks){ +var _285=function(tick){ +var x=this.area.x+tick[0]*this.area.w; +var y=this.area.y+this.area.h; +this._drawLine(x,y,x,y+this.options.axisTickSize,_284); +if(this.options.axisLabelUseDiv){ +var _288=DIV(_283,tick[1]); +_288.style.top=(y+this.options.axisTickSize)+"px"; +_288.style.left=(x-this.options.axisLabelWidth/2)+"px"; +_288.style.textAlign="center"; +_288.style.width=this.options.axisLabelWidth+"px"; +MochiKit.DOM.appendChildNodes(this.container,_288); +this.xlabels.push(_288); +}else{ +var _289={y:(y+this.options.axisTickSize+this.options.axisLabelFontSize),x:x-3,width:this.options.axisLabelWidth+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString(),textAnchor:"middle"}; +var _288=this.createSVGElement("text",_289); +_288.appendChild(this.document.createTextNode(tick[1])); +this.root.appendChild(_288); +} +}; +MochiKit.Iter.forEach(this.layout.xticks,bind(_285,this)); +} +this._drawLine(this.area.x,this.area.y+this.area.h,this.area.x+this.area.w,this.area.y+this.area.h,_284); +} +}; +PlotKit.SVGRenderer.prototype._renderPieAxis=function(){ +if(this.layout.xticks){ +var _290=new Array(); +for(var i=0;iMath.PI*2){ +_297=_297-Math.PI*2; +}else{ +if(_297<0){ +_297=_297+Math.PI*2; +} +} +var _298=_291+Math.sin(_297)*(_293+10); +var _299=_292-Math.cos(_297)*(_293+10); +var _300={"position":"absolute","zIndex":11,"width":_294+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()}; +var _301={"width":_294+"px","fontSize":this.options.axisLabelFontSize+"px","height":(this.options.axisLabelFontSize+3)+"px","fill":this.options.axisLabelColor.toRGBString()}; +if(_297<=Math.PI*0.5){ +MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"top","left":_298+"px","top":(_299-this.options.axisLabelFontSize)+"px"}); +MochiKit.Base.update(_301,{"x":_298,"y":(_299-this.options.axisLabelFontSize),"textAnchor":"left"}); +}else{ +if((_297>Math.PI*0.5)&&(_297<=Math.PI)){ +MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"bottom","left":_298+"px","top":_299+"px"}); +MochiKit.Base.update(_301,{"textAnchor":"left","x":_298,"y":_299}); +}else{ +if((_297>Math.PI)&&(_297<=Math.PI*1.5)){ +MochiKit.Base.update(_300,{"textAlign":"right","verticalAlign":"bottom","left":_298+"px","top":_299+"px"}); +MochiKit.Base.update(_301,{"textAnchor":"right","x":_298-_294,"y":_299}); +}else{ +MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"bottom","left":_298+"px","top":_299+"px"}); +MochiKit.Base.update(_301,{"textAnchor":"left","x":_298-_294,"y":_299-this.options.axisLabelFontSize}); +} +} +} +if(this.options.axisLabelUseDiv){ +var _302=DIV({"style":_300},this.layout.xticks[i][1]); +this.xlabels.push(_302); +MochiKit.DOM.appendChildNodes(this.container,_302); +}else{ +var _302=this.createSVGElement("text",_301); +_302.appendChild(this.document.createTextNode(this.layout.xticks[i][1])); +this.root.appendChild(_302); +} +} +} +}; +PlotKit.SVGRenderer.prototype._renderBackground=function(){ +var opts={"stroke":"none","fill":this.options.backgroundColor.toRGBString()}; +this._drawRect(0,0,this.width,this.height,opts); +}; +PlotKit.SVGRenderer.prototype._drawRect=function(x,y,w,h,_304){ +var _305={x:x+"px",y:y+"px",width:w+"px",height:h+"px"}; +if(_304){ +MochiKit.Base.update(_305,_304); +} +var elem=this.createSVGElement("rect",_305); +this.root.appendChild(elem); +}; +PlotKit.SVGRenderer.prototype._drawLine=function(x1,y1,x2,y2,_306){ +var _307={x1:x1+"px",y1:y1+"px",x2:x2+"px",y2:y2+"px"}; +if(_306){ +MochiKit.Base.update(_307,_306); +} +var elem=this.createSVGElement("line",_307); +this.root.appendChild(elem); +}; +PlotKit.SVGRenderer.prototype.clear=function(){ +while(this.element.firstChild){ +this.element.removeChild(this.element.firstChild); +} +if(this.options.axisLabelUseDiv){ +for(var i=0;i=6)&&(!_313)){ +var _314=_312["width"]?_312["width"]:"100"; +var _315=_312["height"]?_312["height"]:"100"; +var eid=_312["id"]?_312["id"]:"notunique"; +var html=""; +var _318=document.createElement(html); +var _319=_318.getSVGDocument().createElementNS(PlotKit.SVGRenderer.SVGNS,"svg"); +_319.setAttribute("width",_314); +_319.setAttribute("height",_315); +_318.getSVGDocument().appendChild(_319); +return _318; +}else{ +return PlotKit.SVGRenderer.prototype.createSVGElement("svg",_312); +} +}; +PlotKit.SVGRenderer.isSupported=function(){ +var _320=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1); +var _321=navigator.appVersion.match(/MSIE (\d\.\d)/); +var _322=navigator.userAgent.match(/AppleWebKit\/(\d+)/); +var _323=navigator.userAgent.match(/Opera\/(\d*\.\d*)/); +var _324=navigator.userAgent.match(/rv:(\d*\.\d*).*Gecko/); +var _325="http://www.w3.org/TR/SVG11/feature#SVG"; +if(_321&&(_321[1]>=6)&&!_320){ +return document.implementation.hasFeature(_325,"1.1"); +} +if(_323&&(_323[1]>8.9)){ +return true; +} +if(_324&&(_324>1.7)){ +return true; +} +return false; +}; +PlotKit.SVG={}; +PlotKit.SVG.SVGRenderer=PlotKit.SVGRenderer; +PlotKit.SVG.EXPORT=["SVGRenderer"]; +PlotKit.SVG.EXPORT_OK=["SVGRenderer"]; +PlotKit.SVG.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +PlotKit.SVG.__new__(); +MochiKit.Base._exportSymbols(this,PlotKit.SVG); +try{ +if(typeof (PlotKit.CanvasRenderer)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "SweetCanvas depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, Canvas}"; +} +if(typeof (PlotKit.SweetCanvasRenderer)=="undefined"){ +PlotKit.SweetCanvasRenderer={}; +} +PlotKit.SweetCanvasRenderer=function(_326,_327,_328){ +if(arguments.length>0){ +this.__init__(_326,_327,_328); +} +}; +PlotKit.SweetCanvasRenderer.NAME="PlotKit.SweetCanvasRenderer"; +PlotKit.SweetCanvasRenderer.VERSION=PlotKit.VERSION; +PlotKit.SweetCanvasRenderer.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.SweetCanvasRenderer.toString=function(){ +return this.__repr__(); +}; +PlotKit.SweetCanvasRenderer.prototype=new PlotKit.CanvasRenderer(); +PlotKit.SweetCanvasRenderer.prototype.constructor=PlotKit.SweetCanvasRenderer; +PlotKit.SweetCanvasRenderer.__super__=PlotKit.CanvasRenderer.prototype; +PlotKit.SweetCanvasRenderer.prototype.__init__=function(el,_330,opts){ +var _331=PlotKit.Base.officeBlue(); +MochiKit.Base.update(_331,opts); +PlotKit.SweetCanvasRenderer.__super__.__init__.call(this,el,_330,_331); +}; +PlotKit.SweetCanvasRenderer.prototype._renderBarChart=function(){ +var bind=MochiKit.Base.bind; +var _332=Color.blackColor().colorWithAlpha(0.1).toRGBString(); +var _333=function(_334,x,y,w,h){ +_334.fillStyle=_332; +_334.fillRect(x-2,y-2,w+4,h+2); +_334.fillStyle=_332; +_334.fillRect(x-1,y-1,w+2,h+1); +}; +var _335=this.options.colorScheme.length; +var _336=this.options.colorScheme; +var _337=PlotKit.Base.keys(this.layout.datasets); +var _338=_337.length; +var _339=function(name){ +for(var i=0;i<_338;i++){ +if(name==_337[i]){ +return _336[i%_335]; +} +} +return _336[0]; +}; +var _340=function(_341,bar){ +var x=this.area.w*bar.x+this.area.x; +var y=this.area.h*bar.y+this.area.y; +var w=this.area.w*bar.w; +var h=this.area.h*bar.h; +if((w<1)||(h<1)){ +return; +} +_341.save(); +_341.shadowBlur=5; +_341.shadowColor=Color.fromHexString("#888888").toRGBString(); +if(this.isIE){ +_341.save(); +_341.fillStyle="#cccccc"; +_341.fillRect(x-2,y-2,w+4,h+2); +_341.restore(); +}else{ +_333(_341,x,y,w,h); +} +if(this.options.shouldFill){ +_341.fillStyle=_339(bar.name).toRGBString(); +_341.fillRect(x,y,w,h); +} +_341.shadowBlur=0; +_341.strokeStyle=Color.whiteColor().toRGBString(); +_341.lineWidth=2; +if(this.options.shouldStroke){ +_341.strokeRect(x,y,w,h); +} +_341.restore(); +}; +this._renderBarChartWrap(this.layout.bars,bind(_340,this)); +}; +PlotKit.SweetCanvasRenderer.prototype._renderLineChart=function(){ +var _342=this.element.getContext("2d"); +var _343=this.options.colorScheme.length; +var _344=this.options.colorScheme; +var _345=PlotKit.Base.keys(this.layout.datasets); +var _346=_345.length; +var bind=MochiKit.Base.bind; +for(var i=0;i<_346;i++){ +var _347=_345[i]; +var _348=_344[i%_343]; +var _349=this.options.strokeColorTransform; +_342.save(); +var _350=function(ctx){ +ctx.beginPath(); +ctx.moveTo(this.area.x,this.area.y+this.area.h); +var _351=function(ctx_,_352){ +if(_352.name==_347){ +ctx_.lineTo(this.area.w*_352.x+this.area.x,this.area.h*_352.y+this.area.y); +} +}; +MochiKit.Iter.forEach(this.layout.points,partial(_351,ctx),this); +ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y); +ctx.lineTo(this.area.x,this.area.y+this.area.h); +ctx.closePath(); +}; +if(this.options.shouldFill){ +_342.save(); +if(this.isIE){ +_342.fillStyle="#cccccc"; +}else{ +_342.fillStyle=Color.blackColor().colorWithAlpha(0.2).toRGBString(); +} +_342.translate(-1,-2); +bind(_350,this)(_342); +if(this.options.shouldFill){ +_342.fill(); +} +_342.restore(); +} +_342.shadowBlur=5; +_342.shadowColor=Color.fromHexString("#888888").toRGBString(); +_342.fillStyle=_348.toRGBString(); +_342.lineWidth=2; +_342.strokeStyle=Color.whiteColor().toRGBString(); +if(this.options.shouldFill){ +bind(_350,this)(_342); +_342.fill(); +} +if(this.options.shouldStroke){ +bind(_350,this)(_342); +_342.stroke(); +} +_342.restore(); +} +}; +PlotKit.SweetCanvasRenderer.prototype._renderPieChart=function(){ +var _353=this.element.getContext("2d"); +var _354=this.options.colorScheme.length; +var _355=this.layout.slices; +var _356=this.area.x+this.area.w*0.5; +var _357=this.area.y+this.area.h*0.5; +var _358=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius); +if(this.isIE){ +_356=parseInt(_356); +_357=parseInt(_357); +_358=parseInt(_358); +} +if(!this.isIE){ +_353.save(); +var _359=Color.blackColor().colorWithAlpha(0.2); +_353.fillStyle=_359.toRGBString(); +_353.shadowBlur=5; +_353.shadowColor=Color.fromHexString("#888888").toRGBString(); +_353.translate(1,1); +_353.beginPath(); +_353.moveTo(_356,_357); +_353.arc(_356,_357,_358+2,0,Math.PI*2,false); +_353.closePath(); +_353.fill(); +_353.restore(); +} +_353.save(); +_353.strokeStyle=Color.whiteColor().toRGBString(); +_353.lineWidth=2; +for(var i=0;i<_355.length;i++){ +var _360=this.options.colorScheme[i%_354]; +_353.fillStyle=_360.toRGBString(); +var _361=function(){ +_353.beginPath(); +_353.moveTo(_356,_357); +_353.arc(_356,_357,_358,_355[i].startAngle-Math.PI/2,_355[i].endAngle-Math.PI/2,false); +_353.lineTo(_356,_357); +_353.closePath(); +}; +if(Math.abs(_355[i].startAngle-_355[i].endAngle)>0.0001){ +if(this.options.shouldFill){ +_361(); +_353.fill(); +} +if(this.options.shouldStroke){ +_361(); +_353.stroke(); +} +} +} +_353.restore(); +}; +PlotKit.SweetCanvasRenderer.prototype._renderBackground=function(){ +var _362=this.element.getContext("2d"); +if(this.layout.style=="bar"||this.layout.style=="line"){ +_362.save(); +_362.fillStyle=this.options.backgroundColor.toRGBString(); +_362.fillRect(this.area.x,this.area.y,this.area.w,this.area.h); +_362.strokeStyle=this.options.axisLineColor.toRGBString(); +_362.lineWidth=1; +var _363=this.layout.yticks; +var _364=false; +if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){ +_363=this.layout.xticks; +_364=true; +} +for(var i=0;i<_363.length;i++){ +var x1=0; +var y1=0; +var x2=0; +var y2=0; +if(_364){ +x1=_363[i][0]*this.area.w+this.area.x; +y1=this.area.y; +x2=x1; +y2=y1+this.area.h; +}else{ +x1=this.area.x; +y1=_363[i][0]*this.area.h+this.area.y; +x2=x1+this.area.w; +y2=y1; +} +_362.beginPath(); +_362.moveTo(x1,y1); +_362.lineTo(x2,y2); +_362.closePath(); +_362.stroke(); +} +_362.restore(); +}else{ +PlotKit.SweetCanvasRenderer.__super__._renderBackground.call(this); +} +}; +PlotKit.SweetCanvas={}; +PlotKit.SweetCanvas.SweetCanvasRenderer=PlotKit.SweetCanvasRenderer; +PlotKit.SweetCanvas.EXPORT=["SweetCanvasRenderer"]; +PlotKit.SweetCanvas.EXPORT_OK=["SweetCanvasRenderer"]; +PlotKit.SweetCanvas.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +PlotKit.SweetCanvas.__new__(); +MochiKit.Base._exportSymbols(this,PlotKit.SweetCanvas); +try{ +if(typeof (PlotKit.SVGRenderer)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "SweetSVG depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, SVG}"; +} +if(typeof (PlotKit.SweetSVGRenderer)=="undefined"){ +PlotKit.SweetSVGRenderer={}; +} +PlotKit.SweetSVGRenderer=function(_365,_366,_367){ +if(arguments.length>0){ +this.__init__(_365,_366,_367); +} +}; +PlotKit.SweetSVGRenderer.NAME="PlotKit.SweetSVGRenderer"; +PlotKit.SweetSVGRenderer.VERSION=PlotKit.VERSION; +PlotKit.SweetSVGRenderer.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.SweetSVGRenderer.toString=function(){ +return this.__repr__(); +}; +PlotKit.SweetSVGRenderer.prototype=new PlotKit.SVGRenderer(); +PlotKit.SweetSVGRenderer.prototype.constructor=PlotKit.SweetSVGRenderer; +PlotKit.SweetSVGRenderer.__super__=PlotKit.SVGRenderer.prototype; +PlotKit.SweetSVGRenderer.prototype.__init__=function(_368,_369,_370){ +var _371=PlotKit.Base.officeBlue(); +MochiKit.Base.update(_371,_370); +PlotKit.SweetSVGRenderer.__super__.__init__.call(this,_368,_369,_371); +}; +PlotKit.SweetSVGRenderer.prototype._addDropShadowFilter=function(){ +var _372=this.createSVGElement("filter",{x:0,y:0,"id":"dropShadow"}); +var _373=this.createSVGElement("feOffset",{"in":"SourceGraphic","dx":0,"dy":0,"result":"topCopy"}); +var blur=this.createSVGElement("feGaussianBlur",{"in":"SourceAlpha","StdDeviation":2,"result":"shadow"}); +var _375=this.createSVGElement("feOffset",{"in":"shadow","dx":-1,"dy":-2,"result":"movedShadow"}); +var _376=this.createSVGElement("feMerge"); +var _377=this.createSVGElement("feMergeNode",{"in":"topCopy"}); +var _378=this.createSVGElement("feMergeNode",{"in":"movedShadow"}); +_376.appendChild(_377); +_376.appendChild(_378); +_372.appendChild(_373); +_372.appendChild(blur); +_372.appendChild(_375); +_372.appendChild(_376); +this.defs.appendChild(_372); +}; +PlotKit.SweetSVGRenderer.prototype._renderBarChart=function(){ +var bind=MochiKit.Base.bind; +var _379=Color.blackColor().toRGBString(); +var _380="fill:"+_379+";fill-opacity:0.15"; +var _381="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString(); +var _382=function(_383,bar){ +var x=this.area.w*bar.x+this.area.x; +var y=this.area.h*bar.y+this.area.y; +var w=this.area.w*bar.w; +var h=this.area.h*bar.h; +if((w<1)||(h<1)){ +return; +} +_383["style"]=_381; +this._drawRect(x-2,y-1,w+4,h+2,{"style":_380}); +this._drawRect(x,y,w,h,_383); +}; +this._renderBarOrLine(this.layout.bars,bind(_382,this)); +}; +PlotKit.SweetSVGRenderer.prototype._renderLineChart=function(){ +var bind=MochiKit.Base.bind; +var _384=Color.blackColor().toRGBString(); +var _385="fill:"+_384+";fill-opacity:0.15"; +var _386="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString(); +var _387=function(_388,_389){ +this._tempPointsBuffer+=(this.area.w*_389.x+this.area.x)+","+(this.area.h*_389.y+this.area.y)+" "; +}; +var _390=function(_391){ +this._tempPointsBuffer=""; +this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" "; +}; +var _392=function(_393){ +this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y); +_393["points"]=this._tempPointsBuffer; +_393["stroke"]="none"; +_393["transform"]="translate(-2, -1)"; +_393["style"]=_385; +var _394=this.createSVGElement("polygon",_393); +this.root.appendChild(_394); +_393["transform"]=""; +_393["style"]=_386; +var elem=this.createSVGElement("polygon",_393); +this.root.appendChild(elem); +}; +this._renderBarOrLine(this.layout.points,bind(_387,this),bind(_390,this),bind(_392,this)); +}; +PlotKit.SweetSVGRenderer.prototype._renderPieChart=function(){ +var _395=this.area.x+this.area.w*0.5; +var _396=this.area.y+this.area.h*0.5; +var _397=Color.blackColor().toRGBString(); +var _398=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius); +var _399="fill:"+_397+";fill-opacity:0.15"; +var _400=this.createSVGElement("circle",{"style":_399,"cx":_395+1,"cy":_396+1,"r":_398+1}); +this.root.appendChild(_400); +PlotKit.SweetSVGRenderer.__super__._renderPieChart.call(this); +}; +PlotKit.SweetSVGRenderer.prototype._renderBackground=function(){ +var _401={"fill":this.options.backgroundColor.toRGBString(),"stroke":"none"}; +if(this.layout.style=="bar"||this.layout.style=="line"){ +this._drawRect(this.area.x,this.area.y,this.area.w,this.area.h,_401); +var _402=this.layout.yticks; +var _403=false; +if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){ +_402=this.layout.xticks; +_403=true; +} +for(var i=0;i<_402.length;i++){ +var x=0; +var y=0; +var w=0; +var h=0; +if(_403){ +x=_402[i][0]*this.area.w+this.area.x; +y=this.area.y; +w=1; +h=this.area.w; +}else{ +x=this.area.x; +y=_402[i][0]*this.area.h+this.area.y; +w=this.area.w; +h=1; +} +this._drawRect(x,y,w,h,{"fill":this.options.axisLineColor.toRGBString()}); +} +}else{ +PlotKit.SweetSVGRenderer.__super__._renderBackground.call(this); +} +}; +PlotKit.SweetSVG={}; +PlotKit.SweetSVG.SweetSVGRenderer=PlotKit.SweetSVGRenderer; +PlotKit.SweetSVG.EXPORT=["SweetSVGRenderer"]; +PlotKit.SweetSVG.EXPORT_OK=["SweetSVGRenderer"]; +PlotKit.SweetSVG.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +PlotKit.SweetSVG.__new__(); +MochiKit.Base._exportSymbols(this,PlotKit.SweetSVG); +try{ +if(typeof (PlotKit.CanvasRenderer)=="undefined"){ +throw ""; +} +} +catch(e){ +throw "PlotKit.EasyPlot depends on all of PlotKit's components"; +} +if(typeof (PlotKit.EasyPlot)=="undefined"){ +PlotKit.EasyPlot={}; +} +PlotKit.EasyPlot.NAME="PlotKit.EasyPlot"; +PlotKit.EasyPlot.VERSION=PlotKit.VERSION; +PlotKit.EasyPlot.__repr__=function(){ +return "["+this.NAME+" "+this.VERSION+"]"; +}; +PlotKit.EasyPlot.toString=function(){ +return this.__repr__(); +}; +PlotKit.EasyPlot=function(_404,_405,_406,_407){ +this.layout=new Layout(_404,_405); +this.divElem=_406; +this.width=parseInt(_406.getAttribute("width")); +this.height=parseInt(_406.getAttribute("height")); +this.deferredCount=0; +if(this.width<1){ +this.width=this.divElem.width?this.divElem.width:300; +} +if(this.height<1){ +this.height=this.divElem.height?this.divElem.height:300; +} +if(isArrayLike(_407)){ +for(var i=0;i<_407.length;i++){ +if(typeof (_407[i])=="string"){ +this.deferredCount++; +var d=MochiKit.Async.doSimpleXMLHttpRequest(_407[i]); +d.addCallback(MochiKit.Base.bind(PlotKit.EasyPlot.onDataLoaded,this)); +}else{ +if(isArrayLike(_407[i])){ +this.layout.addDataset("data-"+i,_407[i]); +} +} +} +}else{ +if(!isUndefinedOrNull(_407)){ +throw "Passed datasources are not Array like"; +} +} +if(CanvasRenderer.isSupported()){ +this.element=CANVAS({"id":this.divElem.getAttribute("id")+"-canvas","width":this.width,"height":this.height},""); +this.divElem.appendChild(this.element); +this.renderer=new SweetCanvasRenderer(this.element,this.layout,_405); +}else{ +if(SVGRenderer.isSupported()){ +this.element=SVGRenderer.SVG({"id":this.divElem.getAttribute("id")+"-svg","width":this.width,"height":this.height,"version":"1.1","baseProfile":"full"},""); +this.divElem.appendChild(this.element); +this.renderer=new SweetSVGRenderer(this.element,this.layout,_405); +} +} +if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){ +this.layout.evaluate(); +this.renderer.clear(); +this.renderer.render(); +} +}; +PlotKit.EasyPlot.onDataLoaded=function(_409){ +var _410=new Array(); +var _411=_409.responseText.split("\n"); +for(var i=0;i<_411.length;i++){ +var _412=MochiKit.Format.strip(_411[i]); +if((_412.length>1)&&(_412.charAt(0)!="#")){ +_410.push(_412.split(",")); +} +} +this.layout.addDataset("data-ajax-"+this.deferredCount,_410); +this.deferredCount--; +if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){ +this.layout.evaluate(); +this.renderer.clear(); +this.renderer.render(); +} +}; +PlotKit.EasyPlot.prototype.reload=function(){ +this.layout.evaluate(); +this.renderer.clear(); +this.renderer.render(); +}; +PlotKit.EasyPlotModule={}; +PlotKit.EasyPlotModule.EasyPlot=PlotKit.EasyPlot; +PlotKit.EasyPlotModule.EXPORT=["EasyPlot"]; +PlotKit.EasyPlotModule.EXPORT_OK=[]; +PlotKit.EasyPlotModule.__new__=function(){ +var m=MochiKit.Base; +m.nameFunctions(this); +this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; +}; +PlotKit.EasyPlotModule.__new__(); +MochiKit.Base._exportSymbols(this,PlotKit.EasyPlotModule); + + +// Copyright 2006 Dan Vanderkam (danvdk@gmail.com) +// All Rights Reserved. + +/** + * @fileoverview Subclasses various parts of PlotKit to meet the additional + * needs of DateGraph: grid overlays and error bars + */ + +// Subclass PlotKit.Layout to add: +// 1. Sigma/errorBars properties +// 2. Copy error terms for PlotKit.CanvasRenderer._renderLineChart + +/** + * Creates a new DateGraphLayout object. Options are the same as those allowed + * by the PlotKit.Layout constructor. + * @param {Object} options Options for PlotKit.Layout + * @return {Object} The DateGraphLayout object + */ +DateGraphLayout = function(options) { + PlotKit.Layout.call(this, "line", options); +}; +DateGraphLayout.prototype = new PlotKit.Layout(); + +/** + * Behaves the same way as PlotKit.Layout, but also copies the errors + * @private + */ +DateGraphLayout.prototype.evaluateWithError = function() { + this.evaluate(); + if (!this.options.errorBars) return; + + // Copy over the error terms + var i = 0; // index in this.points + for (var setName in this.datasets) { + var j = 0; + var dataset = this.datasets[setName]; + if (PlotKit.Base.isFuncLike(dataset)) continue; + for (var j = 0; j < dataset.length; j++, i++) { + var item = dataset[j]; + var xv = parseFloat(item[0]); + var yv = parseFloat(item[1]); + + if (xv == this.points[i].xval && + yv == this.points[i].yval) { + this.points[i].errorMinus = parseFloat(item[2]); + this.points[i].errorPlus = parseFloat(item[3]); + } + } + } +}; + +/** + * Convenience function to remove all the data sets from a graph + */ +DateGraphLayout.prototype.removeAllDatasets = function() { + delete this.datasets; + this.datasets = new Array(); +}; + +/** + * Change the values of various layout options + * @param {Object} new_options an associative array of new properties + */ +DateGraphLayout.prototype.updateOptions = function(new_options) { + MochiKit.Base.update(this.options, new_options ? new_options : {}); +}; + +// Subclass PlotKit.CanvasRenderer to add: +// 1. X/Y grid overlay +// 2. Ability to draw error bars (if required) + +/** + * Sets some PlotKit.CanvasRenderer options + * @param {Object} element The canvas to attach to + * @param {Layout} layout The DateGraphLayout object for this graph. + * @param {Object} options Options to pass on to CanvasRenderer + */ +DateGraphCanvasRenderer = function(element, layout, options) { + PlotKit.CanvasRenderer.call(this, element, layout, options); + this.options.shouldFill = false; + this.options.shouldStroke = true; + this.options.drawYGrid = true; + this.options.drawXGrid = true; + this.options.gridLineColor = MochiKit.Color.Color.grayColor(); + MochiKit.Base.update(this.options, options); + + // TODO(danvk) This shouldn't be necessary: effects should be overlaid + this.options.drawBackground = false; +}; +DateGraphCanvasRenderer.prototype = new PlotKit.CanvasRenderer(); + +/** + * Draw an X/Y grid on top of the existing plot + */ +DateGraphCanvasRenderer.prototype.render = function() { + // Do the ordinary rendering, as before + // TODO(danvk) Call super.render() + this._renderLineChart(); + this._renderLineAxis(); + + // Draw the new X/Y grid + var ctx = this.element.getContext("2d"); + if (this.options.drawYGrid) { + var ticks = this.layout.yticks; + ctx.save(); + ctx.strokeStyle = this.options.gridLineColor.toRGBString(); + ctx.lineWidth = this.options.axisLineWidth; + for (var i = 0; i < ticks.length; i++) { + var x = this.area.x; + var y = this.area.y + ticks[i][0] * this.area.h; + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.lineTo(x + this.area.w, y); + ctx.closePath(); + ctx.stroke(); + } + } + + if (this.options.drawXGrid) { + var ticks = this.layout.xticks; + ctx.save(); + ctx.strokeStyle = this.options.gridLineColor.toRGBString(); + ctx.lineWidth = this.options.axisLineWidth; + for (var i=0; i= 0) { + ctx_.moveTo(prevX, prevYs[0]); + ctx_.lineTo(point.canvasx, newYs[0]); + ctx_.lineTo(point.canvasx, newYs[1]); + ctx_.lineTo(prevX, prevYs[1]); + ctx_.closePath(); + } + prevYs[0] = newYs[0]; + prevYs[1] = newYs[1]; + prevX = point.canvasx; + } + }; + // should be same color as the lines + var err_color = color.colorWithAlpha(0.15); + ctx.fillStyle = err_color.toRGBString(); + ctx.beginPath(); + MochiKit.Iter.forEach(this.layout.points, partial(errorTrapezoid, ctx), this); + ctx.fill(); + } + }; + + if (errorBars) + bind(makeErrorBars, this)(context); + bind(makePath, this)(context); + context.restore(); +}; +// Copyright 2006 Dan Vanderkam (danvdk@gmail.com) +// All Rights Reserved. + +/** + * @fileoverview Creates an interactive, zoomable graph based on a CSV file or + * string. DateGraph can handle multiple series with or without error bars. The + * date/value ranges will be automatically set. DateGraph uses the + * <canvas> tag, so it only works in FF1.5+. + * @author danvdk@gmail.com (Dan Vanderkam) + + Usage: +
+ + + The CSV file is of the form + + YYYYMMDD,A1,B1,C1 + YYYYMMDD,A2,B2,C2 + + If null is passed as the third parameter (series names), then the first line + of the CSV file is assumed to contain names for each series. + + If the 'errorBars' option is set in the constructor, the input should be of + the form + + YYYYMMDD,A1,sigmaA1,B1,sigmaB1,... + YYYYMMDD,A2,sigmaA2,B2,sigmaB2,... + + If the 'fractions' option is set, the input should be of the form: + + YYYYMMDD,A1/B1,A2/B2,... + YYYYMMDD,A1/B1,A2/B2,... + + And error bars will be calculated automatically using a binomial distribution. + + For further documentation and examples, see http://www/~danvk/dg/ + + */ + +/** + * An interactive, zoomable graph + * @param {String | Function} file A file containing CSV data or a function that + * returns this data. The expected format for each line is + * YYYYMMDD,val1,val2,... or, if attrs.errorBars is set, + * YYYYMMDD,val1,stddev1,val2,stddev2,... + * @param {Array.} labels Labels for the data series + * @param {Object} attrs Various other attributes, e.g. errorBars determines + * whether the input data contains error ranges. + */ +DateGraph = function(div, file, labels, attrs) { + if (arguments.length > 0) + this.__init__(div, file, labels, attrs); +}; + +DateGraph.NAME = "DateGraph"; +DateGraph.VERSION = "1.1"; +DateGraph.__repr__ = function() { + return "[" + this.NAME + " " + this.VERSION + "]"; +}; +DateGraph.toString = function() { + return this.__repr__(); +}; + +// Various default values +DateGraph.DEFAULT_ROLL_PERIOD = 1; +DateGraph.DEFAULT_WIDTH = 480; +DateGraph.DEFAULT_HEIGHT = 320; +DateGraph.DEFAULT_STROKE_WIDTH = 1.0; +DateGraph.AXIS_LINE_WIDTH = 0.3; + +/** + * Initializes the DateGraph. This creates a new DIV and constructs the PlotKit + * and interaction <canvas> inside of it. See the constructor for details + * on the parameters. + * @param {String | Function} file Source data + * @param {Array.} labels Names of the data series + * @param {Object} attrs Miscellaneous other options + * @private + */ +DateGraph.prototype.__init__ = function(div, file, labels, attrs) { + // Copy the important bits into the object + this.maindiv_ = div; + this.labels_ = labels; + this.file_ = file; + this.rollPeriod_ = attrs.rollPeriod || DateGraph.DEFAULT_ROLL_PERIOD; + this.previousVerticalX_ = -1; + this.width_ = parseInt(div.style.width, 10); + this.height_ = parseInt(div.style.height, 10); + this.errorBars_ = attrs.errorBars || false; + this.fractions_ = attrs.fractions || false; + this.strokeWidth_ = attrs.strokeWidth || DateGraph.DEFAULT_STROKE_WIDTH; + this.dateWindow_ = attrs.dateWindow || null; + this.valueRange_ = attrs.valueRange || null; + this.labelsSeparateLines = attrs.labelsSeparateLines || false; + this.labelsDiv_ = attrs.labelsDiv || null; + this.labelsKMB_ = attrs.labelsKMB || false; + this.minTickSize_ = attrs.minTickSize || 0; + this.xValueParser_ = attrs.xValueParser || DateGraph.prototype.dateParser; + this.xValueFormatter_ = attrs.xValueFormatter || + DateGraph.prototype.dateString_; + this.xTicker_ = attrs.xTicker || DateGraph.prototype.dateTicker; + this.sigma_ = attrs.sigma || 2.0; + this.wilsonInterval_ = attrs.wilsonInterval || true; + this.customBars_ = attrs.customBars || false; + this.attrs_ = attrs; + + // Make a note of whether labels will be pulled from the CSV file. + this.labelsFromCSV_ = (this.labels_ == null); + if (this.labels_ == null) + this.labels_ = []; + + // Prototype of the callback is "void clickCallback(event, date)" + this.clickCallback_ = attrs.clickCallback || null; + + // Prototype of zoom callback is "void dragCallback(minDate, maxDate)" + this.zoomCallback_ = attrs.zoomCallback || null; + + // Create the containing DIV and other interactive elements + this.createInterface_(); + + // Create the PlotKit grapher + this.layoutOptions_ = { 'errorBars': (this.errorBars_ || this.customBars_), + 'xOriginIsZero': false }; + MochiKit.Base.update(this.layoutOptions_, attrs); + this.setColors_(attrs); + + this.layout_ = new DateGraphLayout(this.layoutOptions_); + + this.renderOptions_ = { colorScheme: this.colors_, + strokeColor: null, + strokeWidth: this.strokeWidth_, + axisLabelFontSize: 14, + axisLineWidth: DateGraph.AXIS_LINE_WIDTH }; + MochiKit.Base.update(this.renderOptions_, attrs); + this.plotter_ = new DateGraphCanvasRenderer(this.hidden_, this.layout_, + this.renderOptions_); + + this.createStatusMessage_(); + this.createRollInterface_(); + this.createDragInterface_(); + + MochiKit.DOM.addLoadEvent(this.start_()); +}; + +/** + * Returns the current rolling period, as set by the user or an option. + * @return {Number} The number of days in the rolling window + */ +DateGraph.prototype.rollPeriod = function() { + return this.rollPeriod_; +} + +/** + * Generates interface elements for the DateGraph: a containing div, a div to + * display the current point, and a textbox to adjust the rolling average + * period. + * @private + */ +DateGraph.prototype.createInterface_ = function() { + // Create the all-enclosing graph div + var enclosing = this.maindiv_; + + this.graphDiv = MochiKit.DOM.DIV( { style: { 'width': this.width_ + "px", + 'height': this.height_ + "px" + }}); + appendChildNodes(enclosing, this.graphDiv); + + // Create the canvas to store + var canvas = MochiKit.DOM.CANVAS; + this.canvas_ = canvas( { style: { 'position': 'absolute' }, + width: this.width_, + height: this.height_}); + appendChildNodes(this.graphDiv, this.canvas_); + + this.hidden_ = this.createPlotKitCanvas_(this.canvas_); + connect(this.hidden_, 'onmousemove', this, function(e) { this.mouseMove_(e) }); + connect(this.hidden_, 'onmouseout', this, function(e) { this.mouseOut_(e) }); +} + +/** + * Creates the canvas containing the PlotKit graph. Only plotkit ever draws on + * this particular canvas. All DateGraph work is done on this.canvas_. + * @param {Object} canvas The DateGraph canvas to over which to overlay the plot + * @return {Object} The newly-created canvas + * @private + */ +DateGraph.prototype.createPlotKitCanvas_ = function(canvas) { + var h = document.createElement("canvas"); + h.style.position = "absolute"; + h.style.top = canvas.style.top; + h.style.left = canvas.style.left; + h.width = this.width_; + h.height = this.height_; + MochiKit.DOM.appendChildNodes(this.graphDiv, h); + return h; +}; + +/** + * Generate a set of distinct colors for the data series. This is done with a + * color wheel. Saturation/Value are customizable, and the hue is + * equally-spaced around the color wheel. If a custom set of colors is + * specified, that is used instead. + * @param {Object} attrs Various attributes, e.g. saturation and value + * @private + */ +DateGraph.prototype.setColors_ = function(attrs) { + var num = this.labels_.length; + this.colors_ = []; + if (!attrs.colors) { + var sat = attrs.colorSaturation || 1.0; + var val = attrs.colorValue || 0.5; + for (var i = 1; i <= num; i++) { + var hue = (1.0*i/(1+num)); + this.colors_.push( MochiKit.Color.Color.fromHSV(hue, sat, val) ); + } + } else { + for (var i = 0; i < num; i++) { + var colorStr = attrs.colors[i % attrs.colors.length]; + this.colors_.push( MochiKit.Color.Color.fromString(colorStr) ); + } + } +} + +/** + * Create the div that contains information on the selected point(s) + * This goes in the top right of the canvas, unless an external div has already + * been specified. + * @private + */ +DateGraph.prototype.createStatusMessage_ = function(){ + if (!this.labelsDiv_) { + var divWidth = 250; + var messagestyle = { "style": { + "position": "absolute", + "fontSize": "14px", + "zIndex": 10, + "width": divWidth + "px", + "top": "0px", + "left": this.width_ - divWidth + "px", + "background": "white", + "textAlign": "left", + "overflow": "hidden"}}; + this.labelsDiv_ = MochiKit.DOM.DIV(messagestyle); + MochiKit.DOM.appendChildNodes(this.graphDiv, this.labelsDiv_); + } +}; + +/** + * Create the text box to adjust the averaging period + * @return {Object} The newly-created text box + * @private + */ +DateGraph.prototype.createRollInterface_ = function() { + var padding = this.plotter_.options.padding; + var textAttr = { "type": "text", + "size": "2", + "value": this.rollPeriod_, + "style": { "position": "absolute", + "zIndex": 10, + "top": (this.height_ - 25 - padding.bottom) + "px", + "left": (padding.left+1) + "px" } + }; + var roller = MochiKit.DOM.INPUT(textAttr); + var pa = this.graphDiv; + MochiKit.DOM.appendChildNodes(pa, roller); + connect(roller, 'onchange', this, + function() { this.adjustRoll(roller.value); }); + return roller; +} + +/** + * Set up all the mouse handlers needed to capture dragging behavior for zoom + * events. Uses MochiKit.Signal to attach all the event handlers. + * @private + */ +DateGraph.prototype.createDragInterface_ = function() { + var self = this; + + // Tracks whether the mouse is down right now + var mouseDown = false; + var dragStartX = null; + var dragStartY = null; + var dragEndX = null; + var dragEndY = null; + var prevEndX = null; + + // Utility function to convert page-wide coordinates to canvas coords + var px = PlotKit.Base.findPosX(this.canvas_); + var py = PlotKit.Base.findPosY(this.canvas_); + var getX = function(e) { return e.mouse().page.x - px }; + var getY = function(e) { return e.mouse().page.y - py }; + + // Draw zoom rectangles when the mouse is down and the user moves around + connect(this.hidden_, 'onmousemove', function(event) { + if (mouseDown) { + dragEndX = getX(event); + dragEndY = getY(event); + + self.drawZoomRect_(dragStartX, dragEndX, prevEndX); + prevEndX = dragEndX; + } + }); + + // Track the beginning of drag events + connect(this.hidden_, 'onmousedown', function(event) { + mouseDown = true; + dragStartX = getX(event); + dragStartY = getY(event); + }); + + // If the user releases the mouse button during a drag, but not over the + // canvas, then it doesn't count as a zooming action. + connect(document, 'onmouseup', this, function(event) { + if (mouseDown) { + mouseDown = false; + dragStartX = null; + dragStartY = null; + } + }); + + // Temporarily cancel the dragging event when the mouse leaves the graph + connect(this.hidden_, 'onmouseout', this, function(event) { + if (mouseDown) { + dragEndX = null; + dragEndY = null; + } + }); + + // If the mouse is released on the canvas during a drag event, then it's a + // zoom. Only do the zoom if it's over a large enough area (>= 10 pixels) + connect(this.hidden_, 'onmouseup', this, function(event) { + if (mouseDown) { + mouseDown = false; + dragEndX = getX(event); + dragEndY = getY(event); + var regionWidth = Math.abs(dragEndX - dragStartX); + var regionHeight = Math.abs(dragEndY - dragStartY); + + if (regionWidth < 2 && regionHeight < 2 && + self.clickCallback_ != null && + self.lastx_ != undefined) { + self.clickCallback_(event, new Date(self.lastx_)); + } + + if (regionWidth >= 10) { + self.doZoom_(Math.min(dragStartX, dragEndX), + Math.max(dragStartX, dragEndX)); + } else { + self.canvas_.getContext("2d").clearRect(0, 0, + self.canvas_.width, + self.canvas_.height); + } + + dragStartX = null; + dragStartY = null; + } + }); + + // Double-clicking zooms back out + connect(this.hidden_, 'ondblclick', this, function(event) { + self.dateWindow_ = null; + self.drawGraph_(self.rawData_); + var minDate = self.rawData_[0][0]; + var maxDate = self.rawData_[self.rawData_.length - 1][0]; + self.zoomCallback_(minDate, maxDate); + }); +}; + +/** + * Draw a gray zoom rectangle over the desired area of the canvas. Also clears + * up any previous zoom rectangles that were drawn. This could be optimized to + * avoid extra redrawing, but it's tricky to avoid interactions with the status + * dots. + * @param {Number} startX The X position where the drag started, in canvas + * coordinates. + * @param {Number} endX The current X position of the drag, in canvas coords. + * @param {Number} prevEndX The value of endX on the previous call to this + * function. Used to avoid excess redrawing + * @private + */ +DateGraph.prototype.drawZoomRect_ = function(startX, endX, prevEndX) { + var ctx = this.canvas_.getContext("2d"); + + // Clean up from the previous rect if necessary + if (prevEndX) { + ctx.clearRect(Math.min(startX, prevEndX), 0, + Math.abs(startX - prevEndX), this.height_); + } + + // Draw a light-grey rectangle to show the new viewing area + if (endX && startX) { + ctx.fillStyle = "rgba(128,128,128,0.33)"; + ctx.fillRect(Math.min(startX, endX), 0, + Math.abs(endX - startX), this.height_); + } +}; + +/** + * Zoom to something containing [lowX, highX]. These are pixel coordinates + * in the canvas. The exact zoom window may be slightly larger if there are no + * data points near lowX or highX. This function redraws the graph. + * @param {Number} lowX The leftmost pixel value that should be visible. + * @param {Number} highX The rightmost pixel value that should be visible. + * @private + */ +DateGraph.prototype.doZoom_ = function(lowX, highX) { + // Find the earliest and latest dates contained in this canvasx range. + var points = this.layout_.points; + var minDate = null; + var maxDate = null; + // Find the nearest [minDate, maxDate] that contains [lowX, highX] + for (var i = 0; i < points.length; i++) { + var cx = points[i].canvasx; + var x = points[i].xval; + if (cx < lowX && (minDate == null || x > minDate)) minDate = x; + if (cx > highX && (maxDate == null || x < maxDate)) maxDate = x; + } + // Use the extremes if either is missing + if (minDate == null) minDate = points[0].xval; + if (maxDate == null) maxDate = points[points.length-1].xval; + + this.dateWindow_ = [minDate, maxDate]; + this.drawGraph_(this.rawData_); + this.zoomCallback_(minDate, maxDate); +}; + +/** + * When the mouse moves in the canvas, display information about a nearby data + * point and draw dots over those points in the data series. This function + * takes care of cleanup of previously-drawn dots. + * @param {Object} event The mousemove event from the browser. + * @private + */ +DateGraph.prototype.mouseMove_ = function(event) { + var canvasx = event.mouse().page.x - PlotKit.Base.findPosX(this.hidden_); + var points = this.layout_.points; + + var lastx = -1; + var lasty = -1; + + // Loop through all the points and find the date nearest to our current + // location. + var minDist = 1e+100; + var idx = -1; + for (var i = 0; i < points.length; i++) { + var dist = Math.abs(points[i].canvasx - canvasx); + if (dist > minDist) break; + minDist = dist; + idx = i; + } + if (idx >= 0) lastx = points[idx].xval; + // Check that you can really highlight the last day's data + if (canvasx > points[points.length-1].canvasx) + lastx = points[points.length-1].xval; + + // Extract the points we've selected + var selPoints = []; + for (var i = 0; i < points.length; i++) { + if (points[i].xval == lastx) { + selPoints.push(points[i]); + } + } + + // Clear the previously drawn vertical, if there is one + var circleSize = 3; + var ctx = this.canvas_.getContext("2d"); + if (this.previousVerticalX_ >= 0) { + var px = this.previousVerticalX_; + ctx.clearRect(px - circleSize - 1, 0, 2 * circleSize + 2, this.height_); + } + + if (selPoints.length > 0) { + var canvasx = selPoints[0].canvasx; + + // Set the status message to indicate the selected point(s) + var replace = this.xValueFormatter_(lastx) + ":"; + var clen = this.colors_.length; + for (var i = 0; i < selPoints.length; i++) { + if (this.labelsSeparateLines) { + replace += "
"; + } + var point = selPoints[i]; + replace += " " + + point.name + ":" + + this.round_(point.yval, 2); + } + this.labelsDiv_.innerHTML = replace; + + // Save last x position for callbacks. + this.lastx_ = lastx; + + // Draw colored circles over the center of each selected point + ctx.save() + for (var i = 0; i < selPoints.length; i++) { + ctx.beginPath(); + ctx.fillStyle = this.colors_[i%clen].toRGBString(); + ctx.arc(canvasx, selPoints[i%clen].canvasy, circleSize, 0, 360, false); + ctx.fill(); + } + ctx.restore(); + + this.previousVerticalX_ = canvasx; + } +}; + +/** + * The mouse has left the canvas. Clear out whatever artifacts remain + * @param {Object} event the mouseout event from the browser. + * @private + */ +DateGraph.prototype.mouseOut_ = function(event) { + // Get rid of the overlay data + var ctx = this.canvas_.getContext("2d"); + ctx.clearRect(0, 0, this.width_, this.height_); + this.labelsDiv_.innerHTML = ""; +}; + +/** + * Convert a JS date (millis since epoch) to YYYY/MM/DD + * @param {Number} date The JavaScript date (ms since epoch) + * @return {String} A date of the form "YYYY/MM/DD" + * @private + */ +DateGraph.prototype.dateString_ = function(date) { + var d = new Date(date); + + // Get the year: + var year = "" + d.getFullYear(); + // Get a 0 padded month string + var month = "" + (d.getMonth() + 1); //months are 0-offset, sigh + if (month.length < 2) month = "0" + month; + // Get a 0 padded day string + var day = "" + d.getDate(); + if (day.length < 2) day = "0" + day; + + return year + "/" + month + "/" + day; +}; + +/** + * Round a number to the specified number of digits past the decimal point. + * @param {Number} num The number to round + * @param {Number} places The number of decimals to which to round + * @return {Number} The rounded number + * @private + */ +DateGraph.prototype.round_ = function(num, places) { + var shift = Math.pow(10, places); + return Math.round(num * shift)/shift; +}; + +/** + * Fires when there's data available to be graphed. + * @param {String} data Raw CSV data to be plotted + * @private + */ +DateGraph.prototype.loadedEvent_ = function(data) { + this.rawData_ = this.parseCSV_(data); + this.drawGraph_(this.rawData_); +}; + +DateGraph.prototype.months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; +DateGraph.prototype.quarters = ["Jan", "Apr", "Jul", "Oct"]; + +/** + * Add ticks on the x-axis representing years, months, quarters, weeks, or days + * @private + */ +DateGraph.prototype.addXTicks_ = function() { + // Determine the correct ticks scale on the x-axis: quarterly, monthly, ... + var startDate, endDate; + if (this.dateWindow_) { + startDate = this.dateWindow_[0]; + endDate = this.dateWindow_[1]; + } else { + startDate = this.rawData_[0][0]; + endDate = this.rawData_[this.rawData_.length - 1][0]; + } + + var xTicks = this.xTicker_(startDate, endDate); + this.layout_.updateOptions({xTicks: xTicks}); +} + +/** + * Add ticks to the x-axis based on a date range. + * @param {Number} startDate Start of the date window (millis since epoch) + * @param {Number} endDate End of the date window (millis since epoch) + * @return {Array.} Array of {label, value} tuples. + * @public + */ +DateGraph.prototype.dateTicker = function(startDate, endDate) { + var ONE_DAY = 24*60*60*1000; + startDate = startDate / ONE_DAY; + endDate = endDate / ONE_DAY; + var dateSpan = endDate - startDate; + + var scale = []; + var isMonthly = false; + var yearMod = 1; + if (dateSpan > 30 * 366) { // decadal + isMonthly = true; + scale = ["Jan"]; + yearMod = 10; + } else if (dateSpan > 4*366) { // annual + scale = ["Jan"]; + isMonthly = true; + } else if (dateSpan > 366) { // quarterly + scale = this.quarters; + isMonthly = true; + } else if (dateSpan > 40) { // monthly + scale = this.months; + isMonthly = true; + } else if (dateSpan > 10) { // weekly + for (var week = startDate - 14; week < endDate + 14; week += 7) { + scale.push(week * ONE_DAY); + } + } else { // daily + for (var day = startDate - 14; day < endDate + 14; day += 1) { + scale.push(day * ONE_DAY); + } + } + + var xTicks = []; + + if (isMonthly) { + var startYear = 1900 + (new Date(startDate* ONE_DAY)).getYear(); + var endYear = 1900 + (new Date(endDate * ONE_DAY)).getYear(); + for (var i = startYear; i <= endYear; i++) { + if (i % yearMod != 0) continue; + for (var j = 0; j < scale.length; j++ ) { + var date = Date.parse(scale[j] + " 1, " + i); + xTicks.push( {label: scale[j] + "'" + ("" + i).substr(2,2), v: date } ); + } + } + } else { + for (var i = 0; i < scale.length; i++) { + var date = new Date(scale[i]); + var year = date.getFullYear().toString(); + var label = this.months[date.getMonth()] + date.getDate(); + label += "'" + year.substr(year.length - 2, 2); + xTicks.push( {label: label, v: date} ); + } + } + return xTicks; +}; + +/** + * Add ticks when the x axis has numbers on it (instead of dates) + * @param {Number} startDate Start of the date window (millis since epoch) + * @param {Number} endDate End of the date window (millis since epoch) + * @return {Array.} Array of {label, value} tuples. + * @public + */ +DateGraph.prototype.numericTicks = function(minV, maxV) { + var scale; + if (maxV <= 0.0) { + scale = 1.0; + } else { + scale = Math.pow( 10, Math.floor(Math.log(maxV)/Math.log(10.0)) ); + } + + // Add a smallish number of ticks at human-friendly points + var nTicks = (maxV - minV) / scale; + while (2 * nTicks < 20) { + nTicks *= 2; + } + if ((maxV - minV) / nTicks < this.minTickSize_) { + nTicks = this.round_((maxV - minV) / this.minTickSize_, 1); + } + + // Construct labels for the ticks + var ticks = []; + for (var i = 0; i <= nTicks; i++) { + var tickV = minV + i * (maxV - minV) / nTicks; + var label = this.round_(tickV, 2); + if (this.labelsKMB_) { + var k = 1000; + if (tickV >= k*k*k) { + label = this.round_(tickV/(k*k*k), 1) + "B"; + } else if (tickV >= k*k) { + label = this.round_(tickV/(k*k), 1) + "M"; + } else if (tickV >= k) { + label = this.round_(tickV/k, 1) + "K"; + } + } + ticks.push( {label: label, v: tickV} ); + } + return ticks; +}; + +/** + * Adds appropriate ticks on the y-axis + * @param {Number} minY The minimum Y value in the data set + * @param {Number} maxY The maximum Y value in the data set + * @private + */ +DateGraph.prototype.addYTicks_ = function(minY, maxY) { + // Set the number of ticks so that the labels are human-friendly. + var ticks = this.numericTicks(minY, maxY); + this.layout_.updateOptions( { yAxis: [minY, maxY], + yTicks: ticks } ); +}; + +/** + * Update the graph with new data. Data is in the format + * [ [date1, val1, val2, ...], [date2, val1, val2, ...] if errorBars=false + * or, if errorBars=true, + * [ [date1, [val1,stddev1], [val2,stddev2], ...], [date2, ...], ...] + * @param {Array.} data The data (see above) + * @private + */ +DateGraph.prototype.drawGraph_ = function(data) { + var maxY = null; + this.layout_.removeAllDatasets(); + // Loop over all fields in the dataset + for (var i = 1; i < data[0].length; i++) { + var series = []; + for (var j = 0; j < data.length; j++) { + var date = data[j][0]; + series[j] = [date, data[j][i]]; + } + series = this.rollingAverage(series, this.rollPeriod_); + + // Prune down to the desired range, if necessary (for zooming) + var bars = this.errorBars_ || this.customBars_; + if (this.dateWindow_) { + var low = this.dateWindow_[0]; + var high= this.dateWindow_[1]; + var pruned = []; + for (var k = 0; k < series.length; k++) { + if (series[k][0] >= low && series[k][0] <= high) { + pruned.push(series[k]); + var y = bars ? series[k][1][0] : series[k][1]; + if (maxY == null || y > maxY) maxY = y; + } + } + series = pruned; + } else { + for (var j = 0; j < series.length; j++) { + var y = bars ? series[j][1][0] : series[j][1]; + if (maxY == null || y > maxY) { + maxY = bars ? y + series[j][1][1] : y; + } + } + } + + if (bars) { + var vals = []; + for (var j=0; j= 0) { + num -= originalData[i - rollPeriod][1][0]; + den -= originalData[i - rollPeriod][1][1]; + } + + var date = originalData[i][0]; + var value = den ? num / den : 0.0; + if (this.errorBars_) { + if (this.wilsonInterval_) { + // For more details on this confidence interval, see: + // http://en.wikipedia.org/wiki/Binomial_confidence_interval + if (den) { + var p = value < 0 ? 0 : value, n = den; + var pm = sigma * Math.sqrt(p*(1-p)/n + sigma*sigma/(4*n*n)); + var denom = 1 + sigma * sigma / den; + var low = (p + sigma * sigma / (2 * den) - pm) / denom; + var high = (p + sigma * sigma / (2 * den) + pm) / denom; + rollingData[i] = [date, + [p * mult, (p - low) * mult, (high - p) * mult]]; + } else { + rollingData[i] = [date, [0, 0, 0]]; + } + } else { + var stddev = den ? sigma * Math.sqrt(value * (1 - value) / den) : 1.0; + rollingData[i] = [date, [mult * value, mult * stddev, mult * stddev]]; + } + } else { + rollingData[i] = [date, mult * value]; + } + } + } else if (this.customBars_) { + // just ignore the rolling for now. + // TODO(danvk): do something reasonable. + for (var i = 0; i < originalData.length; i++) { + var data = originalData[i][1]; + var y = data[1]; + rollingData[i] = [originalData[i][0], [y, y - data[0], data[2] - y]]; + } + } else { + // Calculate the rolling average for the first rollPeriod - 1 points where + // there is not enough data to roll over the full number of days + var num_init_points = Math.min(rollPeriod - 1, originalData.length - 2); + if (!this.errorBars_){ + for (var i = 0; i < num_init_points; i++) { + var sum = 0; + for (var j = 0; j < i + 1; j++) + sum += originalData[j][1]; + rollingData[i] = [originalData[i][0], sum / (i + 1)]; + } + // Calculate the rolling average for the remaining points + for (var i = Math.min(rollPeriod - 1, originalData.length - 2); + i < originalData.length; + i++) { + var sum = 0; + for (var j = i - rollPeriod + 1; j < i + 1; j++) + sum += originalData[j][1]; + rollingData[i] = [originalData[i][0], sum / rollPeriod]; + } + } else { + for (var i = 0; i < num_init_points; i++) { + var sum = 0; + var variance = 0; + for (var j = 0; j < i + 1; j++) { + sum += originalData[j][1][0]; + variance += Math.pow(originalData[j][1][1], 2); + } + var stddev = Math.sqrt(variance)/(i+1); + rollingData[i] = [originalData[i][0], + [sum/(i+1), sigma * stddev, sigma * stddev]]; + } + // Calculate the rolling average for the remaining points + for (var i = Math.min(rollPeriod - 1, originalData.length - 2); + i < originalData.length; + i++) { + var sum = 0; + var variance = 0; + for (var j = i - rollPeriod + 1; j < i + 1; j++) { + sum += originalData[j][1][0]; + variance += Math.pow(originalData[j][1][1], 2); + } + var stddev = Math.sqrt(variance) / rollPeriod; + rollingData[i] = [originalData[i][0], + [sum / rollPeriod, sigma * stddev, sigma * stddev]]; + } + } + } + + return rollingData; +}; + +/** + * Parses a date, returning the number of milliseconds since epoch. This can be + * passed in as an xValueParser in the DateGraph constructor. + * @param {String} A date in YYYYMMDD format. + * @return {Number} Milliseconds since epoch. + * @public + */ +DateGraph.prototype.dateParser = function(dateStr) { + var dateStrSlashed; + if (dateStr.search("-") != -1) { + dateStrSlashed = dateStr.replace("-", "/", "g"); + } else if (dateStr.search("/") != -1) { + return Date.parse(dateStr); + } else { + dateStrSlashed = dateStr.substr(0,4) + "/" + dateStr.substr(4,2) + + "/" + dateStr.substr(6,2); + } + return Date.parse(dateStrSlashed); +}; + +/** + * Parses a string in a special csv format. We expect a csv file where each + * line is a date point, and the first field in each line is the date string. + * We also expect that all remaining fields represent series. + * if this.errorBars_ is set, then interpret the fields as: + * date, series1, stddev1, series2, stddev2, ... + * @param {Array.} data See above. + * @private + */ +DateGraph.prototype.parseCSV_ = function(data) { + var ret = []; + var lines = data.split("\n"); + var start = this.labelsFromCSV_ ? 1 : 0; + if (this.labelsFromCSV_) { + var labels = lines[0].split(","); + labels.shift(); // a "date" parameter is assumed. + this.labels_ = labels; + // regenerate automatic colors. + this.setColors_(this.attrs_); + this.renderOptions_.colorScheme = this.colors_; + MochiKit.Base.update(this.plotter_.options, this.renderOptions_); + MochiKit.Base.update(this.layoutOptions_, this.attrs_); + } + + for (var i = start; i < lines.length; i++) { + var line = lines[i]; + if (line.length == 0) continue; // skip blank lines + var inFields = line.split(','); + if (inFields.length < 2) + continue; + + var fields = []; + fields[0] = this.xValueParser_(inFields[0]); + + // If fractions are expected, parse the numbers as "A/B" + if (this.fractions_) { + for (var j = 1; j < inFields.length; j++) { + // TODO(danvk): figure out an appropriate way to flag parse errors. + var vals = inFields[j].split("/"); + fields[j] = [parseFloat(vals[0]), parseFloat(vals[1])]; + } + } else if (this.errorBars_) { + // If there are error bars, values are (value, stddev) pairs + for (var j = 1; j < inFields.length; j += 2) + fields[(j + 1) / 2] = [parseFloat(inFields[j]), + parseFloat(inFields[j + 1])]; + } else if (this.customBars_) { + // Bars are a low;center;high tuple + for (var j = 1; j < inFields.length; j++) { + var vals = inFields[j].split(";"); + fields[j] = [ parseFloat(vals[0]), + parseFloat(vals[1]), + parseFloat(vals[2]) ]; + } + } else { + // Values are just numbers + for (var j = 1; j < inFields.length; j++) + fields[j] = parseFloat(inFields[j]); + } + ret.push(fields); + } + return ret; +}; + +/** + * Get the CSV data. If it's in a function, call that function. If it's in a + * file, do an XMLHttpRequest to get it. + * @private + */ +DateGraph.prototype.start_ = function() { + if (typeof this.file_ == 'function') { + // Stubbed out to allow this to run off a filesystem + this.loadedEvent_(this.file_()); + } else { + var req = new XMLHttpRequest(); + var caller = this; + req.onreadystatechange = function () { + if (req.readyState == 4) { + if (req.status == 200) { + caller.loadedEvent_(req.responseText); + } + } + }; + + req.open("GET", this.file_, true); + req.send(null); + } +}; + +/** + * Changes various properties of the graph. These can include: + *
    + *
  • file: changes the source data for the graph
  • + *
  • errorBars: changes whether the data contains stddev
  • + *
+ * @param {Object} attrs The new properties and values + */ +DateGraph.prototype.updateOptions = function(attrs) { + if (attrs.errorBars) { + this.errorBars_ = attrs.errorBars; + } + if (attrs.customBars) { + this.customBars_ = attrs.customBars; + } + if (attrs.strokeWidth) { + this.strokeWidth_ = attrs.strokeWidth; + } + if (attrs.rollPeriod) { + this.rollPeriod_ = attrs.rollPeriod; + } + if (attrs.dateWindow) { + this.dateWindow_ = attrs.dateWindow; + } + if (attrs.valueRange) { + this.valueRange_ = attrs.valueRange; + } + if (attrs.minTickSize) { + this.minTickSize_ = attrs.minTickSize; + } + if (typeof(attrs.labels) != 'undefined') { + this.labels_ = attrs.labels; + this.labelsFromCSV_ = (attrs.labels == null); + } + this.layout_.updateOptions({ 'errorBars': this.errorBars_ }); + if (attrs['file'] && attrs['file'] != this.file_) { + this.file_ = attrs['file']; + this.start_(); + } else { + this.drawGraph_(this.rawData_); + } +}; + +/** + * Adjusts the number of days in the rolling average. Updates the graph to + * reflect the new averaging period. + * @param {Number} length Number of days over which to average the data. + */ +DateGraph.prototype.adjustRoll = function(length) { + this.rollPeriod_ = length; + this.drawGraph_(this.rawData_); +}; diff --git a/docs/excanvas.js b/docs/excanvas.js new file mode 100644 index 0000000..1d9ddb2 --- /dev/null +++ b/docs/excanvas.js @@ -0,0 +1,876 @@ +// Copyright 2006 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// Known Issues: +// +// * Patterns are not implemented. +// * Radial gradient are not implemented. The VML version of these look very +// different from the canvas one. +// * Clipping paths are not implemented. +// * Coordsize. The width and height attribute have higher priority than the +// width and height style values which isn't correct. +// * Painting mode isn't implemented. +// * Canvas width/height should is using content-box by default. IE in +// Quirks mode will draw the canvas using border-box. Either change your +// doctype to HTML5 +// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype) +// or use Box Sizing Behavior from WebFX +// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html) +// * Non uniform scaling does not correctly scale strokes. +// * Optimize. There is always room for speed improvements. + +// Only add this code if we do not already have a canvas implementation +if (!document.createElement('canvas').getContext) { + +(function() { + + // alias some functions to make (compiled) code shorter + var m = Math; + var mr = m.round; + var ms = m.sin; + var mc = m.cos; + var abs = m.abs; + var sqrt = m.sqrt; + + // this is used for sub pixel precision + var Z = 10; + var Z2 = Z / 2; + + /** + * This funtion is assigned to the elements as element.getContext(). + * @this {HTMLElement} + * @return {CanvasRenderingContext2D_} + */ + function getContext() { + return this.context_ || + (this.context_ = new CanvasRenderingContext2D_(this)); + } + + var slice = Array.prototype.slice; + + /** + * Binds a function to an object. The returned function will always use the + * passed in {@code obj} as {@code this}. + * + * Example: + * + * g = bind(f, obj, a, b) + * g(c, d) // will do f.call(obj, a, b, c, d) + * + * @param {Function} f The function to bind the object to + * @param {Object} obj The object that should act as this when the function + * is called + * @param {*} var_args Rest arguments that will be used as the initial + * arguments when the function is called + * @return {Function} A new function that has bound this + */ + function bind(f, obj, var_args) { + var a = slice.call(arguments, 2); + return function() { + return f.apply(obj, a.concat(slice.call(arguments))); + }; + } + + var G_vmlCanvasManager_ = { + init: function(opt_doc) { + if (/MSIE/.test(navigator.userAgent) && !window.opera) { + var doc = opt_doc || document; + // Create a dummy element so that IE will allow canvas elements to be + // recognized. + doc.createElement('canvas'); + doc.attachEvent('onreadystatechange', bind(this.init_, this, doc)); + } + }, + + init_: function(doc) { + // create xmlns + if (!doc.namespaces['g_vml_']) { + doc.namespaces.add('g_vml_', 'urn:schemas-microsoft-com:vml', + '#default#VML'); + + } + if (!doc.namespaces['g_o_']) { + doc.namespaces.add('g_o_', 'urn:schemas-microsoft-com:office:office', + '#default#VML'); + } + + // Setup default CSS. Only add one style sheet per document + if (!doc.styleSheets['ex_canvas_']) { + var ss = doc.createStyleSheet(); + ss.owningElement.id = 'ex_canvas_'; + ss.cssText = 'canvas{display:inline-block;overflow:hidden;' + + // default size is 300x150 in Gecko and Opera + 'text-align:left;width:300px;height:150px}' + + 'g_vml_\\:*{behavior:url(#default#VML)}' + + 'g_o_\\:*{behavior:url(#default#VML)}'; + + } + + // find all canvas elements + var els = doc.getElementsByTagName('canvas'); + for (var i = 0; i < els.length; i++) { + this.initElement(els[i]); + } + }, + + /** + * Public initializes a canvas element so that it can be used as canvas + * element from now on. This is called automatically before the page is + * loaded but if you are creating elements using createElement you need to + * make sure this is called on the element. + * @param {HTMLElement} el The canvas element to initialize. + * @return {HTMLElement} the element that was created. + */ + initElement: function(el) { + if (!el.getContext) { + + el.getContext = getContext; + + // do not use inline function because that will leak memory + el.attachEvent('onpropertychange', onPropertyChange); + el.attachEvent('onresize', onResize); + + var attrs = el.attributes; + if (attrs.width && attrs.width.specified) { + // TODO: use runtimeStyle and coordsize + // el.getContext().setWidth_(attrs.width.nodeValue); + el.style.width = attrs.width.nodeValue + 'px'; + } else { + el.width = el.clientWidth; + } + if (attrs.height && attrs.height.specified) { + // TODO: use runtimeStyle and coordsize + // el.getContext().setHeight_(attrs.height.nodeValue); + el.style.height = attrs.height.nodeValue + 'px'; + } else { + el.height = el.clientHeight; + } + //el.getContext().setCoordsize_() + } + return el; + } + }; + + function onPropertyChange(e) { + var el = e.srcElement; + + switch (e.propertyName) { + case 'width': + el.style.width = el.attributes.width.nodeValue + 'px'; + el.getContext().clearRect(); + break; + case 'height': + el.style.height = el.attributes.height.nodeValue + 'px'; + el.getContext().clearRect(); + break; + } + } + + function onResize(e) { + var el = e.srcElement; + if (el.firstChild) { + el.firstChild.style.width = el.clientWidth + 'px'; + el.firstChild.style.height = el.clientHeight + 'px'; + } + } + + G_vmlCanvasManager_.init(); + + // precompute "00" to "FF" + var dec2hex = []; + for (var i = 0; i < 16; i++) { + for (var j = 0; j < 16; j++) { + dec2hex[i * 16 + j] = i.toString(16) + j.toString(16); + } + } + + function createMatrixIdentity() { + return [ + [1, 0, 0], + [0, 1, 0], + [0, 0, 1] + ]; + } + + function matrixMultiply(m1, m2) { + var result = createMatrixIdentity(); + + for (var x = 0; x < 3; x++) { + for (var y = 0; y < 3; y++) { + var sum = 0; + + for (var z = 0; z < 3; z++) { + sum += m1[x][z] * m2[z][y]; + } + + result[x][y] = sum; + } + } + return result; + } + + function copyState(o1, o2) { + o2.fillStyle = o1.fillStyle; + o2.lineCap = o1.lineCap; + o2.lineJoin = o1.lineJoin; + o2.lineWidth = o1.lineWidth; + o2.miterLimit = o1.miterLimit; + o2.shadowBlur = o1.shadowBlur; + o2.shadowColor = o1.shadowColor; + o2.shadowOffsetX = o1.shadowOffsetX; + o2.shadowOffsetY = o1.shadowOffsetY; + o2.strokeStyle = o1.strokeStyle; + o2.globalAlpha = o1.globalAlpha; + o2.arcScaleX_ = o1.arcScaleX_; + o2.arcScaleY_ = o1.arcScaleY_; + o2.lineScale_ = o1.lineScale_; + } + + function processStyle(styleString) { + var str, alpha = 1; + + styleString = String(styleString); + if (styleString.substring(0, 3) == 'rgb') { + var start = styleString.indexOf('(', 3); + var end = styleString.indexOf(')', start + 1); + var guts = styleString.substring(start + 1, end).split(','); + + str = '#'; + for (var i = 0; i < 3; i++) { + str += dec2hex[Number(guts[i])]; + } + + if (guts.length == 4 && styleString.substr(3, 1) == 'a') { + alpha = guts[3]; + } + } else { + str = styleString; + } + + return {color: str, alpha: alpha}; + } + + function processLineCap(lineCap) { + switch (lineCap) { + case 'butt': + return 'flat'; + case 'round': + return 'round'; + case 'square': + default: + return 'square'; + } + } + + /** + * This class implements CanvasRenderingContext2D interface as described by + * the WHATWG. + * @param {HTMLElement} surfaceElement The element that the 2D context should + * be associated with + */ + function CanvasRenderingContext2D_(surfaceElement) { + this.m_ = createMatrixIdentity(); + + this.mStack_ = []; + this.aStack_ = []; + this.currentPath_ = []; + + // Canvas context properties + this.strokeStyle = '#000'; + this.fillStyle = '#000'; + + this.lineWidth = 1; + this.lineJoin = 'miter'; + this.lineCap = 'butt'; + this.miterLimit = Z * 1; + this.globalAlpha = 1; + this.canvas = surfaceElement; + + var el = surfaceElement.ownerDocument.createElement('div'); + el.style.width = surfaceElement.clientWidth + 'px'; + el.style.height = surfaceElement.clientHeight + 'px'; + el.style.overflow = 'hidden'; + el.style.position = 'absolute'; + surfaceElement.appendChild(el); + + this.element_ = el; + this.arcScaleX_ = 1; + this.arcScaleY_ = 1; + this.lineScale_ = 1; + } + + var contextPrototype = CanvasRenderingContext2D_.prototype; + contextPrototype.clearRect = function() { + this.element_.innerHTML = ''; + this.currentPath_ = []; + }; + + contextPrototype.beginPath = function() { + // TODO: Branch current matrix so that save/restore has no effect + // as per safari docs. + this.currentPath_ = []; + }; + + contextPrototype.moveTo = function(aX, aY) { + var p = this.getCoords_(aX, aY); + this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y}); + this.currentX_ = p.x; + this.currentY_ = p.y; + }; + + contextPrototype.lineTo = function(aX, aY) { + var p = this.getCoords_(aX, aY); + this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y}); + + this.currentX_ = p.x; + this.currentY_ = p.y; + }; + + contextPrototype.bezierCurveTo = function(aCP1x, aCP1y, + aCP2x, aCP2y, + aX, aY) { + var p = this.getCoords_(aX, aY); + var cp1 = this.getCoords_(aCP1x, aCP1y); + var cp2 = this.getCoords_(aCP2x, aCP2y); + bezierCurveTo(this, cp1, cp2, p); + }; + + // Helper function that takes the already fixed cordinates. + function bezierCurveTo(self, cp1, cp2, p) { + self.currentPath_.push({ + type: 'bezierCurveTo', + cp1x: cp1.x, + cp1y: cp1.y, + cp2x: cp2.x, + cp2y: cp2.y, + x: p.x, + y: p.y + }); + self.currentX_ = p.x; + self.currentY_ = p.y; + } + + contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) { + // the following is lifted almost directly from + // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes + + var cp = this.getCoords_(aCPx, aCPy); + var p = this.getCoords_(aX, aY); + + var cp1 = { + x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_), + y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_) + }; + var cp2 = { + x: cp1.x + (p.x - this.currentX_) / 3.0, + y: cp1.y + (p.y - this.currentY_) / 3.0 + }; + + bezierCurveTo(this, cp1, cp2, p); + }; + + contextPrototype.arc = function(aX, aY, aRadius, + aStartAngle, aEndAngle, aClockwise) { + aRadius *= Z; + var arcType = aClockwise ? 'at' : 'wa'; + + var xStart = aX + mc(aStartAngle) * aRadius - Z2; + var yStart = aY + ms(aStartAngle) * aRadius - Z2; + + var xEnd = aX + mc(aEndAngle) * aRadius - Z2; + var yEnd = aY + ms(aEndAngle) * aRadius - Z2; + + // IE won't render arches drawn counter clockwise if xStart == xEnd. + if (xStart == xEnd && !aClockwise) { + xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something + // that can be represented in binary + } + + var p = this.getCoords_(aX, aY); + var pStart = this.getCoords_(xStart, yStart); + var pEnd = this.getCoords_(xEnd, yEnd); + + this.currentPath_.push({type: arcType, + x: p.x, + y: p.y, + radius: aRadius, + xStart: pStart.x, + yStart: pStart.y, + xEnd: pEnd.x, + yEnd: pEnd.y}); + + }; + + contextPrototype.rect = function(aX, aY, aWidth, aHeight) { + this.moveTo(aX, aY); + this.lineTo(aX + aWidth, aY); + this.lineTo(aX + aWidth, aY + aHeight); + this.lineTo(aX, aY + aHeight); + this.closePath(); + }; + + contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) { + // Will destroy any existing path (same as FF behaviour) + this.beginPath(); + this.moveTo(aX, aY); + this.lineTo(aX + aWidth, aY); + this.lineTo(aX + aWidth, aY + aHeight); + this.lineTo(aX, aY + aHeight); + this.closePath(); + this.stroke(); + this.currentPath_ = []; + }; + + contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) { + // Will destroy any existing path (same as FF behaviour) + this.beginPath(); + this.moveTo(aX, aY); + this.lineTo(aX + aWidth, aY); + this.lineTo(aX + aWidth, aY + aHeight); + this.lineTo(aX, aY + aHeight); + this.closePath(); + this.fill(); + this.currentPath_ = []; + }; + + contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) { + var gradient = new CanvasGradient_('gradient'); + gradient.x0_ = aX0; + gradient.y0_ = aY0; + gradient.x1_ = aX1; + gradient.y1_ = aY1; + return gradient; + }; + + contextPrototype.createRadialGradient = function(aX0, aY0, aR0, + aX1, aY1, aR1) { + var gradient = new CanvasGradient_('gradientradial'); + gradient.x0_ = aX0; + gradient.y0_ = aY0; + gradient.r0_ = aR0; + gradient.x1_ = aX1; + gradient.y1_ = aY1; + gradient.r1_ = aR1; + return gradient; + }; + + contextPrototype.drawImage = function(image, var_args) { + var dx, dy, dw, dh, sx, sy, sw, sh; + + // to find the original width we overide the width and height + var oldRuntimeWidth = image.runtimeStyle.width; + var oldRuntimeHeight = image.runtimeStyle.height; + image.runtimeStyle.width = 'auto'; + image.runtimeStyle.height = 'auto'; + + // get the original size + var w = image.width; + var h = image.height; + + // and remove overides + image.runtimeStyle.width = oldRuntimeWidth; + image.runtimeStyle.height = oldRuntimeHeight; + + if (arguments.length == 3) { + dx = arguments[1]; + dy = arguments[2]; + sx = sy = 0; + sw = dw = w; + sh = dh = h; + } else if (arguments.length == 5) { + dx = arguments[1]; + dy = arguments[2]; + dw = arguments[3]; + dh = arguments[4]; + sx = sy = 0; + sw = w; + sh = h; + } else if (arguments.length == 9) { + sx = arguments[1]; + sy = arguments[2]; + sw = arguments[3]; + sh = arguments[4]; + dx = arguments[5]; + dy = arguments[6]; + dw = arguments[7]; + dh = arguments[8]; + } else { + throw Error('Invalid number of arguments'); + } + + var d = this.getCoords_(dx, dy); + + var w2 = sw / 2; + var h2 = sh / 2; + + var vmlStr = []; + + var W = 10; + var H = 10; + + // For some reason that I've now forgotten, using divs didn't work + vmlStr.push(' ' , + '', + ''); + + this.element_.insertAdjacentHTML('BeforeEnd', + vmlStr.join('')); + }; + + contextPrototype.stroke = function(aFill) { + var lineStr = []; + var lineOpen = false; + var a = processStyle(aFill ? this.fillStyle : this.strokeStyle); + var color = a.color; + var opacity = a.alpha * this.globalAlpha; + + var W = 10; + var H = 10; + + lineStr.push(''); + + if (!aFill) { + var lineWidth = this.lineScale_ * this.lineWidth; + + // VML cannot correctly render a line if the width is less than 1px. + // In that case, we dilute the color to make the line look thinner. + if (lineWidth < 1) { + opacity *= lineWidth; + } + + lineStr.push( + '' + ); + } else if (typeof this.fillStyle == 'object') { + var fillStyle = this.fillStyle; + var angle = 0; + var focus = {x: 0, y: 0}; + + // additional offset + var shift = 0; + // scale factor for offset + var expansion = 1; + + if (fillStyle.type_ == 'gradient') { + var x0 = fillStyle.x0_ / this.arcScaleX_; + var y0 = fillStyle.y0_ / this.arcScaleY_; + var x1 = fillStyle.x1_ / this.arcScaleX_; + var y1 = fillStyle.y1_ / this.arcScaleY_; + var p0 = this.getCoords_(x0, y0); + var p1 = this.getCoords_(x1, y1); + var dx = p1.x - p0.x; + var dy = p1.y - p0.y; + angle = Math.atan2(dx, dy) * 180 / Math.PI; + + // The angle should be a non-negative number. + if (angle < 0) { + angle += 360; + } + + // Very small angles produce an unexpected result because they are + // converted to a scientific notation string. + if (angle < 1e-6) { + angle = 0; + } + } else { + var p0 = this.getCoords_(fillStyle.x0_, fillStyle.y0_); + var width = max.x - min.x; + var height = max.y - min.y; + focus = { + x: (p0.x - min.x) / width, + y: (p0.y - min.y) / height + }; + + width /= this.arcScaleX_ * Z; + height /= this.arcScaleY_ * Z; + var dimension = m.max(width, height); + shift = 2 * fillStyle.r0_ / dimension; + expansion = 2 * fillStyle.r1_ / dimension - shift; + } + + // We need to sort the color stops in ascending order by offset, + // otherwise IE won't interpret it correctly. + var stops = fillStyle.colors_; + stops.sort(function(cs1, cs2) { + return cs1.offset - cs2.offset; + }); + + var length = stops.length; + var color1 = stops[0].color; + var color2 = stops[length - 1].color; + var opacity1 = stops[0].alpha * this.globalAlpha; + var opacity2 = stops[length - 1].alpha * this.globalAlpha; + + var colors = []; + for (var i = 0; i < length; i++) { + var stop = stops[i]; + colors.push(stop.offset * expansion + shift + ' ' + stop.color); + } + + // When colors attribute is used, the meanings of opacity and o:opacity2 + // are reversed. + lineStr.push(''); + } else { + lineStr.push(''); + } + + lineStr.push(''); + + this.element_.insertAdjacentHTML('beforeEnd', lineStr.join('')); + }; + + contextPrototype.fill = function() { + this.stroke(true); + } + + contextPrototype.closePath = function() { + this.currentPath_.push({type: 'close'}); + }; + + /** + * @private + */ + contextPrototype.getCoords_ = function(aX, aY) { + var m = this.m_; + return { + x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2, + y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2 + } + }; + + contextPrototype.save = function() { + var o = {}; + copyState(this, o); + this.aStack_.push(o); + this.mStack_.push(this.m_); + this.m_ = matrixMultiply(createMatrixIdentity(), this.m_); + }; + + contextPrototype.restore = function() { + copyState(this.aStack_.pop(), this); + this.m_ = this.mStack_.pop(); + }; + + contextPrototype.translate = function(aX, aY) { + var m1 = [ + [1, 0, 0], + [0, 1, 0], + [aX, aY, 1] + ]; + + this.m_ = matrixMultiply(m1, this.m_); + }; + + contextPrototype.rotate = function(aRot) { + var c = mc(aRot); + var s = ms(aRot); + + var m1 = [ + [c, s, 0], + [-s, c, 0], + [0, 0, 1] + ]; + + this.m_ = matrixMultiply(m1, this.m_); + }; + + contextPrototype.scale = function(aX, aY) { + this.arcScaleX_ *= aX; + this.arcScaleY_ *= aY; + var m1 = [ + [aX, 0, 0], + [0, aY, 0], + [0, 0, 1] + ]; + + var m = this.m_ = matrixMultiply(m1, this.m_); + + // Get the line scale. + // Determinant of this.m_ means how much the area is enlarged by the + // transformation. So its square root can be used as a scale factor + // for width. + var det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; + this.lineScale_ = sqrt(abs(det)); + }; + + /******** STUBS ********/ + contextPrototype.clip = function() { + // TODO: Implement + }; + + contextPrototype.arcTo = function() { + // TODO: Implement + }; + + contextPrototype.createPattern = function() { + return new CanvasPattern_; + }; + + // Gradient / Pattern Stubs + function CanvasGradient_(aType) { + this.type_ = aType; + this.x0_ = 0; + this.y0_ = 0; + this.r0_ = 0; + this.x1_ = 0; + this.y1_ = 0; + this.r1_ = 0; + this.colors_ = []; + } + + CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) { + aColor = processStyle(aColor); + this.colors_.push({offset: aOffset, + color: aColor.color, + alpha: aColor.alpha}); + }; + + function CanvasPattern_() {} + + // set up externs + G_vmlCanvasManager = G_vmlCanvasManager_; + CanvasRenderingContext2D = CanvasRenderingContext2D_; + CanvasGradient = CanvasGradient_; + CanvasPattern = CanvasPattern_; + +})(); + +} // if diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..8ce8c64 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,407 @@ + + + dygraphs JavaScript Library + + + + + +
+

dygraphs JavaScript Library
+ (Contact: Dan Vanderkam)

+
+ +

The dygraphs JavaScript library produces produces interactive, zoomable charts of time series based on CSV files.

+ +

Features

+
    +
  • Plots time series without using an external server or Flash
  • +
  • Supports multiple data series
  • +
  • Supports error bands around data series
  • +
  • Displays values on mouseover
  • +
  • Interactive zoom
  • +
  • Adjustable averaging period
  • +
  • Customizable click-through actions
  • +
+ +

Caveats

+
    +
  • Requires Firefox 1.5+ or Safari/WebKit 1.3+.
  • +
  • Internet Explorer is not at all supported!
  • +
  • Can only plot time series with granularity >= 1 day
  • +
+ +

Demo

+(Mouse over to highlight individual values. Click and drag to zoom. Double-click to zoom out.)
+ +
+
+
+
+

+ + +

Usage

+ +

The DateGraph library depends on two other JS libraries: MochiKit and PlotKit. Rather than tracking down copies of these libraries, I recommend using a packed version of dygraphs that combines all three libraries into a single JS file. To generate this file, go to a perforce client and run:

+ +
blaze build spam/utils/dygraphs:combined
+ +

The combined JS file is now in blaze-genfiles/spam/utils/dygraphs/combined.js. Here's a basic example to get things started:

+ + + + + + +
HTMLOutput
+<html>
+<head>
+<script type="text/javascript" src="combined.js"></script>
+</head>
+<body>
+<div id="graphdiv" style="width:400px; height:300px;"></div>
+<script type="text/javascript">
+  g = new DateGraph(
+        document.getElementById("graphdiv"),  // containing div
+        function() {                // function or path to CSV file.
+          return "20080507,75\n" +
+                 "20080508,70\n" +
+                 "20080509,80\n";
+        },
+        [ "Temperature" ],          // names of data series
+        {}                          // additional options (see below)
+      );
+</script>
+</body>
+</html>
+
+
+
+ +
+ +

In order to keep this example self-contained, the second parameter is a function that returns CSV data. These lines must begin with a date in the form YYYYMMDD. In most applications, it makes more sense to include a CSV file instead. If the second parameter to the constructor is a string, it will be interpreted as the path to a CSV file. The DateGraph will perform an XMLHttpRequest to retrieve this file and display the data when it becomes available. Make sure your CSV file is readable and serving from a place that understands XMLHttpRequest's! In particular, you cannot specify a CSV file using "file:///". Here's an example: (data from Weather Underground)

+ + + + + + +
HTMLOutput
+<html>
+<head>
+<script type="text/javascript" src="combined.js"></script>
+</head>
+<body>
+<div id="graphdiv" style="width:600px; height:300px;"></div>
+<script type="text/javascript">
+  g = new DateGraph(
+        document.getElementById("graphdiv"),
+        "temperatures.csv",  // path to CSV file
+        null,                // labels in top line of CSV file
+        {}
+      );
+</script>
+</body>
+</html>
+
+
+
+ +
+ +

Click here to view the temperatures.csv file. There are a few things to note here:

+ +
    +
  • Because the third parameter to the DateGraph constructor was null, the labels were taken from the first line of the data instead. The first line of temperatures.csv is Date,High,Low.
  • +
  • DateGraph automatically chose two different, easily-distinguishable colors for the two data series.
  • +
  • The labels on the x-axis have switched from days to months. If you zoom in, they'll switch to weeks and then days.
  • +
  • Some heuristics are used to determine a good vertical range for the data. The idea is to make all the data visible and have human-friendly values on the axis (i.e. 200 instead of 193.4). Generally this works well, but in this case the vertical range is way too large.
  • +
  • The data is very spiky. A moving average would be easier to interpret.
  • +
+ +

These last two problems can be fixed by specifying the appropriate options in the fourth parameter to the DateGraph constructor. To set the number of days for a moving average, use the rollPeriod option. To set the range of the y-axis, use the valueRange option. Here's how it's done:

+ + + + + + +
HTMLOutput
+<html>
+<head>
+<script type="text/javascript" src="combined.js"></script>
+</head>
+<body>
+<div id="graphdiv" style="width:600px; height:300px;"></div>
+<script type="text/javascript">
+  g = new DateGraph(
+        document.getElementById("graphdiv"),
+        "temperatures.csv", null,
+        { rollPeriod: 7,
+          valueRange: [25, 100]
+        }
+      );
+</script>
+</body>
+</html>
+
+
+
+ +
+ +

A rolling average can always be set using the text box in the lower left-hand corner of the graph.

+ +

Error Bars

+

Another significant feature of the dygraphs library is the ability to display error bars around data series. One standard deviation must be specified for each data point. A +/-n sigma band will be drawn around the data series at that point. If a moving average is being displayed, DateGraph will compute the standard deviation of the average at each point. (i.e. σ = sqrt((σ_1^2 + σ_2^2 + ... + σ_n^2)/n))

+ +

Here's a demonstration. There are two data series. One is N(100,10) with a standard deviation of 10 specified at each point. The other is N(80,20) with a standard deviation of 20 specified at each point. The CSV file was generated using Octave and can be viewed here.

+ + + + + + +
HTMLOutput
+<html>
+<head>
+<script type="text/javascript"
+  src="combined.js"></script>
+</head>
+<body>
+<div id="graphdiv" 
+ style="width:800px; height:400px;"
+ ></div>
+<script type="text/javascript">
+$ = document.getElementById;
+g = new DateGraph(
+  $("graphdiv"),
+  "twonormals.csv",
+  null,
+  { rollPeriod: 7,
+    errorBars: true,
+    valueRange: [50,125]
+  }
+);
+</script>
+</body>
+</html>
+
+
+
+ +
+ +

Things to note here:

+
    +
  • The errorBars option affects both the interpretation of the CSV file and the display of the graph. When errorBars is set to true, each line is interpreted as YYYYMMDD,A,sigma_A,B,sigma_B,...
  • +
  • The first line of the CSV file doesn't mention the error columns. In this case, it's just "Date,Series1,Series2".
  • +
  • The averaging visibly affects the error bars. This is most clear if you crank up the rolling period to something like 100 days. For the earliest dates, there won't be 100 data points to average so the signal will be noisier. The error bars get smaller like sqrt(N) going forward in time until there's a full 100 points to average.
  • +
  • The error bars are partially transparent. This can be seen when they overlap one another.
  • +
+ +

Other Options

+

These are the options that can be passed in through the fourth parameter of the DateGraph constructor.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSample ValueDescription
rollPeriod7Number of days over which to average data. Discussed extensively above.
colors['red', '#00FF00']List of colors for the data series. These can be of the form "#AABBCC" + or "rgb(255,100,200)" or "yellow", etc. If not specified, equally-spaced + points around a color wheel are used.
colorSaturation1.0If colors is not specified, saturation of the + automatically-generated data series colors. (0.0-1.0, default: + 1.0)
colorValue0.5If colors is not specified, value of the data series colors, as in + hue/saturation/value. (0.0-1.0, default 0.5)
clickCallbackfunction(e,date){ alert(date); }A function to call when a data point is clicked. The function should take + two arguments, the event object for the click and the date that was + clicked. (default null)
errorBarsfalseDoes the data contain standard deviations? Setting this to true alters + the input format (see above). (default false)
strokeWidth2.0Width of the data lines. This can be used to increase the contrast or + some graphs. (default 1.0)
dateWindow[(new Date('2006-01-01')).valueOf(),
+ (new Date()).valueOf()]
Initially zoom in on a section of the graph. Is of the form [earliest, + latest], where earliest/latest are millis since epoch. By default, the + full range of the input is shown.
valueRange[10, 110]Explicitly set the vertical range of the graph to [low, high]. By + default, some clever heuristics are used (see above).
minTickSize1 + The difference between ticks on the y-axis can be greater than or equal + to this, but no less. If you set it to 1, for instance, you'll never get + nonintegral gaps between ticks.
labelsSeparateLinestruePut <br/> between lines in the label string. Often used in + conjunction with labelsDiv. (default false)
labelsDivdocument.getElementById('foo')Show data labels in an external div, rather than on the graph. (default + null)
labelsKMBtrueShow K/M/B for thousands/millions/billions on y-axis (default + false).
padding{left: 40, right: 30,
top: 5, + bottom: 15}
Adds extra pixels of padding around the graph. Sometimes a dygraph + gets clipped by surrounding text (see the Demo at the top of this page). + Setting this property appropriately will fix this problem.
+ +

Any options you specify also get passed on to PlotKit's Renderer class. DateGraph will override some of these (e.g. strokeColor), but others may be useful. The padding property is an example of this.

+ +

Common Gotchas

+

Here are a few problems that I've frequently run into while using the +dygraphs library.

+ +
    +
  • Make sure your CSV files are readable! If your graph isn't showing up, + the XMLHttpRequest for the CSV file may be failing. You can determine whether + this is the case using tools like Firebug.
  • + +
  • Make sure your CSV files are in the correct format. They must be of the + form YYYYMMDD,series1,series2,.... If you're specifying the + names of each data series in the CSV file itself, make sure that you pass + null as the third parameter to the DateGraph constructor to let + the library know that. And if you set the errorBars property, + make sure you alternate data series and standard deviations.
  • + +
  • dygraphs are not happy when placed inside a <center> + tag. This applies to the CSS text-align property as well. If you + want to center a DateGraph, put it inside a table with "align=center" + set.
  • + +
  • If you specify the colors property or name the data series + using the third parameter of the DateGraph constructor, make sure the number + of data series agree in all places: colors, third parameter and + in each line of the CSV file itself.
  • + +
  • Don't set the dateWindow property to a date. It expects + milliseconds since epoch, which can be obtained from a JavaScript Date + object's valueOf method.
  • +
+ +

Created May 9, 2008 by Dan Vanderkam

+ + + diff --git a/docs/temperatures.csv b/docs/temperatures.csv new file mode 100644 index 0000000..9d00173 --- /dev/null +++ b/docs/temperatures.csv @@ -0,0 +1,367 @@ +Date,High,Low +200701011,62,39 +200701021,62,44 +200701031,62,42 +200701041,57,45 +200701051,54,44 +200701061,55,36 +200701071,62,45 +200701081,66,48 +200701091,63,39 +200701101,57,37 +200701111,50,37 +200701121,48,35 +200701131,48,30 +200701141,48,28 +200701151,53,28 +200701161,50,30 +200701171,57,37 +200701181,61,33 +200701191,55,35 +200701201,61,35 +200701211,64,43 +200701221,61,36 +200701231,57,35 +200701241,60,35 +200701251,55,39 +200701261,54,44 +200701271,57,48 +200701281,59,45 +200701291,63,45 +200701301,59,41 +200701311,55,48 +200702011,53,46 +200702021,55,44 +200702031,59,37 +200702041,66,39 +200702051,64,43 +200702061,61,46 +200702071,61,51 +200702081,60,51 +200702091,61,55 +200702101,62,55 +200702111,61,46 +200702121,59,43 +200702131,57,46 +200702141,61,39 +200702151,64,44 +200702161,71,46 +200702171,73,51 +200702181,60,46 +200702191,63,44 +200702201,57,45 +200702211,59,48 +200702221,55,44 +200702231,55,42 +200702241,57,39 +200702251,55,48 +200702261,57,44 +200702271,53,39 +200702281,53,37 +200703011,54,37 +200703021,61,39 +200703031,66,43 +200703041,70,48 +200703051,68,53 +200703061,69,46 +200703071,62,51 +200703081,61,46 +200703091,60,45 +200703101,68,46 +200703111,79,48 +200703121,80,52 +200703131,73,53 +200703141,64,48 +200703151,78,46 +200703161,78,50 +200703171,62,51 +200703181,66,46 +200703191,64,48 +200703201,60,48 +200703211,66,46 +200703221,73,43 +200703231,78,48 +200703241,68,48 +200703251,64,53 +200703261,66,48 +200703271,57,46 +200703281,66,42 +200703291,73,42 +200703301,72,46 +200703311,69,46 +200704011,64,46 +200704021,69,46 +200704031,71,46 +200704041,69,50 +200704051,71,52 +200704061,64,52 +200704071,68,51 +200704081,71,51 +200704091,66,50 +200704101,72,46 +200704111,63,50 +200704121,64,46 +200704131,70,44 +200704141,57,51 +200704151,68,46 +200704161,75,46 +200704171,62,48 +200704181,61,45 +200704191,57,42 +200704201,64,46 +200704211,61,43 +200704221,63,48 +200704231,70,44 +200704241,66,46 +200704251,66,48 +200704261,69,48 +200704271,82,50 +200704281,81,55 +200704291,70,53 +200704301,77,51 +200705011,70,48 +200705021,66,52 +200705031,63,48 +200705041,64,51 +200705051,73,46 +200705061,88,54 +200705071,91,57 +200705081,84,60 +200705091,73,55 +200705101,57,52 +200705111,64,51 +200705121,64,50 +200705131,72,46 +200705141,66,50 +200705151,63,51 +200705161,70,48 +200705171,68,50 +200705181,73,50 +200705191,70,52 +200705201,73,51 +200705211,78,54 +200705221,81,51 +200705231,86,55 +200705241,78,55 +200705251,69,54 +200705261,69,55 +200705271,69,54 +200705281,73,52 +200705291,69,53 +200705301,66,55 +200705311,64,54 +200706011,66,54 +200706021,64,54 +200706031,70,55 +200706041,73,59 +200706051,68,55 +200706061,70,53 +200706071,75,51 +200706081,70,50 +200706091,75,53 +200706101,75,55 +200706111,75,53 +200706121,79,52 +200706131,90,59 +200706141,89,60 +200706151,86,59 +200706161,72,55 +200706171,79,53 +200706181,79,57 +200706191,73,55 +200706201,71,55 +200706211,77,55 +200706221,79,54 +200706231,77,54 +200706241,77,53 +200706251,82,53 +200706261,71,54 +200706271,73,55 +200706281,73,57 +200706291,77,60 +200706301,75,54 +200707011,78,54 +200707021,82,57 +200707031,72,57 +200707041,84,59 +200707051,84,61 +200707061,75,60 +200707071,73,55 +200707081,78,55 +200707091,73,57 +200707101,73,59 +200707111,78,62 +200707121,75,59 +200707131,79,60 +200707141,73,60 +200707151,78,62 +200707161,75,59 +200707171,77,60 +200707181,75,63 +200707191,80,59 +200707201,79,59 +200707211,77,61 +200707221,75,63 +200707231,79,64 +200707241,73,61 +200707251,72,57 +200707261,75,60 +200707271,78,60 +200707281,77,57 +200707291,73,57 +200707301,80,59 +200707311,75,59 +200708011,75,59 +200708021,73,60 +200708031,79,60 +200708041,77,59 +200708051,71,57 +200708061,71,59 +200708071,73,57 +200708081,71,55 +200708091,77,60 +200708101,77,57 +200708111,73,57 +200708121,72,55 +200708131,75,55 +200708141,73,55 +200708151,75,57 +200708161,79,60 +200708171,80,55 +200708181,78,57 +200708191,77,55 +200708201,80,64 +200708211,82,62 +200708221,82,60 +200708231,82,57 +200708241,78,59 +200708251,73,61 +200708261,73,61 +200708271,78,59 +200708281,86,62 +200708291,88,68 +200708301,90,68 +200708311,80,66 +200709011,87,62 +200709021,89,61 +200709031,78,61 +200709041,78,63 +200709051,89,57 +200709061,82,64 +200709071,75,61 +200709081,73,62 +200709091,71,61 +200709101,73,59 +200709111,71,59 +200709121,72,60 +200709131,77,57 +200709141,75,60 +200709151,73,57 +200709161,72,61 +200709171,72,55 +200709181,73,55 +200709191,66,55 +200709201,71,52 +200709211,77,57 +200709221,64,57 +200709231,68,55 +200709241,78,52 +200709251,84,53 +200709261,87,57 +200709271,75,55 +200709281,66,54 +200709291,73,52 +200709301,75,48 +200710011,71,57 +200710021,81,53 +200710031,73,54 +200710041,69,55 +200710051,64,50 +200710061,73,45 +200710071,77,46 +200710081,79,53 +200710091,72,53 +200710101,69,54 +200710111,70,48 +200710121,64,54 +200710131,70,53 +200710141,66,51 +200710151,68,52 +200710161,66,52 +200710171,66,50 +200710181,73,50 +200710191,72,57 +200710201,66,54 +200710211,73,51 +200710221,81,51 +200710231,84,53 +200710241,79,55 +200710251,66,53 +200710261,68,46 +200710271,66,52 +200710281,75,52 +200710291,63,55 +200710301,63,53 +200710311,63,54 +200711011,66,53 +200711021,77,50 +200711031,80,48 +200711041,77,48 +200711051,66,48 +200711061,62,52 +200711071,61,48 +200711081,59,53 +200711091,63,48 +200711101,66,48 +200711111,63,48 +200711121,68,44 +200711131,72,51 +200711141,75,55 +200711151,69,51 +200711161,63,55 +200711171,66,51 +200711181,64,53 +200711191,66,48 +200711201,63,46 +200711211,64,43 +200711221,64,37 +200711231,70,37 +200711241,60,37 +200711251,60,46 +200711261,63,42 +200711271,63,45 +200711281,64,46 +200711291,62,41 +200711301,55,42 +200712011,57,37 +200712021,61,45 +200712031,66,50 +200712041,61,54 +200712051,60,50 +200712061,57,48 +200712071,55,45 +200712081,53,42 +200712091,57,39 +200712101,57,39 +200712111,57,41 +200712121,55,35 +200712131,59,34 +200712141,55,34 +200712151,55,39 +200712161,55,43 +200712171,57,48 +200712181,57,43 +200712191,59,41 +200712201,55,43 +200712211,53,39 +200712221,53,32 +200712231,55,37 +200712241,57,45 +200712251,57,37 +200712261,53,43 +200712271,48,37 +200712281,48,43 +200712291,57,44 +200712301,52,43 +200712311,57,42 + diff --git a/docs/temperatures.txt b/docs/temperatures.txt new file mode 100644 index 0000000..9d00173 --- /dev/null +++ b/docs/temperatures.txt @@ -0,0 +1,367 @@ +Date,High,Low +200701011,62,39 +200701021,62,44 +200701031,62,42 +200701041,57,45 +200701051,54,44 +200701061,55,36 +200701071,62,45 +200701081,66,48 +200701091,63,39 +200701101,57,37 +200701111,50,37 +200701121,48,35 +200701131,48,30 +200701141,48,28 +200701151,53,28 +200701161,50,30 +200701171,57,37 +200701181,61,33 +200701191,55,35 +200701201,61,35 +200701211,64,43 +200701221,61,36 +200701231,57,35 +200701241,60,35 +200701251,55,39 +200701261,54,44 +200701271,57,48 +200701281,59,45 +200701291,63,45 +200701301,59,41 +200701311,55,48 +200702011,53,46 +200702021,55,44 +200702031,59,37 +200702041,66,39 +200702051,64,43 +200702061,61,46 +200702071,61,51 +200702081,60,51 +200702091,61,55 +200702101,62,55 +200702111,61,46 +200702121,59,43 +200702131,57,46 +200702141,61,39 +200702151,64,44 +200702161,71,46 +200702171,73,51 +200702181,60,46 +200702191,63,44 +200702201,57,45 +200702211,59,48 +200702221,55,44 +200702231,55,42 +200702241,57,39 +200702251,55,48 +200702261,57,44 +200702271,53,39 +200702281,53,37 +200703011,54,37 +200703021,61,39 +200703031,66,43 +200703041,70,48 +200703051,68,53 +200703061,69,46 +200703071,62,51 +200703081,61,46 +200703091,60,45 +200703101,68,46 +200703111,79,48 +200703121,80,52 +200703131,73,53 +200703141,64,48 +200703151,78,46 +200703161,78,50 +200703171,62,51 +200703181,66,46 +200703191,64,48 +200703201,60,48 +200703211,66,46 +200703221,73,43 +200703231,78,48 +200703241,68,48 +200703251,64,53 +200703261,66,48 +200703271,57,46 +200703281,66,42 +200703291,73,42 +200703301,72,46 +200703311,69,46 +200704011,64,46 +200704021,69,46 +200704031,71,46 +200704041,69,50 +200704051,71,52 +200704061,64,52 +200704071,68,51 +200704081,71,51 +200704091,66,50 +200704101,72,46 +200704111,63,50 +200704121,64,46 +200704131,70,44 +200704141,57,51 +200704151,68,46 +200704161,75,46 +200704171,62,48 +200704181,61,45 +200704191,57,42 +200704201,64,46 +200704211,61,43 +200704221,63,48 +200704231,70,44 +200704241,66,46 +200704251,66,48 +200704261,69,48 +200704271,82,50 +200704281,81,55 +200704291,70,53 +200704301,77,51 +200705011,70,48 +200705021,66,52 +200705031,63,48 +200705041,64,51 +200705051,73,46 +200705061,88,54 +200705071,91,57 +200705081,84,60 +200705091,73,55 +200705101,57,52 +200705111,64,51 +200705121,64,50 +200705131,72,46 +200705141,66,50 +200705151,63,51 +200705161,70,48 +200705171,68,50 +200705181,73,50 +200705191,70,52 +200705201,73,51 +200705211,78,54 +200705221,81,51 +200705231,86,55 +200705241,78,55 +200705251,69,54 +200705261,69,55 +200705271,69,54 +200705281,73,52 +200705291,69,53 +200705301,66,55 +200705311,64,54 +200706011,66,54 +200706021,64,54 +200706031,70,55 +200706041,73,59 +200706051,68,55 +200706061,70,53 +200706071,75,51 +200706081,70,50 +200706091,75,53 +200706101,75,55 +200706111,75,53 +200706121,79,52 +200706131,90,59 +200706141,89,60 +200706151,86,59 +200706161,72,55 +200706171,79,53 +200706181,79,57 +200706191,73,55 +200706201,71,55 +200706211,77,55 +200706221,79,54 +200706231,77,54 +200706241,77,53 +200706251,82,53 +200706261,71,54 +200706271,73,55 +200706281,73,57 +200706291,77,60 +200706301,75,54 +200707011,78,54 +200707021,82,57 +200707031,72,57 +200707041,84,59 +200707051,84,61 +200707061,75,60 +200707071,73,55 +200707081,78,55 +200707091,73,57 +200707101,73,59 +200707111,78,62 +200707121,75,59 +200707131,79,60 +200707141,73,60 +200707151,78,62 +200707161,75,59 +200707171,77,60 +200707181,75,63 +200707191,80,59 +200707201,79,59 +200707211,77,61 +200707221,75,63 +200707231,79,64 +200707241,73,61 +200707251,72,57 +200707261,75,60 +200707271,78,60 +200707281,77,57 +200707291,73,57 +200707301,80,59 +200707311,75,59 +200708011,75,59 +200708021,73,60 +200708031,79,60 +200708041,77,59 +200708051,71,57 +200708061,71,59 +200708071,73,57 +200708081,71,55 +200708091,77,60 +200708101,77,57 +200708111,73,57 +200708121,72,55 +200708131,75,55 +200708141,73,55 +200708151,75,57 +200708161,79,60 +200708171,80,55 +200708181,78,57 +200708191,77,55 +200708201,80,64 +200708211,82,62 +200708221,82,60 +200708231,82,57 +200708241,78,59 +200708251,73,61 +200708261,73,61 +200708271,78,59 +200708281,86,62 +200708291,88,68 +200708301,90,68 +200708311,80,66 +200709011,87,62 +200709021,89,61 +200709031,78,61 +200709041,78,63 +200709051,89,57 +200709061,82,64 +200709071,75,61 +200709081,73,62 +200709091,71,61 +200709101,73,59 +200709111,71,59 +200709121,72,60 +200709131,77,57 +200709141,75,60 +200709151,73,57 +200709161,72,61 +200709171,72,55 +200709181,73,55 +200709191,66,55 +200709201,71,52 +200709211,77,57 +200709221,64,57 +200709231,68,55 +200709241,78,52 +200709251,84,53 +200709261,87,57 +200709271,75,55 +200709281,66,54 +200709291,73,52 +200709301,75,48 +200710011,71,57 +200710021,81,53 +200710031,73,54 +200710041,69,55 +200710051,64,50 +200710061,73,45 +200710071,77,46 +200710081,79,53 +200710091,72,53 +200710101,69,54 +200710111,70,48 +200710121,64,54 +200710131,70,53 +200710141,66,51 +200710151,68,52 +200710161,66,52 +200710171,66,50 +200710181,73,50 +200710191,72,57 +200710201,66,54 +200710211,73,51 +200710221,81,51 +200710231,84,53 +200710241,79,55 +200710251,66,53 +200710261,68,46 +200710271,66,52 +200710281,75,52 +200710291,63,55 +200710301,63,53 +200710311,63,54 +200711011,66,53 +200711021,77,50 +200711031,80,48 +200711041,77,48 +200711051,66,48 +200711061,62,52 +200711071,61,48 +200711081,59,53 +200711091,63,48 +200711101,66,48 +200711111,63,48 +200711121,68,44 +200711131,72,51 +200711141,75,55 +200711151,69,51 +200711161,63,55 +200711171,66,51 +200711181,64,53 +200711191,66,48 +200711201,63,46 +200711211,64,43 +200711221,64,37 +200711231,70,37 +200711241,60,37 +200711251,60,46 +200711261,63,42 +200711271,63,45 +200711281,64,46 +200711291,62,41 +200711301,55,42 +200712011,57,37 +200712021,61,45 +200712031,66,50 +200712041,61,54 +200712051,60,50 +200712061,57,48 +200712071,55,45 +200712081,53,42 +200712091,57,39 +200712101,57,39 +200712111,57,41 +200712121,55,35 +200712131,59,34 +200712141,55,34 +200712151,55,39 +200712161,55,43 +200712171,57,48 +200712181,57,43 +200712191,59,41 +200712201,55,43 +200712211,53,39 +200712221,53,32 +200712231,55,37 +200712241,57,45 +200712251,57,37 +200712261,53,43 +200712271,48,37 +200712281,48,43 +200712291,57,44 +200712301,52,43 +200712311,57,42 + diff --git a/docs/twonormals.csv b/docs/twonormals.csv new file mode 100644 index 0000000..2185e90 --- /dev/null +++ b/docs/twonormals.csv @@ -0,0 +1,366 @@ +Date,Series1,Series2 +200701011,94.0946841239929,10,92.7865064144135,20 +200701021,113.201811313629,10,48.7444639205933,20 +200701031,95.592303276062,10,79.2437474429607,20 +200701041,97.5064766407013,10,77.9290872812271,20 +200701051,106.963732838631,10,95.9084284305573,20 +200701061,80.2781760692596,10,61.6853272914886,20 +200701071,100.051359818317,10,73.4595620632172,20 +200701081,89.2442333698273,10,56.9360947608948,20 +200701091,106.051690578461,10,107.259395122528,20 +200701101,101.531482040882,10,86.664856672287,20 +200701111,89.1888439655304,10,77.707946896553,20 +200701121,107.355877161026,10,77.3741406202316,20 +200701131,94.1611880064011,10,121.865606307983,20 +200701141,96.1331555247307,10,93.0631613731384,20 +200701151,101.575378775597,10,82.4605470895767,20 +200701161,102.771860063076,10,76.7487442493439,20 +200701171,94.0878880023956,10,80.7623960077763,20 +200701181,109.288640022278,10,47.7631306648254,20 +200701191,100.911911055446,10,64.3824207782745,20 +200701201,112.278221845627,10,68.3479058742523,20 +200701211,78.9384078979492,10,103.021440505981,20 +200701221,107.03338265419,10,45.7433104515076,20 +200701231,120.598442554474,10,120.512318611145,20 +200701241,91.6525495052338,10,73.7835818529129,20 +200701251,86.6101157665253,10,61.0721278190613,20 +200701261,76.7657494544983,10,49.9800586700439,20 +200701271,104.709110856056,10,64.9826431274414,20 +200701281,87.2436583042145,10,98.4307944774628,20 +200701291,86.5187978744507,10,56.8577694892883,20 +200701301,96.5837013721466,10,91.8027782440186,20 +200701311,104.319975674152,10,53.7843894958496,20 +200702011,93.6525058746338,10,114.006254673004,20 +200702021,132.866880893707,10,91.8379282951355,20 +200702031,93.4353011846542,10,77.8351998329163,20 +200702041,106.085510253906,10,130.814952850342,20 +200702051,93.2852751016617,10,81.5491008758545,20 +200702061,92.3503077030182,10,92.9888260364532,20 +200702071,92.8799241781235,10,67.8397727012634,20 +200702081,90.887468457222,10,106.050927639008,20 +200702091,97.4124673008919,10,61.2136566638947,20 +200702101,93.2560741901398,10,70.8249318599701,20 +200702111,109.902315735817,10,60.8251547813416,20 +200702121,94.9087244272232,10,64.1621708869934,20 +200702131,95.3440955281258,10,75.9353131055832,20 +200702141,102.835389971733,10,67.8751254081726,20 +200702151,84.5214533805847,10,49.9142575263977,20 +200702161,103.06267619133,10,115.240833759308,20 +200702171,97.7182766795158,10,83.3081617951393,20 +200702181,116.737879514694,10,101.066656112671,20 +200702191,120.076403617859,10,90.3911316394806,20 +200702201,95.6556394696236,10,113.495917320251,20 +200702211,94.5879065990448,10,96.415947675705,20 +200702221,101.539226770401,10,61.9145536422729,20 +200702231,98.8678465783596,10,77.8282150626183,20 +200702241,97.6890955865383,10,67.0508527755737,20 +200702251,99.6496134251356,10,86.52967274189,20 +200702261,100.740707740188,10,98.5435569286346,20 +200702271,91.4698106050491,10,69.810516834259,20 +200702281,98.8102301210165,10,47.4838805198669,20 +200703011,99.2288841307163,10,94.5062613487244,20 +200703021,92.5863647460938,10,103.611235618591,20 +200703031,114.908181428909,10,74.837434887886,20 +200703041,109.287412166595,10,91.3202583789825,20 +200703051,95.3682035207748,10,79.3710635602474,20 +200703061,95.1182308793068,10,98.0750358104706,20 +200703071,103.946290016174,10,50.4906249046326,20 +200703081,109.746969342232,10,68.1199038028717,20 +200703091,114.140131473541,10,92.4589133262634,20 +200703101,85.407782793045,10,91.6265773773193,20 +200703111,90.8102822303772,10,55.8610534667969,20 +200703121,96.6755110025406,10,118.259813785553,20 +200703131,83.8195776939392,10,123.414402008057,20 +200703141,108.24079990387,10,88.1427580118179,20 +200703151,104.835974276066,10,113.903331756592,20 +200703161,93.1726837158203,10,64.5078217983246,20 +200703171,103.685465157032,10,110.236563682556,20 +200703181,90.1124656200409,10,83.8830429315567,20 +200703191,97.3299288749695,10,87.7998399734497,20 +200703201,107.909459471703,10,42.5621438026428,20 +200703211,95.2882331609726,10,82.12317019701,20 +200703221,108.571609854698,10,102.018263339996,20 +200703231,99.6926294267178,10,59.2778038978577,20 +200703241,112.102061510086,10,94.2071461677551,20 +200703251,94.4191563129425,10,77.509905397892,20 +200703261,100.833547562361,10,94.6505665779114,20 +200703271,106.16162955761,10,61.8702232837677,20 +200703281,98.9218898117542,10,112.216217517853,20 +200703291,96.4712545275688,10,55.2638268470764,20 +200703301,96.4686763286591,10,89.237694144249,20 +200703311,101.455799043179,10,88.7331908941269,20 +200704011,102.23684206605,10,111.971719264984,20 +200704021,114.709233045578,10,66.1184501647949,20 +200704031,107.03797519207,10,124.90466594696,20 +200704041,101.396441310644,10,107.248797416687,20 +200704051,103.902289569378,10,64.0629303455353,20 +200704061,92.3808485269547,10,76.2916377186775,20 +200704071,105.23556470871,10,43.2561206817627,20 +200704081,87.1553158760071,10,82.2280541062355,20 +200704091,119.241544008255,10,53.4055876731873,20 +200704101,111.096258163452,10,79.0462526679039,20 +200704111,97.4128222465515,10,55.7952237129211,20 +200704121,110.409885644913,10,70.3491985797882,20 +200704131,95.4885852336884,10,58.0946588516235,20 +200704141,103.764507174492,10,61.7675912380219,20 +200704151,114.021297693253,10,94.2548739910126,20 +200704161,98.9073173701763,10,43.8510704040527,20 +200704171,115.810360908508,10,68.9345467090607,20 +200704181,101.422971785069,10,100.504853725433,20 +200704191,119.795391559601,10,100.85517168045,20 +200704201,92.0360016822815,10,82.4440509080887,20 +200704211,112.404752969742,10,81.8624790012836,20 +200704221,104.059817194939,10,51.2524080276489,20 +200704231,93.1676262617111,10,86.5015059709549,20 +200704241,93.2092815637589,10,90.7923364639282,20 +200704251,104.13601398468,10,101.198389530182,20 +200704261,98.1847678124905,10,42.97687292099,20 +200704271,121.308670043945,10,45.9942388534546,20 +200704281,115.053536891937,10,71.6148275136948,20 +200704291,94.0280091762543,10,56.2359380722046,20 +200704301,88.1207823753357,10,99.3783688545227,20 +200705011,111.701385974884,10,80.2669881284237,20 +200705021,98.714727461338,10,56.6372489929199,20 +200705031,103.363722264767,10,100.052332878113,20 +200705041,111.602603197098,10,77.2077092528343,20 +200705051,99.4656148552895,10,82.2163315117359,20 +200705061,77.7958679199219,10,105.606355667114,20 +200705071,104.113802611828,10,50.6052374839783,20 +200705081,123.41313123703,10,77.7422100305557,20 +200705091,94.3239623308182,10,81.5457877516747,20 +200705101,88.1108486652374,10,57.1634531021118,20 +200705111,105.014639496803,10,99.3462133407593,20 +200705121,100.885331854224,10,84.4843065738678,20 +200705131,100.741365477443,10,66.0745120048523,20 +200705141,91.6865712404251,10,96.2191820144653,20 +200705151,114.093443155289,10,102.257599830627,20 +200705161,97.6279026269913,10,130.860342979431,20 +200705171,112.286994457245,10,78.5536044836044,20 +200705181,95.2370589971542,10,44.7373557090759,20 +200705191,97.7498243749142,10,93.4921395778656,20 +200705201,108.320077061653,10,69.7792756557465,20 +200705211,99.222916662693,10,67.9618048667908,20 +200705221,96.8812572956085,10,102.4937748909,20 +200705231,69.8594975471497,10,70.4179978370667,20 +200705241,89.9046337604523,10,108.971984386444,20 +200705251,96.7731782793999,10,71.2224543094635,20 +200705261,112.635122537613,10,122.293920516968,20 +200705271,104.880233108997,10,75.9474596381187,20 +200705281,108.829988837242,10,66.4318740367889,20 +200705291,113.387352228165,10,85.2988499403,20 +200705301,94.149631857872,10,73.1878679990768,20 +200705311,106.634711623192,10,93.1930267810822,20 +200706011,99.3034096062183,10,57.9911375045776,20 +200706021,103.288851976395,10,46.1840200424194,20 +200706031,107.427718043327,10,94.0104794502258,20 +200706041,86.3590371608734,10,77.0007252693176,20 +200706051,101.470438838005,10,77.6732224225998,20 +200706061,95.8705332875252,10,102.285735607147,20 +200706071,116.72345161438,10,82.1839436888695,20 +200706081,88.9263653755188,10,29.0613269805908,20 +200706091,99.8003915697336,10,75.9601619839668,20 +200706101,99.5304548367858,10,79.3176300823689,20 +200706111,96.5316081047058,10,95.626939535141,20 +200706121,84.9738717079163,10,63.4740471839905,20 +200706131,103.224220573902,10,76.5348345041275,20 +200706141,90.2293705940247,10,58.5764074325562,20 +200706151,82.8239297866821,10,88.4199869632721,20 +200706161,108.036482334137,10,79.1778791695833,20 +200706171,111.484116315842,10,59.3552279472351,20 +200706181,107.548137307167,10,84.4000813364983,20 +200706191,108.109716176987,10,48.3497023582458,20 +200706201,115.827913284302,10,90.9793400764465,20 +200706211,100.512249879539,10,105.234756469727,20 +200706221,105.511372685432,10,93.8042879104614,20 +200706231,96.7094963788986,10,117.535014152527,20 +200706241,94.7944843769073,10,96.3854289054871,20 +200706251,98.8138699531555,10,67.9375243186951,20 +200706261,87.5452423095703,10,110.896701812744,20 +200706271,95.6386211514473,10,87.176525592804,20 +200706281,105.971124768257,10,104.18493270874,20 +200706291,105.616582632065,10,100.755131244659,20 +200706301,87.1863389015198,10,87.1826964616776,20 +200707011,122.550580501556,10,29.0275621414185,20 +200707021,97.9201781749725,10,75.8811420202255,20 +200707031,101.693934798241,10,26.1782026290894,20 +200707041,106.984695196152,10,87.9097819328308,20 +200707051,101.652606278658,10,80.0788712035865,20 +200707061,103.062781989574,10,75.9296423196793,20 +200707071,85.9849941730499,10,111.249039173126,20 +200707081,111.554799079895,10,84.0449270606041,20 +200707091,108.148396611214,10,78.3289317786694,20 +200707101,120.08163690567,10,73.9953505992889,20 +200707111,95.8106634020805,10,77.5311101973057,20 +200707121,109.306951761246,10,98.9882755279541,20 +200707131,109.748197793961,10,77.1462577581406,20 +200707141,107.401624917984,10,70.9187364578247,20 +200707151,115.204228162766,10,51.7829537391663,20 +200707161,101.363894045353,10,62.3194003105164,20 +200707171,101.237911954522,10,82.4289344251156,20 +200707181,101.364123821259,10,112.487089633942,20 +200707191,82.0579624176025,10,84.9630063772202,20 +200707201,87.840758562088,10,113.736288547516,20 +200707211,96.2999013066292,10,90.8173656463623,20 +200707221,74.482958316803,10,96.8275988101959,20 +200707231,92.1898084878922,10,81.5540917217731,20 +200707241,111.657168865204,10,99.6730208396912,20 +200707251,95.6442388892174,10,84.8401191830635,20 +200707261,126.834321022034,10,49.5946288108826,20 +200707271,104.035118818283,10,106.899120807648,20 +200707281,114.844251871109,10,71.1432409286499,20 +200707291,93.8618439435959,10,72.0631432533264,20 +200707301,110.952197313309,10,86.6521227359772,20 +200707311,94.7132760286331,10,80.2921519987285,20 +200708011,108.074281215668,10,83.1143301725388,20 +200708021,102.066531479359,10,81.2765935063362,20 +200708031,96.064564883709,10,68.3822906017303,20 +200708041,94.8778116703033,10,105.685148239136,20 +200708051,96.9068056344986,10,83.0777508020401,20 +200708061,72.676248550415,10,102.971677780151,20 +200708071,102.892329394817,10,95.9137535095215,20 +200708081,100.392684154212,10,67.2186517715454,20 +200708091,102.075793892145,10,98.5560536384583,20 +200708101,97.244453728199,10,67.8452551364899,20 +200708111,95.4441091418266,10,102.870435714722,20 +200708121,98.565482199192,10,76.2988811731339,20 +200708131,104.287070035934,10,82.662740945816,20 +200708141,109.793092012405,10,39.3169212341309,20 +200708151,112.275532484055,10,77.8041803836823,20 +200708161,77.7145385742188,10,72.9709446430206,20 +200708171,109.886486530304,10,38.7261343002319,20 +200708181,108.64046394825,10,67.3095226287842,20 +200708191,85.4451429843903,10,62.3904550075531,20 +200708201,83.6442470550537,10,106.529610157013,20 +200708211,109.308217763901,10,60.1290965080261,20 +200708221,108.235449790955,10,42.5594019889832,20 +200708231,123.438725471497,10,70.7120442390442,20 +200708241,96.0279887914658,10,98.3958852291107,20 +200708251,116.927028894424,10,64.0689778327942,20 +200708261,98.9606958627701,10,91.1650800704956,20 +200708271,95.2501532435417,10,67.9479813575745,20 +200708281,127.378940582275,10,81.7891944944859,20 +200708291,101.324769854546,10,70.4397636651993,20 +200708301,103.480939865112,10,99.0965926647186,20 +200708311,106.017985343933,10,38.3763265609741,20 +200709011,77.277090549469,10,97.051066160202,20 +200709021,97.553293555975,10,53.2996654510498,20 +200709031,112.12229013443,10,48.2950472831726,20 +200709041,88.9848005771637,10,64.006495475769,20 +200709051,113.623507022858,10,90.6919419765472,20 +200709061,117.776914834976,10,65.5359637737274,20 +200709071,95.3629437088966,10,65.0978481769562,20 +200709081,107.617252469063,10,132.306122779846,20 +200709091,84.3433558940887,10,76.6177946329117,20 +200709101,103.260976672173,10,100.815682411194,20 +200709111,88.3913385868073,10,85.6291252374649,20 +200709121,102.712529301643,10,125.389094352722,20 +200709131,101.77043363452,10,58.5648274421692,20 +200709141,111.676977872849,10,107.442679405212,20 +200709151,116.648640632629,10,67.8087985515594,20 +200709161,93.7750494480133,10,73.3145958185196,20 +200709171,103.814198076725,10,59.816951751709,20 +200709181,102.28799149394,10,63.2355391979218,20 +200709191,102.797355353832,10,78.1814505159855,20 +200709201,90.6087863445282,10,72.3672294616699,20 +200709211,95.8696460723877,10,101.906864643097,20 +200709221,101.489384919405,10,105.947561264038,20 +200709231,88.5241162776947,10,72.0068687200546,20 +200709241,103.184829056263,10,73.6309725046158,20 +200709251,108.286160826683,10,87.141484618187,20 +200709261,99.1833540052176,10,92.3960912227631,20 +200709271,105.875065922737,10,97.6024556159973,20 +200709281,109.003535509109,10,116.824145317078,20 +200709291,119.159464836121,10,84.8063838481903,20 +200709301,88.9144706726074,10,42.9914784431458,20 +200710011,107.298363447189,10,91.3336789608002,20 +200710021,108.407359719276,10,66.9903635978699,20 +200710031,89.8164367675781,10,54.9865126609802,20 +200710041,114.692898988724,10,70.2726489305496,20 +200710051,99.0317782759666,10,121.484136581421,20 +200710061,95.2851551771164,10,77.5017619132996,20 +200710071,75.3657913208008,10,91.8574166297913,20 +200710081,93.4729248285294,10,43.2036662101746,20 +200710091,118.223353624344,10,75.5406692624092,20 +200710101,103.33395242691,10,97.8111124038696,20 +200710111,85.7886075973511,10,59.4538998603821,20 +200710121,92.8499019145966,10,86.2665349245071,20 +200710131,90.1979243755341,10,60.1760244369507,20 +200710141,113.305931091309,10,74.9672168493271,20 +200710151,98.8471588492393,10,46.5943837165833,20 +200710161,105.021520853043,10,75.8990100026131,20 +200710171,103.107974529266,10,48.1224822998047,20 +200710181,94.6753841638565,10,101.704847812653,20 +200710191,92.0168948173523,10,63.6530780792236,20 +200710201,95.3590556979179,10,83.1053757667542,20 +200710211,103.06764870882,10,93.262699842453,20 +200710221,107.505331039429,10,135.405459403992,20 +200710231,114.560452699661,10,91.0899269580841,20 +200710241,90.034704208374,10,47.4418616294861,20 +200710251,93.8096088171005,10,64.0784442424774,20 +200710261,88.0993688106537,10,61.059547662735,20 +200710271,110.720720291138,10,93.6888122558594,20 +200710281,102.795536518097,10,82.3270231485367,20 +200710291,97.5641116499901,10,89.780347943306,20 +200710301,105.768427848816,10,56.7267251014709,20 +200710311,91.7177611589432,10,121.892156600952,20 +200711011,111.892886161804,10,89.5366156101227,20 +200711021,100.893505290151,10,82.8624200820923,20 +200711031,106.685945391655,10,80.6789672374725,20 +200711041,91.3279163837433,10,67.0352756977081,20 +200711051,101.440892368555,10,56.3839888572693,20 +200711061,96.4535877108574,10,74.6495789289474,20 +200711071,82.3770368099213,10,68.8839828968048,20 +200711081,116.052260398865,10,43.0678629875183,20 +200711091,125.71759223938,10,71.6680705547333,20 +200711101,103.291112780571,10,98.5829889774323,20 +200711111,109.987460970879,10,54.6437668800354,20 +200711121,125.61119556427,10,83.1547689437866,20 +200711131,81.9022762775421,10,76.0121485590935,20 +200711141,101.001473367214,10,52.9020714759827,20 +200711151,97.4931824207306,10,94.7068226337433,20 +200711161,100.898016765714,10,71.1474251747131,20 +200711171,87.1413099765778,10,87.4912250041962,20 +200711181,99.8441741894931,10,75.5515825748444,20 +200711191,101.680787652731,10,74.8838800191879,20 +200711201,101.4102037251,10,38.1694889068604,20 +200711211,104.962818622589,10,79.2502553761005,20 +200711221,100.41438985616,10,63.105149269104,20 +200711231,96.3839226961136,10,93.790431022644,20 +200711241,88.1726503372192,10,104.002554416656,20 +200711251,99.3147452920675,10,75.3712517023087,20 +200711261,92.6553928852081,10,83.6958381533623,20 +200711271,126.858286857605,10,74.9949443340302,20 +200711281,109.922057986259,10,82.4879696965218,20 +200711291,104.839740395546,10,74.3334722518921,20 +200711301,91.77410364151,10,84.5260953903198,20 +200712011,104.208002388477,10,70.7656121253967,20 +200712021,84.3402886390686,10,67.908148765564,20 +200712031,112.135351896286,10,80.6186366081238,20 +200712041,88.3082449436188,10,79.4679778069258,20 +200712051,108.096032738686,10,96.3960409164429,20 +200712061,102.557981014252,10,74.2482161521912,20 +200712071,89.1109883785248,10,84.9787417054176,20 +200712081,107.703627347946,10,40.3948593139648,20 +200712091,103.8067689538,10,100.3515625,20 +200712101,98.8902306556702,10,70.5492150783539,20 +200712111,113.535689115524,10,73.7627375125885,20 +200712121,110.228134393692,10,75.3778123855591,20 +200712131,104.585482180119,10,100.361814498901,20 +200712141,106.728765964508,10,85.6635415554047,20 +200712151,103.84180277586,10,88.3290749788284,20 +200712161,113.178231716156,10,89.592170715332,20 +200712171,114.0374147892,10,85.6432050466537,20 +200712181,103.519011437893,10,63.2945621013641,20 +200712191,95.9166973829269,10,72.5889933109283,20 +200712201,98.520376086235,10,68.655389547348,20 +200712211,112.214257717133,10,97.4554777145386,20 +200712221,94.7806811332703,10,68.030036687851,20 +200712231,97.4172702431679,10,61.5741550922394,20 +200712241,111.523776054382,10,91.1805129051208,20 +200712251,98.2731455564499,10,115.216774940491,20 +200712261,106.441938281059,10,90.604395866394,20 +200712271,84.2323613166809,10,66.9695138931274,20 +200712281,91.1851263046265,10,92.4789094924927,20 +200712291,126.743235588074,10,87.0600241422653,20 +200712301,100.71555621922,10,101.07501745224,20 +200712311,114.120811223984,10,49.1957330703735,20 -- 2.7.4