Page 1 of 1

horizontal time axis - day switch

Posted: Fri Mar 10, 2017 2:57 pm
by 16878745
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.

Re: horizontal time axis - day switch

Posted: Mon Mar 13, 2017 10:18 am
by yeray
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;

Re: horizontal time axis - day switch

Posted: Mon Mar 13, 2017 2:35 pm
by 16878745
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