[Kst] [Bug 121534] log axis tickmarks switch to linear spacing too soon

Andrew Walker arwalker at sumusltd.com
Wed Jun 14 00:09:00 CEST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=121534         
arwalker sumusltd com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From arwalker sumusltd com  2006-06-14 00:08 -------
SVN commit 551195 by arwalker:

BUG:121534 Go to base 2 when base 10 does not display enough valuse on the axis.

 M  +35 -8     kst2dplot.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #551194:551195
 @ -756,6 +756,15  @
 
   if (checkLRange(xmin_in, xmax_in, _xLog, _xLogBase)) {
     if (_xLog) {
+      if (_xLogBase == 10.0 && xmax_in - xmin_in < 1.5) {
+        _xLogBase = 2.0;
+        xmin_in *= 1.0/log10(2.0);
+        xmax_in *= 1.0/log10(2.0);
+      } else if (_xLogBase == 2.0 && xmax_in - xmin_in > 4.0) {
+        _xLogBase = 10.0;
+        xmin_in *= log10(2.0);
+        xmax_in *= log10(2.0);
+      }
       XMax = pow(_xLogBase, xmax_in);
       XMin = pow(_xLogBase, xmin_in);
     } else {
 @ -774,6 +783,11  @
 
   if (checkLRange(ymin_in, ymax_in, _yLog, _yLogBase)) {
     if (_yLog) {
+      if (_yLogBase == 10.0 && ymax_in - ymin_in < 1.1) {
+        _yLogBase = 2.0;
+      } else if (_yLogBase == 2.0 && ymax_in - ymin_in > 3.5) {
+        _yLogBase = 10.0;
+      }
       YMax = pow(_yLogBase, ymax_in);
       YMin = pow(_yLogBase, ymin_in);
     } else {
 @ -1433,7 +1447,7  @
   int accuracy = 0;
 
   // check how many decimal places we need based on the scale
-  getLScale(xmin,ymin,xmax,ymax);
+  getLScale(xmin, ymin, xmax, ymax);
   if (isXLog()) {
     xdelta = (pow(_xLogBase, xmax) - pow(_xLogBase, xmin))/double(pr.width());
   } else {
 @ -3024,17 +3038,30  @
     tick = _tickYLast;
     auto_tick = _autoTickYLast;
   } else if (is_log) {
-    if (max - min <= (double)majorDensity && max - min > 1.5) {
-      // show in logarithmic mode with major ticks nicely labelled and 9 minor ticks 
-      //  between each major label...
-      auto_tick = 9;
+    if (max - min <= (double)majorDensity && ((_xLogBase == 10.0 && max - min > 1.5) ||
+                                              (_xLogBase ==  2.0 && max - min > 1.0))) {
+      // show in logarithmic mode with major ticks nicely labelled and the specified
+      //  number of minor ticks between each major label...
+      if (logBase == 2.0) {
+        auto_tick = 10;
+      } else if (logBase == 10.0) {
+        auto_tick = 9;
+      } else {
+        auto_tick = 5;
+      }
       tick = 1.0;
     } else if (max - min >= (double)majorDensity) {
       // show in logarithmic mode with major ticks nicely labelled and no minor ticks...  
       auto_tick = 0;
       tick = floor((max - min) / (double)majorDensity);
       if (tick == 1.0) {
-        auto_tick = 9;
+        if (logBase == 2.0) {
+          auto_tick = 10;
+        } else if (logBase == 10.0) {
+          auto_tick = 9;
+        } else {
+          auto_tick = 5;
+        }
       }
     } else {
       // show in "linear" mode with major ticks linearly spaced and no minor ticks...
 @ -3047,10 +3074,10  @
           tick = ticks[i] * Exp;
         }
       }
-    }
+    } 
   } else {
     // determine tick interval...
-    Exp = 0;
+    Exp = 0.0;
     if (base == 60) {
       if ((b60_ticks[0]*0.7 < St) &&
           (b60_ticks[n_b60_ticks-1] > St*0.7)) {


More information about the Kst mailing list