Page 1 of 1

Change color of axis label

Posted: Thu Nov 11, 2010 6:29 am
by 15046375
I would like to change the color of labels on axis.

I tested two codes below, but both of these did not works.

1)
chart.GetAxis().GetLeft().GetLabels().GetFont().SetColor(RGB(255, 0, 0));
chart.GetAxis().GetLeft().GetLabels().Add(1, "test");


2)
unsigned long idx = chart.GetAxis().GetLeft().GetLabels().Add(1, "test");
chart.GetAxis().GetLeft().GetLabels().GetItem(idx).SetColor(RGB(255, 0, 0));


How can I do it?

Re: Change color of axis label

Posted: Thu Nov 11, 2010 3:41 pm
by narcis
Hi corwl,

Code below works fine for me here. Which TeeChart version are you using?

Code: Select all

	m_Chart1.GetAxis().GetLeft().GetLabels().GetFont().SetColor(RGB(255, 0, 0));
If problem persists can you please attach a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.

Re: Change color of axis label

Posted: Mon Nov 15, 2010 2:10 am
by 15046375
Thank you for your reply.

Please check the attached project.

project was produced with VC2003 and TChart version is V8.0 1.

Re: Change color of axis label

Posted: Mon Nov 15, 2010 3:47 pm
by yeray
Hi corwl,

In v8, if you are using custom labels, you have to change the label font:

Code: Select all

m_chart.GetAxis().GetLeft().GetLabels().GetItem(0).GetFont().SetColor(RGB(255, 0, 0));
In v2010 changing the axis labels font also applies to the custom labels.

Re: Change color of axis label

Posted: Tue Nov 16, 2010 12:20 am
by 15046375
Yes it works!

I really appreciate you Yeray.