Page 1 of 1

How to change legend color according to series color

Posted: Tue Jun 20, 2006 10:15 am
by 9529132
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

Posted: Tue Jun 20, 2006 10:44 am
by narcis
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();

Posted: Tue Jun 20, 2006 11:02 am
by 9529132
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?

Posted: Tue Jun 20, 2006 1:09 pm
by narcis
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.

Posted: Wed Jul 02, 2008 11:57 am
by narcis
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.