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

MSChart control

Status
Not open for further replies.

toon10

Programmer
Mar 26, 2004
303
DE
Hi

I’m using the MSChart control to take two pieces of data from a recordset and populating and array to display them on my chart. The following is from my code. The data displays fine apart from I can’t get the column labels to print. It just generically calls them R1 for row 1, R2 for row 2, etc. I want them to display the actual figures (in this case week numbers.) I’ve tried this command “MSChart1.RowLabel = rs.Fields(0)” and although MSChart1.RowLabel gets populated with the correct data, the graph ignores it when it displays and puts the R1, R2, etc back!

Any ideas?

rs.Open DEInstance2.Commands("cmdGraphDataRetrieve").Execute
rs.MoveFirst

If Not rs.EOF Then
lngCount = rs.RecordCount
ReDim arrData(lngCount - 1, 1)
With MSChart1 'setup chart dynamics
.ShowLegend = False
.Title = "Chart”
.FootnoteText = "Print date: " & Now()
.ChartType = VtChChartType2dBar
End With

For a = 0 To 1 'fill the array by looping through the recordset, a corresponds to cols
rs.MoveFirst
For b = 0 To lngCount - 1 'b corresponds to rows
arrData(b, a) = rs(a)
rs.MoveNext
Next b
Next a

MSChart1.ChartData = arrData 'set chart data to array

With MSChart1.Plot 'add titles to the axes
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Week Number"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Time Taken (Days)"
End With

End If
rs.Close 'close the recordset object and destroy the instance
Set rs = Nothing
Yada yada…


Thanks
Andrew
 
hhmm. I've been doing some tests and it seems that my data source for the chart is to blame somewhat.

If the X-axis data is built up from text i.e. "week 1", "week 2", etc then the labels print fine. If it is built up from numbers they don't print. I don't know why but that seems to be the case.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top