aspx.cs:
#region 组合(子节点)set
private string setstr = ""; /// <summary> /// fc3 拼的 set 的xml字符串: 例如 x轴 label就显示 李文,y轴 value就显示 60(销售量) /// </summary> /// <param name="label">显示轴下的字</param> /// <param name="value">显示轴对应的数字</param> private void AddSetStr(string label, int value) { setstr += string.Format("<set label='{0}' value='{1}'/>", label, value); } #endregion#region 组合(父节点)chart
private string chartstr = ""; /// <summary> /// fc3 拼的 chart 的xml字符串 /// </summary> /// <param name="caption">图标的标题</param> /// <param name="xname">X轴</param> /// <param name="yname">Y轴</param> /// <param name="showvalue">是否显示轴上的数字(0不显示,1显示)</param> private void AddChartStr(string caption, string xname, string yname, string showvalue) { chartstr = "<chart caption='" + caption + "' xAxisName='" + xname + "' yAxisName='" + yname + "' showValues='" + showvalue + "' formatNumberScale='0' useRoundEdges='0' baseFont='宋体' baseFontSize='16'>"; chartstr += setstr; chartstr += "</chart>"; } #endregion// 查询数据库的数据
SaleCountService service = new SaleCountService(); private string username; // 用户名 private int number; // 销售量/// <summary>
/// 创建图形 /// </summary> /// <param name="caption">图标的标题</param> /// <param name="xname">X轴</param> /// <param name="yname">Y轴</param> /// <param name="showvalue">是否显示轴上的数字(0不显示,1显示)</param> /// <returns></returns> public string CreateChart(string flash,string caption, string xname, string yname, string showvalue) { DataTable dt = service.GetSaleCount(); for (int i = 0; i < dt.Rows.Count; i++) { username = dt.Rows[i]["username"].ToString(); number = Convert.ToInt32(dt.Rows[i]["number"]); AddSetStr(username, number); } AddChartStr(caption, xname, yname, showvalue); //创建图表-质谱柱线组合三维图的数据载于strXML return FusionCharts.RenderChart("fc3/charts/" + flash, "", chartstr, "", "780", "330", false, false); }aspx:
<script src="fc3/FusionCharts-up.js" type="text/javascript"></script>
</head><body> <form id="form1" runat="server"> <div> <%=CreateChart("VLED.swf", "Emmy测试图--VLED.swf", "用户名", "销售量", "1")%> </div>...
图形上显示的数据都是2维的哦!!!!
以上就是我截的2维数据运用的图形了。