Page 1 of 1

Need more information on axis label

Posted: Mon Feb 21, 2005 8:18 pm
by 8441963
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

Posted: Tue Feb 22, 2005 7:21 am
by Marjan
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';

Posted: Tue Feb 22, 2005 11:46 am
by 8441963
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

Posted: Sat Feb 26, 2005 7:03 pm
by 9338026
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?

Posted: Mon Feb 28, 2005 10:51 am
by narcis
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;