Commits

Chris Leonello committed 8b3fb6f

Working on bug in log axes under zooming with small plots. Something wrong with scalefactor.

  • Participants
  • Parent commits 6dc733d

Comments (0)

Files changed (7)

File examples/dataTracking.html

                 followMouse: true,
                 showTooltipDataPosition:true,
                 zoom:true,
-                looseZoom: true,
                 intersectionThreshold:6,
                 tooltipFormatString: '%s x:%s, y:%s'
             },

File examples/zoom1.html

     
 </head>
 <body>
-    <!-- <?php include "topbanner.inc"; ?> -->
+    <?php include "topbanner.inc"; ?>
     <div class="example-content">
     <?php include "nav.inc"; ?>
 

File examples/zoom2.html

 plot = $.jqplot('chart', [goog], {
     title: 'Google, Inc.',
     series: [{
-        // label: 'Google, Inc.',
+        label: 'Google, Inc.',
         neighborThreshold: 0
     }],
     axes: {
           tickOptions:{formatString:"%Y/%#m/%#d"}
         },
         yaxis: {
-            // renderer: $.jqplot.LogAxisRenderer
+            renderer: $.jqplot.LogAxisRenderer
         }
     },
-    cursor:{ zoom: true, looseZoom: true},
+    cursor:{ zoom: true },
     highlighter:{show:true}
 });
   });

File examples/zoomOptions.html

   
   <!-- BEGIN: load jqplot -->
   <script language="javascript" type="text/javascript" src="../src/jquery.jqplot.js"></script>
-<!--   // <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.logAxisRenderer.js"></script> -->
+  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.logAxisRenderer.js"></script>
   <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.dateAxisRenderer.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.highlighter.js"></script>
                 tickOptions:{prefix: '$'}
             }
         },
-        cursor:{zoom:true, looseZoom: true},
+        cursor:{zoom:true},
         highlighter:{show:true}
     };
 

File src/jqplot.linearAxisRenderer.js

         var name = this.name;
         // databounds were set on axis initialization.
         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;
         var userMax = this.max;
         var userNT = this.numberTicks;
         var userTI = this.tickInterval;
+
+        var threshold = 30;
+        this._scalefact =  (Math.max(dim, threshold+1) - threshold)/300.0;
         
         // if we already have ticks, use them.
         // ticks must be in order of increasing value.
                     }
                 }
 
-                var threshold = 30;
-                var tdim = Math.max(dim, threshold+1);
-                this._scalefact =  (tdim-threshold)/300.0;
+                // var threshold = 30;
+                // var tdim = Math.max(dim, threshold+1);
+                // this._scalefact =  (tdim-threshold)/300.0;
                 var ret = $.jqplot.LinearTickGenerator(min, max, this._scalefact, _numberTicks); 
                 // calculate a padded max and min, points should be less than these
                 // so that they aren't too close to the edges of the plot.

File src/jqplot.linearTickGenerator.js

             temp = Math.abs(nttarget - currentNT) + sd.digitsRight;
             if (temp < badness) {
                 badness = temp;
-                bestNT = currentNT
+                bestNT = currentNT;
                 bestPrec = sd.digitsRight;
             }
             else if (temp === badness) {
         }
 
         fsd = Math.max(bestPrec, Math.max(gsf(min).digitsRight, gsf(max).digitsRight));
-        fs = '%.' + fsd + 'f';
+        if (fsd === 0) {
+            fs = '%d';
+        }
+        else {
+            fs = '%.' + fsd + 'f';
+        }
         temp = r / (bestNT - 1);
         // min, max, number ticks, format string, tick interval
         return [min, max, bestNT, fs, temp];

File src/plugins/jqplot.logAxisRenderer.js

         // Major ticks are ticks supplied by user or auto computed.
         // Minor ticks cannot be created by user.
         this.minorTicks = 'auto';
+        this._scalefact = 1.0;
 
         $.extend(true, this, options);
 
         var pos1, pos2;
         var tt, i;
 
+        var threshold = 30;
+        // For some reason scalefactor is screwing up ticks.
+        // this._scalefact =  (Math.max(dim, threshold+1) - threshold)/200;
+
         // if we already have ticks, use them.
         // ticks must be in order of increasing value.
         if (userTicks.length) {
             // 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 threshold = 30;
                 var tdim = Math.max(dim, threshold+1);
                 var nttarget =  Math.ceil((tdim-threshold)/35 + 1);
 
                 var ret = $.jqplot.LinearTickGenerator.bestConstrainedInterval(this.min, this.max, nttarget);
 
                 this._autoFormatString = ret[3];
+                console.log(reg[3]);
                 nt = ret[2];
                 ti = ret[4];
 
             }
 
             // for loose zoom, number ticks and interval are also set.
-            if (this.numberTicks != null && this.tickInterval != null) {
+            else if (this.numberTicks != null && this.tickInterval != null) {
                 nt = this.numberTicks;
                 for (var i=0; i<nt; i++) {
                     opts.value = this.min + i * this.tickInterval;