horizontal time axis - day switch

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
2knuckels
Newbie
Newbie
Posts: 2
Joined: Thu Jul 14, 2016 12:00 am

horizontal time axis - day switch

Post by 2knuckels » Fri Mar 10, 2017 2:57 pm

I have data with a timestamp (hh:mm - Format) that is used for the x-axis.
If the time starts e.g. at 22:00 and ends at 3:00 am the next morning, then the chart shows the data from 0:00 to 3:00 am first and then the previous data starting at 22:00 to 0:00

ORDER of DATA as recorded
time data
22:00 1
23:00 2
00:00 3
01:00 4
02:00 5
03:00 6

in the chart the data is shown in the order below

00:00 01:00 02:00 03:00 22:00 23:00


Is there any option to force the chart to show the data in the given order like shown below (Due to layout limits it is not an option to include the date in diagramm labels, but date could be included in the data)

22:00 23:00 00:00 01:00 02:00 03:00

(Using Delphi XE10.1)


Any help would be great.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: horizontal time axis - day switch

Post by Yeray » Mon Mar 13, 2017 10:18 am

Hello,

The options I see are:
- To add the x values into the series with date and time. Ie:

Code: Select all

  with Chart1.AddSeries(TLineSeries) do
  begin
    XValues.DateTime:=True;
    AddXY(StrToDateTime('01/01/2017 22:00'), 10);
    AddXY(StrToDateTime('01/01/2017 23:00'), 20);
    AddXY(StrToDateTime('02/01/2017 0:00'), 30);
    AddXY(StrToDateTime('02/01/2017 1:00'), 20);
    AddXY(StrToDateTime('02/01/2017 2:00'), 10);
  end;
To add the strings you want as labels and let the x values to be the default (0, 1, 2,...):

Code: Select all

  with Chart1.AddSeries(TLineSeries) do
  begin
    Add(10, '22:00');
    Add(20, '23:00');
    Add(30, '0:00');
    Add(20, '1:00');
    Add(10, '2:00');
  end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

2knuckels
Newbie
Newbie
Posts: 2
Joined: Thu Jul 14, 2016 12:00 am

Re: horizontal time axis - day switch

Post by 2knuckels » Mon Mar 13, 2017 2:35 pm

Thank you for the fast help

When using time and date as you suggestet the order stays.

Note for users with same problem
The date just needs to be included in the data.
When using
" BottomAxis.DateTimeFormat := 'hh:mm'; "
the date is not displayed in the chart
the sort parameter does not help in this case


-> solved

Post Reply