每日雕蟲一技[2013-02-18]玩转FusionCharts的客户端导出实现

using System;
using System.Data;
using System.Text;
using System.Data.Odbc;

namespace InfoSoftGlobal
{
	/// <summary>
	/// 扩展
	/// </summary>
	public partial class FusionCharts
	{
        /// <summary>
        /// 附带导出配置的呈现
        public static string RenderChartWithExport(string chartSWF, string strURL, string strXML, string chartId,
            string chartWidth, string chartHeight, bool debugMode, bool registerWithJS)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("<!-- START Script Block for Chart {0} -->" + Environment.NewLine, chartId);
            builder.AppendFormat("<div id='{0}Div' align='center'>" + Environment.NewLine, chartId);
            builder.Append("Chart." + Environment.NewLine);
            builder.Append("</div>" + Environment.NewLine);
            builder.Append("<script type=\"text/javascript\">" + Environment.NewLine);
            builder.AppendFormat("var chart_{0} = new FusionCharts(\"{1}\", \"{0}\", \"{2}\", \"{3}\", \"{4}\", \"{5}\");" + Environment.NewLine, chartId, chartSWF, chartWidth, chartHeight, boolToNum(debugMode), boolToNum(registerWithJS));
            if (strXML.Length == 0)
            {
                builder.AppendFormat("chart_{0}.setDataURL(\"{1}\");" + Environment.NewLine, chartId, strURL);
            }
            else
            {
                builder.AppendFormat("chart_{0}.setDataXML(\"{1}\");" + Environment.NewLine, chartId, strXML);
            }


            builder.AppendFormat("chart_{0}.render(\"{1}Div\");" + Environment.NewLine, chartId, chartId);
            
            //客户端导出配置
            builder.Append(" var myExportComponent = new FusionChartsExportObject(\"fcExporter1\",\"FusionCharts/FCExporter.swf\");" + Environment.NewLine); 
            builder.Append(" myExportComponent.componentAttributes.btnColor = 'EAF4FD';"+Environment.NewLine);
            builder.Append(" myExportComponent.componentAttributes.btnBorderColor = '0372AB';"+Environment.NewLine);
            builder.Append(" myExportComponent.componentAttributes.btnFontFace = 'Verdana';"+Environment.NewLine);
            builder.Append(" myExportComponent.componentAttributes.btnFontColor = '0372AB';"+Environment.NewLine);
            builder.Append(" myExportComponent.componentAttributes.btnFontSize = '12'; " + Environment.NewLine);
            builder.Append(" myExportComponent.componentAttributes.btnsavetitle = 'Save the chart';" + Environment.NewLine);
            builder.Append(" myExportComponent.componentAttributes.btndisabledtitle = 'Waiting for export';  " + Environment.NewLine);
            builder.Append(" myExportComponent.Render(\"exproterDiv\");" + Environment.NewLine);
            
            
            builder.Append("</script>" + Environment.NewLine);
            builder.AppendFormat("<!-- END Script Block for Chart {0} -->" + Environment.NewLine, chartId);
            return builder.ToString();
        }

	}
}
1.要素1: <script LANGUAGE="Javascript" SRC="FusionCharts/FusionChartsExportComponent.js"></script>
2.要素2: <div id="exproterDiv" align="center">导  出</div>  <!--警示:该div必须出现在myExportComponent.Render()语句之前-->

3. 要素3: exportEnabled='1' exportFormats='PNG=导出为PNG|JPG=导出为JPG|PDF=导出为PDF' exportAtClient='1' exportHandler='fcExporter1'

4.要素4: 

          new FusionChartsExportObject 中的id必须和exportHandler='fcExporter1'中的handlerId相同



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值