因为项目需要,需要使用FusionCharts进行导出.
下面就是自己写得例子.
这个是就是FusionCharts的Readme.txt中提示的导出步骤
FusionCharts服务器端输出处理程序- JSP的
============================================== ==============================================
For exporting the chart as image/pdf at server side using JSP, copy-paste the required files to your server
1. FCExporter.jsp
2. FCExporterError.jsp
3. fcexporter.jar
4. Resources/FCExporter_IMG.jsp
5. Resources/FCExporter_PDF.jsp
6. /Classes/fusioncharts_export.properties
----- -----
Please place the JSP in your web application, fcexporter.jar in WEB-INF/lib and fusioncharts_export.properties in WEB-INF/classes folder.
FusionCharts Exporter has been tested with Java 6. FusionCharts出口商已经过测试 , 与Java 6。
The exportHandler attribute should have value "{Path}/FCExporter.jsp".在exportHandler属性应具有的价值“(路径)/ FCExporter.jsp”。
Configuration of save folder for server-side save配置保存文件夹服务器端保存
我是把
1.FCExporterError.jsp FCExporter.jsp 还有测试的test.jsp放到了根目录下.
2.Resources/FCExporter_IMG.jspResources/FCExporter_PDF.jsp保持目录结果.复制到根目录下.
3.fusioncharts_export.properties 放到src下
4.fcexporter.jar放到lib目录下
5.test.jsp的写法
<html>
<script language="JavaScript" src="FusionCharts.js"></script>
<script type="text/javascript">
//当下载到客户端后,的回调函数
function FC_Exported(objRtn){
if (objRtn.statusCode=="1"){
alert("这个chart成功保存到服务端,这个文件可以从这个地址访问:" + objRtn.fileName);
}else{
alert("这个chart不能保存到服务端.这有一个错误:描述 : " + objRtn.statusMessage);
}
}
</script>
</head>
<body bgcolor="#ffffff">
<div id="chartdiv" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div>
<script type="text/javascript">
var myChart = new FusionCharts("Column2D.swf", "myChartId", "400", "300", "0", "1");
myChart.setDataURL("a.xml");
myChart.render("chartdiv");
</script>
</body>
</html>
注意:红色的部分需要注意路径
6.a.xml的写法
<chart yAxisName='Sales Figure' caption='Top 5 Sales Person' numberPrefix='$' useRoundEdges='1' bgColor='FFFFFF,FFFFFF' showBorder='0' exportEnabled='1' exportAtClient='0' exportAction='save' exportHandler='FCExporter.jsp'>
<set label='Alex' value='25000' />
<set label='Mark' value='35000' />
<set label='David' value='42300' />
<set label='Graham' value='35300' />
<set label='John' value='31300' />
</chart>
注意:FCExporter.jsp这个要根据自己的路径来写
这是我的测试目录
测试后的图,右键flash会多出4个选项.点击就可以导出了.