Anonymous avatar Anonymous committed 4fc010d

Fixes for excanvas and highlighting with canvas manager. There is still a conflict with cursor and highlighter plugin when replotting and reusing canvases. They canvas manager not re-assigning canvases in proper order?

Comments (0)

Files changed (13)

examples/area.html

   <script language="javascript" type="text/javascript" src="../src/jquery.jqplot.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.barRenderer.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.categoryAxisRenderer.js"></script>
+  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.highlighter.js"></script>
+  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.cursor.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.pieRenderer.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.donutRenderer.js"></script>
-  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.highlighter.js"></script>
-  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.cursor.js"></script>
-  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.funnelRenderer.js"></script>
+<!--  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.funnelRenderer.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.canvasTextRenderer.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.canvasAxisTickRenderer.js"></script>
+-->
   <!-- END: load jqplot -->
 
 <style type="text/css">

src/jqplot.canvasGridRenderer.js

           if ($.jqplot.use_excanvas) {
             elem = this._elem.get(0);
             window.G_vmlCanvasManager.uninitElement(elem);
-            elem = null;    
+            elem = null;
           }
           
           this._elem.emptyForce();
           this._elem = null;
         }
       
-        //var elem = document.createElement('canvas');
-        var elem = plot.canvasManager.getCanvas();
+        // don't use the canvas manager with excanvas.
+        if ($.jqplot.use_excanvas) {
+          elem = document.createElement('canvas');
+        }
+        else {
+          elem = plot.canvasManager.getCanvas();
+        }
+
         var w = this._plotDimensions.width;
         var h = this._plotDimensions.height;
         elem.width = w;

src/jqplot.core.js

         }
   
         // Remove any remaining nodes
-        if ($.browser.msie) {
+        if ($.jqplot_use_excanvas) {
           elem.outerHTML = "";
         } else {
           while ( elem.firstChild ) {
         }
     };
 
-
     // canvas manager to reuse canvases on the plot.
     // Should help solve problem of canvases not being freed and
     // problem of waiting forever for firefox to decide to free memory.
         };
 
         this.destroyAllCanvases = function() {
-            
+            return null;
         };
 
         this.freeCanvas = function(idx) {
         };
 
         this.destroyCanvas = function(idx) {
-            
+            return null;
         };
     };
 
         this.renderer.init.call(this, this.rendererOptions);
     };
     
-    Grid.prototype.createElement = function(offsets, plot) {
+    Grid.prototype.createElement = function(offsets,plot) {
         this._offsets = offsets;
         return this.renderer.createElement.call(this, plot);
     };
     $.jqplot.GenericCanvas.prototype.constructor = $.jqplot.GenericCanvas;
     
     $.jqplot.GenericCanvas.prototype.createElement = function(offsets, clss, plotDimensions, plot) {
-        if (!plot) {
-            throw('No Plot Specified for Generic Canvas Create Element');
-        }
-
         this._offsets = offsets;
         var klass = 'jqplot';
         if (clss != undefined) {
             }
         }
         else {
-            //elem = document.createElement('canvas');
-            elem = plot.canvasManager.getCanvas();
+            elem = document.createElement('canvas');
+            // don't use the canvas manager with excanvas.
+            if ($.jqplot.use_excanvas) {
+                elem = document.createElement('canvas');
+            }
+            else {
+                elem = plot.canvasManager.getCanvas();
+            }
+
         }
         // if new plotDimensions supplied, use them.
         if (plotDimensions != null) {
         //this._elem.remove();
         this._elem.emptyForce();
       }
-      // not compatible with canvas manager?  maybe even before?
-      //this._ctx = null;
+      
+      this._ctx = null;
     };
     
     $.jqplot.HooksManager = function () {
         this.eventListenerHooks = new $.jqplot.EventListenerManager();
         this.preDrawSeriesShadowHooks = new $.jqplot.HooksManager();
         this.postDrawSeriesShadowHooks = new $.jqplot.HooksManager();
-
+        
         this.colorGenerator = $.jqplot.ColorGenerator;
 
         this.canvasManager = new $.jqplot.CanvasManager();

src/jqplot.lineRenderer.js

         this.plugins.lineRenderer.highlightedSeriesIndex = null;
         this.plugins.lineRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
         
-        this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-lineRenderer-highlight-canvas', null, this));
+        this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-lineRenderer-highlight-canvas', this._plotDimensions, this));
         this.plugins.lineRenderer.highlightCanvas.setContext();
     } 
     
Add a comment to this file

src/plugins/jqplot.barRenderer.js

File contents unchanged.

src/plugins/jqplot.bubbleRenderer.js

     // create a canvas which we can draw on.
     // insert it before the eventCanvas, so eventCanvas will still capture events.
     function postPlotDraw() {
+        // Memory Leaks patch    
+        if (this.plugins.bubbleRenderer && this.plugins.bubbleRenderer.highlightCanvas) {
+            this.plugins.bubbleRenderer.highlightCanvas.resetCanvas();
+            this.plugins.bubbleRenderer.highlightCanvas = null;
+        }
+        
         this.plugins.bubbleRenderer = {highlightedSeriesIndex:null};
         this.plugins.bubbleRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
         this.plugins.bubbleRenderer.highlightLabel = null;

src/plugins/jqplot.canvasOverlay.js

     // create a canvas which we can draw on.
     // insert it before the eventCanvas, so eventCanvas will still capture events.
     $.jqplot.CanvasOverlay.postPlotDraw = function() {
+        // Memory Leaks patch    
+        if (this.plugins.canvasOverlay && this.plugins.canvasOverlay.highlightCanvas) {
+            this.plugins.canvasOverlay.highlightCanvas.resetCanvas();
+            this.plugins.canvasOverlay.highlightCanvas = null;
+        }
         this.plugins.canvasOverlay.canvas = new $.jqplot.GenericCanvas();
         
         this.eventCanvas._elem.before(this.plugins.canvasOverlay.canvas.createElement(this._gridPadding, 'jqplot-overlayCanvas-canvas', this._plotDimensions, this));
Add a comment to this file

src/plugins/jqplot.cursor.js

File contents unchanged.

src/plugins/jqplot.donutRenderer.js

     // create a canvas which we can draw on.
     // insert it before the eventCanvas, so eventCanvas will still capture events.
     function postPlotDraw() {
+        // Memory Leaks patch    
+        if (this.plugins.donutRenderer && this.plugins.donutRenderer.highlightCanvas) {
+            this.plugins.donutRenderer.highlightCanvas.resetCanvas();
+            this.plugins.donutRenderer.highlightCanvas = null;
+        }
+
         this.plugins.donutRenderer = {highlightedSeriesIndex:null};
         this.plugins.donutRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
         // do we have any data labels?  if so, put highlight canvas before those

src/plugins/jqplot.dragable.js

     // insert it before the eventCanvas, so eventCanvas will still capture events.
     // add a new DragCanvas object to the plot plugins to handle drawing on this new canvas.
     $.jqplot.Dragable.postPlotDraw = function() {
+        // Memory Leaks patch    
+        if (this.plugins.dragable && this.plugins.dragable.highlightCanvas) {
+            this.plugins.dragable.highlightCanvas.resetCanvas();
+            this.plugins.dragable.highlightCanvas = null;
+        }
+
         this.plugins.dragable = {previousCursor:'auto', isOver:false};
         this.plugins.dragable.dragCanvas = new DragCanvas();
         

src/plugins/jqplot.funnelRenderer.js

     // create a canvas which we can draw on.
     // insert it before the eventCanvas, so eventCanvas will still capture events.
     function postPlotDraw() {
+        // Memory Leaks patch    
+        if (this.plugins.funnelRenderer && this.plugins.funnelRenderer.highlightCanvas) {
+            this.plugins.funnelRenderer.highlightCanvas.resetCanvas();
+            this.plugins.funnelRenderer.highlightCanvas = null;
+        }
+
         this.plugins.funnelRenderer = {};
         this.plugins.funnelRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
         

src/plugins/jqplot.highlighter.js

     // insert it before the eventCanvas, so eventCanvas will still capture events.
     $.jqplot.Highlighter.postPlotDraw = function() {
         // Memory Leaks patch    
-        if (this.plugins.highlighter &&
-        this.plugins.highlighter.highlightCanvas) {
+        if (this.plugins.highlighter && this.plugins.highlighter.highlightCanvas) {
             this.plugins.highlighter.highlightCanvas.resetCanvas();
             this.plugins.highlighter.highlightCanvas = null;
         }

src/plugins/jqplot.pieRenderer.js

     // insert it before the eventCanvas, so eventCanvas will still capture events.
     function postPlotDraw() {
         // Memory Leaks patch    
-        if (this.plugins.pieRenderer &&
-        this.plugins.pieRenderer.highlightCanvas) {
+        if (this.plugins.pieRenderer && this.plugins.pieRenderer.highlightCanvas) {
             this.plugins.pieRenderer.highlightCanvas.resetCanvas();
             this.plugins.pieRenderer.highlightCanvas = null;
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.