Page 1 of 1

time format for botom axis

Posted: Fri Nov 08, 2013 10:57 am
by 15666633
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?

Re: time format for botom axis

Posted: Fri Nov 08, 2013 12:48 pm
by 15666633
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.

Re: time format for botom axis

Posted: Fri Nov 08, 2013 5:27 pm
by 10050769
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,

Re: time format for botom axis

Posted: Mon Nov 11, 2013 11:08 am
by 15666633
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?

Re: time format for botom axis

Posted: Mon Nov 11, 2013 4:06 pm
by 10050769
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,

Re: time format for botom axis

Posted: Tue Nov 12, 2013 6:40 am
by 15666633
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".

Re: time format for botom axis

Posted: Tue Nov 12, 2013 1:16 pm
by 10050769
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,