Changing serie colour

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Vectar
Newbie
Newbie
Posts: 8
Joined: Mon Mar 07, 2005 5:00 am
Location: United Kingdom

Changing serie colour

Post by Vectar » Thu Mar 10, 2005 9:57 pm

Hi folks,

I have a bar chart in which the user can change bar colours programmatically. The colour of the bar changes OK but the corresponding colour in the chart legend remains as it was before the change. In V5 the legend colour changed with the bar colour (I think) but not in V7.

How do I persuade the legend colour to change?

Thanks in advance.

John

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

Post by Marjan » Fri Mar 11, 2005 8:24 am

Hi.

Perhaps the problem is the ColorEachPoint property is set to True and you're only changing individual series points ? In this case internal legend drawing routine uses series Color and not the specific point color.

If this is the case the setting barSeries.SeriesColor (or barSeries.Color) property to specific color will do the trick.
Marjan Slatinek,
http://www.steema.com

Vectar
Newbie
Newbie
Posts: 8
Joined: Mon Mar 07, 2005 5:00 am
Location: United Kingdom

Post by Vectar » Fri Mar 11, 2005 7:44 pm

Hi Marjan,

The code I'm using is below.

Code: Select all

procedure TDataForm.On1Click(Sender: TObject);
begin
  with ColorDialog1 do
  begin
    Options := [];
    if Execute then OnColour := Color;
    with Chart1.Series[ 0 ] do
    begin
      SeriesColor := Color ;
    end;
    Grafit(Treatnumb,Numb);
  end;

end;
As you can see, I'm using SeriesColor but the legend colour doesn't change. Do you have any other idea what might be wrong, please?

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 Mar 14, 2005 10:43 am

Hi Vectar,

It works fine here using SeriesColor and assigning a ColorDialog.Color to it. You may use Chart1.Legend.Repaint or Chart1.Legend.Draw to force the legend being redrawn.

If this doesn't work could you please send us a small example project we can run "as-is" to reproduce the problem here? You can post it at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
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

Vectar
Newbie
Newbie
Posts: 8
Joined: Mon Mar 07, 2005 5:00 am
Location: United Kingdom

Post by Vectar » Tue Mar 15, 2005 8:18 pm

Hi Narcis,

I've tried your suggestions but neither option forces the change of colour in the legend. So I've posted the project as you suggested.

Regards,

John

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

Post by Narcís » Wed Mar 16, 2005 11:12 am

Hi John,

I can't see your example in the newsgroups. Would you be so kind to check it an post it again if necessary?

Thanks in advance.
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

Vectar
Newbie
Newbie
Posts: 8
Joined: Mon Mar 07, 2005 5:00 am
Location: United Kingdom

Post by Vectar » Thu Mar 17, 2005 7:38 pm

Hi Narcis,

I've posted the project again and this time it's there!

Regards,

John

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

Post by Pep » Fri Mar 18, 2005 12:29 pm

Hi John,

using the following code works fine (just add ColorDialog1 before Color) :

Code: Select all

procedure TDataForm.On1Click(Sender: TObject);
begin
  with ColorDialog1 do
  begin
    Options := [];
    if Execute then OnColour := Color;
    with Chart1.Series[ 0 ] do
    begin
      SeriesColor := ColorDialog1.Color ;
    end;
    Grafit(Treatnumb,Numb);
    Chart1.Legend.Draw;
  end;
end;

Vectar
Newbie
Newbie
Posts: 8
Joined: Mon Mar 07, 2005 5:00 am
Location: United Kingdom

Post by Vectar » Sun Mar 20, 2005 11:08 pm

Thanks Josep. That's sorted the problem.

Regards,

John

Post Reply