Commits

Chris Leonello  committed 487201b

More refactoring to get replot to be more useful. Fixed bug where hooks manager addOnce method was not working and duplicate hooks would get added.

  • Participants
  • Parent commits 5c0f4f0

Comments (0)

Files changed (1)

File src/jqplot.core.js

     Axis.prototype.constructor = Axis;
     
     Axis.prototype.init = function() {
-        this.renderer = new this.renderer();
+        if ($.isFunction(this.renderer)) {
+            this.renderer = new this.renderer();  
+        }
         // set the axis name
         this.tickOptions.axis = this.name;
         // if showMark or showLabel tick options not specified, use value of axis option.
     };
     
     Legend.prototype.init = function() {
-        this.renderer = new this.renderer();
+        if ($.isFunction(this.renderer)) {
+            this.renderer = new this.renderer();  
+        }
         this.renderer.init.call(this, this.rendererOptions);
     };
     
     Title.prototype.constructor = Title;
     
     Title.prototype.init = function() {
-        this.renderer = new this.renderer();
+        if ($.isFunction(this.renderer)) {
+            this.renderer = new this.renderer();  
+        }
         this.renderer.init.call(this, this.rendererOptions);
     };
     
             var comp = $.jqplot.getColorComponents(comp);
             this.fillColor = 'rgba('+comp[0]+','+comp[1]+','+comp[2]+','+this.fillAlpha+')';
         }
-        this.renderer = new this.renderer();
+        if ($.isFunction(this.renderer)) {
+            this.renderer = new this.renderer();  
+        }
         this.renderer.init.call(this, this.rendererOptions, plot);
         this.markerRenderer = new this.markerRenderer();
         if (!this.markerOptions.color) {
     Grid.prototype.constructor = Grid;
     
     Grid.prototype.init = function() {
-        this.renderer = new this.renderer();
+        if ($.isFunction(this.renderer)) {
+            this.renderer = new this.renderer();  
+        }
         this.renderer.init.call(this, this.rendererOptions);
     };
     
         args = args || [];
         var havehook = false;
         for (var i=0, l=this.hooks.length; i<l; i++) {
-            if (this.hooks[i][0] == fn) {
+            if (this.hooks[i] == fn) {
                 havehook = true;
             }
         }
             this.seriesStack = [];
             this.previousSeriesStack = [];
 
-            for (var i=0; i<this.series.length; i++) {
+            var target = this.targetId.substr(1);
+
+            for (var i=0, l=this.series.length; i<l; i++) {
                 // set default stacking order for series canvases
                 this.seriesStack.push(i);
                 this.previousSeriesStack.push(i);
                 this._sumx += this.series[i]._sumx;
             }
 
-            var name;
+            var name,
+                t, 
+                j,
+                axis;
             for (var i=0; i<12; i++) {
                 name = _axisNames[i];
+                axis = this.axes[name];
+
 
                 // Memory Leaks patch : clear ticks elements
-                var t = this.axes[name]._ticks;
-                for (var i = 0; i < t.length; i++) {
-                  var el = t[i]._elem;
+                t = axis._ticks;
+                for (var j = 0, tlen = t.length; j < tlen; j++) {
+                  var el = t[j]._elem;
                   if (el) {
                     // if canvas renderer
                     if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
                 }
                 t = null;
 
-                this.axes[name]._plotDimensions = this._plotDimensions;
-                this.axes[name].init();
-                if (this.axes[name].borderColor == null) {
-                    if (name.charAt(0) !== 'x' && this.axes[name].useSeriesColor === true && this.axes[name].show) {
-                        this.axes[name].borderColor = this.axes[name]._series[0].color;
+                axis.ticks = [];
+                axis._ticks = [];
+                axis._plotDimensions = this._plotDimensions;
+                axis.init();
+                if (axis.borderColor == null) {
+                    if (name.charAt(0) !== 'x' && axis.useSeriesColor === true && axis.show) {
+                        axis.borderColor = axis._series[0].color;
                     }
                     else {
-                        this.axes[name].borderColor = this.grid.borderColor;
+                        axis.borderColor = this.grid.borderColor;
                     }
                 }
             }
             
             this.legend._series = this.series;
 
-            for (var i=0; i<$.jqplot.postInitHooks.length; i++) {
+            for (var i=0, l=$.jqplot.postInitHooks.length; i<l; i++) {
                 $.jqplot.postInitHooks[i].call(this, target, this.data, options);
             }
 
-            for (var i=0; i<this.postInitHooks.hooks.length; i++) {
+            for (var i=0, l=this.postInitHooks.hooks.length; i<l; i++) {
                 this.postInitHooks.hooks[i].call(this, target, this.data, options);
             }
         };