在每个 purok(x 轴)中显示 PWD(y 轴)的数量

Displaying number of PWD(y-axis) in every purok(x-axis)

Desired chart

Current chart

大家好,我正在尝试使用 purok 和状态列制作柱形图。您如何将 PWD 和 Pregnant 显示为带有标签和计数的条形图?提前谢谢你

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()

我终于找到了修复程序,但它仍然无法支持怀孕的第二个系列。

                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()