Changing Series Color

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Changing Series Color

Post by tbonejo » Wed Jan 24, 2007 11:50 am

I seem to be having some trouble changing the color of a series in code. I am dynamically setting up series and just do a color scheme like this:

Code: Select all

chart1.Series[mycol].Color := GetDefaultColor(mycol);
   if chart1.Series[mycol].Color = 16777215 then
           chart1.Series[mycol].Color := 0;

However if the color is white, I want it to be something the user can see since my panel is white. The code seems to execute ok but does not change the color at all.

What are some of the other color schemes to use dynamically?


Thanks,

Tom
Tom

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 Jan 24, 2007 12:36 pm

Hi Tom,

This will depend on the series style you are using as you may need to type cast them to have access to the specific series style properties, as shown in the example below for line series.

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 10 do
  begin
    Chart1.AddSeries(TLineSeries.Create(self));
    Chart1[i].FillSampleValues();
  end;

end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin

  for i:=0 to Chart1.SeriesCount - 1 do
  begin
    if (Chart1[i] is TLineSeries) then
    begin
      (Chart1[i] as TLineSeries).LinePen.Color:=RGB(10*i,10*i,10*i);
      Chart1[i].Color:=RGB(10*i,10*i,10*i);
    end
    else
      Chart1[i].Color:=clRed;
  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

tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Post by tbonejo » Wed Jan 24, 2007 3:43 pm

Narcis,

I tried modifying the code a bit to set the color if white to black but it ends up turning all the series colors to black.


Any ideas?


Thanks,

Tom
Tom

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 Jan 24, 2007 4:09 pm

Hi Tom,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post the files at news://www.steema.net/steema.public.attachments or our new upload page at http://www.steema.net/upload/.

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

Post Reply