Anonymous avatar Anonymous committed 98ad5b2

Updates so axes tick formatting will auto adjust when zoomed.

Comments (0)

Files changed (2)

src/jqplot.linearAxisRenderer.js

         // are set:  autoscale, min, max, numberTicks or tickInterval.
         this.forceTickAt100 = false;
         this._autoFormatString = '';
+        this._overrideFormatString = false;
         $.extend(true, this, options);
 		if (this.breakPoints) {
 			if (!$.isArray(this.breakPoints)) {
                 dim = this._plotDimensions.height;
             }
             
-            // if min, max and number of ticks specified, user can't specify interval.
-            if (!this.autoscale && this.min != null && this.max != null && this.numberTicks != null) {
-                this.tickInterval = null;
-            }
+            // // if min, max and number of ticks specified, user can't specify interval.
+            // if (!this.autoscale && this.min != null && this.max != null && this.numberTicks != null) {
+            //     console.log('doing this');
+            //     this.tickInterval = null;
+            // }
             
             // if max, min, and interval specified and interval won't fit, ignore interval.
             // if (this.min != null && this.max != null && this.tickInterval != null) {
 
             // Doing complete autoscaling
             if (this.min == null && this.max == null && this.numberTicks == null && this.tickInterval == null && !this.autoscale) {
+                // check to see if we can override tick format string with autocalculated one
+                if (this.tickOptions == null || !this.tickOptions.formatString) {
+                    this._overrideFormatString = true;
+                }
+
+
                 // Check if user must have tick at 0 or 100 and ensure they are in range.
                 // The autoscaling algorithm will always place ticks at 0 and 100 if they are in range.
                 if (this.forceTickAt0) {
                     }
                 }
                 
-                if (this.renderer.constructor == $.jqplot.LinearAxisRenderer) {
+                if (this.renderer.constructor == $.jqplot.LinearAxisRenderer && this._autoFormatString == '') {
                     // fix for misleading tick display with small range and low precision.
                     range = this.max - this.min;
                     // figure out precision
                 
             }
             
-            if ((this.tickOptions == null || !this.tickOptions.formatString) && this._autoFormatString != '') {
+            if (this._overrideFormatString && this._autoFormatString != '') {
                 this.tickOptions = this.tickOptions || {};
                 this.tickOptions.formatString = this._autoFormatString;
             }

src/plugins/jqplot.cursor.js

         var c = this.plugins.cursor;
         
         // Memory Leaks patch
-        if (c.zoomCanvas) {
-            c.zoomCanvas.resetCanvas();
-            c.zoomCanvas = null;
-        }
-        
-        if (c.cursorCanvas) {
-            c.cursorCanvas.resetCanvas();
-            c.cursorCanvas = null;
-        }
-        
-        if (c._tooltipElem) {
-            c._tooltipElem.emptyForce();
-            c._tooltipElem = null;
-        }
+        if (c.zoomCanvas) {
+            c.zoomCanvas.resetCanvas();
+            c.zoomCanvas = null;
+        }
+        
+        if (c.cursorCanvas) {
+            c.cursorCanvas.resetCanvas();
+            c.cursorCanvas = null;
+        }
+        
+        if (c._tooltipElem) {
+            c._tooltipElem.emptyForce();
+            c._tooltipElem = null;
+        }
 
         
         // if (c.zoom) {
                                 var ret = $.jqplot.LinearTickGenerator(newmin, newmax);
                                 axes[ax].min = ret[0];
                                 axes[ax].max = ret[1];
+                                axes[ax]._autoFormatString = ret[3];
                                 axes[ax].numberTicks = ret[2];
                                 axes[ax].tickInterval = ret[4];
                                 // for date axes...
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.