Show X axis in seconds or minutes or hours?
Show X axis in seconds or minutes or hours?
Hi !
Our x axis normally displays seconds. But you can imagine that it is difficult for an user to think about how many minutes / hours are 13567 seconds.
So how can I switch the X achis labels to show another format:
- minutes (example: 5682 seconds = 94m42s or 94,7)
- hours (example: 5682 seconds = 1h34m42s or 1h34,7m or 1,5783)
Would it be possible that you give me a short example how to calculate and display these formats? It would be ok if the example shows only the two minute formats. I think calculating the hours isn´t so difficult then.
Our x axis normally displays seconds. But you can imagine that it is difficult for an user to think about how many minutes / hours are 13567 seconds.
So how can I switch the X achis labels to show another format:
- minutes (example: 5682 seconds = 94m42s or 94,7)
- hours (example: 5682 seconds = 1h34m42s or 1h34,7m or 1,5783)
Would it be possible that you give me a short example how to calculate and display these formats? It would be ok if the example shows only the two minute formats. I think calculating the hours isn´t so difficult then.
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Here you can use axes DateTimeFormat property as told in Tutorial 4 - Axis Design. You'll find the tutorials at TeeChart's program group.
You can also complete your parsing using OnGetAxisLabels event. You'll also find examples in tutorial 4.
Here you can use axes DateTimeFormat property as told in Tutorial 4 - Axis Design. You'll find the tutorials at TeeChart's program group.
You can also complete your parsing using OnGetAxisLabels event. You'll also find examples in tutorial 4.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcís,
well I tried to set the bottom axis to the format "mm:ss".
The result ...
Seconds are always zero and the mnutes start with 6 and not with 0.
I unselect the auto checkbox at the minimum tab. At the maximum tab it is set to auto.
What´s wrong here?
well I tried to set the bottom axis to the format "mm:ss".
The result ...
Seconds are always zero and the mnutes start with 6 and not with 0.
I unselect the auto checkbox at the minimum tab. At the maximum tab it is set to auto.
What´s wrong here?
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Have you set Series.XValues.DateTime:=true? If so, 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 or at our upload page.
Thanks in advance.
Have you set Series.XValues.DateTime:=true? If so, 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 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 |
Instructions - How to post in this forum |
Hi !
>Have you set Series.XValues.DateTime:=true?
Yes
>If so, could you please send us a simple example project we can run "as-is" to reproduce the problem here?
See ...
>Have you set Series.XValues.DateTime:=true?
Yes
>If so, could you please send us a simple example project we can run "as-is" to reproduce the problem here?
See ...
Received Axis Demo 2.zip Content Type application/x-zip-compressed Length 24261
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Thanks for the example.
This is most likely because of the way you populate series. Using FillSampleValues(NumValues) uses integer values (from 0 to NumValues-1) for series' X values. Please read how TDateTime works here. This will help you setting x values to be displayed as you request.
Thanks in advance.
Thanks for the example.
This is most likely because of the way you populate series. Using FillSampleValues(NumValues) uses integer values (from 0 to NumValues-1) for series' X values. Please read how TDateTime works here. This will help you setting x values to be displayed as you request.
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 |
Instructions - How to post in this forum |
Hi Narcís,
So I must convert all X values to TDateTime !?
Is there an easier way ?
Well that´s the way we use it in our application. There is only one difference ... We use double values instead of integer.Using FillSampleValues(NumValues) uses integer values (from 0 to NumValues-1) for series' X values
So I must convert all X values to TDateTime !?
Is there an easier way ?
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
As told in the TDateTime documentation I pointed you to, the integer part of a TDateTime value only determines the date. If you want those values to be in mm:ss format you need to specify the decimal part. You can see an example doing this:
There's no need to convert values to TDateTime you can assign them as doubles, for example:
As told in the TDateTime documentation I pointed you to, the integer part of a TDateTime value only determines the date. If you want those values to be in mm:ss format you need to specify the decimal part. You can see an example doing this:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=FloatToStr(Now);
end;
Code: Select all
Series1.AddXY(Now,Y);
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcís,
well maybe I´m blinded today ... I don´t get it working.
Could you please make a very simple demo for me with this terms:
- x values are double values starting from 0 to something (for example 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, and so on)
- if you switch to mm:ss view every whole-number is one second. So in the above example 0.6 are 0.6 seconds.
Many thanks !
well maybe I´m blinded today ... I don´t get it working.
Could you please make a very simple demo for me with this terms:
- x values are double values starting from 0 to something (for example 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, and so on)
- if you switch to mm:ss view every whole-number is one second. So in the above example 0.6 are 0.6 seconds.
Many thanks !
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
You can try executing this code:
Hope it helps!
You can try executing this code:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
const second=1/(24*3600); //Fractional number representing one second in TDateTime
var i: Integer;
x: double;
begin
x:=0;
for i:=0 to 10 do
begin
Series1.AddXY(x,random);
x:=x+second;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1.Axes.Bottom.DateTimeFormat:='hh:mm:ss';
Series1.XValues.DateTime:=not Series1.XValues.DateTime;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
we come closer
This works ok.
This will start with 12:00 and mm is always 12
And the second problem:
Our normal X Axis is calculated similar to this:
x := 0;
Series.add ....
x := x + Step; // <- Step is for example 0.2 = 200MilliSeconds
To get your code working I have to use this line of code:
If I switch to the time axes, I got 00:00:20 = 20 seconds and thats correct.
But if I switch back to the normal view I have values from 0 to 0,000
This is because second is a really small value ...
Hope to get this solved
we come closer
Code: Select all
Chart1.Axes.Bottom.DateTimeFormat:='hh:mm:ss';
Code: Select all
Chart1.Axes.Bottom.DateTimeFormat:='mm:ss';
And the second problem:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
const second = 1 / (24 * 3600); //Fractional number representing one second in TDateTime
Const Step = 0.2;
var i: Integer;
x: double;
begin
x := 0;
for i := 0 to 100 do
begin
Series1.AddXY(x,random);
x := x + (Step * second);
end;
end;
x := 0;
Series.add ....
x := x + Step; // <- Step is for example 0.2 = 200MilliSeconds
To get your code working I have to use this line of code:
Code: Select all
x := x + (Step * second);
But if I switch back to the normal view I have values from 0 to 0,000
This is because second is a really small value ...
Hope to get this solved
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Can you please send us a simple example project we can run "as-is" to reproduce the problem here?his will start with 12:00 and mm is always 12
This is quite strange as it works fine for me here. Every loop x value is incremented by one second. Anyway, yes, as I told you, hours, minutes, seconds, ... Are fractions of a day and thus represented by the decimal part of a double value.To get your code working I have to use this line of code:
Code:
x := x + (Step * second);
If I switch to the time axes, I got 00:00:20 = 20 seconds and thats correct.
But if I switch back to the normal view I have values from 0 to 0,000 Wink
This is because second is a really small value ...
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
at first ... Thx for your really great support job !!
I will make a small example project, tomorrow. Maybe I can include a short WMV video which shows you my results.
You wil hear from me.
at first ... Thx for your really great support job !!
I will make a small example project, tomorrow. Maybe I can include a short WMV video which shows you my results.
You wil hear from me.
Greetz Dominik
http://www.logview.info
http://www.logview.info
Hi Narcís,
I´ve just uploaded a small sample application to your server:
1) Always recalculate the X values
As you can see in the source, I have always to recalculate the x values if I switch between the normal and the time axis view. This is because the timeaxis needs the
for a correct display.
If I switch back (and don´t recalculate the X values) then I got very very small values for the normal view. You can try this if you use this code for button2:
2) Axes.Bottom.DateTimeFormat "mm:ss"
If you set Chart1.Axes.Bottom.DateTimeFormat to "mm:ss" the time always starts with 12:00. Only switch the combo in the demo and press "Set X to time" again.
And the next problem is ... after 12:00 you will have 12:30 and then it switched back to 12:00.
It´s a little bit confusing
3) Axes.Bottom.DateTimeFormat "ss"
This will show values from 00 to 59, go back to 00 and so on ...
Changing DateTimeFormat to ssss don´t bring better results.
4) floating seconds and / or minutes
I have no idea how to set up the axis to see the time in this format:
94,7 (which means 94m42s). Or something like this: 1,5783 (which means 1h34m42s).
How can I do this?
5) adding characters instead of ":"
It would be a better to see 1h34m42s instead of 1:34:42. But no idea how to set up the axis, too.
It would be great if you can enhance my short demo in that way, that I can switch between the different views with correct results. I think this is also interesting for other people who need a time axis ...
So it would be great if I can switch between this time formats:
Some hints to the format ss ... This is not really important because it is the normal view. Keep in mind that we always use seconds for the x axis.
And our x axis always start from 0 or from 1!
Hope on any help
And one last question ...
Is it possible to reduce times like 00:00:01 to 1 or 00:02:41 to 2:41? Is think this would look better for the users.
I´ve just uploaded a small sample application to your server:
Let me explain some usecases where I have trouble...Received TimeAxis Demo.zip Content Type application/x-zip-compressed Length 33937
1) Always recalculate the X values
As you can see in the source, I have always to recalculate the x values if I switch between the normal and the time axis view. This is because the timeaxis needs the
Code: Select all
const second=1/(24*3600);
If I switch back (and don´t recalculate the X values) then I got very very small values for the normal view. You can try this if you use this code for button2:
Code: Select all
procedure TForm1.Button2Click(Sender: TObject);
Var i: Integer;
begin
Series1.XValues.DateTime := False;
end;
If you set Chart1.Axes.Bottom.DateTimeFormat to "mm:ss" the time always starts with 12:00. Only switch the combo in the demo and press "Set X to time" again.
And the next problem is ... after 12:00 you will have 12:30 and then it switched back to 12:00.
It´s a little bit confusing
3) Axes.Bottom.DateTimeFormat "ss"
This will show values from 00 to 59, go back to 00 and so on ...
Changing DateTimeFormat to ssss don´t bring better results.
4) floating seconds and / or minutes
I have no idea how to set up the axis to see the time in this format:
94,7 (which means 94m42s). Or something like this: 1,5783 (which means 1h34m42s).
How can I do this?
5) adding characters instead of ":"
It would be a better to see 1h34m42s instead of 1:34:42. But no idea how to set up the axis, too.
It would be great if you can enhance my short demo in that way, that I can switch between the different views with correct results. I think this is also interesting for other people who need a time axis ...
So it would be great if I can switch between this time formats:
- hh:mm:ss
hhhmmmsss (See point 5)
mm:ss
mmmsss (See point 5)
sss
Some hints to the format ss ... This is not really important because it is the normal view. Keep in mind that we always use seconds for the x axis.
And our x axis always start from 0 or from 1!
Hope on any help
And one last question ...
Is it possible to reduce times like 00:00:01 to 1 or 00:02:41 to 2:41? Is think this would look better for the users.
Greetz Dominik
http://www.logview.info
http://www.logview.info
Hi Narcís,
do you have some news for me?
Did you take a look at my sample application ?
do you have some news for me?
Did you take a look at my sample application ?
Greetz Dominik
http://www.logview.info
http://www.logview.info