remove some unneeded bits from Canvas.js
authorDan Vanderkam <danvdk@gmail.com>
Mon, 30 Nov 2009 04:38:44 +0000 (23:38 -0500)
committerDan Vanderkam <danvdk@gmail.com>
Mon, 30 Nov 2009 04:38:44 +0000 (23:38 -0500)
dygraph-canvas.js
dygraph-combined.js
plotkit_v091/PlotKit/Base.js
plotkit_v091/PlotKit/Canvas.js
tests/grid_dot.html

index 05ac0cc..beef2c0 100644 (file)
@@ -166,8 +166,6 @@ DygraphCanvasRenderer = function(dygraph, element, layout, options) {
   // TODO(danvk): remove options, just use dygraph.attr_.
   PlotKit.CanvasRenderer.call(this, element, layout, options);
   this.dygraph_ = dygraph;
-  this.options.shouldFill = false;
-  this.options.shouldStroke = true;
   this.options.drawYGrid = true;
   this.options.drawXGrid = true;
   this.options.gridLineColor = MochiKit.Color.Color.grayColor();
index 2ecfe7b..609028e 100644 (file)
@@ -3879,13 +3879,6 @@ throw "";
 catch(e){
 throw "PlotKit depends on MochiKit.{Base,Color,DOM}";
 }
-MochiKit.Base.update(MochiKit.Color.Color.prototype,{asFillColor:function(){
-return this.lighterColorWithLevel(0.3);
-},asStrokeColor:function(){
-return this.darkerColorWithLevel(0.1);
-},asPointColor:function(){
-return this.lighterColorWithLevel(0.1);
-}});
 if(typeof (PlotKit)=="undefined"){
 PlotKit={};
 }
@@ -4080,7 +4073,7 @@ this.__init__(_28,_29,_30);
 PlotKit.CanvasRenderer.prototype.__init__=function(_31,_32,_33){
 var _34=MochiKit.Base.isUndefinedOrNull;
 var _35=MochiKit.Color.Color;
-this.options={"drawBackground":true,"backgroundColor":_35.whiteColor(),"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"strokeColor":_35.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_35.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_35.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true};
+this.options={"strokeWidth":0.5,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_35.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_35.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,};
 MochiKit.Base.update(this.options,_33?_33:{});
 this.layout=_32;
 this.element=MochiKit.DOM.getElement(_31);
@@ -4250,17 +4243,6 @@ 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);
 
 
 Date.ext={};Date.ext.util={};Date.ext.util.xPad=function(x,pad,r){if(typeof (r)=="undefined"){r=10}for(;parseInt(x,10)<r&&r>1;r/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(d){return Date.ext.util.xPad(parseInt(Date.ext.util.G(d)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date.ext.util.xPad(doy,0,100)},m:function(d){return Date.ext.util.xPad(d.getMonth()+1,0)},M:["getMinutes","0"],p:function(d){return Date.ext.locales[d.locale].p[d.getHours()>=12?1:0]},P:function(d){return Date.ext.locales[d.locale].P[d.getHours()>=12?1:0]},S:["getSeconds","0"],u:function(d){var dow=d.getDay();return dow===0?7:dow},U:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=6-d.getDay();var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0,10)},y:function(d){return Date.ext.util.xPad(d.getFullYear()%100,0)},Y:"getFullYear",z:function(d){var o=d.getTimezoneOffset();var H=Date.ext.util.xPad(parseInt(Math.abs(o/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a-zA-Z]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a-zA-Z]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY%])/g,function(m0,m1){var f=Date.ext.formats[m1];if(typeof (f)=="string"){return d[f]()}else{if(typeof (f)=="function"){return f.call(d,d)}else{if(typeof (f)=="object"&&typeof (f[0])=="string"){return Date.ext.util.xPad(d[f[0]](),f[1])}else{return m1}}}});d=null;return str};
@@ -4373,8 +4355,6 @@ MochiKit.Base.update(this.options,_24?_24:{});
 DygraphCanvasRenderer=function(_25,_26,_27,_28){
 PlotKit.CanvasRenderer.call(this,_26,_27,_28);
 this.dygraph_=_25;
-this.options.shouldFill=false;
-this.options.shouldStroke=true;
 this.options.drawYGrid=true;
 this.options.drawXGrid=true;
 this.options.gridLineColor=MochiKit.Color.Color.grayColor();
index 41f16ca..e672c0f 100644 (file)
@@ -29,25 +29,6 @@ catch (e) {
 }
 
 // -------------------------------------------------------------------
-// Inject Common Shortcuts we use into MochiKit.Color.Color
-// -------------------------------------------------------------------
-
-MochiKit.Base.update(MochiKit.Color.Color.prototype, {
-    asFillColor: function() {
-        return this.lighterColorWithLevel(0.3);
-    },
-        
-    asStrokeColor: function() {
-        return this.darkerColorWithLevel(0.1);
-    },
-
-    asPointColor: function() {
-        return this.lighterColorWithLevel(0.1);
-    }
-});
-
-
-// -------------------------------------------------------------------
 // Define our own PlotKit namespace
 // -------------------------------------------------------------------
 
index 044caba..0d117f7 100644 (file)
@@ -62,14 +62,7 @@ PlotKit.CanvasRenderer.prototype.__init__ = function(element, layout, options) {
     
     // default options
     this.options = {
-        "drawBackground": true,
-        "backgroundColor": Color.whiteColor(),
-        "colorScheme": PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),
-        "strokeColor": Color.whiteColor(),
-        "strokeColorTransform": "asStrokeColor",
         "strokeWidth": 0.5,
-        "shouldFill": true,
-        "shouldStroke": true,
         "drawXAxis": true,
         "drawYAxis": true,
         "axisLineColor": Color.blackColor(),
@@ -78,9 +71,7 @@ PlotKit.CanvasRenderer.prototype.__init__ = function(element, layout, options) {
         "axisLabelColor": Color.blackColor(),
         "axisLabelFont": "Arial",
         "axisLabelFontSize": 9,
-               "axisLabelWidth": 50,
-               "pieRadius": 0.4,
-        "enableEvents": true
+        "axisLabelWidth": 50,
     };
     MochiKit.Base.update(this.options, options ? options : {});
 
@@ -304,31 +295,3 @@ PlotKit.CanvasRenderer.isSupported = function(canvasName) {
     }
     return true;
 };
-
-// Namespace Iniitialisation
-
-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);
-
index 19480d1..838f780 100644 (file)
@@ -7,8 +7,11 @@
     <script type="text/javascript" src="../dygraph-combined.js"></script>
     <script type="text/javascript" src="../dygraph-canvas.js"></script>
     <script type="text/javascript" src="../dygraph.js"></script>
+    <script type="text/javascript" src="../plotkit_v091/PlotKit/Base.js"></script>
+    <script type="text/javascript" src="../plotkit_v091/PlotKit/Canvas.js"></script>
     <script type="text/javascript" src="data.js"></script>
   </head>
+
   <body>
     <p>Dot and lines should be extra large. Grid is red.</p>
     <div id="g14" style="width:600px; height:300px;"></div>