Page 1 of 1
Get next color, colorpalette
Posted: Thu Feb 11, 2010 8:38 pm
by 10555199
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
Re: Get next color, colorpalette
Posted: Mon Feb 15, 2010 10:05 am
by narcis
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;
Re: Get next color, colorpalette
Posted: Tue Feb 16, 2010 7:22 am
by 10555199
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?
Re: Get next color, colorpalette
Posted: Tue Feb 16, 2010 8:30 am
by narcis
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.