";
-}
-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;i
Math.PI*2){
-_216=_216-Math.PI*2;
-}else{
-if(_216<0){
-_216=_216+Math.PI*2;
-}
-}
-var _217=_210+Math.sin(_216)*(_212+10);
-var _218=_211-Math.cos(_216)*(_212+10);
-var _219={"position":"absolute","zIndex":11,"width":_213+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()};
-if(_216<=Math.PI*0.5){
-_219["textAlign"]="left";
-_219["verticalAlign"]="top";
-_219["left"]=_217+"px";
-_219["top"]=(_218-this.options.axisLabelFontSize)+"px";
-}else{
-if((_216>Math.PI*0.5)&&(_216<=Math.PI)){
-_219["textAlign"]="left";
-_219["verticalAlign"]="bottom";
-_219["left"]=_217+"px";
-_219["top"]=_218+"px";
-}else{
-if((_216>Math.PI)&&(_216<=Math.PI*1.5)){
-_219["textAlign"]="right";
-_219["verticalAlign"]="bottom";
-_219["left"]=(_217-_213)+"px";
-_219["top"]=_218+"px";
-}else{
-_219["textAlign"]="right";
-_219["verticalAlign"]="bottom";
-_219["left"]=(_217-_213)+"px";
-_219["top"]=(_218-this.options.axisLabelFontSize)+"px";
-}
-}
-}
-var _220=DIV({"style":_219},this.layout.xticks[i][1]);
-this.xlabels.push(_220);
-MochiKit.DOM.appendChildNodes(this.container,_220);
-}
-}
-};
-PlotKit.CanvasRenderer.prototype._renderBackground=function(){
-var _221=this.element.getContext("2d");
-_221.save();
-_221.fillStyle=this.options.backgroundColor.toRGBString();
-_221.fillRect(0,0,this.width,this.height);
-_221.restore();
-};
-PlotKit.CanvasRenderer.prototype.clear=function(){
-if(this.isIE){
-try{
-if(this.clearDelay){
-this.clearDelay.cancel();
-this.clearDelay=null;
-}
-var _222=this.element.getContext("2d");
-}
-catch(e){
-this.isFirstRender=false;
-this.clearDelay=MochiKit.Async.wait(this.IEDelay);
-this.clearDelay.addCallback(bind(this.clear,this));
-return;
-}
-}
-var _222=this.element.getContext("2d");
-_222.clearRect(0,0,this.width,this.height);
-MochiKit.Iter.forEach(this.xlabels,MochiKit.DOM.removeElement);
-MochiKit.Iter.forEach(this.ylabels,MochiKit.DOM.removeElement);
-this.xlabels=new Array();
-this.ylabels=new Array();
-};
-PlotKit.CanvasRenderer.prototype._initialiseEvents=function(){
-var _223=MochiKit.Signal.connect;
-var bind=MochiKit.Base.bind;
-_223(this.element,"onclick",bind(this.onclick,this));
-};
-PlotKit.CanvasRenderer.prototype._resolveObject=function(e){
-var x=(e.mouse().page.x-PlotKit.Base.findPosX(this.element)-this.area.x)/this.area.w;
-var y=(e.mouse().page.y-PlotKit.Base.findPosY(this.element)-this.area.y)/this.area.h;
-var _225=this.layout.hitTest(x,y);
-if(_225){
-return _225;
-}
-return null;
-};
-PlotKit.CanvasRenderer.prototype._createEventObject=function(_226,e){
-if(_226==null){
-return null;
-}
-e.chart=_226;
-return e;
-};
-PlotKit.CanvasRenderer.prototype.onclick=function(e){
-var _227=this._resolveObject(e);
-var _228=this._createEventObject(_227,e);
-if(_228!=null){
-MochiKit.Signal.signal(this,"onclick",_228);
-}
-};
-PlotKit.CanvasRenderer.prototype.onmouseover=function(e){
-var _229=this._resolveObject(e);
-var _230=this._createEventObject(_229,e);
-if(_230!=null){
-signal(this,"onmouseover",_230);
-}
-};
-PlotKit.CanvasRenderer.prototype.onmouseout=function(e){
-var _231=this._resolveObject(e);
-var _232=this._createEventObject(_231,e);
-if(_232==null){
-signal(this,"onmouseout",e);
-}else{
-signal(this,"onmouseout",_232);
-}
-};
-PlotKit.CanvasRenderer.prototype.onmousemove=function(e){
-var _233=this._resolveObject(e);
-var _234=this._createEventObject(_233,e);
-if((_233==null)&&(this.event_isinside==null)){
-return;
-}
-if((_233!=null)&&(this.event_isinside==null)){
-signal(this,"onmouseover",_234);
-}
-if((_233==null)&&(this.event_isinside!=null)){
-signal(this,"onmouseout",_234);
-}
-if((_233!=null)&&(this.event_isinside!=null)){
-signal(this,"onmousemove",_234);
-}
-this.event_isinside=_233;
-};
-PlotKit.CanvasRenderer.isSupported=function(_235){
-var _236=null;
-try{
-if(MochiKit.Base.isUndefinedOrNull(_235)){
-_236=MochiKit.DOM.CANVAS({});
-}else{
-_236=MochiKit.DOM.getElement(_235);
-}
-var _237=_236.getContext("2d");
-}
-catch(e){
-var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
-var _239=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
-if((!ie)||(ie[1]<6)||(_239)){
-return false;
-}
-return true;
-}
-return true;
-};
-PlotKit.Canvas={};
-PlotKit.Canvas.CanvasRenderer=PlotKit.CanvasRenderer;
-PlotKit.Canvas.EXPORT=["CanvasRenderer"];
-PlotKit.Canvas.EXPORT_OK=["CanvasRenderer"];
-PlotKit.Canvas.__new__=function(){
-var m=MochiKit.Base;
-m.nameFunctions(this);
-this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
-};
-PlotKit.Canvas.__new__();
-MochiKit.Base._exportSymbols(this,PlotKit.Canvas);
-try{
-if(typeof (PlotKit.Layout)=="undefined"){
-throw "";
-}
-}
-catch(e){
-throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Layout";
-}
-PlotKit.SVGRenderer=function(_240,_241,_242){
-if(arguments.length>0){
-this.__init__(_240,_241,_242);
-}
-};
-PlotKit.SVGRenderer.NAME="PlotKit.SVGRenderer";
-PlotKit.SVGRenderer.VERSION=PlotKit.VERSION;
-PlotKit.SVGRenderer.__repr__=function(){
-return "["+this.NAME+" "+this.VERSION+"]";
-};
-PlotKit.SVGRenderer.toString=function(){
-return this.__repr__();
-};
-PlotKit.SVGRenderer.SVGNS="http://www.w3.org/2000/svg";
-PlotKit.SVGRenderer.prototype.__init__=function(_243,_244,_245){
-var _246=MochiKit.Base.isUndefinedOrNull;
-this.options={"drawBackground":true,"backgroundColor":Color.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"strokeColor":Color.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"axisLabelUseDiv":true,"pieRadius":0.4,"enableEvents":true};
-MochiKit.Base.update(this.options,_245?_245:{});
-this.layout=_244;
-this.element=MochiKit.DOM.getElement(_243);
-this.container=this.element.parentNode;
-this.height=parseInt(this.element.getAttribute("height"));
-this.width=parseInt(this.element.getAttribute("width"));
-this.document=document;
-this.root=this.element;
-try{
-this.document=this.element.getSVGDocument();
-this.root=_246(this.document.documentElement)?this.element:this.document.documentElement;
-}
-catch(e){
-}
-this.element.style.zIndex=1;
-if(_246(this.element)){
-throw "SVGRenderer() - passed SVG object is not found";
-}
-if(_246(this.container)||this.container.nodeName.toLowerCase()!="div"){
-throw "SVGRenderer() - No DIV's around the SVG.";
-}
-this.xlabels=new Array();
-this.ylabels=new Array();
-this.defs=this.createSVGElement("defs");
-this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom};
-MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}});
-};
-PlotKit.SVGRenderer.prototype.render=function(){
-if(this.options.drawBackground){
-this._renderBackground();
-}
-if(this.layout.style=="bar"){
-this._renderBarChart();
-this._renderBarAxis();
-}else{
-if(this.layout.style=="pie"){
-this._renderPieChart();
-this._renderPieAxis();
-}else{
-if(this.layout.style=="line"){
-this._renderLineChart();
-this._renderLineAxis();
-}
-}
-}
-};
-PlotKit.SVGRenderer.prototype._renderBarOrLine=function(data,_247,_248,_249){
-var _250=this.options.colorScheme.length;
-var _251=this.options.colorScheme;
-var _252=MochiKit.Base.keys(this.layout.datasets);
-var _253=_252.length;
-for(var i=0;i<_253;i++){
-var _254=_252[i];
-var _255=new Array();
-var _256=_251[i%_250];
-if(this.options.shouldFill){
-_255["fill"]=_256.toRGBString();
-}else{
-_255["fill"]="none";
-}
-if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
-if(this.options.strokeColor){
-_255["stroke"]=this.options.strokeColor.toRGBString();
-}else{
-if(this.options.strokeColorTransform){
-_255["stroke"]=_256[this.options.strokeColorTransform]().toRGBString();
-}
-}
-_255["strokeWidth"]=this.options.strokeWidth;
-}
-if(_248){
-_248(_255);
-}
-var _257=function(obj){
-if(obj.name==_254){
-_247(_255,obj);
-}
-};
-MochiKit.Iter.forEach(data,bind(_257,this));
-if(_249){
-_249(_255);
-}
-}
-};
-PlotKit.SVGRenderer.prototype._renderBarChart=function(){
-var bind=MochiKit.Base.bind;
-var _258=function(_259,bar){
-var x=this.area.w*bar.x+this.area.x;
-var y=this.area.h*bar.y+this.area.y;
-var w=this.area.w*bar.w;
-var h=this.area.h*bar.h;
-this._drawRect(x,y,w,h,_259);
-};
-this._renderBarOrLine(this.layout.bars,bind(_258,this));
-};
-PlotKit.SVGRenderer.prototype._renderLineChart=function(){
-var bind=MochiKit.Base.bind;
-var _260=function(_261,_262){
-this._tempPointsBuffer+=(this.area.w*_262.x+this.area.x)+","+(this.area.h*_262.y+this.area.y)+" ";
-};
-var _263=function(_264){
-this._tempPointsBuffer="";
-this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" ";
-};
-var _265=function(_266){
-this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y);
-_266["points"]=this._tempPointsBuffer;
-var elem=this.createSVGElement("polygon",_266);
-this.root.appendChild(elem);
-};
-this._renderBarOrLine(this.layout.points,bind(_260,this),bind(_263,this),bind(_265,this));
-};
-PlotKit.SVGRenderer.prototype._renderPieChart=function(){
-var _268=this.options.colorScheme.length;
-var _269=this.layout.slices;
-var _270=this.area.x+this.area.w*0.5;
-var _271=this.area.y+this.area.h*0.5;
-var _272=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
-if(_269.length==1&&(Math.abs(_269[0].startAngle)-Math.abs(_269[0].endAngle)<0.1)){
-var _273={"cx":_270,"cy":_271,"r":_272};
-var _274=this.options.colorScheme[0];
-if(this.options.shouldFill){
-_273["fill"]=_274.toRGBString();
-}else{
-_273["fill"]="none";
-}
-if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
-if(this.options.strokeColor){
-_273["stroke"]=this.options.strokeColor.toRGBString();
-}else{
-if(this.options.strokeColorTransform){
-_273["stroke"]=_274[this.options.strokeColorTransform]().toRGBString();
-}
-}
-_273["style"]="stroke-width: "+this.options.strokeWidth;
-}
-this.root.appendChild(this.createSVGElement("circle",_273));
-return;
-}
-for(var i=0;i<_269.length;i++){
-var _273=new Array();
-var _274=this.options.colorScheme[i%_268];
-if(this.options.shouldFill){
-_273["fill"]=_274.toRGBString();
-}else{
-_273["fill"]="none";
-}
-if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
-if(this.options.strokeColor){
-_273["stroke"]=this.options.strokeColor.toRGBString();
-}else{
-if(this.options.strokeColorTransform){
-_273["stroke"]=_274[this.options.strokeColorTransform]().toRGBString();
-}
-}
-_273["style"]="stroke-width:"+this.options.strokeWidth;
-}
-var _275=0;
-if(Math.abs(_269[i].endAngle-_269[i].startAngle)>Math.PI){
-_275=1;
-}
-var x1=Math.cos(_269[i].startAngle-Math.PI/2)*_272;
-var y1=Math.sin(_269[i].startAngle-Math.PI/2)*_272;
-var x2=Math.cos(_269[i].endAngle-Math.PI/2)*_272;
-var y2=Math.sin(_269[i].endAngle-Math.PI/2)*_272;
-var rx=x2-x1;
-var ry=y2-y1;
-var _282="M"+_270+","+_271+" ";
-_282+="l"+x1+","+y1+" ";
-_282+="a"+_272+","+_272+" 0 "+_275+",1 "+rx+","+ry+" z";
-_273["d"]=_282;
-var elem=this.createSVGElement("path",_273);
-this.root.appendChild(elem);
-}
-};
-PlotKit.SVGRenderer.prototype._renderBarAxis=function(){
-this._renderAxis();
-};
-PlotKit.SVGRenderer.prototype._renderLineAxis=function(){
-this._renderAxis();
-};
-PlotKit.SVGRenderer.prototype._renderAxis=function(){
-if(!this.options.drawXAxis&&!this.options.drawYAxis){
-return;
-}
-var _283={"style":{"position":"absolute","textAlign":"center","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}};
-var _284={"stroke":this.options.axisLineColor.toRGBString(),"strokeWidth":this.options.axisLineWidth};
-if(this.options.drawYAxis){
-if(this.layout.yticks){
-var _285=function(tick){
-var x=this.area.x;
-var y=this.area.y+tick[0]*this.area.h;
-this._drawLine(x,y,x-3,y,_284);
-if(this.options.axisLabelUseDiv){
-var _286=DIV(_283,tick[1]);
-_286.style.top=(y-this.options.axisLabelFontSize)+"px";
-_286.style.left=(x-this.options.padding.left+this.options.axisTickSize)+"px";
-_286.style.textAlign="left";
-_286.style.width=(this.options.padding.left-3)+"px";
-MochiKit.DOM.appendChildNodes(this.container,_286);
-this.ylabels.push(_286);
-}else{
-var _287={y:y+3,x:(x-this.options.padding.left+3),width:(this.options.padding.left-this.options.axisTickSize)+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString()};
-var _286=this.createSVGElement("text",_287);
-_286.appendChild(this.document.createTextNode(tick[1]));
-this.root.appendChild(_286);
-}
-};
-MochiKit.Iter.forEach(this.layout.yticks,bind(_285,this));
-}
-this._drawLine(this.area.x,this.area.y,this.area.x,this.area.y+this.area.h,_284);
-}
-if(this.options.drawXAxis){
-if(this.layout.xticks){
-var _285=function(tick){
-var x=this.area.x+tick[0]*this.area.w;
-var y=this.area.y+this.area.h;
-this._drawLine(x,y,x,y+this.options.axisTickSize,_284);
-if(this.options.axisLabelUseDiv){
-var _288=DIV(_283,tick[1]);
-_288.style.top=(y+this.options.axisTickSize)+"px";
-_288.style.left=(x-this.options.axisLabelWidth/2)+"px";
-_288.style.textAlign="center";
-_288.style.width=this.options.axisLabelWidth+"px";
-MochiKit.DOM.appendChildNodes(this.container,_288);
-this.xlabels.push(_288);
-}else{
-var _289={y:(y+this.options.axisTickSize+this.options.axisLabelFontSize),x:x-3,width:this.options.axisLabelWidth+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString(),textAnchor:"middle"};
-var _288=this.createSVGElement("text",_289);
-_288.appendChild(this.document.createTextNode(tick[1]));
-this.root.appendChild(_288);
-}
-};
-MochiKit.Iter.forEach(this.layout.xticks,bind(_285,this));
-}
-this._drawLine(this.area.x,this.area.y+this.area.h,this.area.x+this.area.w,this.area.y+this.area.h,_284);
-}
-};
-PlotKit.SVGRenderer.prototype._renderPieAxis=function(){
-if(this.layout.xticks){
-var _290=new Array();
-for(var i=0;iMath.PI*2){
-_297=_297-Math.PI*2;
-}else{
-if(_297<0){
-_297=_297+Math.PI*2;
-}
-}
-var _298=_291+Math.sin(_297)*(_293+10);
-var _299=_292-Math.cos(_297)*(_293+10);
-var _300={"position":"absolute","zIndex":11,"width":_294+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()};
-var _301={"width":_294+"px","fontSize":this.options.axisLabelFontSize+"px","height":(this.options.axisLabelFontSize+3)+"px","fill":this.options.axisLabelColor.toRGBString()};
-if(_297<=Math.PI*0.5){
-MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"top","left":_298+"px","top":(_299-this.options.axisLabelFontSize)+"px"});
-MochiKit.Base.update(_301,{"x":_298,"y":(_299-this.options.axisLabelFontSize),"textAnchor":"left"});
-}else{
-if((_297>Math.PI*0.5)&&(_297<=Math.PI)){
-MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"bottom","left":_298+"px","top":_299+"px"});
-MochiKit.Base.update(_301,{"textAnchor":"left","x":_298,"y":_299});
-}else{
-if((_297>Math.PI)&&(_297<=Math.PI*1.5)){
-MochiKit.Base.update(_300,{"textAlign":"right","verticalAlign":"bottom","left":_298+"px","top":_299+"px"});
-MochiKit.Base.update(_301,{"textAnchor":"right","x":_298-_294,"y":_299});
-}else{
-MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"bottom","left":_298+"px","top":_299+"px"});
-MochiKit.Base.update(_301,{"textAnchor":"left","x":_298-_294,"y":_299-this.options.axisLabelFontSize});
-}
-}
-}
-if(this.options.axisLabelUseDiv){
-var _302=DIV({"style":_300},this.layout.xticks[i][1]);
-this.xlabels.push(_302);
-MochiKit.DOM.appendChildNodes(this.container,_302);
-}else{
-var _302=this.createSVGElement("text",_301);
-_302.appendChild(this.document.createTextNode(this.layout.xticks[i][1]));
-this.root.appendChild(_302);
-}
-}
-}
-};
-PlotKit.SVGRenderer.prototype._renderBackground=function(){
-var opts={"stroke":"none","fill":this.options.backgroundColor.toRGBString()};
-this._drawRect(0,0,this.width,this.height,opts);
-};
-PlotKit.SVGRenderer.prototype._drawRect=function(x,y,w,h,_304){
-var _305={x:x+"px",y:y+"px",width:w+"px",height:h+"px"};
-if(_304){
-MochiKit.Base.update(_305,_304);
-}
-var elem=this.createSVGElement("rect",_305);
-this.root.appendChild(elem);
-};
-PlotKit.SVGRenderer.prototype._drawLine=function(x1,y1,x2,y2,_306){
-var _307={x1:x1+"px",y1:y1+"px",x2:x2+"px",y2:y2+"px"};
-if(_306){
-MochiKit.Base.update(_307,_306);
-}
-var elem=this.createSVGElement("line",_307);
-this.root.appendChild(elem);
-};
-PlotKit.SVGRenderer.prototype.clear=function(){
-while(this.element.firstChild){
-this.element.removeChild(this.element.firstChild);
-}
-if(this.options.axisLabelUseDiv){
-for(var i=0;i=6)&&(!_313)){
-var _314=_312["width"]?_312["width"]:"100";
-var _315=_312["height"]?_312["height"]:"100";
-var eid=_312["id"]?_312["id"]:"notunique";
-var html="";
-var _318=document.createElement(html);
-var _319=_318.getSVGDocument().createElementNS(PlotKit.SVGRenderer.SVGNS,"svg");
-_319.setAttribute("width",_314);
-_319.setAttribute("height",_315);
-_318.getSVGDocument().appendChild(_319);
-return _318;
-}else{
-return PlotKit.SVGRenderer.prototype.createSVGElement("svg",_312);
-}
-};
-PlotKit.SVGRenderer.isSupported=function(){
-var _320=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
-var _321=navigator.appVersion.match(/MSIE (\d\.\d)/);
-var _322=navigator.userAgent.match(/AppleWebKit\/(\d+)/);
-var _323=navigator.userAgent.match(/Opera\/(\d*\.\d*)/);
-var _324=navigator.userAgent.match(/rv:(\d*\.\d*).*Gecko/);
-var _325="http://www.w3.org/TR/SVG11/feature#SVG";
-if(_321&&(_321[1]>=6)&&!_320){
-return document.implementation.hasFeature(_325,"1.1");
-}
-if(_323&&(_323[1]>8.9)){
-return true;
-}
-if(_324&&(_324>1.7)){
-return true;
-}
-return false;
-};
-PlotKit.SVG={};
-PlotKit.SVG.SVGRenderer=PlotKit.SVGRenderer;
-PlotKit.SVG.EXPORT=["SVGRenderer"];
-PlotKit.SVG.EXPORT_OK=["SVGRenderer"];
-PlotKit.SVG.__new__=function(){
-var m=MochiKit.Base;
-m.nameFunctions(this);
-this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
-};
-PlotKit.SVG.__new__();
-MochiKit.Base._exportSymbols(this,PlotKit.SVG);
-try{
-if(typeof (PlotKit.CanvasRenderer)=="undefined"){
-throw "";
-}
-}
-catch(e){
-throw "SweetCanvas depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, Canvas}";
-}
-if(typeof (PlotKit.SweetCanvasRenderer)=="undefined"){
-PlotKit.SweetCanvasRenderer={};
-}
-PlotKit.SweetCanvasRenderer=function(_326,_327,_328){
-if(arguments.length>0){
-this.__init__(_326,_327,_328);
-}
-};
-PlotKit.SweetCanvasRenderer.NAME="PlotKit.SweetCanvasRenderer";
-PlotKit.SweetCanvasRenderer.VERSION=PlotKit.VERSION;
-PlotKit.SweetCanvasRenderer.__repr__=function(){
-return "["+this.NAME+" "+this.VERSION+"]";
-};
-PlotKit.SweetCanvasRenderer.toString=function(){
-return this.__repr__();
-};
-PlotKit.SweetCanvasRenderer.prototype=new PlotKit.CanvasRenderer();
-PlotKit.SweetCanvasRenderer.prototype.constructor=PlotKit.SweetCanvasRenderer;
-PlotKit.SweetCanvasRenderer.__super__=PlotKit.CanvasRenderer.prototype;
-PlotKit.SweetCanvasRenderer.prototype.__init__=function(el,_330,opts){
-var _331=PlotKit.Base.officeBlue();
-MochiKit.Base.update(_331,opts);
-PlotKit.SweetCanvasRenderer.__super__.__init__.call(this,el,_330,_331);
-};
-PlotKit.SweetCanvasRenderer.prototype._renderBarChart=function(){
-var bind=MochiKit.Base.bind;
-var _332=Color.blackColor().colorWithAlpha(0.1).toRGBString();
-var _333=function(_334,x,y,w,h){
-_334.fillStyle=_332;
-_334.fillRect(x-2,y-2,w+4,h+2);
-_334.fillStyle=_332;
-_334.fillRect(x-1,y-1,w+2,h+1);
-};
-var _335=this.options.colorScheme.length;
-var _336=this.options.colorScheme;
-var _337=PlotKit.Base.keys(this.layout.datasets);
-var _338=_337.length;
-var _339=function(name){
-for(var i=0;i<_338;i++){
-if(name==_337[i]){
-return _336[i%_335];
-}
-}
-return _336[0];
-};
-var _340=function(_341,bar){
-var x=this.area.w*bar.x+this.area.x;
-var y=this.area.h*bar.y+this.area.y;
-var w=this.area.w*bar.w;
-var h=this.area.h*bar.h;
-if((w<1)||(h<1)){
-return;
-}
-_341.save();
-_341.shadowBlur=5;
-_341.shadowColor=Color.fromHexString("#888888").toRGBString();
-if(this.isIE){
-_341.save();
-_341.fillStyle="#cccccc";
-_341.fillRect(x-2,y-2,w+4,h+2);
-_341.restore();
-}else{
-_333(_341,x,y,w,h);
-}
-if(this.options.shouldFill){
-_341.fillStyle=_339(bar.name).toRGBString();
-_341.fillRect(x,y,w,h);
-}
-_341.shadowBlur=0;
-_341.strokeStyle=Color.whiteColor().toRGBString();
-_341.lineWidth=2;
-if(this.options.shouldStroke){
-_341.strokeRect(x,y,w,h);
-}
-_341.restore();
-};
-this._renderBarChartWrap(this.layout.bars,bind(_340,this));
-};
-PlotKit.SweetCanvasRenderer.prototype._renderLineChart=function(){
-var _342=this.element.getContext("2d");
-var _343=this.options.colorScheme.length;
-var _344=this.options.colorScheme;
-var _345=PlotKit.Base.keys(this.layout.datasets);
-var _346=_345.length;
-var bind=MochiKit.Base.bind;
-for(var i=0;i<_346;i++){
-var _347=_345[i];
-var _348=_344[i%_343];
-var _349=this.options.strokeColorTransform;
-_342.save();
-var _350=function(ctx){
-ctx.beginPath();
-ctx.moveTo(this.area.x,this.area.y+this.area.h);
-var _351=function(ctx_,_352){
-if(_352.name==_347){
-ctx_.lineTo(this.area.w*_352.x+this.area.x,this.area.h*_352.y+this.area.y);
-}
-};
-MochiKit.Iter.forEach(this.layout.points,partial(_351,ctx),this);
-ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y);
-ctx.lineTo(this.area.x,this.area.y+this.area.h);
-ctx.closePath();
-};
-if(this.options.shouldFill){
-_342.save();
-if(this.isIE){
-_342.fillStyle="#cccccc";
-}else{
-_342.fillStyle=Color.blackColor().colorWithAlpha(0.2).toRGBString();
-}
-_342.translate(-1,-2);
-bind(_350,this)(_342);
-if(this.options.shouldFill){
-_342.fill();
-}
-_342.restore();
-}
-_342.shadowBlur=5;
-_342.shadowColor=Color.fromHexString("#888888").toRGBString();
-_342.fillStyle=_348.toRGBString();
-_342.lineWidth=2;
-_342.strokeStyle=Color.whiteColor().toRGBString();
-if(this.options.shouldFill){
-bind(_350,this)(_342);
-_342.fill();
-}
-if(this.options.shouldStroke){
-bind(_350,this)(_342);
-_342.stroke();
-}
-_342.restore();
-}
-};
-PlotKit.SweetCanvasRenderer.prototype._renderPieChart=function(){
-var _353=this.element.getContext("2d");
-var _354=this.options.colorScheme.length;
-var _355=this.layout.slices;
-var _356=this.area.x+this.area.w*0.5;
-var _357=this.area.y+this.area.h*0.5;
-var _358=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
-if(this.isIE){
-_356=parseInt(_356);
-_357=parseInt(_357);
-_358=parseInt(_358);
-}
-if(!this.isIE){
-_353.save();
-var _359=Color.blackColor().colorWithAlpha(0.2);
-_353.fillStyle=_359.toRGBString();
-_353.shadowBlur=5;
-_353.shadowColor=Color.fromHexString("#888888").toRGBString();
-_353.translate(1,1);
-_353.beginPath();
-_353.moveTo(_356,_357);
-_353.arc(_356,_357,_358+2,0,Math.PI*2,false);
-_353.closePath();
-_353.fill();
-_353.restore();
-}
-_353.save();
-_353.strokeStyle=Color.whiteColor().toRGBString();
-_353.lineWidth=2;
-for(var i=0;i<_355.length;i++){
-var _360=this.options.colorScheme[i%_354];
-_353.fillStyle=_360.toRGBString();
-var _361=function(){
-_353.beginPath();
-_353.moveTo(_356,_357);
-_353.arc(_356,_357,_358,_355[i].startAngle-Math.PI/2,_355[i].endAngle-Math.PI/2,false);
-_353.lineTo(_356,_357);
-_353.closePath();
-};
-if(Math.abs(_355[i].startAngle-_355[i].endAngle)>0.0001){
-if(this.options.shouldFill){
-_361();
-_353.fill();
-}
-if(this.options.shouldStroke){
-_361();
-_353.stroke();
-}
-}
-}
-_353.restore();
-};
-PlotKit.SweetCanvasRenderer.prototype._renderBackground=function(){
-var _362=this.element.getContext("2d");
-if(this.layout.style=="bar"||this.layout.style=="line"){
-_362.save();
-_362.fillStyle=this.options.backgroundColor.toRGBString();
-_362.fillRect(this.area.x,this.area.y,this.area.w,this.area.h);
-_362.strokeStyle=this.options.axisLineColor.toRGBString();
-_362.lineWidth=1;
-var _363=this.layout.yticks;
-var _364=false;
-if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){
-_363=this.layout.xticks;
-_364=true;
-}
-for(var i=0;i<_363.length;i++){
-var x1=0;
-var y1=0;
-var x2=0;
-var y2=0;
-if(_364){
-x1=_363[i][0]*this.area.w+this.area.x;
-y1=this.area.y;
-x2=x1;
-y2=y1+this.area.h;
-}else{
-x1=this.area.x;
-y1=_363[i][0]*this.area.h+this.area.y;
-x2=x1+this.area.w;
-y2=y1;
-}
-_362.beginPath();
-_362.moveTo(x1,y1);
-_362.lineTo(x2,y2);
-_362.closePath();
-_362.stroke();
-}
-_362.restore();
-}else{
-PlotKit.SweetCanvasRenderer.__super__._renderBackground.call(this);
-}
-};
-PlotKit.SweetCanvas={};
-PlotKit.SweetCanvas.SweetCanvasRenderer=PlotKit.SweetCanvasRenderer;
-PlotKit.SweetCanvas.EXPORT=["SweetCanvasRenderer"];
-PlotKit.SweetCanvas.EXPORT_OK=["SweetCanvasRenderer"];
-PlotKit.SweetCanvas.__new__=function(){
-var m=MochiKit.Base;
-m.nameFunctions(this);
-this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
-};
-PlotKit.SweetCanvas.__new__();
-MochiKit.Base._exportSymbols(this,PlotKit.SweetCanvas);
-try{
-if(typeof (PlotKit.SVGRenderer)=="undefined"){
-throw "";
-}
-}
-catch(e){
-throw "SweetSVG depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, SVG}";
-}
-if(typeof (PlotKit.SweetSVGRenderer)=="undefined"){
-PlotKit.SweetSVGRenderer={};
-}
-PlotKit.SweetSVGRenderer=function(_365,_366,_367){
-if(arguments.length>0){
-this.__init__(_365,_366,_367);
-}
-};
-PlotKit.SweetSVGRenderer.NAME="PlotKit.SweetSVGRenderer";
-PlotKit.SweetSVGRenderer.VERSION=PlotKit.VERSION;
-PlotKit.SweetSVGRenderer.__repr__=function(){
-return "["+this.NAME+" "+this.VERSION+"]";
-};
-PlotKit.SweetSVGRenderer.toString=function(){
-return this.__repr__();
-};
-PlotKit.SweetSVGRenderer.prototype=new PlotKit.SVGRenderer();
-PlotKit.SweetSVGRenderer.prototype.constructor=PlotKit.SweetSVGRenderer;
-PlotKit.SweetSVGRenderer.__super__=PlotKit.SVGRenderer.prototype;
-PlotKit.SweetSVGRenderer.prototype.__init__=function(_368,_369,_370){
-var _371=PlotKit.Base.officeBlue();
-MochiKit.Base.update(_371,_370);
-PlotKit.SweetSVGRenderer.__super__.__init__.call(this,_368,_369,_371);
-};
-PlotKit.SweetSVGRenderer.prototype._addDropShadowFilter=function(){
-var _372=this.createSVGElement("filter",{x:0,y:0,"id":"dropShadow"});
-var _373=this.createSVGElement("feOffset",{"in":"SourceGraphic","dx":0,"dy":0,"result":"topCopy"});
-var blur=this.createSVGElement("feGaussianBlur",{"in":"SourceAlpha","StdDeviation":2,"result":"shadow"});
-var _375=this.createSVGElement("feOffset",{"in":"shadow","dx":-1,"dy":-2,"result":"movedShadow"});
-var _376=this.createSVGElement("feMerge");
-var _377=this.createSVGElement("feMergeNode",{"in":"topCopy"});
-var _378=this.createSVGElement("feMergeNode",{"in":"movedShadow"});
-_376.appendChild(_377);
-_376.appendChild(_378);
-_372.appendChild(_373);
-_372.appendChild(blur);
-_372.appendChild(_375);
-_372.appendChild(_376);
-this.defs.appendChild(_372);
-};
-PlotKit.SweetSVGRenderer.prototype._renderBarChart=function(){
-var bind=MochiKit.Base.bind;
-var _379=Color.blackColor().toRGBString();
-var _380="fill:"+_379+";fill-opacity:0.15";
-var _381="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString();
-var _382=function(_383,bar){
-var x=this.area.w*bar.x+this.area.x;
-var y=this.area.h*bar.y+this.area.y;
-var w=this.area.w*bar.w;
-var h=this.area.h*bar.h;
-if((w<1)||(h<1)){
-return;
-}
-_383["style"]=_381;
-this._drawRect(x-2,y-1,w+4,h+2,{"style":_380});
-this._drawRect(x,y,w,h,_383);
-};
-this._renderBarOrLine(this.layout.bars,bind(_382,this));
-};
-PlotKit.SweetSVGRenderer.prototype._renderLineChart=function(){
-var bind=MochiKit.Base.bind;
-var _384=Color.blackColor().toRGBString();
-var _385="fill:"+_384+";fill-opacity:0.15";
-var _386="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString();
-var _387=function(_388,_389){
-this._tempPointsBuffer+=(this.area.w*_389.x+this.area.x)+","+(this.area.h*_389.y+this.area.y)+" ";
-};
-var _390=function(_391){
-this._tempPointsBuffer="";
-this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" ";
-};
-var _392=function(_393){
-this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y);
-_393["points"]=this._tempPointsBuffer;
-_393["stroke"]="none";
-_393["transform"]="translate(-2, -1)";
-_393["style"]=_385;
-var _394=this.createSVGElement("polygon",_393);
-this.root.appendChild(_394);
-_393["transform"]="";
-_393["style"]=_386;
-var elem=this.createSVGElement("polygon",_393);
-this.root.appendChild(elem);
-};
-this._renderBarOrLine(this.layout.points,bind(_387,this),bind(_390,this),bind(_392,this));
-};
-PlotKit.SweetSVGRenderer.prototype._renderPieChart=function(){
-var _395=this.area.x+this.area.w*0.5;
-var _396=this.area.y+this.area.h*0.5;
-var _397=Color.blackColor().toRGBString();
-var _398=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
-var _399="fill:"+_397+";fill-opacity:0.15";
-var _400=this.createSVGElement("circle",{"style":_399,"cx":_395+1,"cy":_396+1,"r":_398+1});
-this.root.appendChild(_400);
-PlotKit.SweetSVGRenderer.__super__._renderPieChart.call(this);
-};
-PlotKit.SweetSVGRenderer.prototype._renderBackground=function(){
-var _401={"fill":this.options.backgroundColor.toRGBString(),"stroke":"none"};
-if(this.layout.style=="bar"||this.layout.style=="line"){
-this._drawRect(this.area.x,this.area.y,this.area.w,this.area.h,_401);
-var _402=this.layout.yticks;
-var _403=false;
-if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){
-_402=this.layout.xticks;
-_403=true;
-}
-for(var i=0;i<_402.length;i++){
-var x=0;
-var y=0;
-var w=0;
-var h=0;
-if(_403){
-x=_402[i][0]*this.area.w+this.area.x;
-y=this.area.y;
-w=1;
-h=this.area.w;
-}else{
-x=this.area.x;
-y=_402[i][0]*this.area.h+this.area.y;
-w=this.area.w;
-h=1;
-}
-this._drawRect(x,y,w,h,{"fill":this.options.axisLineColor.toRGBString()});
-}
-}else{
-PlotKit.SweetSVGRenderer.__super__._renderBackground.call(this);
-}
-};
-PlotKit.SweetSVG={};
-PlotKit.SweetSVG.SweetSVGRenderer=PlotKit.SweetSVGRenderer;
-PlotKit.SweetSVG.EXPORT=["SweetSVGRenderer"];
-PlotKit.SweetSVG.EXPORT_OK=["SweetSVGRenderer"];
-PlotKit.SweetSVG.__new__=function(){
-var m=MochiKit.Base;
-m.nameFunctions(this);
-this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
-};
-PlotKit.SweetSVG.__new__();
-MochiKit.Base._exportSymbols(this,PlotKit.SweetSVG);
-try{
-if(typeof (PlotKit.CanvasRenderer)=="undefined"){
-throw "";
-}
-}
-catch(e){
-throw "PlotKit.EasyPlot depends on all of PlotKit's components";
-}
-if(typeof (PlotKit.EasyPlot)=="undefined"){
-PlotKit.EasyPlot={};
-}
-PlotKit.EasyPlot.NAME="PlotKit.EasyPlot";
-PlotKit.EasyPlot.VERSION=PlotKit.VERSION;
-PlotKit.EasyPlot.__repr__=function(){
-return "["+this.NAME+" "+this.VERSION+"]";
-};
-PlotKit.EasyPlot.toString=function(){
-return this.__repr__();
-};
-PlotKit.EasyPlot=function(_404,_405,_406,_407){
-this.layout=new Layout(_404,_405);
-this.divElem=_406;
-this.width=parseInt(_406.getAttribute("width"));
-this.height=parseInt(_406.getAttribute("height"));
-this.deferredCount=0;
-if(this.width<1){
-this.width=this.divElem.width?this.divElem.width:300;
-}
-if(this.height<1){
-this.height=this.divElem.height?this.divElem.height:300;
-}
-if(isArrayLike(_407)){
-for(var i=0;i<_407.length;i++){
-if(typeof (_407[i])=="string"){
-this.deferredCount++;
-var d=MochiKit.Async.doSimpleXMLHttpRequest(_407[i]);
-d.addCallback(MochiKit.Base.bind(PlotKit.EasyPlot.onDataLoaded,this));
-}else{
-if(isArrayLike(_407[i])){
-this.layout.addDataset("data-"+i,_407[i]);
-}
-}
-}
-}else{
-if(!isUndefinedOrNull(_407)){
-throw "Passed datasources are not Array like";
-}
-}
-if(CanvasRenderer.isSupported()){
-this.element=CANVAS({"id":this.divElem.getAttribute("id")+"-canvas","width":this.width,"height":this.height},"");
-this.divElem.appendChild(this.element);
-this.renderer=new SweetCanvasRenderer(this.element,this.layout,_405);
-}else{
-if(SVGRenderer.isSupported()){
-this.element=SVGRenderer.SVG({"id":this.divElem.getAttribute("id")+"-svg","width":this.width,"height":this.height,"version":"1.1","baseProfile":"full"},"");
-this.divElem.appendChild(this.element);
-this.renderer=new SweetSVGRenderer(this.element,this.layout,_405);
-}
-}
-if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){
-this.layout.evaluate();
-this.renderer.clear();
-this.renderer.render();
-}
-};
-PlotKit.EasyPlot.onDataLoaded=function(_409){
-var _410=new Array();
-var _411=_409.responseText.split("\n");
-for(var i=0;i<_411.length;i++){
-var _412=MochiKit.Format.strip(_411[i]);
-if((_412.length>1)&&(_412.charAt(0)!="#")){
-_410.push(_412.split(","));
-}
-}
-this.layout.addDataset("data-ajax-"+this.deferredCount,_410);
-this.deferredCount--;
-if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){
-this.layout.evaluate();
-this.renderer.clear();
-this.renderer.render();
-}
-};
-PlotKit.EasyPlot.prototype.reload=function(){
-this.layout.evaluate();
-this.renderer.clear();
-this.renderer.render();
-};
-PlotKit.EasyPlotModule={};
-PlotKit.EasyPlotModule.EasyPlot=PlotKit.EasyPlot;
-PlotKit.EasyPlotModule.EXPORT=["EasyPlot"];
-PlotKit.EasyPlotModule.EXPORT_OK=[];
-PlotKit.EasyPlotModule.__new__=function(){
-var m=MochiKit.Base;
-m.nameFunctions(this);
-this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
-};
-PlotKit.EasyPlotModule.__new__();
-MochiKit.Base._exportSymbols(this,PlotKit.EasyPlotModule);
-
-
-// Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
-// All Rights Reserved.
-
-/**
- * @fileoverview Subclasses various parts of PlotKit to meet the additional
- * needs of DateGraph: grid overlays and error bars
- */
-
-// Subclass PlotKit.Layout to add:
-// 1. Sigma/errorBars properties
-// 2. Copy error terms for PlotKit.CanvasRenderer._renderLineChart
-
-/**
- * Creates a new DateGraphLayout object. Options are the same as those allowed
- * by the PlotKit.Layout constructor.
- * @param {Object} options Options for PlotKit.Layout
- * @return {Object} The DateGraphLayout object
- */
-DateGraphLayout = function(options) {
- PlotKit.Layout.call(this, "line", options);
-};
-DateGraphLayout.prototype = new PlotKit.Layout();
-
-/**
- * Behaves the same way as PlotKit.Layout, but also copies the errors
- * @private
- */
-DateGraphLayout.prototype.evaluateWithError = function() {
- this.evaluate();
- if (!this.options.errorBars) return;
-
- // Copy over the error terms
- var i = 0; // index in this.points
- for (var setName in this.datasets) {
- var j = 0;
- var dataset = this.datasets[setName];
- if (PlotKit.Base.isFuncLike(dataset)) continue;
- for (var j = 0; j < dataset.length; j++, i++) {
- var item = dataset[j];
- var xv = parseFloat(item[0]);
- var yv = parseFloat(item[1]);
-
- if (xv == this.points[i].xval &&
- yv == this.points[i].yval) {
- this.points[i].errorMinus = parseFloat(item[2]);
- this.points[i].errorPlus = parseFloat(item[3]);
- }
- }
- }
-};
-
-/**
- * Convenience function to remove all the data sets from a graph
- */
-DateGraphLayout.prototype.removeAllDatasets = function() {
- delete this.datasets;
- this.datasets = new Array();
-};
-
-/**
- * Change the values of various layout options
- * @param {Object} new_options an associative array of new properties
- */
-DateGraphLayout.prototype.updateOptions = function(new_options) {
- MochiKit.Base.update(this.options, new_options ? new_options : {});
-};
-
-// Subclass PlotKit.CanvasRenderer to add:
-// 1. X/Y grid overlay
-// 2. Ability to draw error bars (if required)
-
-/**
- * Sets some PlotKit.CanvasRenderer options
- * @param {Object} element The canvas to attach to
- * @param {Layout} layout The DateGraphLayout object for this graph.
- * @param {Object} options Options to pass on to CanvasRenderer
- */
-DateGraphCanvasRenderer = function(element, layout, options) {
- PlotKit.CanvasRenderer.call(this, element, layout, options);
- this.options.shouldFill = false;
- this.options.shouldStroke = true;
- this.options.drawYGrid = true;
- this.options.drawXGrid = true;
- this.options.gridLineColor = MochiKit.Color.Color.grayColor();
- MochiKit.Base.update(this.options, options);
-
- // TODO(danvk) This shouldn't be necessary: effects should be overlaid
- this.options.drawBackground = false;
-};
-DateGraphCanvasRenderer.prototype = new PlotKit.CanvasRenderer();
-
-/**
- * Draw an X/Y grid on top of the existing plot
- */
-DateGraphCanvasRenderer.prototype.render = function() {
- // Do the ordinary rendering, as before
- // TODO(danvk) Call super.render()
- this._renderLineChart();
- this._renderLineAxis();
-
- // Draw the new X/Y grid
- var ctx = this.element.getContext("2d");
- if (this.options.drawYGrid) {
- var ticks = this.layout.yticks;
- ctx.save();
- ctx.strokeStyle = this.options.gridLineColor.toRGBString();
- ctx.lineWidth = this.options.axisLineWidth;
- for (var i = 0; i < ticks.length; i++) {
- var x = this.area.x;
- var y = this.area.y + ticks[i][0] * this.area.h;
- ctx.beginPath();
- ctx.moveTo(x, y);
- ctx.lineTo(x + this.area.w, y);
- ctx.closePath();
- ctx.stroke();
- }
- }
-
- if (this.options.drawXGrid) {
- var ticks = this.layout.xticks;
- ctx.save();
- ctx.strokeStyle = this.options.gridLineColor.toRGBString();
- ctx.lineWidth = this.options.axisLineWidth;
- for (var i=0; i= 0) {
- ctx_.moveTo(prevX, prevYs[0]);
- ctx_.lineTo(point.canvasx, newYs[0]);
- ctx_.lineTo(point.canvasx, newYs[1]);
- ctx_.lineTo(prevX, prevYs[1]);
- ctx_.closePath();
- }
- prevYs[0] = newYs[0];
- prevYs[1] = newYs[1];
- prevX = point.canvasx;
- }
- };
- // should be same color as the lines
- var err_color = color.colorWithAlpha(0.15);
- ctx.fillStyle = err_color.toRGBString();
- ctx.beginPath();
- MochiKit.Iter.forEach(this.layout.points, partial(errorTrapezoid, ctx), this);
- ctx.fill();
- }
- };
-
- if (errorBars)
- bind(makeErrorBars, this)(context);
- bind(makePath, this)(context);
- context.restore();
-};
-// Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
-// All Rights Reserved.
-
-/**
- * @fileoverview Creates an interactive, zoomable graph based on a CSV file or
- * string. DateGraph can handle multiple series with or without error bars. The
- * date/value ranges will be automatically set. DateGraph uses the
- * <canvas> tag, so it only works in FF1.5+.
- * @author danvdk@gmail.com (Dan Vanderkam)
-
- Usage:
-
-
-
- The CSV file is of the form
-
- YYYYMMDD,A1,B1,C1
- YYYYMMDD,A2,B2,C2
-
- If null is passed as the third parameter (series names), then the first line
- of the CSV file is assumed to contain names for each series.
-
- If the 'errorBars' option is set in the constructor, the input should be of
- the form
-
- YYYYMMDD,A1,sigmaA1,B1,sigmaB1,...
- YYYYMMDD,A2,sigmaA2,B2,sigmaB2,...
-
- If the 'fractions' option is set, the input should be of the form:
-
- YYYYMMDD,A1/B1,A2/B2,...
- YYYYMMDD,A1/B1,A2/B2,...
-
- And error bars will be calculated automatically using a binomial distribution.
-
- For further documentation and examples, see http://www/~danvk/dg/
-
- */
-
-/**
- * An interactive, zoomable graph
- * @param {String | Function} file A file containing CSV data or a function that
- * returns this data. The expected format for each line is
- * YYYYMMDD,val1,val2,... or, if attrs.errorBars is set,
- * YYYYMMDD,val1,stddev1,val2,stddev2,...
- * @param {Array.} labels Labels for the data series
- * @param {Object} attrs Various other attributes, e.g. errorBars determines
- * whether the input data contains error ranges.
- */
-DateGraph = function(div, file, labels, attrs) {
- if (arguments.length > 0)
- this.__init__(div, file, labels, attrs);
-};
-
-DateGraph.NAME = "DateGraph";
-DateGraph.VERSION = "1.1";
-DateGraph.__repr__ = function() {
- return "[" + this.NAME + " " + this.VERSION + "]";
-};
-DateGraph.toString = function() {
- return this.__repr__();
-};
-
-// Various default values
-DateGraph.DEFAULT_ROLL_PERIOD = 1;
-DateGraph.DEFAULT_WIDTH = 480;
-DateGraph.DEFAULT_HEIGHT = 320;
-DateGraph.DEFAULT_STROKE_WIDTH = 1.0;
-DateGraph.AXIS_LINE_WIDTH = 0.3;
-
-/**
- * Initializes the DateGraph. This creates a new DIV and constructs the PlotKit
- * and interaction <canvas> inside of it. See the constructor for details
- * on the parameters.
- * @param {String | Function} file Source data
- * @param {Array.} labels Names of the data series
- * @param {Object} attrs Miscellaneous other options
- * @private
- */
-DateGraph.prototype.__init__ = function(div, file, labels, attrs) {
- // Copy the important bits into the object
- this.maindiv_ = div;
- this.labels_ = labels;
- this.file_ = file;
- this.rollPeriod_ = attrs.rollPeriod || DateGraph.DEFAULT_ROLL_PERIOD;
- this.previousVerticalX_ = -1;
- this.width_ = parseInt(div.style.width, 10);
- this.height_ = parseInt(div.style.height, 10);
- this.errorBars_ = attrs.errorBars || false;
- this.fractions_ = attrs.fractions || false;
- this.strokeWidth_ = attrs.strokeWidth || DateGraph.DEFAULT_STROKE_WIDTH;
- this.dateWindow_ = attrs.dateWindow || null;
- this.valueRange_ = attrs.valueRange || null;
- this.labelsSeparateLines = attrs.labelsSeparateLines || false;
- this.labelsDiv_ = attrs.labelsDiv || null;
- this.labelsKMB_ = attrs.labelsKMB || false;
- this.minTickSize_ = attrs.minTickSize || 0;
- this.xValueParser_ = attrs.xValueParser || DateGraph.prototype.dateParser;
- this.xValueFormatter_ = attrs.xValueFormatter ||
- DateGraph.prototype.dateString_;
- this.xTicker_ = attrs.xTicker || DateGraph.prototype.dateTicker;
- this.sigma_ = attrs.sigma || 2.0;
- this.wilsonInterval_ = attrs.wilsonInterval || true;
- this.customBars_ = attrs.customBars || false;
- this.attrs_ = attrs;
-
- // Make a note of whether labels will be pulled from the CSV file.
- this.labelsFromCSV_ = (this.labels_ == null);
- if (this.labels_ == null)
- this.labels_ = [];
-
- // Prototype of the callback is "void clickCallback(event, date)"
- this.clickCallback_ = attrs.clickCallback || null;
-
- // Prototype of zoom callback is "void dragCallback(minDate, maxDate)"
- this.zoomCallback_ = attrs.zoomCallback || null;
-
- // Create the containing DIV and other interactive elements
- this.createInterface_();
-
- // Create the PlotKit grapher
- this.layoutOptions_ = { 'errorBars': (this.errorBars_ || this.customBars_),
- 'xOriginIsZero': false };
- MochiKit.Base.update(this.layoutOptions_, attrs);
- this.setColors_(attrs);
-
- this.layout_ = new DateGraphLayout(this.layoutOptions_);
-
- this.renderOptions_ = { colorScheme: this.colors_,
- strokeColor: null,
- strokeWidth: this.strokeWidth_,
- axisLabelFontSize: 14,
- axisLineWidth: DateGraph.AXIS_LINE_WIDTH };
- MochiKit.Base.update(this.renderOptions_, attrs);
- this.plotter_ = new DateGraphCanvasRenderer(this.hidden_, this.layout_,
- this.renderOptions_);
-
- this.createStatusMessage_();
- this.createRollInterface_();
- this.createDragInterface_();
-
- 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.