Show TimeSpan

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
none
Newbie
Newbie
Posts: 3
Joined: Tue Jun 12, 2007 12:00 am

Show TimeSpan

Post by none » Thu Dec 06, 2007 2:00 pm

hi all,

I have a chart that shows measured values over a time period (the x axis represents the time). I currently have the time stored in ticks but want to show them in seconds (starting from 0 seconds and so on)

Does Steema provide me with a way to show TimeSpan in the X-axis?

Thanks
Stijn

fano
Newbie
Newbie
Posts: 56
Joined: Wed Jun 22, 2005 4:00 am
Location: USA, California

Same/similar issue regarding time span/durations

Post by fano » Thu Dec 06, 2007 6:30 pm

Hi,
I used DateTime for X-axis and formatted HH:mm:ss to get the X-axis
look like duration of time passed. I use a base-date like 1/2/2000 and add
the time passed to it and then the X-axis labels looks like this for the
(DateTime, Y-value) data pairs.

00:00:00 00:01:22 etc.

This works for a 1 day, i.e. 24 hours. But the same trick doesn't work
for longer time periods where days are needed because there is no
valid date with day '0'. It is always 1 or 31, i.e. not 0 and then the labels
would look like:

1.00:00:00 1.00:01:22 while I really want to start with:
0.00:00:00 0.00:01:22 and then they reach eventually one full day, two full days etc.

How can one overcome this issue?

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Dec 07, 2007 9:06 am

Hello Stijn,

At this thread you'll see how the time to draw a chart is calculated. You could use similar approach to add the time values to your series but converting them to seconds instead of milliseconds. Also notice that you'll need to set your series to display DateTime values, for example:

Code: Select all

line1.XValues.DateTime=true;
For further information on how to set DateTime values format please read Tutorial 4 - Axis Control. You'll find the tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Dec 07, 2007 11:47 am

Hi fano,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

fano
Newbie
Newbie
Posts: 56
Joined: Wed Jun 22, 2005 4:00 am
Location: USA, California

Time duration for X-Axis

Post by fano » Fri Dec 07, 2007 9:18 pm

Hi Narcis,

(sorry for the long text but I want to explain this better)

there seems to be a misunderstanding. I did not report a bug but only showed how I did use TimeDate for the X-axis to simulate a duration on
the X-axis as labels. You see we don't want the X-Axis to say how much
time has elapsed in sec or hours or minutes, but we want the labels to
show the duration formatted like one can do it in a DateTime, i.e.
[hh:mm:ss]. So a label would say: 00:12:33 (i.e. 0 hours, 12 mins, 33 secs). It is not sufficient to just use one unit, i.e. sec. because that is not well readable for the user when the duration is long, i.e. 4315 min, etc. Users want the label to state how many days/hours/min/sec that are.

My 'trick' as described in the previous message works for durations of 24 hours but not for more than that because once you include days, it always will have at least 1 day in the label, because there is no valid DateTime with a day '0', i.e. January 0th 2008 does not exist and so the first label would already start with a non-0 day even though no full day has elapes yet.

So I wondered if you know a way to show duration in a format like:
[days:hours:minutes:seconds] as X-is labels. I simply used a DateTime as X-labels but surpressed the year, month, and day, i.e. formatted [HH:mm:ss}. That gives the 'illusion' of time duration labels. But it works only for 24 hours, i.e. if start and end day of the DateTime are the same.

Any ideas how to put X-labels on teechart that indicate passed:
[days:hours:minutes:seconds]

Many Thanks,
Norman

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Dec 10, 2007 8:59 am

Hi Norman,

Thanks for the information.

You could look at the System.DateTime definition on how zero value for this type is defined and then format labels accordingly. You may also be interested in checking System.TimeSpan.

http://msdn2.microsoft.com/en-us/librar ... S.80).aspx
http://msdn2.microsoft.com/en-us/librar ... S.80).aspx
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply