Page 1 of 1

Set Position of Axis Lable

Posted: Tue Jan 06, 2015 5:58 pm
by 13052810
I'm trying to set the position of the Axis Label with respect to the axis.
If I have the Axis scaled for 0 to 1000 and marks every 100, then the spacing between the label and the values is too great.
We want to reduce the spacing to something less.
How can I accomplish this?

Thanks!

Re: Set Position of Axis Lable

Posted: Wed Jan 07, 2015 9:03 am
by yeray
Hi Tirby,
tirby wrote:the spacing between the label and the values is too great.
We want to reduce the spacing to something less.
I'm not sure to understand what exact distance do you mean.
This is how it looks for me here:
test.png
test.png (26.98 KiB) Viewed 11476 times

Code: Select all

Private Sub Form_Load()  
  TChart1.AddSeries scLine
  TChart1.Series(0).FillSampleValues
  
  TChart1.Axis.Left.SetMinMax 0, 1000
  TChart1.Axis.Left.Increment = 100
End Sub
What space do you want to reduce?

Re: Set Position of Axis Lable

Posted: Wed Jan 07, 2015 2:34 pm
by 13052810
Yeray,

Thanks for looking at this.

What I'm trying to do is change the spacing between the the 2 black arrows as shown on the picture below.

Re: Set Position of Axis Lable

Posted: Thu Jan 08, 2015 2:38 pm
by yeray
Hello,

I'm afraid you can't control the axis title position.
Instead, you could hide the axis title and draw its text manually as follows:

Code: Select all

Private Sub TChart1_OnAfterDraw()
  With TChart1.Axis.Left
    XPos = .Position - .Labels.MaxWidth - .TickLength
    YPos = .IStartPos + ((.IEndPos - .IStartPos) / 2) + (TChart1.Canvas.TextWidth(.Title.Caption) / 2)
  End With
  
  With TChart1.Canvas
    .RotateLabel XPos, YPos, TChart1.Axis.Left.Title.Caption, 90
  End With