X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-combined.js;h=e6380defa9e2bbfed1946475241d644bb7318ada;hb=0c59a4284a1fe42d254fb07df67d6c01a9577a84;hp=f0123aeb98a58cb967f3a15b7e5bf2f7fb0a96c2;hpb=79f17b42e332b8029a7d574f11a26844530e3120;p=dygraphs.git diff --git a/dygraph-combined.js b/dygraph-combined.js index f0123ae..e6380de 100644 --- a/dygraph-combined.js +++ b/dygraph-combined.js @@ -1,6038 +1,7 @@ -/*** +This is not the file you are looking for. +A reasonably up-to-date version can be found at http://dygraphs.com/dygraph-combined.js - MochiKit.MochiKit 1.4 : PACKED VERSION +dygraph-combined.js is a "packed" version of the larger dygraphs JS files. It is +smaller and loads more quickly, but is harder to debug. - 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_154){ -var i=_15c.length-_154; -res=fmt.separator+_15c.substring(i,_15c.length)+res; -_15c=_15c.substring(0,i); -} -} -res=_15c+res; -if(_152>0){ -while(frac.length<_155){ -frac=frac+"0"; -} -res=res+fmt.decimal+frac; -} -return _157+res+_158; -}; -}; -MochiKit.Format.numberFormatter=function(_160,_161,_162){ -if(typeof (_161)=="undefined"){ -_161=""; -} -var _163=_160.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/); -if(!_163){ -throw TypeError("Invalid pattern"); -} -var _164=_160.substr(0,_163.index); -var _165=_160.substr(_163.index+_163[0].length); -if(_164.search(/-/)==-1){ -_164=_164+"-"; -} -var _166=_163[1]; -var frac=(typeof (_163[2])=="string"&&_163[2]!="")?_163[2]:""; -var _168=(typeof (_163[3])=="string"&&_163[3]!=""); -var tmp=_166.split(/,/); -var _16a; -if(typeof (_162)=="undefined"){ -_162="default"; -} -if(tmp.length==1){ -_16a=null; -}else{ -_16a=tmp[1].length; -} -var _16b=_166.length-_166.replace(/0/g,"").length; -var _16c=frac.length-frac.replace(/0/g,"").length; -var _16d=frac.length; -var rval=MochiKit.Format._numberFormatter(_161,_164,_165,_162,_168,_16d,_16b,_16a,_16c); -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(_172){ -if(typeof (_172)=="undefined"||_172===null){ -_172="default"; -} -if(typeof (_172)=="string"){ -var rval=MochiKit.Format.LOCALE[_172]; -if(typeof (rval)=="string"){ -rval=arguments.callee(rval); -MochiKit.Format.LOCALE[_172]=rval; -} -return rval; -}else{ -return _172; -} -}; -MochiKit.Format.twoDigitAverage=function(_174,_175){ -if(_175){ -var res=_174/_175; -if(!isNaN(res)){ -return MochiKit.Format.twoDigitFloat(_174/_175); -} -} -return "0"; -}; -MochiKit.Format.twoDigitFloat=function(_177){ -var sign=(_177<0?"-":""); -var s=Math.floor(Math.abs(_177)*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,_17d){ -str=str+""; -if(typeof (str)!="string"){ -return null; -} -if(!_17d){ -return str.replace(/^\s+/,""); -}else{ -return str.replace(new RegExp("^["+_17d+"]+"),""); -} -}; -MochiKit.Format.rstrip=function(str,_17f){ -str=str+""; -if(typeof (str)!="string"){ -return null; -} -if(!_17f){ -return str.replace(/\s+$/,""); -}else{ -return str.replace(new RegExp("["+_17f+"]+$"),""); -} -}; -MochiKit.Format.strip=function(str,_181){ -var self=MochiKit.Format; -return self.rstrip(self.lstrip(str,_181),_181); -}; -MochiKit.Format.truncToFixed=function(_183,_184){ -_183=Math.floor(_183*Math.pow(10,_184)); -var res=(_183*Math.pow(10,-_184)).toFixed(_184); -if(res.charAt(0)=="."){ -res="0"+res; -} -return res; -}; -MochiKit.Format.roundToFixed=function(_186,_187){ -return MochiKit.Format.truncToFixed(_186+0.5*Math.pow(10,-_187),_187); -}; -MochiKit.Format.percentFormat=function(_188){ -return MochiKit.Format.twoDigitFloat(100*_188)+"%"; -}; -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(_18d,_18e){ -if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){ -var all=_18e.EXPORT_TAGS[":all"]; -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; -} -} -_198.push(name); -_199.push(v); -return null; -} -_198.push(name); -_199.push(""); -return null; -}else{ -var opts=elem.options; -if(!opts.length){ -_198.push(name); -_199.push(""); -return null; -} -for(var i=0;i]+\svalue\s*=/i)){ -v=opt.text; -} -} -_198.push(name); -_199.push(v); -} -return null; -} -} -if(_19e==="FORM"||_19e==="P"||_19e==="SPAN"||_19e==="DIV"){ -return elem.childNodes; -} -_198.push(name); -_199.push(elem.value||""); -return null; -} -return elem.childNodes; -}); -return [_198,_199]; -},withDocument:function(doc,func){ -var self=MochiKit.DOM; -var _1a7=self._document; -var rval; -try{ -self._document=doc; -rval=func(); -} -catch(e){ -self._document=_1a7; -throw e; -} -self._document=_1a7; -return rval; -},registerDOMConverter:function(name,_1aa,wrap,_1ac){ -MochiKit.DOM.domConverters.register(name,_1aa,wrap,_1ac); -},coerceToDOM:function(node,ctx){ -var m=MochiKit.Base; -var im=MochiKit.Iter; -var self=MochiKit.DOM; -if(im){ -var iter=im.iter; -var _1b3=im.repeat; -var map=m.map; -} -var _1b5=self.domConverters; -var _1b6=arguments.callee; -var _1b7=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 _1b8=null; -try{ -_1b8=iter(node); -} -catch(e){ -} -if(_1b8){ -return map(_1b6,_1b8,_1b3(ctx)); -} -} -try{ -node=_1b5.match(node,ctx); -continue; -} -catch(e){ -if(e!=_1b7){ -throw e; -} -} -return self._document.createTextNode(node.toString()); -} -return undefined; -},isChildNode:function(node,_1ba){ -var self=MochiKit.DOM; -if(typeof (node)=="string"){ -node=self.getElement(node); -} -if(typeof (_1ba)=="string"){ -_1ba=self.getElement(_1ba); -} -if(node===_1ba){ -return true; -} -while(node&&node.tagName.toUpperCase()!="BODY"){ -node=node.parentNode; -if(node===_1ba){ -return true; -} -} -return false; -},setNodeAttribute:function(node,attr,_1be){ -var o={}; -o[attr]=_1be; -try{ -return MochiKit.DOM.updateNodeAttributes(node,o); -} -catch(e){ -} -return null; -},getNodeAttribute:function(node,attr){ -var self=MochiKit.DOM; -var _1c3=self.attributeArray.renames[attr]; -node=self.getElement(node); -try{ -if(_1c3){ -return node[_1c3]; -} -return node.getAttribute(attr); -} -catch(e){ -} -return null; -},removeNodeAttribute:function(node,attr){ -var self=MochiKit.DOM; -var _1c7=self.attributeArray.renames[attr]; -node=self.getElement(node); -try{ -if(_1c7){ -return node[_1c7]; -} -return node.removeAttribute(attr); -} -catch(e){ -} -return null; -},updateNodeAttributes:function(node,_1c9){ -var elem=node; -var self=MochiKit.DOM; -if(typeof (node)=="string"){ -elem=self.getElement(node); -} -if(_1c9){ -var _1cc=MochiKit.Base.updatetree; -if(self.attributeArray.compliant){ -for(var k in _1c9){ -var v=_1c9[k]; -if(typeof (v)=="object"&&typeof (elem[k])=="object"){ -if(k=="style"&&MochiKit.Style){ -MochiKit.Style.setStyle(elem,v); -}else{ -_1cc(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 _1cf=self.attributeArray.renames; -for(var k in _1c9){ -v=_1c9[k]; -var _1d0=_1cf[k]; -if(k=="style"&&typeof (v)=="string"){ -elem.style.cssText=v; -}else{ -if(typeof (_1d0)=="string"){ -elem[_1d0]=v; -}else{ -if(typeof (elem[k])=="object"&&typeof (v)=="object"){ -if(k=="style"&&MochiKit.Style){ -MochiKit.Style.setStyle(elem,v); -}else{ -_1cc(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 _1d4=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; -var _1d5=MochiKit.Base.concat; -while(_1d4.length){ -var n=_1d4.shift(); -if(typeof (n)=="undefined"||n===null){ -}else{ -if(typeof (n.nodeType)=="number"){ -elem.appendChild(n); -}else{ -_1d4=_1d5(n,_1d4); -} -} -} -return elem; -},insertSiblingNodesBefore:function(node){ -var elem=node; -var self=MochiKit.DOM; -if(typeof (node)=="string"){ -elem=self.getElement(node); -} -var _1da=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; -var _1db=elem.parentNode; -var _1dc=MochiKit.Base.concat; -while(_1da.length){ -var n=_1da.shift(); -if(typeof (n)=="undefined"||n===null){ -}else{ -if(typeof (n.nodeType)=="number"){ -_1db.insertBefore(n,elem); -}else{ -_1da=_1dc(n,_1da); -} -} -} -return _1db; -},insertSiblingNodesAfter:function(node){ -var elem=node; -var self=MochiKit.DOM; -if(typeof (node)=="string"){ -elem=self.getElement(node); -} -var _1e1=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; -if(elem.nextSibling){ -return self.insertSiblingNodesBefore(elem.nextSibling,_1e1); -}else{ -return self.appendChildNodes(elem.parentNode,_1e1); -} -},replaceChildNodes:function(node){ -var elem=node; -var self=MochiKit.DOM; -if(typeof (node)=="string"){ -elem=self.getElement(node); -arguments[0]=elem; -} -var _1e5; -while((_1e5=elem.firstChild)){ -elem.removeChild(_1e5); -} -if(arguments.length<2){ -return elem; -}else{ -return self.appendChildNodes.apply(this,arguments); -} -},createDOM:function(name,_1e7){ -var elem; -var self=MochiKit.DOM; -var m=MochiKit.Base; -if(typeof (_1e7)=="string"||typeof (_1e7)=="number"){ -var args=m.extend([name,null],arguments,1); -return arguments.callee.apply(this,args); -} -if(typeof (name)=="string"){ -var _1ec=self._xhtml; -if(_1e7&&!self.attributeArray.compliant){ -var _1ed=""; -if("name" in _1e7){ -_1ed+=" name=\""+self.escapeHTML(_1e7.name)+"\""; -} -if(name=="input"&&"type" in _1e7){ -_1ed+=" type=\""+self.escapeHTML(_1e7.type)+"\""; -} -if(_1ed){ -name="<"+name+_1ed+">"; -_1ec=false; -} -} -var d=self._document; -if(_1ec&&d===document){ -elem=d.createElementNS("http://www.w3.org/1999/xhtml",name); -}else{ -elem=d.createElement(name); -} -}else{ -elem=name; -} -if(_1e7){ -self.updateNodeAttributes(elem,_1e7); -} -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 _1f5=dest.parentNode; -if(src){ -src=self.getElement(src); -_1f5.replaceChild(src,dest); -}else{ -_1f5.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(_1f8,_1f9,_1fa){ -var self=MochiKit.DOM; -if(typeof (_1f8)=="undefined"||_1f8===null){ -_1f8="*"; -} -if(typeof (_1fa)=="undefined"||_1fa===null){ -_1fa=self._document; -} -_1fa=self.getElement(_1fa); -var _1fc=(_1fa.getElementsByTagName(_1f8)||self._document.all); -if(typeof (_1f9)=="undefined"||_1f9===null){ -return MochiKit.Base.extend(null,_1fc); -} -var _1fd=[]; -for(var i=0;i<_1fc.length;i++){ -var _1ff=_1fc[i]; -var cls=_1ff.className; -if(!cls){ -continue; -} -var _201=cls.split(" "); -for(var j=0;j<_201.length;j++){ -if(_201[j]==_1f9){ -_1fd.push(_1ff); -break; -} -} -} -return _1fd; -},_newCallStack:function(path,once){ -var rval=function(){ -var _206=arguments.callee.callStack; -for(var i=0;i<_206.length;i++){ -if(_206[i].apply(this,arguments)===false){ -break; -} -} -if(once){ -try{ -this[path]=null; -} -catch(e){ -} -} -}; -rval.callStack=[]; -return rval; -},addToCallStack:function(_208,path,func,once){ -var self=MochiKit.DOM; -var _20d=_208[path]; -var _20e=_20d; -if(!(typeof (_20d)=="function"&&typeof (_20d.callStack)=="object"&&_20d.callStack!==null)){ -_20e=self._newCallStack(path,once); -if(typeof (_20d)=="function"){ -_20e.callStack.push(_20d); -} -_208[path]=_20e; -} -_20e.callStack.push(func); -},addLoadEvent:function(func){ -var self=MochiKit.DOM; -self.addToCallStack(self._window,"onload",func,true); -},focusOnLoad:function(_211){ -var self=MochiKit.DOM; -self.addLoadEvent(function(){ -_211=self.getElement(_211); -if(_211){ -_211.focus(); -} -}); -},setElementClass:function(_213,_214){ -var self=MochiKit.DOM; -var obj=self.getElement(_213); -if(self.attributeArray.compliant){ -obj.setAttribute("class",_214); -}else{ -obj.setAttribute("className",_214); -} -},toggleElementClass:function(_217){ -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 _23a=[dom]; -var self=MochiKit.DOM; -var _23c=self.escapeHTML; -var _23d=self.attributeArray; -while(_23a.length){ -dom=_23a.pop(); -if(typeof (dom)=="string"){ -lst.push(dom); -}else{ -if(dom.nodeType==1){ -lst.push("<"+dom.tagName.toLowerCase()); -var _23e=[]; -var _23f=_23d(dom); -for(var i=0;i<_23f.length;i++){ -var a=_23f[i]; -_23e.push([" ",a.name,"=\"",_23c(a.value),"\""]); -} -_23e.sort(); -for(i=0;i<_23e.length;i++){ -var _242=_23e[i]; -for(var j=0;j<_242.length;j++){ -lst.push(_242[j]); -} -} -if(dom.hasChildNodes()){ -lst.push(">"); -_23a.push(""); -var _244=dom.childNodes; -for(i=_244.length-1;i>=0;i--){ -_23a.push(_244[i]); -} -}else{ -lst.push("/>"); -} -}else{ -if(dom.nodeType==3){ -lst.push(_23c(dom.nodeValue)); -} -} -} -} -return lst; -},scrapeText:function(node,_246){ -var rval=[]; -(function(node){ -var cn=node.childNodes; -if(cn){ -for(var i=0;i0){ -var _26d=m.filter; -_26c=function(node){ -return _26d(_26c.ignoreAttrFilter,node.attributes); -}; -_26c.ignoreAttr={}; -var _26f=_26b.attributes; -var _270=_26c.ignoreAttr; -for(var i=0;i<_26f.length;i++){ -var a=_26f[i]; -_270[a.name]=a.value; -} -_26c.ignoreAttrFilter=function(a){ -return (_26c.ignoreAttr[a.name]!=a.value); -}; -_26c.compliant=false; -_26c.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"}; -}else{ -_26c=function(node){ -return node.attributes; -}; -_26c.compliant=true; -_26c.renames={}; -} -this.attributeArray=_26c; -var _275=function(_276,arr){ -var _278=arr[1].split("."); -var str=""; -var obj={}; -str+="if (!MochiKit."+_278[1]+") { throw new Error(\""; -str+="This function has been deprecated and depends on MochiKit."; -str+=_278[1]+".\");}"; -str+="return MochiKit."+_278[1]+"."+arr[0]; -str+=".apply(this, arguments);"; -obj[_278[2]]=new Function(str); -MochiKit.Base.update(MochiKit[_276],obj); -}; -for(var i;i0.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,_2f0,blue,_2f2){ -var _2f3=MochiKit.Color.Color; -if(arguments.length==1){ -var rgb=red; -red=rgb.r; -_2f0=rgb.g; -blue=rgb.b; -if(typeof (rgb.a)=="undefined"){ -_2f2=undefined; -}else{ -_2f2=rgb.a; -} -} -return new _2f3(red,_2f0,blue,_2f2); -},fromHSL:function(hue,_2f6,_2f7,_2f8){ -var m=MochiKit.Color; -return m.Color.fromRGB(m.hslToRGB.apply(m,arguments)); -},fromHSV:function(hue,_2fb,_2fc,_2fd){ -var m=MochiKit.Color; -return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments)); -},fromName:function(name){ -var _300=MochiKit.Color.Color; -if(name.charAt(0)=="\""){ -name=name.substr(1,name.length-2); -} -var _301=_300._namedColors[name.toLowerCase()]; -if(typeof (_301)=="string"){ -return _300.fromHexString(_301); -}else{ -if(name=="transparent"){ -return _300.transparentColor(); -} -} -return null; -},fromString:function(_302){ -var self=MochiKit.Color.Color; -var _304=_302.substr(0,3); -if(_304=="rgb"){ -return self.fromRGBString(_302); -}else{ -if(_304=="hsl"){ -return self.fromHSLString(_302); -}else{ -if(_302.charAt(0)=="#"){ -return self.fromHexString(_302); -} -} -} -return self.fromName(_302); -},fromHexString:function(_305){ -if(_305.charAt(0)=="#"){ -_305=_305.substring(1); -} -var _306=[]; -var i,hex; -if(_305.length==3){ -for(i=0;i<3;i++){ -hex=_305.substr(i,1); -_306.push(parseInt(hex+hex,16)/255); -} -}else{ -for(i=0;i<6;i+=2){ -hex=_305.substr(i,2); -_306.push(parseInt(hex,16)/255); -} -} -var _309=MochiKit.Color.Color; -return _309.fromRGB.apply(_309,_306); -},_fromColorString:function(pre,_30b,_30c,_30d){ -if(_30d.indexOf(pre)===0){ -_30d=_30d.substring(_30d.indexOf("(",3)+1,_30d.length-1); -} -var _30e=_30d.split(/\s*,\s*/); -var _30f=[]; -for(var i=0;i<_30e.length;i++){ -var c=_30e[i]; -var val; -var _313=c.substring(c.length-3); -if(c.charAt(c.length-1)=="%"){ -val=0.01*parseFloat(c.substring(0,c.length-1)); -}else{ -if(_313=="deg"){ -val=parseFloat(c)/360; -}else{ -if(_313=="rad"){ -val=parseFloat(c)/(Math.PI*2); -}else{ -val=_30c[i]*parseFloat(c); -} -} -} -_30f.push(val); -} -return this[_30b].apply(this,_30f); -},fromComputedStyle:function(elem,_315){ -var d=MochiKit.DOM; -var cls=MochiKit.Color.Color; -for(elem=d.getElement(elem);elem;elem=elem.parentNode){ -var _318=MochiKit.Style.getStyle.apply(d,arguments); -if(!_318){ -continue; -} -var _319=cls.fromString(_318); -if(!_319){ -break; -} -if(_319.asRGB().a>0){ -return _319; -} -} -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,_31f){ -v*=_31f; -if(v<0){ -return 0; -}else{ -if(v>_31f){ -return _31f; -}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,_325,_326,_327){ -if(arguments.length==1){ -var hsv=hue; -hue=hsv.h; -_325=hsv.s; -_326=hsv.v; -_327=hsv.a; -} -var red; -var _32a; -var blue; -if(_325===0){ -red=_326; -_32a=_326; -blue=_326; -}else{ -var i=Math.floor(hue*6); -var f=(hue*6)-i; -var p=_326*(1-_325); -var q=_326*(1-(_325*f)); -var t=_326*(1-(_325*(1-f))); -switch(i){ -case 1: -red=q; -_32a=_326; -blue=p; -break; -case 2: -red=p; -_32a=_326; -blue=t; -break; -case 3: -red=p; -_32a=q; -blue=_326; -break; -case 4: -red=t; -_32a=p; -blue=_326; -break; -case 5: -red=_326; -_32a=p; -blue=q; -break; -case 6: -case 0: -red=_326; -_32a=t; -blue=p; -break; -} -} -return {r:red,g:_32a,b:blue,a:_327}; -},hslToRGB:function(hue,_332,_333,_334){ -if(arguments.length==1){ -var hsl=hue; -hue=hsl.h; -_332=hsl.s; -_333=hsl.l; -_334=hsl.a; -} -var red; -var _337; -var blue; -if(_332===0){ -red=_333; -_337=_333; -blue=_333; -}else{ -var m2; -if(_333<=0.5){ -m2=_333*(1+_332); -}else{ -m2=_333+_332-(_333*_332); -} -var m1=(2*_333)-m2; -var f=MochiKit.Color._hslValue; -var h6=hue*6; -red=f(m1,m2,h6+2); -_337=f(m1,m2,h6); -blue=f(m1,m2,h6-2); -} -return {r:red,g:_337,b:blue,a:_334}; -},rgbToHSV:function(red,_33e,blue,_340){ -if(arguments.length==1){ -var rgb=red; -red=rgb.r; -_33e=rgb.g; -blue=rgb.b; -_340=rgb.a; -} -var max=Math.max(Math.max(red,_33e),blue); -var min=Math.min(Math.min(red,_33e),blue); -var hue; -var _345; -var _346=max; -if(min==max){ -hue=0; -_345=0; -}else{ -var _347=(max-min); -_345=_347/max; -if(red==max){ -hue=(_33e-blue)/_347; -}else{ -if(_33e==max){ -hue=2+((blue-red)/_347); -}else{ -hue=4+((red-_33e)/_347); -} -} -hue/=6; -if(hue<0){ -hue+=1; -} -if(hue>1){ -hue-=1; -} -} -return {h:hue,s:_345,v:_346,a:_340}; -},rgbToHSL:function(red,_349,blue,_34b){ -if(arguments.length==1){ -var rgb=red; -red=rgb.r; -_349=rgb.g; -blue=rgb.b; -_34b=rgb.a; -} -var max=Math.max(red,Math.max(_349,blue)); -var min=Math.min(red,Math.min(_349,blue)); -var hue; -var _350; -var _351=(max+min)/2; -var _352=max-min; -if(_352===0){ -hue=0; -_350=0; -}else{ -if(_351<=0.5){ -_350=_352/(max+min); -}else{ -_350=_352/(2-max-min); -} -if(red==max){ -hue=(_349-blue)/_352; -}else{ -if(_349==max){ -hue=2+((blue-red)/_352); -}else{ -hue=4+((red-_349)/_352); -} -} -hue/=6; -if(hue<0){ -hue+=1; -} -if(hue>1){ -hue-=1; -} -} -return {h:hue,s:_350,l:_351,a:_34b}; -},toColorPart:function(num){ -num=Math.round(num); -var _354=num.toString(16); -if(num<16){ -return "0"+_354; -} -return _354; -},__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 _356=1/3; -var _357={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_356,_356,_356],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_356,2*_356,2*_356],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 _358=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 _357){ -var name=k+"Color"; -var _361=m.concat([_358,this.Color,name],_357[k]); -this.Color[name]=m.bind.apply(null,_361); -} -var _362=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=_3a4.length-1;i>=0;i--){ -var o=_3a4[i]; -if(o.source===src&&o.signal===sig&&o.objOrFunc===obj&&o.funcOrStr===func){ -self._disconnect(o); -if(!self._lock){ -_3a4.splice(i,1); -}else{ -self._dirty=true; -} -return true; -} -} -}else{ -var idx=m.findIdentical(_3a4,_3a2); -if(idx>=0){ -self._disconnect(_3a2); -if(!self._lock){ -_3a4.splice(idx,1); -}else{ -self._dirty=true; -} -return true; -} -} -return false; -},disconnectAllTo:function(_3ad,_3ae){ -var self=MochiKit.Signal; -var _3b0=self._observers; -var _3b1=self._disconnect; -var _3b2=self._lock; -var _3b3=self._dirty; -if(typeof (_3ae)==="undefined"){ -_3ae=null; -} -for(var i=_3b0.length-1;i>=0;i--){ -var _3b5=_3b0[i]; -if(_3b5.objOrFunc===_3ad&&(_3ae===null||_3b5.funcOrStr===_3ae)){ -_3b1(_3b5); -if(_3b2){ -_3b3=true; -}else{ -_3b0.splice(i,1); -} -} -} -self._dirty=_3b3; -},disconnectAll:function(src,sig){ -src=MochiKit.DOM.getElement(src); -var m=MochiKit.Base; -var _3b9=m.flattenArguments(m.extend(null,arguments,1)); -var self=MochiKit.Signal; -var _3bb=self._disconnect; -var _3bc=self._observers; -var i,_3be; -var _3bf=self._lock; -var _3c0=self._dirty; -if(_3b9.length===0){ -for(i=_3bc.length-1;i>=0;i--){ -_3be=_3bc[i]; -if(_3be.source===src){ -_3bb(_3be); -if(!_3bf){ -_3bc.splice(i,1); -}else{ -_3c0=true; -} -} -} -}else{ -var sigs={}; -for(i=0;i<_3b9.length;i++){ -sigs[_3b9[i]]=true; -} -for(i=_3bc.length-1;i>=0;i--){ -_3be=_3bc[i]; -if(_3be.source===src&&_3be.signal in sigs){ -_3bb(_3be); -if(!_3bf){ -_3bc.splice(i,1); -}else{ -_3c0=true; -} -} -} -} -self._dirty=_3c0; -},signal:function(src,sig){ -var self=MochiKit.Signal; -var _3c5=self._observers; -src=MochiKit.DOM.getElement(src); -var args=MochiKit.Base.extend(null,arguments,2); -var _3c7=[]; -self._lock=true; -for(var i=0;i<_3c5.length;i++){ -var _3c9=_3c5[i]; -if(_3c9.source===src&&_3c9.signal===sig){ -try{ -_3c9.listener.apply(src,args); -} -catch(e){ -_3c7.push(e); -} -} -} -self._lock=false; -if(self._dirty){ -self._dirty=false; -for(var i=_3c5.length-1;i>=0;i--){ -if(!_3c5[i].connected){ -_3c5.splice(i,1); -} -} -} -if(_3c7.length==1){ -throw _3c7[0]; -}else{ -if(_3c7.length>1){ -var e=new Error("Multiple errors thrown in handling 'sig', see errors property"); -e.errors=_3c7; -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); - - -/*** - - 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); - - -// 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_(); - - connect(window, 'onload', this, function(e) { 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_); -}; +To generate this file, run "make" or generate-combined.sh.