Series Chart color and Legend Chart color.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MVBobj
Newbie
Newbie
Posts: 34
Joined: Fri Jul 17, 2015 12:00 am
Contact:

Series Chart color and Legend Chart color.

Post by MVBobj » Wed Aug 05, 2015 12:45 pm

If I set the series color manually, how do I set the associated color in the little box in the legend to the same color?

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

Re: Series Chart color and Legend Chart color.

Post by Narcís » Wed Aug 05, 2015 1:08 pm

Hello,

I'm not sure about which is your exact problem. If I run the code snippet below bar's legend symbol becomes red. Can you please attach a simple example project we can run "as-is" to reproduce the problem here?

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TBarSeries.Create(Self)).FillSampleValues;
  Chart1[0].Color:=clRed;
end;
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

MVBobj
Newbie
Newbie
Posts: 34
Joined: Fri Jul 17, 2015 12:00 am
Contact:

Re: Series Chart color and Legend Chart color.

Post by MVBobj » Wed Aug 05, 2015 1:59 pm

Enclosed is a simple project. DelphiXE7 Win7Pro64Bit

In your FormCreate, the chart hasn't displayed yet.

In my project - the chart and legend with legend colors are visible and when you click Button1, the 3 series are loaded, their colors set and displayed and the legend colors remain as they were on startup!

How do I reset the legend colors?
Attachments
SeriesLegend.zip
(100.22 KiB) Downloaded 775 times

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

Re: Series Chart color and Legend Chart color.

Post by Narcís » Wed Aug 05, 2015 2:20 pm

Hello,

Your code is setting specific point color but not the general color for the series. You should use TChartSeries.Color property instead:

Code: Select all

procedure TForm2.Button1Click(Sender: TObject);
var
  clrBar1, clrBar2, clrBar3: TColor;
begin
  clrBar1 := clWebLightCyan;
  clrBar2 := clWebLightSteelBlue;
  clrBar3 := clWebLemonChiffon;

  Chart[0].Color:=clrBar1;
  Chart[0].Add(7, '01/04/2004', clrBar1);
  Chart[0].Add(17,'01/11/2004', clrBar1);
  Chart[0].Add(6, '01/18/2004', clrBar1);
  Chart[0].Add(12,'01/25/2004', clrBar1);
  Chart[0].Add(5, '02/01/2004', clrBar1);
  Chart[0].Add(7, '02/08/2004', clrBar1);
  Chart[0].Add(14,'02/15/2004', clrBar1);
  Chart[0].Add(4, '02/22/2004', clrBar1);
  Chart[0].Add(12,'03/01/2004', clrBar1);
  Chart[0].Add(9, '03/08/2004', clrBar1);
  Chart[0].Add(17,'03/15/2004', clrBar1);
  Chart[0].Add(2, '03/22/2004', clrBar1);
  Chart[0].Add(5, '03/29/2004', clrBar1);
  Chart[0].Add(10,'04/06/2004', clrBar1);
  Chart[0].Add(6, '04/13/2004', clrBar1);

  Chart[1].Color:=clrBar2;
  Chart[1].Add(17, '01/04/2004', clrBar2);
  Chart[1].Add(27,'01/11/2004', clrBar2);
  Chart[1].Add(16, '01/18/2004', clrBar2);
  Chart[1].Add(22,'01/25/2004', clrBar2);
  Chart[1].Add(15, '02/01/2004', clrBar2);
  Chart[1].Add(17, '02/08/2004', clrBar2);
  Chart[1].Add(24,'02/15/2004', clrBar2);
  Chart[1].Add(14, '02/22/2004', clrBar2);
  Chart[1].Add(22,'03/01/2004', clrBar2);
  Chart[1].Add(19, '03/08/2004', clrBar2);
  Chart[1].Add(27,'03/15/2004', clrBar2);
  Chart[1].Add(12, '03/22/2004', clrBar2);
  Chart[1].Add(15, '03/29/2004', clrBar2);
  Chart[1].Add(20,'04/06/2004', clrBar2);
  Chart[1].Add(16, '04/13/2004', clrBar2);

  Chart[2].Color:=clrBar3;
  Chart[2].Add(27, '01/04/2004', clrBar3);
  Chart[2].Add(37,'01/11/2004', clrBar3);
  Chart[2].Add(26, '01/18/2004', clrBar3);
  Chart[2].Add(32,'01/25/2004', clrBar3);
  Chart[2].Add(25, '02/01/2004', clrBar3);
  Chart[2].Add(27, '02/08/2004', clrBar3);
  Chart[2].Add(34,'02/15/2004', clrBar3);
  Chart[2].Add(24, '02/22/2004', clrBar3);
  Chart[2].Add(32,'03/01/2004', clrBar3);
  Chart[2].Add(29, '03/08/2004', clrBar3);
  Chart[2].Add(37,'03/15/2004', clrBar3);
  Chart[2].Add(22, '03/22/2004', clrBar3);
  Chart[2].Add(25, '03/29/2004', clrBar3);
  Chart[2].Add(30,'04/06/2004', clrBar3);
  Chart[2].Add(26, '04/13/2004', clrBar3);

end;
Actually, you could even remove color setting for each point:

