Change the color of a series

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Geetha Mahendran
Newbie
Newbie
Posts: 4
Joined: Tue Mar 25, 2008 12:00 am

Change the color of a series

Post by Geetha Mahendran » Sat Sep 13, 2008 12:21 pm

Hi,
How can I change the color of a series, If we have explictly given color for each bar.

I had used the following code, If didn’t have any effect on the chart

Added the bar to chart:

Code: Select all

Chart1.AddSeries(TBarSeries);
  Chart1.Series[0].Add(-50,'Test1',clRed);
  Chart1.Series[0].Add(-25,'Test2',clRed);
  Chart1.Series[0].Add(0,'Test3',clgreen);
  Chart1.Series[0].Add(25,'Test4',clgreen);
  Chart1.Series[0].Add(50,'Test4',clgreen);
Code to change the color:

Code: Select all

Chart1.Series[0].Color :=  clblue;
Even coloreach doesn’t have any effect.

Kindly advice. :(

Thanks,
Geetha

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 Sep 15, 2008 8:22 am

Hi Geetha,

I'm afraid this is a bug. I've added it (TV52013394) to the defect list to be fixed for next releases.

The only solution I can think of is "reseting" ValueColor's array like this:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.AddSeries(TBarSeries.Create(self));
  Chart1[0].Add(-50,'Test1',clRed);
  Chart1[0].Add(-25,'Test2',clRed);
  Chart1[0].Add(0,'Test3',clgreen);
  Chart1[0].Add(25,'Test4',clgreen);
  Chart1[0].Add(50,'Test4',clgreen);

  for i:=0 to Chart1[0].Count-1 do
    Chart1[0].ValueColor[i]:=clTeeColor;

  Chart1[0].ColorEachPoint:=false;
  Chart1[0].Color:=clBlue;
end;
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

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

Post by Narcís » Fri Feb 20, 2009 3:43 pm

Hi Geetha,

As an update, this issue has been fixed for the next maintenance release so that code snippet below will draw all bars blue.

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TBarSeries.Create(self));
  Chart1[0].Add(-50,'Test1',clRed);
  Chart1[0].Add(-25,'Test2',clRed);
  Chart1[0].Add(0,'Test3',clgreen);
  Chart1[0].Add(25,'Test4',clgreen);
  Chart1[0].Add(50,'Test4',clgreen);

  Chart1[0].ColorEachPoint:=false;
  Chart1[0].Color:=clBlue;
  //(Chart1[0] as TBarSeries).BarBrush.Color:=clBlue;
end;
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

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 Feb 23, 2009 11:53 am

Hi Geetha,

Sorry for posting contradictory information but one of my colleagues in the technical department brought to my attention that the fix would break existing functionality and also made me aware that's expected behaviour considering series design. Therefore the only option here is reseting colours array as discussed before.

I'd like to apologise for any inconvenience caused.
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

Post Reply