Page 1 of 1

Series Chart color and Legend Chart color.

Posted: Wed Aug 05, 2015 12:45 pm
by 16475083
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?

Re: Series Chart color and Legend Chart color.

Posted: Wed Aug 05, 2015 1:08 pm
by narcis
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.

Re: Series Chart color and Legend Chart color.

Posted: Wed Aug 05, 2015 1:59 pm
by 16475083
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?

Re: Series Chart color and Legend Chart color.

Posted: Wed Aug 05, 2015 2:20 pm
by narcis
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;

Re: Series Chart color and Legend Chart color.

Posted: Wed Aug 05, 2015 3:24 pm
by 16475083
Excellent!

Thank you.

Re: Series Chart color and Legend Chart color.

Posted: Fri Oct 02, 2015 10:01 am
by 16576425
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 15500 times
errorbarPlot-New.jpg
errorbarPlot-New.jpg (22.65 KiB) Viewed 15510 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

Re: Series Chart color and Legend Chart color.

Posted: Fri Oct 02, 2015 1:41 pm
by yeray
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.

Re: Series Chart color and Legend Chart color.

Posted: Wed Oct 07, 2015 7:47 am
by 16576425
Hi

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

BR
emwamin