Code: Select all

procedure TForm2.Button1Click(Sender: TObject);
begin
  Chart[0].Color := clWebLightCyan;
  Chart[1].Color := clWebLightSteelBlue;
  Chart[2].Color := clWebLemonChiffon;

  Chart[0].Add(7, '01/04/2004');
  Chart[0].Add(17,'01/11/2004');
  Chart[0].Add(6, '01/18/2004');
  Chart[0].Add(12,'01/25/2004');
  Chart[0].Add(5, '02/01/2004');
  Chart[0].Add(7, '02/08/2004');
  Chart[0].Add(14,'02/15/2004');
  Chart[0].Add(4, '02/22/2004');
  Chart[0].Add(12,'03/01/2004');
  Chart[0].Add(9, '03/08/2004');
  Chart[0].Add(17,'03/15/2004');
  Chart[0].Add(2, '03/22/2004');
  Chart[0].Add(5, '03/29/2004');
  Chart[0].Add(10,'04/06/2004');
  Chart[0].Add(6, '04/13/2004');

  Chart[1].Add(17, '01/04/2004');
  Chart[1].Add(27,'01/11/2004');
  Chart[1].Add(16, '01/18/2004');
  Chart[1].Add(22,'01/25/2004');
  Chart[1].Add(15, '02/01/2004');
  Chart[1].Add(17, '02/08/2004');
  Chart[1].Add(24,'02/15/2004');
  Chart[1].Add(14, '02/22/2004');
  Chart[1].Add(22,'03/01/2004');
  Chart[1].Add(19, '03/08/2004');
  Chart[1].Add(27,'03/15/2004');
  Chart[1].Add(12, '03/22/2004');
  Chart[1].Add(15, '03/29/2004');
  Chart[1].Add(20,'04/06/2004');
  Chart[1].Add(16, '04/13/2004');

  Chart[2].Add(27, '01/04/2004');
  Chart[2].Add(37,'01/11/2004');
  Chart[2].Add(26, '01/18/2004');
  Chart[2].Add(32,'01/25/2004');
  Chart[2].Add(25, '02/01/2004');
  Chart[2].Add(27, '02/08/2004');
  Chart[2].Add(34,'02/15/2004');
  Chart[2].Add(24, '02/22/2004');
  Chart[2].Add(32,'03/01/2004');
  Chart[2].Add(29, '03/08/2004');
  Chart[2].Add(37,'03/15/2004');
  Chart[2].Add(22, '03/22/2004');
  Chart[2].Add(25, '03/29/2004');
  Chart[2].Add(30,'04/06/2004');
  Chart[2].Add(26, '04/13/2004');
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

MVBobj
Newbie
Newbie
Posts: 34
Joined: Fri Jul 17, 2015 12:00 am
Contact:

Re: Series Chart color and Legend Chart color.

Post by MVBobj » Wed Aug 05, 2015 3:24 pm

Excellent!

Thank you.

emwamin
Newbie
Newbie
Posts: 10
Joined: Tue Sep 22, 2015 12:00 am

Re: Series Chart color and Legend Chart color.

Post by emwamin » Fri Oct 02, 2015 10:01 am

Hi

This solution does not work for me. Not only that the legend does not have correct text color, it is not possible to change it with the Toolbox. I am using ErrorBar serie.
I am using Tee Chart Pro v2015.14.150120. I have to add that this error introduced in the latest release. I have not changes my coding after updating the Tee Chart.

Code: Select all

Procedure myProcedure;
var
   MySeries: TErrorBarSeries;
  CL: TColor;
Begin
...
...
   CL := clRed;
...
Chart1.FreeAllSeries(nil);
Chart1.Legend.Visible := true;
Chart1.Legend.FontSeriesColor := true;
Chart1.Legend.LegendStyle := LsSeries;
...
MySeries := TErrorBarSeries.Create( Self );
Chart1.AddSeries( MySeries );
MySeries.ParentChart := Chart1;
MySeries.Title := 'myTitle';
MySeries.Color := CL;
MySeries.ErrorStyle := essTopBottom;
...
MySeries.AddErrorBar(indx,valAverage,valSEM,'Text1',CL);
...

end;
Here are the images from the previous version and the new version of Tee chart:
errorbarPlot-Old.jpg
errorbarPlot-Old.jpg (19.78 KiB) Viewed 13997 times
errorbarPlot-New.jpg
errorbarPlot-New.jpg (22.65 KiB) Viewed 14007 times
As you can see "Early" and "Late" do not have the same color as the bars.

Please adivise how to solve this issue.

BR
emwamin

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

Re: Series Chart color and Legend Chart color.

Post by Yeray » Fri Oct 02, 2015 1:41 pm

Hello,

Give it a try at the latest version, v2015.16. I could reproduce the problem with v2015.14 but not with the latest version.
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

emwamin
Newbie
Newbie
Posts: 10
Joined: Tue Sep 22, 2015 12:00 am

Re: Series Chart color and Legend Chart color.

Post by emwamin » Wed Oct 07, 2015 7:47 am

Hi

I have upgraded to v2015.16 and can confirm that the problem is solved.
Thanks a lot.

BR
emwamin

Post Reply