dataAccess

Chart does not appear in my ASP.NET page!

Recommended Posts

Hi, the chart does not appear in my page, I spent 2 hours on this but failed, I doubled check the paths to the Fusionchart.js and the path to Oie3D.swf they both correct. The following is my code:

In the front page I included the name of the function:

<%

=GetEmpChartHtml()%>

and here is the body of the function in the code behind:

Public Function GetEmpChartHtml() As String

'xmlData will be used to store the entire XML document generated

Dim xmlData As New StringBuilder()

'Generate the chart element

xmlData.Append(

"<chart caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' Units'>")

Dim strConnection As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString

Dim objConnection As New SqlConnection(strConnection)

Dim strSQL As String = "SELECT Emp_Name, id FROM employee;"

Dim objCommand As New SqlCommand(strSQL, objConnection)

Try

If objConnection.State = 0 Then _

objConnection.Open()

Dim dr As SqlDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)

If dr.HasRows() Then

While dr.Read()

xmlData.Append(

"<set label='" & dr.Item("Emp_Name").ToString() & "' value='" & dr.Item("ID").ToString() & "' />")

End While

End If

dr.Close()

Catch e As Exception

Finally

objConnection.Close()

End Try

'

'Close chart element

xmlData = xmlData.Append(

"</chart>")

'Create the chart - Pie 3D Chart with data from xmlData

Return InfoSoftGlobal.FusionCharts.RenderChart("../../Charts/Pie3D.swf", "", xmlData.ToString, "FactorySum", "600", "300", False, False)

End Function Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

  Could you please tell us whether chart appears white or given some error on page? Also I found one error in your program please rectify it and test again.

'Close chart element

xmlData = xmlData.Append("</chart>")

 Change to:

xmlData.Append("</chart>")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now