heypcguy Report post Posted March 18, 2008 Hi all, I'm having issues with Multi Series Charts when pulling data from a database, I've been through the examples and have stepped through this code a 1000 times since yesterday, but I can't figure out why I'm not getting any data. The chart displays, buts it has not data. No errors, just no data. This is what I'm trying to use, if anybody has any ideas it would be greatly appreciated. Public Function ComputerInventory() As String Dim xmlData As New StringBuilder() Dim categories As New StringBuilder() Dim peopleTotal As New StringBuilder() Dim computerTotal As New StringBuilder() xmlData.Append("<chart caption='Computer Inventory' showLabes='1' >") categories.Append("<categories>") computerTotal.Append("<dataset seriesName='Computer Total'>") peopleTotal.Append("<dataset seriesName='People Total'>") Dim conn As SqlConnection Dim comm As SqlCommand Dim rdr As SqlDataReader Dim connString As String = ConfigurationManager.ConnectionStrings("DPS").ConnectionString conn = New SqlConnection(connString) comm = New SqlCommand("test", conn) conn.Open() Dim ArraySize As Integer = 11 Dim arrData(ArraySize, 2) As String rdr = comm.ExecuteReader() Dim u As Integer = 0 While (rdr.Read And u < ArraySize) arrData(u, 0) = rdr("period") arrData(u, 1) = rdr("comp") arrData(u, 2) = rdr("fte") u += 1 End While rdr.Close() conn.Close() Dim i As Integer = 0 For i = arrData.GetLowerBound(0) To arrData.GetUpperBound(0) categories.Append("<category name= '" & arrData(u, 0) & "' />") computerTotal.Append("<set value='" & arrData(u, 1) & "' />") peopleTotal.Append("<set value='" & arrData(u, 2) & "' />") Next categories.Append("</categories>") computerTotal.Append("</dataset>") peopleTotal.Append("</dataset>") xmlData.Append(categories.ToString() & computerTotal.ToString() & peopleTotal.ToString()) xmlData.Append("</chart>") Return FusionCharts.RenderChart("FusionCharts/MSColumn3D.swf", "", xmlData.ToString(), "computerinventory", "600", "300", False, False) End Function Share this post Link to post Share on other sites
heypcguy Report post Posted March 18, 2008 Never mind... I figured out what was wrong. Mostly user error, shouldn't be working on this stuff when I'm half asleep. Share this post Link to post Share on other sites
Arindam Report post Posted March 19, 2008 Hi, You have a program error in for loop. It seems that you are usin u intead of i. could you please try using this correct code For i = arrData.GetLowerBound(0) To arrData.GetUpperBound(0) categories.Append("<category name= '" & arrData(i, 0) & "' />") computerTotal.Append("<set value='" & arrData(i, 1) & "' />") peopleTotal.Append("<set value='" & arrData(i, 2) & "' />") Next Also could you try this trimmed but efficient code if you want too ================================================================== Public Function ComputerInventory() As String Dim xmlData As New StringBuilder() Dim categories As New StringBuilder() Dim peopleTotal As New StringBuilder() Dim computerTotal As New StringBuilder()xmlData.Append( "<chart caption='Computer Inventory' showLabes='1' >")categories.Append( "<categories>")computerTotal.Append( "<dataset seriesName='Computer Total'>")peopleTotal.Append( "<dataset seriesName='People Total'>") Dim conn As SqlConnection Dim comm As SqlCommand Dim rdr As SqlDataReader Dim connString As String = ConfigurationManager.ConnectionStrings("DPS").ConnectionStringconn = New SqlConnection(connString)comm = New SqlCommand("test", conn)conn.Open() '''' Requires SQL rdr = comm.ExecuteReader() While (rdr.Read)categories.Append( "<category name= '" & rdr("period").ToString() & "' />")computerTotal.Append( "<set value='" & rdr("comp").ToString() & "' />")peopleTotal.Append( "<set value='" & rdr("fte").ToString() & "' />") End Whilerdr.Close() conn.Close() categories.Append( "</categories>")computerTotal.Append( "</dataset>")peopleTotal.Append( "</dataset>")xmlData.Append(categories.ToString() & computerTotal.ToString() & peopleTotal.ToString()) xmlData.Append( "</chart>") Return FusionCharts.RenderChart("FusionCharts/MSColumn3D.swf", "", xmlData.ToString(), "computerinventory", "600", "300", False, False) End Function Share this post Link to post Share on other sites