效果:
说明:此效果只是简单的嵌套flash读取数据库中某两个字段的数据。(【js下载地址:http://163.fm/L6X8OAe 提取码:)
事件:初始化加载。
代码部分:
HTML:
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head runat="server"> 3 <title></title> 4 <script src="flash/FusionCharts.js"type="text/javascript"></script> 5 </head> 6 <body> 7 <form id="form1" runat="server"> 8 <div> 9 <table width="920" align="center" border="0" cellspacing="0" cellpadding="0" id="flash"> 10 <tr> 11 <td> 12 <div id="flashGO" style="width: 900px; border: 1px #ccc solid;"> 13 </div> 14 </td> 15 </tr> 16 </table> 17 </div> 18 </form> 19 20 <script type="text/javascript"> 21 getchart('flash/Column3D.swf'); 22 function getchart(str) { 23 var chart = new FusionCharts(str, "ChartId", "900", "400"); 24 chart.setDataXML('<?xml version="1.0" encoding="UTF-8" ?>'+ 25 '<chart caption="青苹果数据分析" bgColor="#ffffff" xAxisName="试验室检测项目" yAxisName="总条数"' + 26 ' numberPrefix="" sformatNumberScale="1" syncAxisLimits="10" rotateValues="0" showSum="0" baseFontSize="12">' + 27 /***生成柱状图*************************************************/ 28 <%=flash %> 29 /************************************************************/ 30 '</chart>'); 31 chart.render("flashGO"); 32 } 33 </script> 34 35 </body> 36 </html>
后台:
1 namespace qiantaoflash 2 { 3 public partial class _Default : System.Web.UI.Page 4 { 5 SqlConnection con = new SqlConnection("server=NEWSPRING;database=QG_Mis;uid=sa;pwd=pass@word1"); 6 protected void Page_Load(object sender, EventArgs e) 7 { 8 GetData(); 9 } 10 public string flash = string.Empty; 11 protected void GetData() 12 { 13 string sql = string.Format(@"SELECT TOP 30 * FROM ly_tzk"); 14 DataSet ds = new DataSet(); 15 SqlDataAdapter sda = new SqlDataAdapter(sql, con); 16 sda.Fill(ds); 17 foreach (DataRow dr in ds.Tables[0].Rows) 18 { 19 flash += "'<set label=" + '"' + dr["xmmc"].ToString() + '"' + "value=" + '"' + dr["MenuID"].ToString() + '"' + "/>'+"; 20 } 21 } 22 } 23 }