[Kst] [Bug 92855] Major problem with ticks and axis scaling

Andrew Walker arwalker at sumusltd.com
Mon Nov 8 00:37:24 CET 2004


------- 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=92855        




------- Additional Comments From arwalker sumusltd com  2004-11-08 00:37 -------
CVS commit by arwalker: 

Always use 0 or 10 minor ticks for default value for minor ticks when in log mode.

If you are in log mode and the data range is too small (i.e. log(range) < 2) then you really shouldn't be in log mode. Under these conditions you can either give minor ticks at regular intervals which are seemingly random numbers, or minor ticks at irrgeular intervals which are round numbers. Neither is very satisfactory. As a result the current behaviour has been left unchanged.

Also, fixed a problem where some major ticks were not displayed in log mode.

Do we want to check this into HEAD?

CCMAIL: 92855 bugs kde org


  M +38 -30    kst2dplot.cpp   1.299.2.1


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.299:1.299.2.1
 @ -1589,6 +1589,6  @ void Kst2DPlot::genAxisTickLabels(QPaint
 
   setTicks(tp.tick, tp.org, Max*scale, Min*scale, bLog, isX);
-  tp.tick/=scale;
-  tp.org/=scale;
+  tp.tick /= scale;
+  tp.org  /= scale;
 
   tp.iLo = (int)((Min-tp.org)/tp.tick);
 @ -2455,16 +2455,8  @ void Kst2DPlot::setTicks(double& tick, d
   int majorDensity = isX ? _xMajorTicks : _yMajorTicks;
 
-  if (is_log && max - min < 11 && max - min > 1) {
-    tick = 1.0;
-  } else {
-    //
-    // determine tick interval...
-    //
-    St = (max - min) / (double)majorDensity;
-    Exp = pow(10.0, floor(log10(St)));
-
     //
     // check for hysteresis of y-axis tick spacing...
     //
+  St = (max - min) / (double)majorDensity;
     if (!isX && is_log == _isLogLast && _stLast != 0.0 &&
         St/_stLast < TICK_HYSTERESIS_FACTOR &&
 @ -2473,5 +2465,18  @ void Kst2DPlot::setTicks(double& tick, d
       tick = _tickYLast;
       auto_tick = _autoTickYLast;
+  } else if (is_log) {
+    if (max - min <= (double)majorDensity && max - min > 1.5) {
+      auto_tick = 9;
+      tick = 1.0;
+    } else if (max - min >= (double)majorDensity) {
+      auto_tick = 0;
+      tick = floor((max - min) / (double)majorDensity);
+      if (tick == 1.0) {
+        auto_tick = 9;
+      }
     } else {
+      auto_tick = 0;
+      Exp = pow(10.0, floor(log10(St)));
+
       tick = ticks[0] * Exp;
       for (int i=1; i<iNumTicks; i++) {
 @ -2480,15 +2485,19  @ void Kst2DPlot::setTicks(double& tick, d
         }
       }
-      if (tick == 2.0*Exp || tick == 4.0*Exp) {
-        auto_tick = 4;
       }
+  } else {
+    //
+    // determine tick interval...
+    //
+    Exp = pow(10.0, floor(log10(St)));
+
+    tick = ticks[0] * Exp;
+    for (int i=1; i<iNumTicks; i++) {
+      if (fabs((ticks[i] * Exp) - St) < fabs(tick - St)) {
+        tick = ticks[i] * Exp;
     }
   }
-
-  if (is_log) {
-    if (max - min > 50.0) {
-      auto_tick = 1;
-    } else if (max - min > 20.0) {
-      auto_tick /= 2;
+    if (tick == 2.0*Exp || tick == 4.0*Exp) {
+      auto_tick = 4;
     }
   }
 @ -5571,6 +5580,5  @ void Kst2DPlot::plotAxes(QPainter& p, QR
   //
   if (_xLog) {
-    i = (int)floor((double)_xMinorTicks*
-                   (xleft_bdr_px - 1.0 - x_orig_px)/xtick_px);
+    i = (int)floor((double)_xMajorTicks*(xleft_bdr_px - 1.0 - x_orig_px)/xtick_px);
     for (;xtick_px * i + x_orig_px < x_px - xright_bdr_px + 1; i++) {
       //
 @ -5639,5 +5647,5  @ void Kst2DPlot::plotAxes(QPainter& p, QR
   //
   if (_yLog) {
-    i = (int)floor( (double)_yMinorTicks * ( ytop_bdr_px - 1.0 - y_orig_px ) / ytick_px );
+    i = (int)floor( (double)_yMajorTicks * ( ytop_bdr_px - 1.0 - y_orig_px ) / ytick_px );
     for (; ytick_px * i + y_orig_px < y_px - ybot_bdr_px + 1; i++) {
       //



More information about the Kst mailing list