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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSCHART doesn't display final data field

Status
Not open for further replies.

davejazz

Programmer
Nov 3, 2000
42
US
I have 5 items I'm trying to track (chart) over 14 days. It's been a struggle attempting to do this with the VB6 Mschart control and is probably a mental block on my end.

I read the data into an array: myarray(14,5). I'm sure the data is filling the array correctly because I print it to a file as the array is being loaded just for debugging.

Data for the first 4 elements, myarray(1,1) - myarray(14,4), appears accurately in the resulting chart but the final data in myarray(14,5) is missing.

I must be forcing a square peg into a round hole because I've had to add a few lines to the MS sample code to get the final rowlabel and columnlabel to appear. They would be blank otherwise.

Below is my code:

Private Sub cmdShow_Click()
Dim ln(5) As String
xln(1) = "Hot"
xln(2) = "Due"
xln(3) = "Mid"
xln(4) = "Mix"
xln(5) = "Skips"
With MSChart1
.chartType = VtChChartType2dLine
.ColumnCount = 5
.RowCount = 14
For Column = 1 To 5
.ColumnLabel = xln(Column - 1) 'Why minus one?
For Row = 1 To 14
.RowLabel = Str(Row - 1) 'Why minus one again?
.Column = Column
.Row = Row
.Data = myarray(Row, Column)
Next Row
.RowLabel = " 14" 'Prints ... 11 12 13 1 otherwise
Next Column
.ColumnLabel = xln(5) 'Prints C5 without this
.ShowLegend = True
.SelectPart VtChPartTypePlot, index1, index2, index3, index4
.EditCopy
.SelectPart VtChPartTypeLegend, index1, index2, index3, index4
.EditPaste
End With
End Sub


Within the properties of my mschart control, I have "Series in rows" unchecked. (The default.)

If someone can help with a solution or tell me where to get a bigger hammer (square peg into round hole) I'd sure appreciate it.

Best regards,
Dave
 
Most things start with Item 0 being the first. If there are 5 items in the array (4), they are 0-4, not 1-5. You need to start with 0 if you are using (-1) because 5-1=4, so 0-4

-David
2006 Microsoft Most Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Oops!

Upon closer inspection of my data I discovered two of the array fields contain exactly the same values.

One line is just overwriting (hiding) the other. I discovered this by changing to the 3D line chart.

Guess I owe Bill Gates an apology for all those things I was muttering under my breath. "Sorry, Bill!"
 
LOL

-David
2006 Microsoft Most Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top