1ページに複数のグラフがありますが、実行すると次のエラーが発生します。
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.
チャートを1つだけ保持すれば、それは幸せです。どうすればこれを修正できますか?これが私のコードです:
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);
}
ASPXコード:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<div>
<% =CreateChart() %>
</div>
<div>
<% =CreateChart_2() %>
</div>
</asp:Content>
私はすべてを試しましたが、これまでのところ解決策は見つかりませんでした。