Auto-Resizing Labels and Titles for Custom Axes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
AMS
Newbie
Newbie
Posts: 24
Joined: Wed Mar 31, 2004 5:00 am
Location: South Africa
Contact:

Auto-Resizing Labels and Titles for Custom Axes

Post by AMS » Wed Oct 20, 2004 5:52 am

Hi Steema Software Users,
I'm using TChart Pro Ver 7 together with Builder C++ Ver 7.

My problem has to do with auto-resizing lable and title items on custom axes. I have read and searched through all existing forums and can not find a solution.

In many discussions it is suggested that the "Series->Axis->TitleSize and Series->Axis->LabelsSize" be manipulated but this has no effect. I mean this literally, if I assign values to these properties at runtime, I see no effect on the displayed chart.

I must also add that I do not use the LeftAxis and BottomAxis of the TChart object, only "Chart->CustomAxes->Add()". With this, I add my own custom axes to the Series->CustomVertAxis and Series->CustomHorizAxis.

Here is my example code...

Code: Select all

  // 1 - Add my vertical axis...
  Chart->CustomAxes->Add();
  Chart->CustomAxes->Items[0]->PositionPercent     = 0;
  Chart->CustomAxes->Items[0]->StartPosition       = 0;
  Chart->CustomAxes->Items[0]->EndPosition         = 100;
  Chart->CustomAxes->Items[0]->Title->Caption      = "Vertical Custom Axis";
  Chart->CustomAxes->Items[0]->Title->Angle        = 0;
  Chart->CustomAxes->Items[0]->TitleSize           = 0;
  Chart->CustomAxes->Items[0]->Labels              = true;
  Chart->CustomAxes->Items[0]->LabelsSize          = 0;
  Chart->CustomAxes->Items[0]->LabelsAngle         = 0;
  Chart->CustomAxes->Items[0]->Horizontal          = false;
  Chart->CustomAxes->Items[0]->AutomaticMaximum    = true;
  Chart->CustomAxes->Items[0]->AutomaticMinimum    = true;

  // 2 - Add my horizontal axis...
  Chart->CustomAxes->Add();
  Chart->CustomAxes->Items[1]->PositionPercent     = 0;
  Chart->CustomAxes->Items[1]->StartPosition       = 0;
  Chart->CustomAxes->Items[1]->EndPosition         = 100;
  Chart->CustomAxes->Items[1]->Title->Caption      = "Horizontal Custom Axis";
  Chart->CustomAxes->Items[1]->Title->Angle        = 0;
  Chart->CustomAxes->Items[1]->TitleSize           = 0;
  Chart->CustomAxes->Items[1]->Labels              = true;
  Chart->CustomAxes->Items[1]->LabelsSize          = 0;
  Chart->CustomAxes->Items[1]->LabelsAngle         = 90;
  Chart->CustomAxes->Items[1]->Horizontal          = true;
  Chart->CustomAxes->Items[1]->AutomaticMaximum    = true;
  Chart->CustomAxes->Items[1]->AutomaticMinimum    = true;

  // 3 - Now assign to my series...
  Series1->Add(10);
  Series1->CustomVertAxis  = Chart->CustomAxes->Items[0];
  Series1->CustomHorizAxis = Chart->CustomAxes->Items[1];
  Series2->Add(10);
  Series2->CustomVertAxis  = Chart->CustomAxes->Items[0];
  Series2->CustomHorizAxis = Chart->CustomAxes->Items[1];

Q1 - Should I be using Left and Bottom Axes? (Although my application implementation requires a number of custom axes.)

Q2 - How do I resize Title and Labels on a Custom Axis?(Even though I manipulate Series->Axis->TitleSize and Series->Axis->LabelsSize.)

Regards John.

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Oct 21, 2004 6:44 am

Hi,
Q1 - Should I be using Left and Bottom Axes? (Although my application implementation requires a number of custom axes.)
No, if you want you can use only custom axes.
Q2 - How do I resize Title and Labels on a Custom Axis?(Even though I manipulate Series->Axis->TitleSize and Series->Axis->LabelsSize.)
You must use the following code instead :
Chart1->CustomAxes->Items[0]->LabelsFont->Size = x;
Chart1->CustomAxes->Items[0]->Title.Font->Size = x;

AMS
Newbie
Newbie
Posts: 24
Joined: Wed Mar 31, 2004 5:00 am
Location: South Africa
Contact:

Post by AMS » Thu Oct 21, 2004 7:38 am

Hi Pep,
The problem is not with adjusting Title.Font->Size or LabelsFont->Size, it is in fact with the spacing position of the labels from the left or bottom of the chart. The label and title on any custom axes I draw is partially hidden. Adjusting the font size only makes more the information 'dissapear' off the edge of the chart.

I am sure it has to do with the TitleSize and LabelsSize property, the reason I say this is that when I adjust this property, using the editor, on the LeftAxis and BottomAxis, the entire left axis and bottom axis is shifted accordingly and the desired effect is achieved. This presents a problem however when using custom axes because adjusting the TitleSize and LabelsSize property has no effect, even when using the editor.

I hope the question makes more sense... Waiting in suspence...
Thanks, John.

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Oct 21, 2004 10:31 am

Hi John,

have you tried to set a marginbottom and marginleft ?
Chart1->MarginBottom = x;

AMS
Newbie
Newbie
Posts: 24
Joined: Wed Mar 31, 2004 5:00 am
Location: South Africa
Contact:

Post by AMS » Thu Oct 21, 2004 12:18 pm

Pep,
I hadn't... But I did try it now and it does work.

Q1 - Although this works... Why do series assigned to the LeftAxis and BottomAxis of Chart1 "seem" to set the margins accordingly so that title and label data is correctly displayed?

Q2 - If I have to manually set the margins when using custom axes, how can I do this programatically by calculating the appropriate size?

Thanks again for the help... Much appreciated!
John

Post Reply