How to change legend color according to series color

TeeChart for ActiveX, COM and ASP
Post Reply
David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

How to change legend color according to series color

Post by David » Tue Jun 20, 2006 10:15 am

Hi,

I tried to change the color of the fastline series like
m_chart2.Series(0).GetPen().SetColor(RGB(255,0,0));
m_chart2.Series(1).GetPen().SetColor(RGB(128,128,128));
m_chart2.Series(2).GetPen().SetColor(RGB(0,0,255));
And the series colors can be changed correctly. Now the problem is the legend. The item colors in the legend seem to maintain the default ones. How to change legend color according to series color?

Thank you,
David

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

Post by Narcís » Tue Jun 20, 2006 10:44 am

Hi David,

This is default behaviour and works fine for me here using TeeChart Pro v7.0.0.8 maintenance release using this code:

Code: Select all

	m_Chart1.AddSeries(scFastLine);
	m_Chart1.AddSeries(scFastLine);
	m_Chart1.AddSeries(scFastLine);
	m_Chart1.Series(0).FillSampleValues(10);
	m_Chart1.Series(1).FillSampleValues(10);
	m_Chart1.Series(2).FillSampleValues(10);
	m_Chart1.Series(0).GetPen().SetColor(RGB(255,0,0)); 
	m_Chart1.Series(1).GetPen().SetColor(RGB(128,128,128)); 
	m_Chart1.Series(2).GetPen().SetColor(RGB(0,0,255)); 
	m_Chart1.AboutBox();
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

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Post by David » Tue Jun 20, 2006 11:02 am

I tried again and it seems the problem comes from
m_chart1.GetLegend().SetFontSeriesColor(TRUE);
The legend label's color is correct, but the legend text is not. Any suggestion?

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

Post by Narcís » Tue Jun 20, 2006 1:09 pm

Hi David,

Thanks for the information.

Now I could reproduce the problem and added it (TA05011509) to our bug list to be fixed for future releases.
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

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

Post by Narcís » Wed Jul 02, 2008 11:57 am

Hi David,

As an udpate,

We have been reviewing the issue here and think it's not a bug. You should use this code:

Code: Select all

    TChart1.AddSeries scFastLine
    TChart1.AddSeries scFastLine
    TChart1.AddSeries scFastLine
    
    TChart1.Series(0).FillSampleValues 10
    TChart1.Series(1).FillSampleValues 10
    TChart1.Series(2).FillSampleValues 10
    
    TChart1.Series(0).Color = RGB(255, 0, 0)
    TChart1.Series(1).Color = RGB(128, 128, 128)
    TChart1.Series(2).Color = RGB(0, 0, 255)
    
    TChart1.Legend.FontSeriesColor = True
You need to use Series.Color instead of Series.Pen.Color to achieve what you request as for example, using line series, you can have different color settings for series brush (Series.Color) and Series.Pen.Color.
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