Page 1 of 1

Changing serie colour

Posted: Thu Mar 10, 2005 9:57 pm
by 9341180
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

Posted: Fri Mar 11, 2005 8:24 am
by Marjan
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.

Posted: Fri Mar 11, 2005 7:44 pm
by 9341180
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?

Posted: Mon Mar 14, 2005 10:43 am
by narcis
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.

Posted: Tue Mar 15, 2005 8:18 pm
by 9341180
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

Posted: Wed Mar 16, 2005 11:12 am
by narcis
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.

Posted: Thu Mar 17, 2005 7:38 pm
by 9341180
Hi Narcis,

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

Regards,

John

Posted: Fri Mar 18, 2005 12:29 pm
by Pep
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;

Posted: Sun Mar 20, 2005 11:08 pm
by 9341180
Thanks Josep. That's sorted the problem.

Regards,

John