Page 1 of 1

TeeChart Labels and Grids

Posted: Fri Oct 22, 2004 1:57 pm
by 5886535
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 :?

Posted: Fri Oct 22, 2004 3:10 pm
by Pep
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.

Changing labels at runtime

Posted: Wed Oct 27, 2004 12:48 pm
by 9339637
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 :(

Posted: Wed Oct 27, 2004 2:36 pm
by Marjan
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.

Posted: Thu Oct 28, 2004 7:01 am
by 9339637
That' it! Thanks a lot, works very well and saved me a lot of time :D