Page 1 of 1

Can't position Left Axis accurately

Posted: Thu Jun 10, 2004 2:18 pm
by 32639
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

Posted: Fri Jun 11, 2004 10:30 am
by Pep
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.

Posted: Fri Jun 11, 2004 2:39 pm
by 32639
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

Posted: Sun Jun 13, 2004 11:31 pm
by Pep
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

Posted: Mon Jun 14, 2004 4:19 pm
by 32639
Hey Pep,
Thanks for the code when using Automatic axis. I wasn't aware of that.
Bob