Bug 66138 - kst should have have a "time vector" which is a unix-type time, which displays in a human readable format
Summary: kst should have have a "time vector" which is a unix-type time, which display...
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Unlisted Binaries Linux
: NOR wishlist
Target Milestone: ---
Assignee: Andrew Walker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-17 00:13 UTC by Matthew Truch
Modified: 2004-10-15 20:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2003-10-17 00:13:46 UTC
Version:           0.92 (using KDE KDE 3.1)
Installed from:    Unspecified Linux
OS:          Linux

Often one plots data as a function of time, and often this time is a vector which contains seconds since some time epoch (often the UNIX epoch).  It would be very useful to have a time vector type which displays the time in a human readable format (ie 13:32:12 or 2003-10-03 21:34:53).  It should only display the minimum time info required at each tick mark to be un-ambiguous.
Comment 1 Andrew Walker 2003-10-17 12:11:20 UTC
Another possibility would be to display the human readable time associated with the leftmost point of the plot in the plot title or some other identifiable area. The time axis would then display only the delta from this time in appropriate units (hours, minutes, or seconds).
Comment 2 Matthew Truch 2003-10-17 17:29:26 UTC
Andrew:  You've hit at exactly what I was trying (and failed) to say.  Thanks.  
Comment 3 Andrew Walker 2004-08-10 01:17:53 UTC
We now have the functionality to do this in that we automatically use a 
similar approach when the x-axis value range becomes too small to be 
displayed with the specified maximum accuracy of the x-axis tick labels. In 
this situation we now present an x-axis value at full precision just above 
the x-axis label, and the x-axis tick values are given relative to this. 

It would be relatively simple to extend this so that the user can have this 
display mechanism as the default, and a checkbox indicating the the x-axis 
value are time_t values. We would then only need to indicate the delta units 
(days, hours, etc.).

Comment 4 Andrew Walker 2004-10-15 20:21:36 UTC
CVS commit by arwalker: 

Display delta time values in seconds, minutes, hours, days depending on the range of the data.

I think this about wraps about the time value on the x-axis. If there are any additional features that are wanted please submit a wishlist request.

CCMAIL: 66138-done@bugs.kde.org


  M +20 -6     kst2dplot.cpp   1.282
  M +2 -2      kst2dplot.h   1.118


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.281:1.282
@@ -1402,5 +1402,5 @@ void Kst2DPlot::convertTimeValueToString
 
 
-void Kst2DPlot::convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog) {
+void Kst2DPlot::convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog, double scale) {
   double zdiff;
 
@@ -1432,4 +1432,6 @@ void Kst2DPlot::convertDiffTimevalueToSt
   }
 
+  zdiff *= scale;
+  
   if (zdiff > 0.0) {
     label = i18n("+[%1]").arg(zdiff, 0, 'g', DIFFERENCE_PRECISION);
@@ -1455,9 +1457,9 @@ void Kst2DPlot::genAxisTickLabelFullPrec
 
 
-void Kst2DPlot::genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX) {
+void Kst2DPlot::genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX, double scale) {
   double zdiff;
 
   if (isX && _isXAxisInterpreted) {
-    convertDiffTimevalueToString(label, zbase, zvalue, isLog);    
+    convertDiffTimevalueToString(label, zbase, zvalue, isLog, scale);    
   } else {
     if (isLog) {
@@ -1501,4 +1503,5 @@ void Kst2DPlot::genAxisTickLabels(QPaint
   double dWidth;
   double dHeight;
+  double scale = 1.0;
   bool bDuplicate = false;
   uint uiShortestLength = 1000;
@@ -1553,5 +1556,16 @@ void Kst2DPlot::genAxisTickLabels(QPaint
       case X_AXIS_DISPLAY_QTTEXTDATEHHMMSS_SS:
       case X_AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS:
+        if( range > 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 ) {
+          scale /= 60.0 * 60.0;
+          strUnits  = i18n("hours");
+        } else if( range > 10.0 * 60.0 ) {
+          scale /= 60.0;
+          strUnits  = i18n("minutes");
+        } else {
         strUnits  = i18n("seconds");
+        }
         break;
       case X_AXIS_DISPLAY_JD:
@@ -1613,7 +1627,7 @@ void Kst2DPlot::genAxisTickLabels(QPaint
       }
       if (bLog) {
-        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick + Org, (double)i * Tick + Org, bLog, isX);
+        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick + Org, (double)i * Tick + Org, bLog, isX, scale);
       } else {
-        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick, (double)i * Tick, bLog, isX);
+        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick, (double)i * Tick, bLog, isX, scale);
       }
       labelList.append(strTmp);

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.117:1.118
@@ -347,7 +347,7 @@ private:
   void convertJDToDateString(QString& label, uint& length, KstXAxisDisplay display, double dJD);
   void convertTimeValueToString(QString& label, uint& length, double z, bool isLog);
-  void convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog);
+  void convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog, double scale);
   void genAxisTickLabelFullPrecision(QString& label, uint& length, double z, bool isLog, bool isX);
-  void genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX);
+  void genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX, double scale);
   void genAxisTickLabels(QPainter& p, double Min, double Max,
       double Org, double Tick, bool isLog, KstLabel *Label, bool &delta,