Re: MSChart X Axis Labels
Hi TheBao,
I would like to receive sample code of an MSChart line graph with code for the x-axis labels. I use the following code, but instead of the correct labels I gete blsck bar under the x-axis and the default R- labels are kept and partly overwritten by the black bar.
What is wrong with my code? My email address is jvdpeet01@hotmail.com. Thanks in advance.
Here is my code:
Private Sub Command5_Click()
Dim Koersen() As Variant, i As Integer
ReDim Koersen(0 To NumRegels(1) + 1, 0 To 1) As Variant
'Set column labels.
Koersen(0, 1) = "Open"
' Set data.
For i = 1 To UBound(Koersen, 1)
If Left(Datum(i, 1), 4) <> Left(Datum(i - 1, 1), 4) Then
Koersen(i, 0) = " " & RTrim(CStr(Left(Datum(i, 1), 4)))
ElseIf Left(Right(Datum(i, 1), 4), 2) <> Left(Right(Datum(i - 1, 1), 4), 2) Then
Koersen(i, 0) = " " & RTrim(CStr(Left(Right(Datum(i, 1), 4), 2)))
End If
Koersen(i, 1) = OpenK(i, 1)
Next i
With frmGrafiekLITE.chtPlot ' chtPlot is de name of MSChart1
' Shows 2D graph with 5 columns and NumRegels(1) + 1 rows.
.chartType = VtChChartType2dLine ' Set chart type.
.TitleText = "Dagkoersen"
.Title.VtFont.Size = 16
.Plot.Axis(VtChAxisIdY).AxisTitle = "Slotkoers"
.Plot.Axis(VtChAxisIdX).AxisTitle = "Datum"
.ColumnCount = 4
.RowCount = NumRegels(1)
.ShowLegend = True
.ColumnLabelCount = 4
.Plot.AutoLayout = True
.ChartData = Koersen ' Assign Koersen to chart
End With
With chtPlot.Legend
.Location.Visible = True
.VtFont.Name = "Arial"
.VtFont.Size = 8
.Location.LocationType = VtChLocationTypeTop
.VtFont.Effect = VtFontStyleBold
End With
'Set graph data
frmGrafiekLITE.chtPlot.chartType = VtChChartType2dLine
frmGrafiekLITE.chtPlot.ChartData = Koersen
End Sub