Bug 133769 - Odd axis intervals displaying JD as kde short date and time
Summary: Odd axis intervals displaying JD as kde short date and time
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-08 18:25 UTC by Netterfield
Modified: 2007-01-04 23:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
image showing the bug - look at the X axis intervals (20.91 KB, image/png)
2006-09-08 18:26 UTC, Netterfield
Details
Proposed patch (3.48 KB, patch)
2006-10-21 06:06 UTC, Andrew Walker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Netterfield 2006-09-08 18:25:33 UTC
Version:           1.2.1 (using KDE 3.5.2, Gentoo)
Compiler:          gcc version 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)
OS:                Linux (i686) release 2.6.15-gentoo-r1

Attached is a plot where the X axis is JD, interpreted as kde short date and time.  The tick intervals are not friendly...

The should be 1s or some other friendly interval...
Comment 1 Netterfield 2006-09-08 18:26:32 UTC
Created attachment 17670 [details]
image showing the bug - look at the X axis intervals
Comment 2 Andrew Walker 2006-10-21 06:06:18 UTC
Created attachment 18215 [details]
Proposed patch

I believe this fixes the described problem and also makes log mode better when
interpreting the x-axis values.
Comment 3 Andrew Walker 2007-01-04 23:42:30 UTC
SVN commit 619972 by arwalker:

BUG:133769 Provide better tick intervals. Apply proposed patch after two months and no feedback.

 M  +26 -18    kst2dplot.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #619971:619972
@@ -1709,14 +1709,13 @@
     case AXIS_DISPLAY_KDE_SHORTDATE:
     case AXIS_DISPLAY_KDE_LONGDATE:
       zdiff *= 24.0 * 60.0 * 60.0;
+      zdiff *= scale;
       break;
     case AXIS_DISPLAY_JD:
     case AXIS_DISPLAY_MJD:
     case AXIS_DISPLAY_RJD:
       break;
   }
-
-  zdiff *= scale;
 }
 
 
@@ -1799,16 +1798,9 @@
 void Kst2DPlot::getPrefixUnitsScale(bool isInterpreted, KstAxisInterpretation axisInterpretation, KstAxisDisplay axisDisplay, bool bLog, double logBase, double Min, double Max, double& range, double& scale, int& base, QString& strPrefix, QString& strUnits) {
   range = 1.0;
   scale = 1.0;
-  base = 60;
+  base = 10;
 
   if (isInterpreted) {
-    // determine the time range
-    if (bLog) {
-      range = pow(logBase, Max) - pow(logBase, Min);
-    } else {
-      range = Max - Min;
-    }
-
     // convert time range to seconds
     switch (axisInterpretation) {
       case AXIS_INTERP_YEAR:
@@ -1829,6 +1821,7 @@
       case AXIS_DISPLAY_YEAR:
         strPrefix = i18n("Prefix for Julian Year", "J");
         strUnits  = i18n("years");
+        scale /= 365.25 * 24.0 * 60.0 * 60.0;
         break;
       case AXIS_DISPLAY_YYMMDDHHMMSS_SS:
       case AXIS_DISPLAY_DDMMYYHHMMSS_SS:
@@ -1836,14 +1829,21 @@
       case AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS:
       case AXIS_DISPLAY_KDE_SHORTDATE:
       case AXIS_DISPLAY_KDE_LONGDATE:
-        if( range > 10.0 * 24.0 * 60.0 * 60.0 ) {
+        double value;
+        
+        if( bLog ) {
+          value = ( pow( logBase, Max ) - pow( logBase, Min ) ) * range;
+        } else {
+          value = ( Max - Min ) * range;
+        }
+        if( value > 10.0 * 24.0 * 60.0 * 60.0 ) {
           scale /= 24.0 * 60.0 * 60.0;
           strUnits  = i18n("days");
-        } else if( range > 10.0 * 24.0 * 60.0 ) {
+        } else if( value > 10.0 * 24.0 * 60.0 ) {
           scale /= 60.0 * 60.0;
           strUnits  = i18n("hours");
           base = 24;
-        } else if( range > 10.0 * 60.0 ) {
+        } else if( value > 10.0 * 60.0 ) {
           scale /= 60.0;
           strUnits  = i18n("minutes");
           base = 60;
@@ -1855,14 +1855,17 @@
       case AXIS_DISPLAY_JD:
         strPrefix = i18n("Prefix for Julian Date", "JD");
         strUnits  = i18n("days");
+        scale /= 24.0 * 60.0 * 60.0;
         break;
       case AXIS_DISPLAY_MJD:
         strPrefix = i18n("Prefix for Modified Julian Date", "MJD");
         strUnits  = i18n("days");
+        scale /= 24.0 * 60.0 * 60.0;
         break;
       case AXIS_DISPLAY_RJD:
         strPrefix = i18n("Prefix for Reduced Julian Date", "RJD");
         strUnits  = i18n("days");
+        scale /= 24.0 * 60.0 * 60.0;
         break;
     }
   }
@@ -1901,11 +1904,16 @@
   tp.labels.clear();
   tp.oppLabels.clear();
   tp.delta = false;
-
-  setTicks(tp.tick, tp.org, Max*scale, Min*scale, isLog, logBase, isX, base);
-  tp.tick /= scale;
-  tp.org  /= scale;
-
+  
+  if (isLog && isInterpreted) {
+    setTicks(tp.tick, tp.org, Max + log10(range) + log10(scale), Min + log10(range) + log10(scale), isLog, logBase, isX, base);
+    tp.org -= log10(range) + log10(scale);
+  } else {
+    setTicks(tp.tick, tp.org, Max*range*scale, Min*range*scale, isLog, logBase, isX, base);
+    tp.tick /= range*scale;
+    tp.org  /= range*scale;
+  }
+    
   tp.iLo = int((Min-tp.org)/tp.tick);
   tp.iHi = int((Max-tp.org)/tp.tick)+1;
   iShort = tp.iLo;