TeeChart Labels and Grids

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Obelix
Newbie
Newbie
Posts: 1
Joined: Fri Nov 15, 2002 12:00 am

TeeChart Labels and Grids

Post by Obelix » Fri Oct 22, 2004 1:57 pm

Hi folks,

is it possible to show the grid lines of the bottom,left, ... axis and to hide the labels of the axis at the same time?
-> I have 2 different charts, one chart adjected on top of the other and there should be only one bottom axis visible (the one of the lower chart). Any ideas?

Tia and greetings from Obelix :?

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Oct 22, 2004 3:10 pm

Hi,
is it possible to show the grid lines of the bottom,left, ... axis and to hide the labels of the axis at the same time?
Yes, you can do this using the following code :

Code: Select all

    procedure TForm1.FormCreate(Sender: TObject);
    begin
        series1.FillSampleValues(10);
        chart1.BottomAxis.MinorTicks.visible := False;
        chart1.BottomAxis.Ticks.Visible:= False;
    end;

    procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
        Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
    begin
        if Sender = Chart1.BottomAxis then
            Labeltext := ' ';
    end;
    end.

Obelix
Newbie
Newbie
Posts: 10
Joined: Thu Oct 21, 2004 4:00 am

Changing labels at runtime

Post by Obelix » Wed Oct 27, 2004 12:48 pm

Thanks, it's working very good,

but is it also possible to change the color/font and text
for some of the labels?

Assume you have a gantt series within your chart and you want to display the labels of some of your gantt items in a special color/font style (ie. saturday and sunday in red, style to bold)... and only when it's possible, to show weeknames instead of the date on the labels.

Any tips and tricks avaiable?

Tia Obelix


BTW: Mouse scrolling only works for me, you placed an enabled TWinControl on the chart :(

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

Post by Marjan » Wed Oct 27, 2004 2:36 pm

Hi.

Yes, sure, it can be done. The feature is demonstrated in TeeChart demo. Especially, check the following example:

"All Features -> Axes -> Labels -> Custom Labels"

Alternatively, you can also use chart OnGetAxisLabel event to customize individual axis label font properties. Here is an example:

Code: Select all

procedure TAxisLabelsFormat.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var Num : Double;
begin
  Num:=StrToFloat(LabelText);
  // if value > 300, color it red, otherwise blue
  if Sender=Chart1.Axes.Left then
  begin
    if Num>300 then Sender.LabelsFont.Color:=clRed
               else Sender.LabelsFont.Color:=clBlue;
  end;
end;
Similar code, but with different condition (compare axis label value directly with point labels) could also be used in your case.
Marjan Slatinek,
http://www.steema.com

Obelix
Newbie
Newbie
Posts: 10
Joined: Thu Oct 21, 2004 4:00 am

Post by Obelix » Thu Oct 28, 2004 7:01 am

That' it! Thanks a lot, works very well and saved me a lot of time :D

Post Reply