Get next color, colorpalette

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Infront
Newbie
Newbie
Posts: 6
Joined: Thu Feb 04, 2010 12:00 am
Location: Trondheim, Norway

Get next color, colorpalette

Post by Infront » Thu Feb 11, 2010 8:38 pm

Hi.
Chart uses an colorpalette to assign colors to series when they are added.

At runtime I clone the series x number of times. The problem with this is that every clone has the same color in the chart, and I can't tell them apart.
How can I use the charts coloring methods to get the next color?
E.g
newseries.color:= chart1.GetNextColor;

Thanks
Thanks

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

Re: Get next color, colorpalette

Post by Narcís » Mon Feb 15, 2010 10:05 am

Hi Infront,

You can do something like this:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i,j: Integer;
begin
  Chart1.AddSeries(TLineSeries.Create(Self));
  Chart1[0].FillSampleValues;
  j:=0;

  for i:=0 to 15 do
  begin
    CloneChartSeries(Chart1[0]);

    while ((Chart1[Chart1.SeriesCount-1].Color = Chart1[0].Color) and
          (j<High(Chart1.ColorPalette))) do
    begin
      Chart1[Chart1.SeriesCount-1].Color:=Chart1.ColorPalette[j];
      inc(j);
    end;
  end;
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

Infront
Newbie
Newbie
Posts: 6
Joined: Thu Feb 04, 2010 12:00 am
Location: Trondheim, Norway

Re: Get next color, colorpalette

Post by Infront » Tue Feb 16, 2010 7:22 am

Thanks.
But how can I change the color palette used by the TChart.

I have tried this

Code: Select all

const Colors:Array[0..19] of TColor=
                      ( clRed,
                       clGreen,
                      clYellow);
SetDefaultColorPalette(Colors);
And this

Code: Select all

   SetLength(TeeProcs.ColorPalette,2);
  TeeProcs.ColorPalette[0] := clRed;
  TeeProcs.ColorPalette[1] := clBlue;
  TeeProcs.ColorPalette[2] := clYellow;
None of this attempts change the colors in Chart1.Colorpalette.
How can I get all charts to use a colorpalette that I define?
Thanks

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

Re: Get next color, colorpalette

Post by Narcís » Tue Feb 16, 2010 8:30 am

Hi Infront,

You can change TeeChart palette to predefined or custom palettes as shown at the All Features\Welcome!\Aspect\Custom Palettes example in the new feature demo, available at TeeChart's program group.
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