Can't position Left Axis accurately

TeeChart for ActiveX, COM and ASP
Post Reply
Bob
Newbie
Newbie
Posts: 23
Joined: Thu May 27, 2004 4:00 am
Location: Houston, TX USA

Can't position Left Axis accurately

Post by Bob » Thu Jun 10, 2004 2:18 pm

Hello group,
I am having trouble positioning the Left Axis where I want it. It needs to be passing directly through "0" on the Bottom Axis, but is offset to the left. Does anyone know if there is a way to make it always pass through "0" on the bottom axis? I tried the .PositionPercent = 50, but sometimes the "0" point is not in the middle of the bottom axis.

Thanks,
Bob

Private Sub Form_Load()
With TChart1.Axis.Left
.Automatic = True
.MaximumOffset = 10
.MinimumOffset = 10
End With

With TChart1.Axis.Bottom
.Automatic = True
.MaximumOffset = 10
.MinimumOffset = 10
End With

TChart1.Axis.Left.PositionPercent = 50
TChart1.Axis.Bottom.PositionPercent = 50
End Sub

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

Post by Pep » Fri Jun 11, 2004 10:30 am

Hi Bob,

I'm not sure it the following is what you are trying to do :

Code: Select all

Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues (10)

With TChart1.Axis.Left
.Automatic = True
.MaximumOffset = 10
.MinimumOffset = 10
End With

With TChart1.Axis.Bottom
.Automatic = True
.MaximumOffset = 10
.MinimumOffset = 10
End With

TChart1.Axis.Left.PositionPercent = 50
TChart1.Axis.Bottom.PositionPercent = 50
TChart1.Axis.Bottom.SetMinMax -10, 10
End Sub
You can use the SetMinMax method so the Left axis will always pass through "0" on the bottom axis.

Bob
Newbie
Newbie
Posts: 23
Joined: Thu May 27, 2004 4:00 am
Location: Houston, TX USA

Post by Bob » Fri Jun 11, 2004 2:39 pm

Hey Pep,
I am trying to let the range of the Left and Bottom axes be automatic and then position the Left axis so that it passes through zero on the bottom axis. The line: TChart1.Axis.Bottom.SetMinMax -10, 10 forces the range to manual (if I'm not mistaken). That's fine, if it can't be done while using the TChart1.Axis.Bottom.Automatic = True, then I will go ahead and switch to the TChart1.Axis.Bottom.Automatic = False. I was hoping that I could just position the left axis at any point on the bottom axis with a simple command.

Thanks for your help,
Bob

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

Post by Pep » Sun Jun 13, 2004 11:31 pm

Hi Bob,

sorry to not let you know that thiere's another way in case you want to use Automatic axis. You can set the position of the left axis to the 0 position of XAxis using the following code :

Code: Select all

With TChart1
    .Environment.InternalRepaint
    chartRectWidth = .Axis.Right.Position - .Axis.Left.Position
    seriesXLocation = .Series(0).CalcXPosValue(0) 'X-pos of 0 value
    relativeXPercent = (seriesXLocation - .Axis.Left.Position) / chartRectWidth * 100
    .Axis.Left.PositionPercent = relativeXPercent
End With

Bob
Newbie
Newbie
Posts: 23
Joined: Thu May 27, 2004 4:00 am
Location: Houston, TX USA

Post by Bob » Mon Jun 14, 2004 4:19 pm

Hey Pep,
Thanks for the code when using Automatic axis. I wasn't aware of that.
Bob

Post Reply