Hey guys, Im trying to make a column chart using the purok and status column. How can you show the PWD and Pregnant as a bar with label and count also? thankyou in advance
The table name is PWDPregnant | columnName "status" is for PWD/Pregnant. | columnName "purok" is for Pepsi/Coke.
Dim dt As New DataTable
Using pwdcon As New OleDbConnection(con.ConnectionString),
cmd As New OleDbCommand("SELECT purok, status, COUNT(*) As RecCount FROM PWDPregnant GROUP BY purok, status ORDER BY purok", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Using reader = cmd.ExecuteReader
dt.Load(reader)
End Using
End Using
Chart5.Series("PWD").XValueMember = "purok"
Chart5.Series("PWD").YValueMembers = "status"
Chart5.Series("PWD").Label = "#AXISLABEL #VALY"
Chart5.Series("Pregnant").YValueMembers = "status"
Chart5.Series("Pregnant").Label = "#AXISLABEL #VALY"
Chart5.DataSource = dt.DefaultView
Chart5.DataBind()
Finally I found the fix but it still cant support the 2nd series which is Pregnant.
Dim dt As New DataTable
Using pwdcon As New OleDbConnection(con.ConnectionString),
cmd As New OleDbCommand("SELECT purok, status, COUNT (*) as RecCount FROM PWDPregnant WHERE status = @stat GROUP BY purok, status", con)
cmd.Parameters.Add("@stat", OleDb.OleDbType.VarChar).Value = "PWD"
If con.State = ConnectionState.Closed Then
con.Open()
End If
Using reader = cmd.ExecuteReader
dt.Load(reader)
End Using
End Using
Chart5.ChartAreas(0).AxisX.Interval = 1
Chart5.Series("PWD").XValueMember = "purok"
Chart5.Series("PWD").YValueMembers = "RecCount"
Chart5.Series("PWD").Label = "#VALY"
Chart5.DataSource = dt.DefaultView
Chart5.DataBind()