time format for botom axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

time format for botom axis

Post by Petr » Fri Nov 08, 2013 10:57 am

Hello, i'm making a real time chart, and i want to make botom axis in special time format, but it must be not like standart DateTime type, it must ne like "HH:MM:SS" where amount of hours may be more than 24( so the ticks are like time range passed from begining of charting ) is there any way how to implement it?

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: time format for botom axis

Post by Petr » Fri Nov 08, 2013 12:48 pm

And one more question. i'm in the previous situation, and now i use ovveride add method to add values to the line.

Code: Select all

public void AddRange(List<Pair<double, double>> addingRange)
        {
            for (int i = 0; i < addingRange.Count; ++i)
            {
                DateTime tick = new DateTime(1, 1, 1, (int)addingRange[i].First / 3600, ((int)addingRange[i].First % 3600) / 60, (int)addingRange[i].First % 60);
                m_plot.Add(tick, addingRange[i].Second);
            }
            //ScrollAxis();
        }
where pair is similar c++ Pair<>. Here Add gets DateTime as X-value and double as Y. There is some conversion from datetime to double, i want know about. I want to scroll bottom axis for some defined value by code dependency on condition( as you can see now ScroolAxis function, that is commented now), but for this i need to know how converting DateTime to double is going on( in TeeChart )? later i will need the reverse conversion( from double to DateTime), but it's not so hard to find it, if you know direct one.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: time format for botom axis

Post by Sandra » Fri Nov 08, 2013 5:27 pm

Hello Petr,
Hello, i'm making a real time chart, and i want to make botom axis in special time format, but it must be not like standart DateTime type, it must ne like "HH:MM:SS" where amount of hours may be more than 24( so the ticks are like time range passed from begining of charting ) is there any way how to implement it?
You can change the DateTimeFormat of Axes as do in next line of code:

Code: Select all

tChart1.Axes.Bottom.Labels.DateTimeFormat = "HH:MM:SS"; 
...where pair is similar c++ Pair<>. Here Add gets DateTime as X-value and double as Y. There is some conversion from datetime to double, i want know about. I want to scroll bottom axis for some defined value by code dependency on condition( as you can see now ScroolAxis function, that is commented now), but for this i need to know how converting DateTime to double is going on( in TeeChart )? later i will need the reverse conversion( from double to DateTime), but it's not so hard to find it, if you know direct one.
I am not sure, but should be similar functions as C# DateTime.FromOADate to Convert Double to DateTime and ToOADate Converts a DateTime To Double, in C++.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: time format for botom axis

Post by Petr » Mon Nov 11, 2013 11:08 am

Hi Sandra, Thanks for your response! I've made a small investigation and found that 1 second is equal to 0.00001157407 double value in TeeChart Implementation, so, after that it was not so hard convert DateTime to double and back. Now i wonder how can i change value format of labels ( it seems to me that i need to change culture). As you can in the codew below i'm filling it with the values starts from 1 january 1 a.d., and hors minutes ans seconds starts from 0h 0m 0s

[code
for (int i = 0; i < newPlot.Count; ++i)
{

DateTime tick = new DateTime(1, 1, 1, (int)newPlot.First / 3600, ((int)newPlot.First % 3600) / 60 , (int)newPlot.First % 60);
m_plot.Add(tick, newPlot.Second);
}
][/code]

I use Label format "hh:mm:ss", as you recomended me. But it's shown on the plot as for example 12:11:37. I need it ti be shiwn as 00:11:37, how can i switch format(culture) to the value i need?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: time format for botom axis

Post by Sandra » Mon Nov 11, 2013 4:06 pm

Hello Petr,

If you want DateTime format appears in 24 hours format, you must define the hours, minutes and seconds in upper case letters as I do in next line:

Code: Select all

HH:MM:SS
Thanks,
Best Regards,
Sandra Pazos / 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

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: time format for botom axis

Post by Petr » Tue Nov 12, 2013 6:40 am

Thanks, but that didn't work properly, the value were shown as "00:12:SS". It turned to be that proper format is "HH:mm:ss".

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: time format for botom axis

Post by Sandra » Tue Nov 12, 2013 1:16 pm

Hello Petr,

I have made a mistake, you are right, sorry I forgot that when you work with time format, you must use lower case letters for minutes and seconds. I recommend you taking a look in this link where you find the all DateTime formats you can use.

Thanks,
Best Regards,
Sandra Pazos / 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