?
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 { /// <summary> /// Author:jilongliang /// </summary> public partial class index : System.Web.UI.Page { protected void Page_Load (object sender, EventArgs e) { } /// <summary> /// 直接在控件加载出来 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Literal1_Load (object sender, EventArgs e) { Literal1.Text = FusionCharts.RenderChart("swf/ScrollCombiDY2D.swf", "fusioncharts.xml", "", "fusioncharts1", "500", "500", false, true); } /// <summary> /// 用户输入显示的图形fusioncharts /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click (object sender, EventArgs e) { //Request.Form() //Label1.Text = Request["ponit1"]; StringBuilder xmlData = new StringBuilder(); xmlData.Append("<chart caption='报表' subCaption='报表' showPercentValues='1' pieSliceDepth='30' showBorder='1'>"); xmlData.AppendFormat("<set label='Java' value='{0}' />", txtPoint1.Text); //txtPoint1.Text xmlData.AppendFormat("<set label='asp.net' value='{0}' />", txtPoint2.Text); xmlData.AppendFormat("<set label='C++' value='{0}' />", txtPoint3.Text); xmlData.AppendFormat("<set label='Android' value='{0}' />", txtPoint4.Text); xmlData.Append("</chart>"); Literal1.Text = FusionCharts.RenderChart("swf/Pie3D.swf", "", xmlData.ToString(), "fusioncharts2", "800", "500", false, false); } /// <summary> /// 从数据库读数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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)) { //<chart caption='某公司部门报表数据显示' xAxisName='Teams' yAxisName='Points' showValues='0' formatNumberScale='0' showBorder='0'> xmlData.AppendFormat("<chart caption='某公司报表数据显示'>"); while(dr.Read()) { xmlData.AppendFormat("<set label='{0}' value='{1}'/>", dr ["Team"].ToString(), dr ["Points"].ToString()); } xmlData.AppendFormat("</chart>"); Literal2.Text = FusionCharts.RenderChart("swf/Column3D.swf", "", xmlData.ToString(), "testChart", "500", "500", false, true); } } /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void test2_Click (object sender, EventArgs e) { string str1=Request ["ponit1"]; Label1.Text=str1; StringBuilder xmlData = new StringBuilder(); xmlData.Append("<chart caption='报表' subCaption='报表' showPercentValues='1' pieSliceDepth='30' showBorder='1'>"); xmlData.AppendFormat("<set label='Java' value='{0}' />", txtPoint1.Text); //txtPoint1.Text xmlData.AppendFormat("<set label='asp.net' value='{0}' />", txtPoint2.Text); xmlData.AppendFormat("<set label='C++' value='{0}' />", txtPoint3.Text); xmlData.AppendFormat("<set label='Android' value='{0}' />", txtPoint4.Text); xmlData.Append("</chart>"); Literal1.Text = FusionCharts.RenderChart("swf/Pie3D.swf", "", xmlData.ToString(), "fusioncharts2", "800", "500", false, false); } protected void test2_Click1 (object sender, EventArgs e) { } } }
?
fusionchart.xml配置
?
?
?
<chart caption='Sales Volume' PYAxisName='Revenue' SYAxisName='Quantity' showvalues= '0' numberPrefix='$' numVisiblePlot='8'
?useRoundEdges='1' palette='4'>
? <!--paletteColors='FF0000,0372AB,FF5904'-->
? <categories color='0372AB' fontColor='FF0000' boldfont='112'>
? ? <category label='Jan' ?/>
? ? <category label='Mar' />
? ? <category label='Apr' />
? ? <category label='May' />
? ? <category label='Jun' />
? ? <category label='Jul' />
? ? <category label='Aug' />
? ? <category label='Sep' />
? ? <category label='Oct' />
? ? <category label='Nov' />
? ? <category label='Dec' />
? </categories>
? <!--anchorBgColor 更改点的背景颜色.Color是更改线的颜色 060606-->
? <dataset seriesName='Quantity(质量)' parentYAxis='S'>
? ? <set value='340'/>
? ? <set value='120' />
? ? <set value='280' />
? ? <set value='270' />
? ? <set value='430' />
? ? <set value='240' />
? ? <set value='230' />
? ? <set value='310' />
? ? <set value='430' />
? ? <set value='180' />
? ? <set value='260' />
? ? <set value='200' />
? </dataset>
? <dataset seriesName='Produce(产品)' parentYAxis='S'>
? ? <set value='140' />
? ? <set value='220' />
? ? <set value='280' />
? ? <set value='280' />
? ? <set value='330' />
? ? <set value='250' />
? ? <set value='230' />
? ? <set value='310' />
? ? <set value='240' />
? ? <set value='180' />
? ? <set value='360' />
? ? <set value='400' />
? </dataset>
? <dataset seriesName='Revenue(税收)'>
? ? <set value='1700000' />
? ? <set value='610000' />
? ? <set value='1420000' />
? ? <set value='1350000' />
? ? <set value='2140000' />
? ? <set value='1210000' />
? ? <set value='1130000' />
? ? <set value='1560000' />
? ? <set value='2120000' />
? ? <set value='900000' />
? ? <set value='1320000' />
? ? <set value='1010000' />
? </dataset>
? <styles>
? ? <definition>
? ? ? <style name='myBevel' type='Bevel' angle='0' />
? ? ? <style name='myShadow' type='Shadow' distance='5' angle='45'/>
? ? </definition>
? ? <application>
? ? ? <apply toObject='Canvas' styles='myBevel,myShadow' />
? ? </application>
? </styles>
? <trendlines>
? ? <line startValue='Revenue(税收)' color='91C728' displayValue='Target' showOnTop='1'/>
? </trendlines>
</chart>
?
?
?
?
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace MYASP
{
? ? public class SQLDBHelper
? ? {
? ? ? ? static string str = ConfigurationManager.ConnectionStrings["SqlCon"].ToString();
? ? ? ? /// <summary>
? ? ? ? /// 增 删 改方法
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <returns></returns>
? ? ? ? public static int ExecuteNonQuery(CommandType cmdType, string sql, SqlParameter[] parms)
? ? ? ? {
? ? ? ? ? ? int result = -1;
? ? ? ? ? ? using (SqlConnection con = new SqlConnection(str))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SqlCommand cmd = new SqlCommand();
? ? ? ? ? ? ? ? PrepareSQLCommand(cmdType, sql, parms, con, cmd);
? ? ? ? ? ? ? ? result = cmd.ExecuteNonQuery();
? ? ? ? ? ? }
? ? ? ? ? ? return result;
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 提取共同方法
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <param name="con"></param>
? ? ? ? /// <param name="cmd"></param>
? ? ? ? private static void PrepareSQLCommand(CommandType cmdType, string sql, SqlParameter[] parms, SqlConnection con, SqlCommand cmd)
? ? ? ? {
? ? ? ? ? ? cmd.Connection = con;
? ? ? ? ? ? if (con.State != ConnectionState.Open)
? ? ? ? ? ? ? ? con.Open();
? ? ? ? ? ? cmd.CommandText = sql;
? ? ? ? ? ? cmd.CommandType = cmdType;
? ? ? ? ? ? if (parms != null)
? ? ? ? ? ? ? ? foreach (SqlParameter parm in parms)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? cmd.Parameters.Add(parm);
? ? ? ? ? ? ? ? }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 查询
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <returns></returns>
? ? ? ? public static SqlDataReader ExecuteReader(CommandType cmdType, string sql, SqlParameter[] parms)
? ? ? ? {
? ? ? ? ? ? SqlConnection con = new SqlConnection(str);
? ? ? ? ? ? SqlCommand cmd = new SqlCommand();
? ? ? ? ? ? PrepareSQLCommand(cmdType, sql, parms, con, cmd);
? ? ? ? ? ? SqlDataReader reader = cmd.ExecuteReader();
? ? ? ? ? ? return reader;
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 读取单个值
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <returns></returns>
? ? ? ? public static int ExecuteScalar(CommandType cmdType, string sql, SqlParameter[] parms)
? ? ? ? {
? ? ? ? ? ? int result = -1;
? ? ? ? ? ? //连接数据库
? ? ? ? ? ? using (SqlConnection con = new SqlConnection(str))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? //执行
? ? ? ? ? ? ? ? SqlCommand cmd = new SqlCommand();
? ? ? ? ? ? ? ? PrepareSQLCommand(cmdType, sql, parms, con, cmd);
? ? ? ? ? ? ? ? result = (int)cmd.ExecuteScalar();
? ? ? ? ? ? ? ? return result;
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
?
?
?
--创建用户信息表
create database test;
create table log4j
(
id int identity(1,1) not null primary key,?
stamp varchar(10)not null, ? ?
thread varchar(30)not null, ? ? ?
clazz varchar(15)not null,
infoLevel varchar(15)not null,
message varchar(250)?
)
insert ?into log4j values('dddddd','aaaaa','dsfdfsfs','fdsffas');
create table ?tb_charts
(
?team varchar(50),
?Points varchar(50)
)?
insert into tb_charts values('Java','33');
insert into tb_charts values('C++','33');
insert into tb_charts values('Android','33');
insert into tb_charts values('PHP','33');
insert into tb_charts values('C#,ASP.NET','33');
insert into tb_charts values('Oracle','33');
insert into tb_charts values('F','33');
select * from tb_charts;
?
?
?
?
?
?
?
?
?
?
源代码:http://download.csdn.net/detail/l_ji_l/4336918