Xaxis Labels as Dates

Discussion around the SDL Component Suite
Post Reply
Chris348
Posts: 6
Joined: Tue Mar 22, 2022 9:00 am

Xaxis Labels as Dates

Post by Chris348 »

Hi,

I have a fairly long Delphi Community program in which graphs (straightforward line plots) of dates are displayed against other quantities in several TRChart graphs. At present, the axis shows the date values as numbers. Have tried for some time now (and much head scratching) to change the x-axis labels to show dates. The line of Delphi code is:

RChart1.Scale1X.LabelType := ftDateTime;

which gives an error of '[dcc32 Error] Unit1.pas(1838): E2010 Incompatible types: 'TFigType' and 'TFieldType' '

Any advice gratefully received.

The Delphi program is Delphi Community 10.4 update 2. Windows is Windows 10, build 19042 64 bit.

Chris
User avatar
hlohning
Posts: 20
Joined: Fri Sep 04, 2020 4:17 pm

Re: Xaxis Labels as Dates

Post by hlohning »

Hi Chris,

I suspect that the identifier "ftDateDime" is declared in another unit as well. You can solve this by adding the unit specifier where "ftDateTime" is declared in the SDL component suite (ftDateTime is declared in unit sdl_sdlbase):

Code: Select all

sdl_sdlbase.ftDateTime
Let me know if this resolves your problem.

Kind regards, Hans
---
Hans Lohninger
Epina GmbH
Retz, Austria
Chris348
Posts: 6
Joined: Tue Mar 22, 2022 9:00 am

Re: Xaxis Labels as Dates

Post by Chris348 »

Many thanks for the suggestion, but am still struggling, with the same error as previous recurring. Odd thing is that some RChart code works fine, e.g. defining axis ranges , captions and datacolor. (Am only using the graphics light edition). Will continue to explore this as best I can, although the demands of a Spring garden and domestic matters may slow things a bit.

Regards

Chris
Gloucestershire
UK.

P.S. Cannot see the unit sdl_sdlbase. Is that as expected?
Chris348
Posts: 6
Joined: Tue Mar 22, 2022 9:00 am

Re: Xaxis Labels as Dates

Post by Chris348 »

Also, have searched the whole of my code for the variable ftDateTime. There is only one instance of that variable, and that is in the line that gives the above error.

Regards

Chris
User avatar
hlohning
Posts: 20
Joined: Fri Sep 04, 2020 4:17 pm

Re: Xaxis Labels as Dates

Post by hlohning »

Chris,

just an idea: did you specify "sdl_sdlbase" in the "uses" statement?

ftDateTime is a constant which is defined in the unit sdl_sdlbase. In the case another unit accidentally defines the same constant this might result in the effect you described.

Regards,
Hans
---
Hans Lohninger
Epina GmbH
Retz, Austria
Chris348
Posts: 6
Joined: Tue Mar 22, 2022 9:00 am

Re: Xaxis Labels as Dates

Post by Chris348 »

Have spent some more time playing around with this problem. To remove the chance that my old software was fouling thing up, I concocted a simple new program to investigate things, using a recently downloaded copy of Delphi Community and of 107XYLe installed via Getit. The new program produces a very simple line graph of three data points vs tdatetime data on the x-axis. The behaviour is the same, with the x-axis labels being numeric. If the line 'RChart1.Scale1X.LabelType := ftDateTime;' is included in the code the same error occurs as previously. (ftdatetime is undeclared identifier). I have twice done a search for XYZ in all the files on the PC, with nothing found. Am beginning to conclude that I will have to find another solution. The simple program unit 1 code is below. Thanks for the advice.

unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, SDL_rchart;

type
TForm1 = class(TForm)
RChart1: TRChart;
procedure RChart1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
y: array [0..5] of single;
x: array [0..5] of tdatetime;


implementation

{$R *.dfm}

procedure TForm1.RChart1Click(Sender: TObject);
begin

var min_range,max_range: Tdate;

y[0] := 1;
y[1] := 2;
y[2]:= 3;

x[0] := StrToDate('1/1/22');
x[1] := StrToDate('1/2/22');
x[2] := StrToDate('1/3/22');

min_range := StrToDateTime('1/12/21');
max_range := StrToDateTime('1/4/22');

RChart1.SuppressPaint := TRUE;

RChart1.Scale1Y.RangeLow := 0;
RChart1.Scale1Y.RangeHigh := 4;
RChart1.Scale1X.RangeLow := min_range;
RChart1.Scale1X.RangeHigh := max_range;

RChart1.ClearGraf;
RChart1.DataColor := $000000;
//RChart1.Scale1X.LabelType := ftDateTime;
RChart1.moveto(x[0],y[0]);
RChart1.drawto(x[1],y[1]);
RChart1.drawto(x[2],y[2]);
RChart1.SuppressPaint := FALSE;

end;

end.
Chris348
Posts: 6
Joined: Tue Mar 22, 2022 9:00 am

Re: Xaxis Labels as Dates

Post by Chris348 »

Am afraid that the last post is somewhat misleading. With the smaller & newer code the error upon compiling is
'[dcc32 Error] Unit1.pas(54): E2003 Undeclared identifier: 'ftDateTime''.

With the code that is much older and larger, the error is '[dcc32 Error] Unit1.pas(1840):
E2010 Incompatible types: 'TFigType' and 'TFieldType' ' (ftDateTime is given as a type of TFieldType'.)

In both the above cases,

i) the SDL BasePack and Chartpack 10.7/LE and the others are shown as installed.

ii) it is not possible for the x-axis labels to be anything other than numeric, which is not helpful.

Regards

Chris
Chris348
Posts: 6
Joined: Tue Mar 22, 2022 9:00 am

Re: Xaxis Labels as Dates

Post by Chris348 »

Have just tried the suggestion re sdl_sdlbase in the uses statement. Should have tried this earlier.

Think it has done the trick.

Many Thanks

Chris
Post Reply