Commits

Chris Leonello committed d2d5ce5 Merge

merging log axis work.

Comments (0)

Files changed (5)

examples/zoom1.html

   <script language="javascript" type="text/javascript" src="../src/jquery.jqplot.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.dateAxisRenderer.js"></script>
-	
-	<style type="text/css">
-	  .jqplot-cursor-legend {
-	    width: 160px;
-	    font-family: "Courier New";
-	    font-size: 0.85em;
-	  }
-	  
-	  td.jqplot-cursor-legend-swatch {
-	    width: 1.3em;
-	  }
-	  
-	  div.jqplot-cursor-legend-swatch {
+  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.logAxisRenderer.js"></script>
+  
+  <style type="text/css">
+    .jqplot-cursor-legend {
+      width: 160px;
+      font-family: "Courier New";
+      font-size: 0.85em;
+    }
+    
+    td.jqplot-cursor-legend-swatch {
+      width: 1.3em;
+    }
+    
+    div.jqplot-cursor-legend-swatch {
 /*      width: 15px;*/
-	  }
-	</style>
-	
-	<script type="text/javascript" class="code">
-		$(document).ready(function(){
+    }
+  </style>
+  
+  <script type="text/javascript" class="code">
+    $(document).ready(function(){
       // $.jqplot.config.enablePlugins = true;
-		  
+      
     var goog = [["6/22/2009",425.32], ["6/8/2009",424.84], ["5/26/2009",417.23], ["5/11/2009",390], 
     ["4/27/2009",393.69], ["4/13/2009",392.24], ["3/30/2009",369.78], ["3/16/2009",330.16], ["3/2/2009",308.57], 
     ["2/17/2009",346.45], ["2/2/2009",371.28], ["1/20/2009",324.7], ["1/5/2009",315.07], ["12/22/2008",300.36], 
                 tickOptions:{formatString:'%Y/%#m/%#d'} 
             }, 
             yaxis: {  
-                tickOptions:{ prefix: '$' } 
+                renderer: $.jqplot.LogAxisRenderer,
+                // tickOptions:{ prefix: '$' } 
             } 
         }, 
         cursor:{
 </script>
 
 <script type="text/javascript" src="example.js"></script>
-		
+    
 </head>
 <body>
-    <?php include "topbanner.inc"; ?>
+    <!-- <?php include "topbanner.inc"; ?> -->
     <div class="example-content">
     <?php include "nav.inc"; ?>
 

src/jqplot.linearTickGenerator.js

     // it is based soley on the range and number of ticks.  So if user specifies
     // number of ticks, use this.
     function bestInterval(range, numberTicks) {
+        numberTicks = numberTicks || 7;
         var minimum = range / (numberTicks - 1);
         var magnitude = Math.pow(10, Math.floor(Math.log(minimum) / Math.LN10));
         var residual = minimum / magnitude;
     // This will return an interval of form 2 * 10^n, 5 * 10^n or 10 * 10^n
     // it is based soley on the range of data, number of ticks must be computed later.
     function bestLinearInterval(range, scalefact) {
+        scalefact = scalefact || 1;
         var expv = Math.floor(Math.log(range)/Math.LN10);
         var magnitude = Math.pow(10, expv);
         // 0 < f < 10

src/jqplot.sprintf.js

     };
 
     $.jqplot.getPrecision = function(number) {
-        var arr = $.jqplot.getSignificantFigures(number);
-        var p = arr[1] - 1 - parseInt(arr[0][1]);
-        return p;
+        return $.jqplot.getSignificantFigures(number).digitsRight;
     };
 
 })(jQuery);  

src/plugins/jqplot.cursor.js

                                 }
                             }
                             
-                            if (this.looseZoom && (axes[ax].renderer.constructor === $.jqplot.LinearAxisRenderer || axes[ax].renderer.constructor === $.jqplot.DateAxisRenderer)) {
+                            if (this.looseZoom && (axes[ax].renderer.constructor === $.jqplot.LinearAxisRenderer || axes[ax].renderer.constructor === $.jqplot.LogAxisRenderer || axes[ax].renderer.constructor === $.jqplot.DateAxisRenderer)) {
                                 var ret = $.jqplot.LinearTickGenerator(newmin, newmax, curax._scalefact, _numberTicks);
 
                                 // if new minimum is less than "true" minimum of axis display, adjust it

src/plugins/jqplot.logAxisRenderer.js

         var userTicks = this.ticks;
         var name = this.name;
         var db = this._dataBounds;
-        var dim, interval;
+        var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height;
+        var interval;
         var min, max;
         var pos1, pos2;
         var tt, i;
         }
         
         // we don't have any ticks yet, let's make some!
-        else {
-            if (name == 'xaxis' || name == 'x2axis') {
-                dim = this._plotDimensions.width;
-            }
-            else {
-                dim = this._plotDimensions.height;
-            }
-        
+        else if (this.min == null && this.max == null) {
             min = (this.min != null) ? this.min : db.min * (2 - this.padMin);
             max = (this.max != null) ? this.max : db.max * this.padMax;
             
             this.max = rmax;
             var range = this.max - this.min;            
 
-            var fittedTicks = 0;
             var minorTicks = (this.minorTicks === 'auto') ? 0 : this.minorTicks;
             var numberTicks;
             if (this.numberTicks == null){
                 }       
             }     
         }
+
+        // min and max are set as would be the case with zooming
+        else if (this.min != null && this.max != null) {
+            var opts;
+            // don't have an interval yet, pick one that gives the most
+            // "round" ticks we can get.
+            if (this.numberTicks == null && this.tickInterval == null) {
+                var threshold = 30;
+                var tdim = Math.max(dim, threshold+1);
+                var nttarget =  Math.ceil((tdim-threshold)/35 + 1);
+
+                // run through possible number to ticks and see which interval is best
+                var low = Math.floor(nttarget/2);
+                var hi = Math.ceil(nttarget*1.5);
+                var facts = [];
+                var ntarr = [];
+                var r = (this.max - this.min);
+
+                for (var i=0, l=hi-low+1, i<l; i++) {
+                    ntarr.push(low + i);
+                    facts.push($.jqplot.getSignificantFigures(r/(low+i-1)).digitsLeft);
+                }
+            }
+
+            // for loose zoom, number ticks and interval are also set.
+            if (this.numberTicks != null && this.tickInterval != null) {
+                for (var i=0; i<this.numberTicks; i++) {
+                    opts = $.extend(true, {}, this.tickOptions, {name: this.name, value: this.min + i * this.tickInterval});
+                    t = new this.tickRenderer(opts);
+                    
+                    if (this._overrideFormatString && this._autoFormatString != '') {
+                        t.formatString = this._autoFormatString;
+                    }
+                    if (!this.showTicks) {
+                        t.showLabel = false;
+                        t.showMark = false;
+                    }
+                    else if (!this.showTickMarks) {
+                        t.showMark = false;
+                    }
+                    this._ticks.push(t);
+                }
+            }
+
+            
+        }
     };
     
     $.jqplot.LogAxisRenderer.prototype.pack = function(pos, offsets) {
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.