Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label data points in MSChart

Status
Not open for further replies.

norason

Programmer
Jan 28, 2009
139
US
This code produces 16 points on the graph - RC1 to RC16. How do I show the data value on each of the 16 points on the graph? Incidentaly, .ColumnLabel = "LABEL" doesn't produce a column label.

Private Sub cmdDrawGraph_Click()
Dim rc() As Integer
rc1 = 1
rc2 = 2
rc3 = 4
rc4 = 4
rc5 = 6
rc6 = 6
rc7 = 8
rc8 = 8
rc9 = 9
rc10 = 8
rc11 = 7
rc12 = 7
rc13 = 6
rc14 = 6
rc15 = 5
rc16 = 2
Dim intIndex As Integer '*******************
Dim strAbbrev(1 To 16) As String 'Names the Rows
strAbbrev(1) = "3/23/2009 8:12:13 AM"
strAbbrev(2) = "3/23/2009 8:12:24 AM"
strAbbrev(3) = "3/23/2009 8:12:33 AM"
strAbbrev(4) = "3/23/2009 8:12:34 AM"
strAbbrev(5) = "3/23/2009 8:12:35 AM"
strAbbrev(6) = "3/23/2009 8:12:36 AM"
strAbbrev(7) = "3/23/2009 8:12:37 AM"
strAbbrev(8) = "3/23/2009 8:12:38 AM"
strAbbrev(9) = "3/23/2009 8:12:39 AM"
strAbbrev(10) = "3/23/2009 8:12:40 AM"
strAbbrev(11) = "3/23/2009 8:12:41 AM"
strAbbrev(12) = "3/23/2009 8:12:42 AM"
strAbbrev(13) = "3/23/2009 8:12:43 AM"
strAbbrev(14) = "3/23/2009 8:12:44 AM"
strAbbrev(15) = "3/23/2009 8:12:45 AM"
strAbbrev(16) = "3/23/2009 8:12:46 AM"
MSChart1.RowCount = 16
For intIndex = 1 To 16
MSChart1.Row = intIndex
MSChart1.RowLabel = strAbbrev(intIndex) 'Names the Rows
Next intIndex '********************
With MSChart1
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Name = ariel
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Size = 12
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Style = Bold
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.VtColor.Set 0, 153, 0
.TitleText = "TEST DATA"
.ChartType = VtChChartType2dLine
.ColumnCount = 1 'one plotted line
.RowCount = 16 'number of horizontal points
.Column = 1
.ColumnLabel = "LABEL" 'doesn't work
.Row = 1
For Row = 1 To 16
.Row = Row
Select Case Row
Case 1
.Data = rc1
Case 2
.Data = rc2
Case 3
.Data = rc3
Case 4
.Data = rc4
Case 5
.Data = rc5
Case 6
.Data = rc6
Case 7
.Data = rc7
Case 8
.Data = rc8
Case 9
.Data = rc9
Case 10
.Data = rc10
Case 11
.Data = rc11
Case 12
.Data = rc12
Case 13
.Data = rc13
Case 14
.Data = rc14
Case 15
.Data = rc15
Case 16
.Data = rc16
End Select
Next Row
End With
End Sub
 
After hours searching, I found an example that works. Here's the latest code:

Private Sub cmdDrawGraph_Click()
Dim i%, j%, arr(1 To 16, 1 To 1)

arr(1, 1) = 1
arr(2, 1) = 2
arr(3, 1) = 4
arr(4, 1) = 6
arr(5, 1) = 6
arr(6, 1) = 8
arr(7, 1) = 9
arr(8, 1) = 8
arr(9, 1) = 7
arr(10, 1) = 7
arr(11, 1) = 6
arr(12, 1) = 6
arr(13, 1) = 6
arr(14, 1) = 5
arr(15, 1) = 4
arr(16, 1) = 2
With MSChart1
.ChartType = VtChChartType2dLine
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Name = ariel
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Size = 12
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Style = Bold
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.VtColor.Set 0, 153, 0
.TitleText = "TEST PUMP GRAPH"

.ChartData = arr

With .DataGrid
.SetSize 1, 1, 16, 2

Dim intIndex As Integer '*******************
Dim strAbbrev(1 To 16) As String 'Names the Rows

strAbbrev(1) = "3/23/2009 8:12:13 AM"
strAbbrev(2) = "3/23/2009 8:12:24 AM"
strAbbrev(3) = "3/23/2009 8:12:33 AM"
strAbbrev(4) = "3/23/2009 8:12:34 AM"
strAbbrev(5) = "3/23/2009 8:12:35 AM"
strAbbrev(6) = "3/23/2009 8:12:36 AM"
strAbbrev(7) = "3/23/2009 8:12:37 AM"
strAbbrev(8) = "3/23/2009 8:12:38 AM"
strAbbrev(9) = "3/23/2009 8:12:39 AM"
strAbbrev(10) = "3/23/2009 8:12:40 AM"
strAbbrev(11) = "3/23/2009 8:12:41 AM"
strAbbrev(12) = "3/23/2009 8:12:42 AM"
strAbbrev(13) = "3/23/2009 8:12:43 AM"
strAbbrev(14) = "3/23/2009 8:12:44 AM"
strAbbrev(15) = "3/23/2009 8:12:45 AM"
strAbbrev(16) = "3/23/2009 8:12:46 AM"
MSChart1.RowCount = 16
For intIndex = 1 To 16
MSChart1.Row = intIndex
MSChart1.RowLabel = strAbbrev(intIndex) 'Names the Rows
Next intIndex '********************
End With


With .Plot
With .SeriesCollection
With .Item(1).DataPoints(-1)
.DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
.DataPointLabel.VtFont.VtColor.Set 255, 0, 0 '# red
.Brush.FillColor.Set 255, 0, 0
End With
End With '#seriescoll

End With '# plot

End With '#chart

End Sub


Thanks,

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top