Modifying lines colors in TDBChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
WarmBooter
Newbie
Newbie
Posts: 33
Joined: Thu Mar 18, 2004 5:00 am
Location: Brasil
Contact:

Modifying lines colors in TDBChart

Post by WarmBooter » Thu Jul 12, 2012 5:50 pm

Hi!

I have a TDBChart with a Lines series, and I would like to try different color palletes to find the best one (read, the one that repeats less colors) to be used with the situation when the datasource returns several records (meaning more than 15 lines in the chart).

I tried to use DBChart1.ColorPaletteIndex:=<<some existing index>> but seems to produce no effect at all.

Can someone point me to the correct way of doing this?

Carlos

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Modifying lines colors in TDBChart

Post by Yeray » Fri Jul 13, 2012 3:17 pm

Hola Carlos,

Take a look at the example at "All Features\Welcome !\Aspect\Custom Palettes" in the features demo included with the installation. It shows how to change between the different default palettes and how to create a customized one.

However, the default palettes (and any you can create) have a limited size. If you want to create more series than colors your palette has, you will probably want to reuse the colors in the palette. You could do so as in the following example:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;

  ColorPalettes.ApplyPalette(Chart1, WindowsVistaPalette);

  for i:=0 to 20 do
    with Chart1.AddSeries(TFastLineSeries) do
    begin
      FillSampleValues;
      Color:=Chart1.ColorPalette[i mod Length(Chart1.ColorPalette)-1];
    end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply