Custom Axis Label colour

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jfinch
Newbie
Newbie
Posts: 6
Joined: Thu May 19, 2016 12:00 am

Custom Axis Label colour

Post by jfinch » Tue Aug 02, 2016 6:23 am

Hi,
I have a custom axis.
I add items to it using m_pChart->LeftAxis->Items->Add(Position, Value);
This works fine.
However, I would like to be able to set the colour of the labels to something other than the default. Everything I try has failed:
Did not work:
m_pChart->LeftAxis->Items->Add(Position, Value)->Format->Color = clBlue
Did not work:
TAxisItem* NewItem (m_pChart->LeftAxis->Items->Add(Position, Value));
NewItem->Format->Color = clBlue;
None of these work:
LeftAxis->LabelsFormat->Font->Color = clBlue;
LeftAxis->Items->Format->Color = clBlue;
LeftAxis->LabelsFont->Color = clBlue;

In fact the documentation does state that none of these will work with custom axes, so what does?
I am at my wits end!

Thanks
jfinch

jfinch
Newbie
Newbie
Posts: 6
Joined: Thu May 19, 2016 12:00 am

Re: Custom Axis Label colour

Post by jfinch » Tue Aug 02, 2016 6:24 am

Should have stated, I am using Embarcadero® C++Builder 10.1 Berlin Version 24.0.22858.6822

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Axis Label colour

Post by Sandra » Tue Aug 02, 2016 2:41 pm

Hello jfinch,

The code below changes the labels font color for me without problems:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
Chart1->View3D = false;
Series1->FillSampleValues();
Series2->FillSampleValues();

Chart1->CustomAxes->Items[0]->Horizontal = false;
Chart1->CustomAxes->Items[0]->LabelsFont->Color = clBlue;

Chart1->Axes->Left->StartPosition = 0;
Chart1->Axes->Left->EndPosition = 50;
Chart1->Axes->Left->LabelsFont->Color = clRed;


Chart1->CustomAxes->Items[0]->StartPosition = 50;
Chart1->CustomAxes->Items[0]->EndPosition = 100;
Series1->VertAxis = aLeftAxis;
Series2->CustomVertAxis = Chart1->CustomAxes->Items[0];

}
Could you tell us if the above code works in your end? Also, if not, could you tell us which Teechart Pro VCL/FMX are you using?

Thanks in advance
Best Regards,
Sandra Pazos / 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

jfinch
Newbie
Newbie
Posts: 6
Joined: Thu May 19, 2016 12:00 am

Re: Custom Axis Label colour

Post by jfinch » Wed Aug 03, 2016 12:19 am

Hi,
The code you posted throws:
First chance exception at $7672DAE8. Exception class EArgumentOutOfRangeException with message 'Argument out of range'.
So I could not test it out.

However I have a query about it.

You are accessing something called a CustomAxis.
I was actually adding labels using
m_pChart->Axes->Left->Items->Add

So I think my original question was incorrect.
What I need to know is how to change the colour of custom labels on an ordinary axis, not on a custom axis.

Thanks
jfinch

jfinch
Newbie
Newbie
Posts: 6
Joined: Thu May 19, 2016 12:00 am

Re: Custom Axis Label colour

Post by jfinch » Wed Aug 03, 2016 12:20 am

Sorry forgot to give version: Steema TeeChart Pro VCL FMX 2016.18

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Axis Label colour

Post by Sandra » Wed Aug 03, 2016 11:12 am

Hello jfinch,

Many thanks for clarify the information.

I have attached a simple example where the custom labels font color is changed. Could you tell us if it works in your end?
VCLLabelsTest_C++.zip
(59.11 KiB) Downloaded 621 times
Thanks in advance
Best Regards,
Sandra Pazos / 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

jfinch
Newbie
Newbie
Posts: 6
Joined: Thu May 19, 2016 12:00 am

Re: Custom Axis Label colour

Post by jfinch » Thu Aug 04, 2016 12:19 am

Thanks Sandra,

That example you sent does work.
However, when you run it you will notice that the left labels overlap.
In my code I have an AfterDraw function to remove overlapping labels, and it turns out that it is that function (found on one of these forums) that is causing the problem.
I cannot find where to put a color command within that.
I have attached an alteration to your code, where a button click puts it through the type of thing I have in my program.
As you will see, when button1 is pushed a different graph appears, the labels are red but overlapping.
When button2 is pushed the same graph appears, the labels do not overlap, but they are now black.

Hopefully you can tell me where I can put the color command to get the labels to go back to being red.

Thanks again for the prompt and useful help!
jfinch
Attachments
VCLLabelsTest_C++.zip
File with after draw fixing overlapping labels.
(62.25 KiB) Downloaded 553 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Axis Label colour

Post by Sandra » Thu Aug 04, 2016 10:02 am

Hello jfinch,

Good news. After, reviewing the code you send me, we detected where is the problem, basically, is needed set the pAxisLabel font color in the CheclLeftAxisLabel method for each new custom label. I have modified the code and now works in correct way for us here.

Could you review if the attached project below works in your end?
VCLLabelsTest_C++_mod.zip
(61.37 KiB) Downloaded 548 times
Best Regards,
Sandra Pazos / 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

jfinch
Newbie
Newbie
Posts: 6
Joined: Thu May 19, 2016 12:00 am

Re: Custom Axis Label colour

Post by jfinch » Fri Aug 05, 2016 1:00 am

Thank you very much - that works!

Post Reply