Need more information on axis label

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Tooldesign
Newbie
Newbie
Posts: 5
Joined: Thu Nov 27, 2003 5:00 am

Need more information on axis label

Post by Tooldesign » Mon Feb 21, 2005 8:18 pm

Hey

I have a TDBChart with 2 main series (one bound to the left axis, one to the right one). They both have the same X-axis which is of TDateTime

That works fine, but there are 2 things I would add

1. I need some more information in the BottomLabel. I need also the power (Leistung in screenshot) at every label. This value belongs to the one at the same postion in our table (red values are faked on this picture)

2. Is it possible to format TDateTime as mm:ss only? Now it's hh:mm:ss, but I don't need to show hours

I hope, someone may help me solving this problem. I'm using TeeChart Pro 6.01 (if this information is needed)

Thanks lot

Image

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Feb 22, 2005 7:21 am

Hi.

Re #1 : One way to do this is to store complete infomation in series XLabels string array and then use it for axis labels. Example:

Code: Select all

var ctime: TTime;
begin

  Series1.Clear;
  // Point #1
  ctime := EncodeTime(2,3,0,0);
  Series1.AddXY(ctime,160,'160V  ' + TimeToStr(ctime));
  // Point #2
  ctime := EncodeTime(5,0,0,0);
  Series1.AddXY(ctime,119,'119V  ' + TimeToStr(ctime));
  // Point #3
  ctime := EncodeTime(6,2,0,0);
  Series1.AddXY(ctime,52,'52V  ' + TimeToStr(ctime));

  Series1.XValues.DateTime := True;
  Chart1.Axes.Bottom.LabelsAngle := 90;
  Chart1.Axes.Bottom.DateTimeFormat := 'mm:ss';
end;
Another approach you might explore is using chart OnGetAxisLabel event to customize individual axis labels (this includes color, text, ...) I think there is an example of this available in TeeChart demo (under "Axis" node).
You could also increase bottom margin and then manually draw requried texts directly on chart canvas in it's OnAfterDraw event.

Re #2 :This one is easy <g>. Here is the code:

Code: Select all

  Chart1.Axes.Bottom.DateTimeFormat := 'mm:ss';
Marjan Slatinek,
http://www.steema.com

Tooldesign
Newbie
Newbie
Posts: 5
Joined: Thu Nov 27, 2003 5:00 am

Post by Tooldesign » Tue Feb 22, 2005 11:46 am

Hey Marjan

Thanks again for your great help. I did it using OnGetAxisLabel which works fine :D

If there was a kissing smiley you would have gotten =X

Thanks lot

David Novo
Newbie
Newbie
Posts: 71
Joined: Fri Jul 02, 2004 4:00 am
Location: Culver City
Contact:

Post by David Novo » Sat Feb 26, 2005 7:03 pm

I am a little confused as to one of the comments above. Marjan said you could use the onGetAxisLabel to customize the axis, including color etc. However, onGetAxisLabel only has a "var LabelText:string" to pass back the actual text. How would I use this method to customize the color?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Feb 28, 2005 10:51 am

Hi David,

You can change the font color using:

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  Sender.LabelsFont.Color:=clRed;
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
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply