TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
h.hasenack
- Newbie
- Posts: 32
- Joined: Tue Jul 21, 2009 12:00 am
- Location: Nijmegen, Netherlands
Post
by h.hasenack » Thu Jul 23, 2009 9:27 am
I have use for displaying dates before 1900. back to 1850 as a matter of fact.
For some reason, TChart omits dates before 1900, producing a rather strange result
. Check the attachment.
Regards - Hans
Here's the patch:
Code: Select all
Function TChartAxis.LabelValue(Const Value:Double):String;
var tmp : String;
Begin
if IAxisDateTime then
begin
{$ifdef HH_PATCH_TC_DATETIME}
if true then // I also want dates before 01-01-1900 !!!
{$else}
if Value>=0 then
{$endif}
Begin
if FDateTimeFormat='' then tmp:=DateTimeDefaultFormat(IRange)
else tmp:=FDateTimeFormat;
DateTimeToString(result,tmp,Value);
end
else result:='';
end
else result:=FormatFloat(FAxisValuesFormat,Value);
if Assigned(ParentChart.FOnGetAxisLabel) then
ParentChart.FOnGetAxisLabel(TChartAxis(Self),nil,-1,Result);
if FLabelsMultiLine then
result:=ReplaceChar(result,' ',TeeLineSeparator);
end;
-
Attachments
-
- TeeDatesTest.zip
- COntains 2 bmp's demonstrating faulty dates behaviour and a text file with exported native data
- (58.06 KiB) Downloaded 231 times
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Thu Jul 23, 2009 12:52 pm
Hi Hans,
The delphi's DateTimeToString function seems to manage correctly both positive and negative values, so I'm not sure on the reason of the "if Value>=0 then" condition (note that negative doubles represent dates before 30/12/1899).
So here is how is right now the function. You could modify your TeEngine.pas or wait until the next maintenance release.
Code: Select all
Function TChartAxis.LabelValue(Const Value:Double):String;
var tmp : String;
Begin
if IAxisDateTime then
begin
if FDateTimeFormat='' then tmp:=DateTimeDefaultFormat(IRange)
else tmp:=FDateTimeFormat;
DateTimeToString(result,tmp,Value);
end
else result:=FormatFloat(FAxisValuesFormat,Value);
if Assigned(ParentChart.FOnGetAxisLabel) then
ParentChart.FOnGetAxisLabel(TChartAxis(Self),nil,-1,Result);
if FLabelsMultiLine then
result:=ReplaceChar(result,' ',TeeLineSeparator);
end;