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
Custom Axis Label colour
Re: Custom Axis Label colour
Should have stated, I am using Embarcadero® C++Builder 10.1 Berlin Version 24.0.22858.6822
Re: Custom Axis Label colour
Hello jfinch,
The code below changes the labels font color for me without problems:
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
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];
}
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 |
Instructions - How to post in this forum |
Re: Custom Axis Label colour
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
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
Re: Custom Axis Label colour
Sorry forgot to give version: Steema TeeChart Pro VCL FMX 2016.18
Re: Custom Axis Label colour
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?
Thanks in advance
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?
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 |
Instructions - How to post in this forum |
Re: Custom Axis Label colour
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
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 593 times
Re: Custom Axis Label colour
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?
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?
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Custom Axis Label colour
Thank you very much - that works!