Page 1 of 1

Custom Label Colors

Posted: Thu Sep 22, 2005 9:24 pm
by 9233315
I think I must be missing something very simple here. I can't seem to change the colour of a custom label in my chart. I've checked the TeeChart Pro demo program, and I still can't figure it out.

For example: I create a new application, add a TChart and create a new THorizontalBarSeries. I put the following in the main form's OnShow event:

Code: Select all

procedure TForm1.FormShow(Sender: TObject);
var
  i : integer;
begin
  Series1.AddArray([200,0,123,300,260,-100,650,400]);
  Chart1.LeftAxis.Items.Clear;
  for i := 0 to 7 do
  begin
    chart1.Leftaxis.Items.Add(i, 'test' + intToStr(i));
    chart1.Leftaxis.Items[i].color := clRed;
    writeln(chart1.Leftaxis.Items[i].Text);
  end;
  chart1.Repaint;
end;
...all my labels are still black. Just to verify that it was displaying my custom lables, and not the automatic ones, I changed the add line to read

Code: Select all

if i mod 2 = 0 then chart1.leftaxis.items.add(i, 'test' + intoToStr(i));
This results in every other line having a label, so obviously my custom labels are being displayed. Also, opening up a console window and writing the label text as above displays the proper text, so I'm indexing the labels properly when I try to set their colour. Why are they all black?

Just FYI, I'm using TeeChart Pro 7.01 for Delphi 5.0

Thanks,

Andrew

Posted: Fri Sep 23, 2005 9:52 am
by narcis
Hi Andrew,

It works fine here using v7.05, latest version available at our Customer Download Area, and the code below. The key for having a coloured background is turning off transparency.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i : integer;
begin
  Series1.AddArray([200,0,123,300,260,-100,650,400]);

  With Chart1.Axes.Left.Items do
  begin
    Clear;

    for i := 0 to 7 do
      with Add(i*30, 'test' + intToStr(i)) do
      begin
        Transparent:=False;
        Transparency:=50;
        Color := clRed;
        Font.Color:=clBlue;
      end;
  end;
end;

Posted: Fri Sep 23, 2005 4:11 pm
by 9233315
I guess I'll try upgrading the 7.05!

I've noticed that the examples all use chart.Axes.Left as opposed to chart.LeftAxis - is there a difference?

Posted: Fri Sep 23, 2005 5:00 pm
by 9233315
The latest version I can find in the customer download section is 7.04. I found a 7.05 for Builder, but obviously that won't work with Delphi 5. Is 7.04 the latest version for Dephi 5 Professional?

Posted: Fri Sep 23, 2005 6:00 pm
by 9233315
I installed TeeChart 7.04 for Delphi 5 and now it works.

Posted: Mon Sep 26, 2005 8:08 am
by narcis
Hi Andrew,

Sorry, v7.05 is only available for BCB as it only was an update to overcome some installing problems with BCB.
I've noticed that the examples all use chart.Axes.Left as opposed to chart.LeftAxis - is there a difference?
There's no difference but you'd better use the one used in the examples as LeftAxis is deprecated.