0
我有我試圖與一些從一個SqlDataSource一系列動態填充圖表控件,這裏是我的圖表控件:綁定點
<asp:Chart ID="chartMonthly" runat="server" Width="920px" ImageLocation="~/Images/Temp/ChartPic_#SEQ(300,3)" Palette="Berry">
<ChartAreas>
<asp:ChartArea Name="line"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
而這裏的我如何動態地添加系列指出:
Private Sub chartMonthly_DataBinding(sender As Object, e As System.EventArgs) Handles chartMonthly.DataBinding
Dim conStr As String = ConfigurationManager.ConnectionStrings("GenshenPOS").ConnectionString
Dim conn As New SqlConnection(conStr)
conn.Open()
Dim sqlPoints As New SqlCommand("SELECT [m] AS [月], [Store] AS [門市], SUM([amount]) AS [NTD] FROM vwMonthly WHERE [y] = " & dropYear.SelectedValue & " GROUP BY [m], [Store]", conn)
Dim reader As SqlDataReader = sqlPoints.ExecuteReader()
While reader.Read()
If chartMonthly.Series.IndexOf(reader.Item("門市")) = -1 Then
chartMonthly.Series.Add(reader.Item("門市"))
chartMonthly.Legends.Add(reader.Item("門市"))
chartMonthly.Series(reader.Item("門市")).ChartType = SeriesChartType.Line
chartMonthly.Series(reader.Item("門市")).ChartArea = "line"
End If
chartMonthly.Series(reader.Item("門市")).Points.AddXY("月", "NTD")
End While
conn.Close()
End Sub
圖表是基於他們正確地讀取存儲的名稱和創建系列,但我的圖表是空的數據 - 無軸具有值和該系列的線在底部走的圖表爲0 /空值。
我已經單獨運行了底層查詢,並且數據在那裏,並且我假定它看到數據,否則系列和傳說不會被創建,所以我假設我從添加點的方式該系列?!
Image of chart control with series but displaying no datapoints