Chris Leonello avatar Chris Leonello committed 9b3b218

Fix to ensure original tick format strings are applied when resetting zoom.

Comments (0)

Files changed (3)

src/jqplot.axisTickRenderer.js

         this.textColor;
         this._elem;
 		this._breakTick = false;
+        this._applyPrefix = true;
         
         $.extend(true, this, options);
     };
     
     $.jqplot.AxisTickRenderer.prototype.init = function(options) {
         $.extend(true, this, options);
+        if (this.formatString != '') {
+            this._applyPrefix = false;
+        }
     };
     
     $.jqplot.AxisTickRenderer.prototype = new $.jqplot.ElemContainer();
     $.jqplot.AxisTickRenderer.prototype.constructor = $.jqplot.AxisTickRenderer;
     
-    $.jqplot.AxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
+    $.jqplot.AxisTickRenderer.prototype.setTick = function(value, axisName, isMinor, applyPrefix) {
         this.value = value;
         this.axis = axisName;
         if (isMinor) {
             this.isMinorTick = true;
         }
+        if (applyPrefix) {
+            this._applyPrefix = true;
+        }
         return this;
     };
     
             this.label = this.formatter(this.formatString, this.value);
         }
         // add prefix if needed
-        if (this.prefix && !this.formatString) {
+        if (this.prefix && this._applyPrefix) {
             this.label = this.prefix + this.label;
         }
         var style ='style="position:absolute;';

src/jqplot.linearAxisRenderer.js

         this.max = this._max;
         this.tickInterval = this._tickInterval;
         this.numberTicks = this._numberTicks;
+        this._autoFormatString = '';
+        if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
+            this.tickOptions.formatString = '';
+        }
+
         // this._ticks = this.__ticks;
     };
     
                 
             }
             
+            var applyTickPrefix = false;
             if (this._overrideFormatString && this._autoFormatString != '') {
                 this.tickOptions = this.tickOptions || {};
                 this.tickOptions.formatString = this._autoFormatString;
+                applyTickPrefix = true;
             }
 
             for (var i=0; i<this.numberTicks; i++){
                 var t = new this.tickRenderer(this.tickOptions);
                 // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
 
-                t.setTick(tt, this.name);
+                t.setTick(tt, this.name, false, applyTickPrefix);
                 this._ticks.push(t);
             }
         }

src/plugins/jqplot.cursor.js

                 if (!c.zoomProxy) {
                     for (var ax in axes) {
                         axes[ax].reset();
+                        axes[ax]._ticks = [];
+                        // fake out tick creation algorithm to make sure original auto
+                        // computed format string is used if _overrideFormatString is true
+                        axes[ax]._autoFormatString = c._zoom.axes[ax].tickFormatString;
                     }
                     this.redraw();
                 }
         var cax = cursor._zoom.axes;
         if (!plot.plugins.cursor.zoomProxy && cursor._zoom.isZoomed) {
             for (var ax in axes) {
+                // axes[ax]._ticks = [];
+                // axes[ax].min = cax[ax].min;
+                // axes[ax].max = cax[ax].max;
+                // axes[ax].numberTicks = cax[ax].numberTicks; 
+                // axes[ax].tickInterval = cax[ax].tickInterval;
+                // // for date axes
+                // axes[ax].daTickInterval = cax[ax].daTickInterval;
+                axes[ax].reset();
                 axes[ax]._ticks = [];
-                axes[ax].min = cax[ax].min;
-                axes[ax].max = cax[ax].max;
-                axes[ax].numberTicks = cax[ax].numberTicks; 
-                axes[ax].tickInterval = cax[ax].tickInterval;
-                // for date axes
-                axes[ax].daTickInterval = cax[ax].daTickInterval;
+                // fake out tick creation algorithm to make sure original auto
+                // computed format string is used if _overrideFormatString is true
+                axes[ax]._autoFormatString = cax[ax].tickFormatString;
             }
             plot.redraw();
             cursor._zoom.isZoomed = false;
                         c._zoom.axes[ax].daTickInterval = axes[ax].daTickInterval;
                         c._zoom.axes[ax].min = axes[ax].min;
                         c._zoom.axes[ax].max = axes[ax].max;
+                        c._zoom.axes[ax].tickFormatString = (axes[ax].tickOptions != null) ? axes[ax].tickOptions.formatString :  '';
                     }
 
 
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.