在Asp.Net上使用fusionchart报表 图解

阅读更多

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InfoSoftGlobal;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace MYASP
{
	/// 
	/// Author:jilongliang
	/// 
	public partial class index : System.Web.UI.Page
	{
		protected void Page_Load (object sender, EventArgs e)
		{
		}
		/// 
		/// 直接在控件加载出来
		/// 
		/// 
		/// 
		protected void Literal1_Load (object sender, EventArgs e)
		{
            Literal1.Text = FusionCharts.RenderChart("swf/ScrollCombiDY2D.swf",
			 "fusioncharts.xml", "", "fusioncharts1", "500", "500", false, true);
		}
		/// 
		/// 用户输入显示的图形fusioncharts
		/// 
		/// 
		/// 
		protected void btnSubmit_Click (object sender, EventArgs e)
		{
			//Request.Form() 
			//Label1.Text = Request["ponit1"];
			StringBuilder xmlData = new StringBuilder();
			xmlData.Append("");
			xmlData.AppendFormat("", txtPoint1.Text); //txtPoint1.Text
			xmlData.AppendFormat("", txtPoint2.Text);
			xmlData.AppendFormat("", txtPoint3.Text);
			xmlData.AppendFormat("", txtPoint4.Text);
			xmlData.Append("");
			Literal1.Text = FusionCharts.RenderChart("swf/Pie3D.swf", "", xmlData.ToString(), "fusioncharts2", "800", "500", false, false);
		}

		/// 
		/// 从数据库读数据
		/// 
		/// 
		/// 
		protected void Literal2_Load (object sender, EventArgs e)
		{
			string query = "select Team ,Points from tb_charts";

			StringBuilder xmlData = new StringBuilder();
			using(SqlDataReader dr = SQLDBHelper.ExecuteReader(CommandType.Text, query, null))
			{
				//

				xmlData.AppendFormat("");
				while(dr.Read())
				{
					xmlData.AppendFormat("", dr ["Team"].ToString(), dr ["Points"].ToString());
				}
				xmlData.AppendFormat("");
				Literal2.Text = FusionCharts.RenderChart("swf/Column3D.swf", "", xmlData.ToString(), "testChart", "500", "500", false, true);
			}
		}
		/// 
		/// 
		/// 
		/// 
		/// 
		protected void test2_Click (object sender, EventArgs e)
		{
            string str1=Request ["ponit1"];
            Label1.Text=str1;

			StringBuilder xmlData = new StringBuilder();
			xmlData.Append("");
			xmlData.AppendFormat("", txtPoint1.Text); //txtPoint1.Text
			xmlData.AppendFormat("", txtPoint2.Text);
			xmlData.AppendFormat("", txtPoint3.Text);
			xmlData.AppendFormat("", txtPoint4.Text);
			xmlData.Append("");
			Literal1.Text = FusionCharts.RenderChart("swf/Pie3D.swf", "", xmlData.ToString(), "fusioncharts2", "800", "500", false, false);
		}

        protected void test2_Click1 (object sender, EventArgs e)
        {

        }
	}
}

 

fusionchart.xml配置