Chart Id is same as a JavaScript variable name error using Fusion Chart in ASP

Yudonomi

New Member
I have multiple charts in one page but I am getting this error when I run it:\[code\] Chart Id is same as a JavaScript variable name. Variable naming error. Please use unique name for chart JS variable, chart-id and container id.\[/code\]If I keep only one chart then it is happy. How can I fix this? here is my code:\[code\]public string CreateChart() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString); string sqlStatement = "SELECT Category, AvgNumbers FROM MyTable"; SqlCommand cmd = new SqlCommand(sqlStatement, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); string strXML; strXML = "<graph caption='Summary' subCaption='By Category' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"; while (reader.Read()) { strXML += "<set name='" + reader["Category"].ToString() + "' value='" + reader["AvgNumbers"].ToString() + "' />"; } strXML += "</graph>"; return FusionCharts.RenderChart("/FusionCharts/Pie3D.swf", "ChartID", strXML, "FactorySum", "650", "450", false, false); } protected string CreateChart_2() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString); string sqlStatement = "SELECT count (ID)as ID, cat_name FROM MainTable group by cat_name"; SqlCommand cmd = new SqlCommand(sqlStatement, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); string strXML1; strXML1 = "<graph caption='Summary' subCaption='By Cat' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"; while (reader.Read()) { strXML1 += "<set name='" + reader["cat_name"].ToString() + "' value='" + reader["ID"].ToString() + "' />"; } strXML1 += "</graph>"; return FusionCharts.RenderChart("/FusionCharts/Pie3D.swf", "MyChartID", strXML1, "FactorySum", "650", "450", false, false); }\[/code\]ASPX code:\[code\]<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <div> <% =CreateChart() %> </div> <div> <% =CreateChart_2() %> </div></asp:Content>\[/code\]I have tried everything but no solution found so far.
 
Back
Top