Problem getting bottom axis min/max/increment.
Posted: Thu Sep 30, 2010 9:07 am
Hello all,
I want to define a custom x axis as soon as a plot is created. But when I try and get the xMin, xMax and increment, all are returned as zero.
For example, the following code does not work (xmin,xmax and increment all come back from TChart as zero).
But if I separate the code into two subs both behind buttons and click each button in turn, it works.
How can I get the values from the axis?
Tony.
I want to define a custom x axis as soon as a plot is created. But when I try and get the xMin, xMax and increment, all are returned as zero.
For example, the following code does not work (xmin,xmax and increment all come back from TChart as zero).
Code: Select all
Private Sub Command3_Click()
TChart1.AddSeries scGantt
TChart1.AddSeries scGantt
TChart1.Aspect.View3D = False
' Disable automatic sorting by date
TChart1.Series(0).XValues.Order = loNone
TChart1.Series(1).XValues.Order = loNone
' Fill Gantt with sample date-time values:
With TChart1.Series(0)
.asGantt.AddGantt DateSerial(2002, 4, 1), DateSerial(2002, 4, 10), 0, "Series 1 - A"
.asGantt.AddGantt DateSerial(2002, 4, 5), DateSerial(2002, 4, 15), 1, "Series 1 - B"
' Make marks visible
.Marks.Visible = True
.Marks.ShadowSize = 0
.Marks.Gradient.Visible = True
End With
With TChart1.Series(1)
.asGantt.AddGantt DateSerial(2002, 5, 2), DateSerial(2002, 5, 8), 2, "Series 2 - C"
.asGantt.AddGantt DateSerial(2002, 5, 9), DateSerial(2002, 5, 21), 3, "Series 2 - D"
.asGantt.Pointer.VerticalSize = 20
' Make marks visible
.Marks.Visible = True
.Marks.ShadowSize = 0
.Marks.Gradient.Visible = True
End With
Dim nNumLablels As Long
Dim nMin As Double
Dim nMax As Double
Dim nIncrement As Double
Dim strTempString As String
Dim i As Double
Dim nLabelCount As Long
nMin = TChart1.Axis.Bottom.Minimum
nMax = TChart1.Axis.Bottom.Maximum
nIncrement = TChart1.Axis.Bottom.Increment
If nIncrement = 0 Then
nIncrement = 1
End If
For i = nMin To nMax Step nIncrement
strTempString = "QTest + " & i
TChart1.Axis.Bottom.Labels.Add i, strTempString
Next i
nLabelCount = TChart1.Axis.Bottom.Labels.Count
End Sub
But if I separate the code into two subs both behind buttons and click each button in turn, it works.
Code: Select all
Private Sub Command3_Click()
TChart1.AddSeries scGantt
TChart1.AddSeries scGantt
TChart1.Aspect.View3D = False
' Disable automatic sorting by date
TChart1.Series(0).XValues.Order = loNone
TChart1.Series(1).XValues.Order = loNone
' Fill Gantt with sample date-time values:
With TChart1.Series(0)
.asGantt.AddGantt DateSerial(2002, 4, 1), DateSerial(2002, 4, 10), 0, "Series 1 - A"
.asGantt.AddGantt DateSerial(2002, 4, 5), DateSerial(2002, 4, 15), 1, "Series 1 - B"
' Make marks visible
.Marks.Visible = True
.Marks.ShadowSize = 0
.Marks.Gradient.Visible = True
End With
With TChart1.Series(1)
.asGantt.AddGantt DateSerial(2002, 5, 2), DateSerial(2002, 5, 8), 2, "Series 2 - C"
.asGantt.AddGantt DateSerial(2002, 5, 9), DateSerial(2002, 5, 21), 3, "Series 2 - D"
.asGantt.Pointer.VerticalSize = 20
' Make marks visible
.Marks.Visible = True
.Marks.ShadowSize = 0
.Marks.Gradient.Visible = True
End With
Dim nNumLablels As Long
End Sub
Private Sub Command4_Click()
Dim nNumLablels As Long
Dim nMin As Double
Dim nMax As Double
Dim nIncrement As Double
Dim strTempString As String
Dim i As Double
Dim nLabelCount As Long
nMin = TChart1.Axis.Bottom.Minimum
nMax = TChart1.Axis.Bottom.Maximum
nIncrement = TChart1.Axis.Bottom.Increment
If nIncrement = 0 Then
nIncrement = 1
End If
For i = nMin To nMax Step nIncrement
strTempString = "QTest + " & i
TChart1.Axis.Bottom.Labels.Add i, strTempString
Next i
nLabelCount = TChart1.Axis.Bottom.Labels.Count
End Sub
Tony.