tommyready
Member
- Joined
- Jul 1, 2009
- Messages
- 23
- Programming Experience
- 3-5
Hi,
I'm using MSCHART to create a bar graph from some simple data I'm pulling from SQL server. The data gets added to an array and I want to use that data to populate the chart. I can get the data no problem, and I can get it in the chart. I just cant figure out how to tell what data to go where.
Here is my code:
In the plot area Is where taskcount should go, then each employee should have enddate grouped together.
I'm using MSCHART to create a bar graph from some simple data I'm pulling from SQL server. The data gets added to an array and I want to use that data to populate the chart. I can get the data no problem, and I can get it in the chart. I just cant figure out how to tell what data to go where.
Here is my code:
VB.NET:
Private Sub fillChart()
cn = New ADODB.Connection
mfChartData.ToDefaults()
' Establish the connection using the connection string.
cn.ConnectionString = "Provider=SQLOLEDB.1;Password=xxxxx;" & _
"Persist Security Info=True; User ID=sa;" & _
"Initial Catalog=medforcescan; Data Source=xx.x.x.x"
' Open the connection.
cn.Open()
Dim strQuery As String ' SQL query string.
strQuery = "SELECT * FROM vwTaskByEmployeePerMonth"
rsTaskCount = New ADODB.Recordset
' Open the recordset.
rsTaskCount.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rsTaskCount.Open(strQuery, cn, ADODB.CursorTypeEnum.adOpenKeyset)
Dim chrtarr(0 To rsTaskCount.RecordCount, 0 To 3)
mfChartData.ShowLegend = True
mfChartData.chartType = MSChart20Lib.VtChChartType.VtChChartType2dArea
'relate array to the recordset returned
For X = 1 To rsTaskCount.RecordCount
chrtarr(X, 1) = rsTaskCount("Employee")
chrtarr(X, 2) = rsTaskCount("TaskCount")
chrtarr(X, 3) = rsTaskCount("EndDate")
rsTaskCount.MoveNext()
Next X
'feed chart from this array
With mfChartData
.ChartData = chrtarr
.ColumnCount = 3
.ColumnLabelCount = 1
.Column = 1
End With
End Sub
In the plot area Is where taskcount should go, then each employee should have enddate grouped together.