asp.net使用fusioncharts

一、在前台页面创建一个Literal
        <asp:Literal ID="Literal1" runat="server"></asp:Literal>
二、写一个方法:
  public static string CreateChart(string strQuery, string title,string style)
        {
            string strXML;
            SqlDataReader dr = SQLDAL.DBHelper.GetReader(strQuery);
            strXML = "<graph caption='" + title + "' subCaption='' decimalPrecision='0' showNames='1' numberSuffix='' pieSliceDepth='30'  formatNumberScale='0' baseFontSize='12' >";
            while (dr.Read())
            {
                strXML += "<set name='" + dr[0].ToString() + "' value='" + dr[1].ToString() + "'/>";
            }
            strXML += "</graph>";
            dr.Close();
            return FusionCharts.RenderChart("FusionCharts/" + style , "", strXML, "图表分析", "650", "600", false, false);
        }
三、后台:
        Literal1.Text = SQLDAL.DBHelper.CreateChart("select  *** from ***", "数据图表分析", "FCF_Doughnut2D.swf");

你可能感兴趣的:(asp.net,生成图表)