Left Axis Title and Label separation
Left Axis Title and Label separation
How do I increase the "gap" between the Left Axis Title and the labels?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi rperkins,
You should use LabelsSeparation for that:
You should use LabelsSeparation for that:
Code: Select all
Chart1.Axes.Left.LabelsSeparation:=50;
Best Regards,
Narcís Calvet / 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 |
if i change this in the form designer (LeftAxis.LabelSeparation) from 10 to 50, it changes the separation of the horizontal lines (reducing the number of lines).
did i miss something? what i'm looking to do is increase the gap between the axis title (LeftAxis.Title.Caption) - which is turned 90 degrees (up/down), and the labels of the horizontal grid lines, which are numerical values based on the data points.
did i miss something? what i'm looking to do is increase the gap between the axis title (LeftAxis.Title.Caption) - which is turned 90 degrees (up/down), and the labels of the horizontal grid lines, which are numerical values based on the data points.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi rperkins,
I'm not sure about which is your exact problem here. Most likely that since the chart area is reduced by incrementing LabelsSeparation, less labels can be fitted in the bottom axis and therefore its increment automatically increases. Is that your problem? If so you'll have to manually set axes Increment manually.
I'm not sure about which is your exact problem here. Most likely that since the chart area is reduced by incrementing LabelsSeparation, less labels can be fitted in the bottom axis and therefore its increment automatically increases. Is that your problem? If so you'll have to manually set axes Increment manually.
Best Regards,
Narcís Calvet / 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 |
no, that isn't the problem. what i have is a chart (obviously) with a left axis caption called "Corrected Counts" - which is written at 90 degrees - tilt your head 90 degrees to the left to read. the left axis labels run from -5.00 to 5.00, every 0.5. what is happening is that the bottom of the axis caption is right against the left side of the axis labels. what i'd like to do is to increase/add space between the bottom of the caption and the left side of the axis label.
if you still aren't sure about what i'm asking, i can upload a JPEG of a screen capture. that shows it.
thanks....
if you still aren't sure about what i'm asking, i can upload a JPEG of a screen capture. that shows it.
thanks....
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi rperkins,
Thanks for the information. I think I understand which is your problem and I also think setting LabelsSeparation for left axis labels is the solution but if you have any inconvenient with that please post an image of the original chart, what you get after applying LabelsSeparation and what would you like to get.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Thanks for the information. I think I understand which is your problem and I also think setting LabelsSeparation for left axis labels is the solution but if you have any inconvenient with that please post an image of the original chart, what you get after applying LabelsSeparation and what would you like to get.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Best Regards,
Narcís Calvet / 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 |
uploaded PastedImage_12.jpeg. it shows the before "issue" i'm talking about. look at the left and right sides of the chart - the words "Corrected Counts/Pulse". that's what i'm trying to separate from the value labels.
does that help? i can get the result of setting the LabelSeparation, which doesn't change the distance at the bottom of the axis caption, but, increases the gap between the horizontal grid lines, unless there's another labelsSeparation i'm not setting.
does that help? i can get the result of setting the LabelSeparation, which doesn't change the distance at the bottom of the axis caption, but, increases the gap between the horizontal grid lines, unless there's another labelsSeparation i'm not setting.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi rperkins,
Sorry, my bad! Yes, that's the problem I meant. I confused myself. You don't need to use LabelsSeparation, you need to use LabelsSize .
For example, this code:
Produces a chart similar to yours. Increasing LabelsSize solves the problem:
Sorry, my bad! Yes, that's the problem I meant. I confused myself. You don't need to use LabelsSeparation, you need to use LabelsSize .
For example, this code:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to 10 do
Series1.Add(i-5);
Chart1.Axes.Left.Title.Caption:='My left axis title';
Chart1.Axes.Right.Title.Caption:='My right axis title';
end;
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to 10 do
Series1.Add(i-5);
Chart1.Axes.Left.Title.Caption:='My left axis title';
Chart1.Axes.Right.Title.Caption:='My right axis title';
Chart1.Axes.Left.LabelsSize:=30;
Chart1.Axes.Right.LabelsSize:=30;
end;
Best Regards,
Narcís Calvet / 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 |
that did it, at least for a static size of less than 30. if the value is large, say 200,000, it is bigger than 30 pixels, so the caption is overwritten by the label. what i need to do is to add something to the add 20-30 to the length of the updated text values - maybe in the AfterDraw handler?
is there a way to get the size of the labels? more specifically, the maximum size of the labels?
where would be a good place to put this "spacer" function?
is there a way to get the size of the labels? more specifically, the maximum size of the labels?
where would be a good place to put this "spacer" function?
Computing Axis Label Size to space between Axis / Labels
I use the following SetLabelPositions method for Custom Axes. For Left Axis, I think you have to use LabelSize instead of CustomSize. I have found a good place to put this is in a TChart BeforeDraw event handler.
Regards, Ed
Code: Select all
private void SetLabelPositions()
{
SteemaTChart.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
int width = 0;
foreach (Steema.TeeChart.Axis axis in SteemaTChart.Axes.Custom)
{
try
{
width = Math.Max(axis.Labels.LabelWidth(axis.Minimum), width);
width = Math.Max(axis.Labels.LabelWidth(axis.Maximum), width);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Failure in SetLabelPositions()");
}
}
width += 5;
foreach (Steema.TeeChart.Axis axis in SteemaTChart.Axes.Custom)
{
axis.Labels.CustomSize = width;
}
}
Computing Axis Label Space
Expanding on my previous post... I am working with the .NET 3 version which seems to have replaced the LabelsSize property with a Labels.CustomSize property. The following code may work for you. However, I can't confirm that your version has a LabelWidth function as the .NET version does.
Regards,
Ed
Code: Select all
private void SetLeftAxisTitleOffset(Steema.TeeChart.TChart lTChart)
{
Steema.TeeChart.Axis lAxis = lTChart.Axes.Left;
int width = lAxis.Labels.LabelWidth(lAxis.Minimum);
width = Math.Max(lAxis.Labels.LabelWidth(lAxis.Maximum), width);
width += 5;
lAxis.LabelsSize = width;
}
Ed
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi rperkins,
Yes, using the OnAfterDraw event would be an option.
Yes, using the OnAfterDraw event would be an option.
Yes, you can use Chart1.Axes.Left.MaxLabelsWidth. Bear in mind that this property will only have valid values when the chart has already been painted so running the code in the OnAfterDraw event is a good choice. Another option would be calling Chart1.Draw before.is there a way to get the size of the labels? more specifically, the maximum size of the labels?
Best Regards,
Narcís Calvet / 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 |
based on the information in the previous post, i created a BeforeDrawChart handler (tried in the AfterDraw, but it was 1 refresh behind). the code below results in the appropriate "cushion" between the Axis Title and the Labels. not: in my example, the chart is called crtData.
void __fastcall TfrmChannelOverTime::crtDataBeforeDrawChart(TObject *Sender)
{
int width=0;
width = Max ( crtData->LeftAxis->LabelWidth(crtData->LeftAxis->Minimum), width );
width = Max ( crtData->LeftAxis->LabelWidth(crtData->LeftAxis->Maximum), width );
width += 10;
crtData->LeftAxis->LabelsSize = width;
crtData->RightAxis->LabelsSize = width;
}
void __fastcall TfrmChannelOverTime::crtDataBeforeDrawChart(TObject *Sender)
{
int width=0;
width = Max ( crtData->LeftAxis->LabelWidth(crtData->LeftAxis->Minimum), width );
width = Max ( crtData->LeftAxis->LabelWidth(crtData->LeftAxis->Maximum), width );
width += 10;
crtData->LeftAxis->LabelsSize = width;
crtData->RightAxis->LabelsSize = width;
}