Changeset 33

Show
Ignore:
Timestamp:
04/06/06 20:17:37 (2 years ago)
Author:
al
Message:

Fix long standing problem with SweetRenderer? overriding the CanvasRenderer? functions. More fixes for prototype.js compat code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plotkit/trunk/PlotKit/Base.js

    r32 r33  
    8989// Detect whether we are using prototype.js 
    9090PlotKit.Base.usingPrototype =  function() { 
    91     return (typeof(Object.extend) == 'function'); 
     91    try { 
     92        return (typeof(Object.extend) == 'function'); 
     93    } 
     94    catch (e) { 
     95        return false; 
     96    } 
    9297} 
    9398 
     
    275280    } 
    276281    else { 
    277         return MochiKit.Base.items(lst); 
     282        return MochiKit.Base.keys(lst); 
    278283    } 
    279284}; 
  • plotkit/trunk/PlotKit/EasyPlot.js

    r32 r33  
    7878        throw "Passed datasources are not Array like"; 
    7979    } 
    80  
     80     
    8181    // setup canvas to render 
    8282     
     
    9898    } 
    9999     
    100     if ((this.deferredCount == 0) && (this.layout.datasets.length > 0)) { 
     100    if ((this.deferredCount == 0) && (PlotKit.Base.keys(this.layout.datasets).length > 0)) { 
    101101        this.layout.evaluate(); 
    102102        this.renderer.clear(); 
     
    121121    this.deferredCount--; 
    122122     
    123     if ((this.deferredCount == 0) && (this.layout.datasets.length > 0)) { 
     123    if ((this.deferredCount == 0) && (PlotKit.Base.keys(this.layout.datasets).length > 0)) { 
    124124        this.layout.evaluate(); 
    125125        this.renderer.clear(); 
  • plotkit/trunk/PlotKit/PlotKit_Packed.js

    r32 r33  
    5050}; 
    5151PlotKit.Base.usingPrototype=function(){ 
     52try{ 
    5253return (typeof (Object.extend)=="function"); 
     54} 
     55catch(e){ 
     56return false; 
     57} 
    5358}; 
    5459MochiKit.Base.update(PlotKit.Base,{roundInterval:function(_1,_2,_3){ 
     
    194199return _39; 
    195200}else{ 
    196 return MochiKit.Base.items(lst); 
     201return MochiKit.Base.keys(lst); 
    197202} 
    198203}; 
     
    17221727this._renderBarChartWrap(this.layout.bars,bind(_338,this)); 
    17231728}; 
    1724 PlotKit.CanvasRenderer.prototype._renderLineChart=function(){ 
     1729PlotKit.SweetCanvasRenderer.prototype._renderLineChart=function(){ 
    17251730var _340=this.element.getContext("2d"); 
    17261731var _341=this.options.colorScheme.length; 
     
    17751780} 
    17761781}; 
    1777 PlotKit.CanvasRenderer.prototype._renderPieChart=function(){ 
     1782PlotKit.SweetCanvasRenderer.prototype._renderPieChart=function(){ 
    17781783var _351=this.element.getContext("2d"); 
    17791784var _352=this.options.colorScheme.length; 
  • plotkit/trunk/PlotKit/SweetCanvas.js

    r32 r33  
    131131}; 
    132132 
    133 PlotKit.CanvasRenderer.prototype._renderLineChart = function() { 
     133PlotKit.SweetCanvasRenderer.prototype._renderLineChart = function() { 
    134134    var context = this.element.getContext("2d"); 
    135135    var colorCount = this.options.colorScheme.length; 
     
    197197}; 
    198198 
    199 PlotKit.CanvasRenderer.prototype._renderPieChart = function() { 
     199PlotKit.SweetCanvasRenderer.prototype._renderPieChart = function() { 
    200200    var context = this.element.getContext("2d"); 
    201201 
  • plotkit/trunk/doc/PlotKit.Base.txt

    r32 r33  
    4646  Acts like the UNIX uniq, takes a sorted array and returns a new array that only contains uniq elements. 
    4747   
    48 * ``isFuncLike(obj)`` 
     48* ``isFuncLike(obj)`` (PlotKit 0.9+) 
    4949 
    5050  Returns true if it is of type ``function``. 
    5151 
    52 * ``usingPrototype()`` 
     52* ``usingPrototype()``  (PlotKit 0.9+) 
    5353 
    5454  Checks whether the javascript runtime is polluted by prototype.js 
    5555   
    56 * ``items(lst)`` 
     56* ``items(lst)``  (PlotKit 0.9+) 
    5757 
    5858  A version of ``MochiKit.Base.items()`` that is aware of prototype.js 
    5959 
    60 * ``keys(lst)`` 
     60* ``keys(lst)``  (PlotKit 0.9+) 
    6161 
    6262  A version of ``MochiKit.Base.keys()`` that is aware of prototype.js 
    6363 
    64 * ``map(fn, lst)`` 
     64* ``map(fn, lst)``  (PlotKit 0.9+) 
    6565 
    6666  A version of ``MochiKit.Base.map()`` that is aware of prototype.js 
  • plotkit/trunk/tests/basic.js

    r32 r33  
    123123    tests.appendChild(generateUnitTest(11, dualDataSet, dualData,  
    124124    "line", "")); 
    125 /* 
     125 
    126126    tests.appendChild(H2(null, "Drawing and Clearing")); 
    127127    tests.appendChild(generateUnitTest(12, genericTest, floatData1, 
     
    138138    tests.appendChild(generateUnitTest(16, genericTest, ninety, 
    139139    "pie", "")); 
    140     */ 
    141140 
    142141} 
  • plotkit/trunk/tests/sweet.html

    r18 r33  
    99   <script src="/js/mochi/MochiKit.js" type="text/javascript"></script> 
    1010   <script src="/js/plotkit-svn/excanvas.js" type="text/javascript"></script> 
    11    <script src="/js/plotkit-svn/Base.js" type="text/javascript"></script> 
    12    <script src="/js/plotkit-svn/Layout.js" type="text/javascript"></script> 
    13    <script src="/js/plotkit-svn/Canvas.js" type="text/javascript"></script> 
    14    <script src="/js/plotkit-svn/SweetCanvas.js" type="text/javascript"></script> 
     11   <script src="/js/plotkit-svn/PlotKit_Packed.js" type="text/javascript"></script> 
    1512   <script src="/js/plotkit-tests/sweet.js" type="text/javascript"></script> 
    1613</head>