From 43f15770a2542b2b199b936f2e31509f736fe055 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Wed, 19 Aug 2009 04:36:16 +0000 Subject: [PATCH] Use a subset of PlotKit_Packed.js -> 30k savings --- dygraph-combined.js | 909 --------------------------------------------------- generate-combined.sh | 9 +- 2 files changed, 8 insertions(+), 910 deletions(-) diff --git a/dygraph-combined.js b/dygraph-combined.js index ca0a3ee..7ed5828 100644 --- a/dygraph-combined.js +++ b/dygraph-combined.js @@ -8169,915 +8169,6 @@ this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_ }; 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) diff --git a/generate-combined.sh b/generate-combined.sh index b118250..3dde7ed 100755 --- a/generate-combined.sh +++ b/generate-combined.sh @@ -1,9 +1,16 @@ #!/bin/bash # Generates a single JS file that's easier to include. # This packed JS includes a partial copy of MochiKit and PlotKit. + +# Generate the packed version of the subset of PlotKit needed by dygraphs. +# This saves ~30k +cd plotkit_v091 +./scripts/pack.py Base Layout Canvas > /tmp/plotkit-packed.js +cd .. + cat \ mochikit_v14/packed/MochiKit/MochiKit.js \ -plotkit_v091/PlotKit/PlotKit_Packed.js \ +/tmp/plotkit-packed.js \ dygraph-canvas.js \ dygraph.js \ > dygraph-combined.js -- 2.7.4