使用多个系列在ASP图表中显示MySQL查询

时间:2015-01-08 08:49:40

标签: mysql asp.net vb.net series

我有这张桌子。 https://www.dropbox.com/s/7xf6ibn5mr9f9yf/test4.PNG?dl=0

基本上,我想使用多个系列(看起来像这样 - https://www.dropbox.com/s/v15pp818tmgf8co/test5.PNG?dl=0)和COUNT(AttendDet_Type)作为y轴显示“AttendDet_Type”,即P,A和MC作为x轴

我设法使用asp图表显示P的AttendDet_Type,但我完全不知道如何编写多个系列来显示A和MC。任何人都可以帮助我吗?

我的ASP代码

<asp:Chart ID="Chart1" runat="server" SqlDataSourceID="SqlDataSource1" Width="800" Height="500">
            <Titles>
                <asp:Title Text = "Attendance Report"></asp:Title>
            </Titles>
            <Series>
                <asp:Series Name="Series1">
                </asp:Series>
                <asp:Series ChartArea="ChartArea1" Name="Series2">
                </asp:Series>
                <asp:Series ChartArea="ChartArea1" Name="Series3">
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1" >
                </asp:ChartArea>
            </ChartAreas>

我的VB代码

Using con As New MySqlConnection(ConfigurationManager.ConnectionStrings("ConString").ConnectionString)
            Dim CmdString As String = "SELECT Attendance.AttendDet_Type, COUNT(Attendance.AttendDet_Type) AS TotalAttendance FROM Student, Attendance WHERE Student.Stud_ID = Attendance.Stud_ID AND Student.Stud_Class = '1A1' AND Attendance.Attend_Date = '2014-11-12' AND AttendDet_Type = 'P'"
            Dim sda As New MySqlDataAdapter(CmdString, con)
            Dim ds As New DataSet()
            sda.Fill(ds)
            Chart1.DataSource = ds
            Chart1.Series("Series1").XValueMember = "AttendDet_Type"
            Chart1.Series("Series1").YValueMembers = "TotalAttendance"
            Chart1.DataBind()
        End Using

期待收到你的回复。谢谢!

0 个答案:

没有答案