FusionCharts破解版导出图片步骤

1,加入jar包(fcexporter.jarfcexporthandler.jar ),FCExporter.swf,FusionChartsExportComponent.js

2,拷贝文件FCExporter.php到

WebContent/jsp/ExportHandlers/PHP/FCExporter.php

3,web.xml加入servlet

	<servlet>
		<display-name>FCExporter</display-name>
		<servlet-name>FCExporter</servlet-name>
		<servlet-class>com.fusioncharts.exporter.servlet.FCExporter</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>FCExporter</servlet-name>
		<url-pattern>/jsp/ExportHandlers/PHP/FCExporter</url-pattern>
	</servlet-mapping>


servlet的url-pattern和上面的文件FCExporter.php路径要一致,去掉后缀.php

4,加入配置文件fusioncharts_export.properties,放在claess路径下(最后到工程的WEB-INF\classes下就对了,里面的属性自己看着改)

#Please specify the path to a folder with write permissions relative to web application root
#SAVEPATH=./tempphoto/
SAVEPATH=./tempExport/
#Please specify the path to a folder with write permissions relative to web application root
#the folder where exported charts will be saved. 
#the folder where exported charts will be saved. 
#in this constant e.g., http://www.yourdomain.com/images/
#HTTP_URI=http://lsy.helpdesk.citicsinfo.com/tempphoto/
HTTP_URI=http://lsy.helpdesk.citicsinfo.com/tempExport/
#OVERWRITEFILE sets whether the export handler will overwrite an existing file 
#the newly created exported file. If it is set to false the export handler will
#not overwrite. In this case if INTELLIGENTFILENAMING is set to true the handler
#will add a suffix to the new file name. The suffix is a randomly generated UUID.
#Additionally, you can add a timestamp or random number as additional prefix.
OVERWRITEFILE=false
INTELLIGENTFILENAMING=true
FILESUFFIXFORMAT=TIMESTAMP


5,在报表的xml数据中药加入几个属性。

' exportEnabled="1" exportAtClient="0" exportAction="save"'
' exportHandler="http://lsy.helpdesk.citicsinfo.com/jsp/ExportHandlers/PHP/FCExporter"'
' exportCallback="myCallBackFunction" '

其中exportHandler="http://lsy.helpdesk.citicsinfo.com/jsp/ExportHandlers/PHP/FCExporter

是你刚才注册的servlet的请求路径,比如http://xxx:8080/aaa,这里我完整的请求就是上面的路径。

例子:

var dataString11 ='<chart caption="呼入总数 " palette="2" xAxisName="" '
	+'yAxisName="单位:个" formatNumberScale="0" numberPrefix="" '
	+'labeldisplay="ROTATE" slantLabels="1" sNumberSuffix=" pcs." showLabels="1" '
	+'showValues="1" '
	+' exportEnabled="1" exportAtClient="0" exportAction="save"'
	+' exportHandler="http://lsy.helpdesk.citicsinfo.com/jsp/ExportHandlers/PHP/FCExporter"'
	+' exportCallback="myCallBackFunction" '
	+'labelDisplay="STAGGER">\n\
	<set label="11" value="11" />\n\
	<styles>\n\
	<definition><style type="font" name="CaptionFont" size="15" color="666666" />\n\
	<style type="font" name="SubCaptionFont" bold="0" />\n\
	</definition><application>\n\
	<apply toObject="caption" styles="CaptionFont" />\n\
	<apply toObject="SubCaption" styles="SubCaptionFont" />\n\
	</application>\n\
	</styles>\n\
	</chart>';
var dataString12 ='<chart caption="呼入总数 222" palette="2" xAxisName="" '
	+'yAxisName="单位:个" formatNumberScale="0" numberPrefix="" '
	+'labeldisplay="ROTATE" slantLabels="1" sNumberSuffix=" pcs." showLabels="1" '
	+'showValues="1" '
	+' exportEnabled="1" exportAtClient="0" exportAction="save"'
	+' exportHandler="http://lsy.helpdesk.citicsinfo.com/jsp/ExportHandlers/PHP/FCExporter"'
	+' exportCallback="myCallBackFunction" '
	+'labelDisplay="STAGGER">\n\
	<set label="11" value="11" />\n\
	<styles>\n\
	<definition><style type="font" name="CaptionFont" size="15" color="666666" />\n\
	<style type="font" name="SubCaptionFont" bold="0" />\n\
	</definition><application>\n\
	<apply toObject="caption" styles="CaptionFont" />\n\
	<apply toObject="SubCaption" styles="SubCaptionFont" />\n\
	</application>\n\
	</styles>\n\
	</chart>';


6,页面调用。

<html>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%
	String path = request.getContextPath();
%>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <title>Single Series Column 2D Chart</title>
<script src="<%=path%>/script/jquery-1.7.1.js" type="text/javascript"></script>
<link href="<%=path%>/resource/hd/css/style2.css" rel="stylesheet" type="text/css" />


<link href="<%=path%>/script/plugin/FusionCharts_Evaluation/Gallery/assets/ui/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/script/plugin/FusionCharts_Evaluation/Gallery/assets/prettify/prettify.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="<%=path%>/script/plugin/FusionCharts_Evaluation/Charts/FusionCharts.js"></script>
<script type="text/javascript" src="<%=path%>/script/plugin/FusionCharts_Evaluation/Gallery/assets/ui/js/json2.js"></script>
<script type="text/javascript" src="<%=path%>/script/plugin/FusionCharts_Evaluation/Gallery/assets/prettify/prettify.js"></script>
<script type="text/javascript" src="<%=path%>/script/plugin/FusionCharts_Evaluation/Gallery/assets/ui/js/lib.js" ></script>
<script type="text/javascript" src="<%=path%>/script/plugin/FusionCharts_Evaluation/Charts/FusionChartsExportComponent.js" ></script>

<script src="<%=path%>/script/plugin/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

<script src="<%=path%>/resource/tool/hometab/Style/menu.js" type="text/javascript"></script>
<link rel="stylesheet" href="<%=path%>/resource/tool/hometab/Style/default.css" type="text/css" />
<script src="<%=path%>/script/hd/greenpage.js" type="text/javascript"></script>
<link rel="stylesheet" href="<%=path%>/script/hd/greenpage.css" type="text/css" />


<script type="text/javascript" src="<%=path%>/script/hd/greenpage.js"></script>
<link href="<%=path%>/script/hd/greenpage.css" rel="stylesheet" type="text/css" />


</head>

<body style=" overflow-y:scroll;">
<input type="hidden" id="path" value="<%=path%>" />

<div style="width:100%;height:10px"></div>
<h3 style="text-align: center;vertical-align:bottom;padding: 0px,0px,5px,0px; margin: 0px,0px,5px,0px; font-size:14px;color: #0c212b; ">
报表系统--呼入汇总</h3>

<div style="width:100%;"></div>
<div id="fcexpDiv" style="display:none;"  align="center">FusionCharts Export Handler Component</div>
<input type="button" value="sss" οnclick="ffgg()"/>

        <table  style="width:100%;align:center" border="0px" align="center">
           <tr>
              <td style="width:100%;align:center">
               <div id="chartdiv11" style="align:center" align="center"></div>
              </td>
              <td style="width:100%;align:center">
               <div id="chartdiv12" style="align:center" align="center"></div>
              </td>
           </tr>
        </table>


    </body>
 </html>
   <script type="text/javascript" src="temp/insum333.js" ></script>
        
<script type="text/javascript">
var path=document.getElementById("path").value;

if (GALLERY_RENDERER && GALLERY_RENDERER.search(/javascript|flash/i)==0)  FusionCharts.setCurrentRenderer(GALLERY_RENDERER); 


var chart11 = new FusionCharts("<%=path%>/script/plugin/FusionCharts_Evaluation/Charts/Column3D.swf", "ChartId11", "700", "400", "0", "0");
chart11.setXMLData(dataString11);
chart11.render("chartdiv11");

var chart12 = new FusionCharts("<%=path%>/script/plugin/FusionCharts_Evaluation/Charts/Column3D.swf", "ChartId12", "700", "400", "0", "0");
chart12.setXMLData(dataString12);
chart12.render("chartdiv12");


function myCallBackFunction(objRtn){
	if (objRtn.statusCode=="1"){
		alert("Haha!The chart was successfully saved on server. The file can be accessed from " + objRtn.fileName);
	}else{                 
		alert("Oh.The chart could not be saved on server. There was an error. Description : " + objRtn.statusMessage);              
	}
	
}
/*
function FC_Exported(objRtn){
	if (objRtn.statusCode=="1"){
		alert("FC_Exported--The chart was successfully saved on server. The file can be accessed from " + objRtn.fileName);
	}else{                 
		alert("FC_Exported--The chart could not be saved on server. There was an error. Description : " + objRtn.statusMessage);              
	}
	
}
*/
function ffgg(){
	var myExportComponent = new FusionChartsExportObject("fcExporter1", "../../../../script/plugin/FusionCharts_Evaluation/Charts/FCExporter.swf");
	
	//myExportComponent.sourceCharts = ['myChartId1','myChartId2','myChartId3'];
	myExportComponent.sourceCharts = ['ChartId11','ChartId12'];
	myExportComponent.componentAttributes.fullMode='1';
	myExportComponent.componentAttributes.saveMode='both';
	myExportComponent.componentAttributes.showAllowedTypes='0';
  //myExportComponent.componentAttributes.showAllowedTypes='1';
	myExportComponent.componentAttributes.width = '350';
	myExportComponent.componentAttributes.height = '140';
	myExportComponent.componentAttributes.showMessage = '1';
	myExportComponent.componentAttributes.message = 'Click on button above to begin export of charts. Then save from here.';
	myExportComponent.componentAttributes.defaultExportFileName = 'MyCharts';
	myExportComponent.componentAttributes.defaultExportFormat='JPG';// JPG, PNG or PDF
	
	
	myExportComponent.Render("fcexpDiv");
	
	myExportComponent.BeginExport();
	
	
}
</script>


看着挺多挺乱的。

其实有3点要说明。

<div id="fcexpDiv" style="display:none;" align="center">FusionCharts Export Handler Component</div>

这个div是到处时需要用的,方便用户选择导出选项,可以通过showAllowedTypes设置,我直接使用

style="display:none;"隐藏掉了。

还有每导出一张图片,servlet会调一次回调函数

function myCallBackFunction(objRtn){
if (objRtn.statusCode=="1"){
alert("Haha!The chart was successfully saved on server. The file can be accessed from " + objRtn.fileName);
}else{
alert("Oh.The chart could not be saved on server. There was an error. Description : " + objRtn.statusMessage);
}

}

最后就是导出的调用方法和一些参数设置,这样调用

function ffgg(){
var myExportComponent = new FusionChartsExportObject("fcExporter1", "../../../../script/plugin/FusionCharts_Evaluation/Charts/FCExporter.swf");

//myExportComponent.sourceCharts = ['myChartId1','myChartId2','myChartId3'];
myExportComponent.sourceCharts = ['ChartId11','ChartId12'];
myExportComponent.componentAttributes.fullMode='1';
myExportComponent.componentAttributes.saveMode='both';
myExportComponent.componentAttributes.showAllowedTypes='0';
//myExportComponent.componentAttributes.showAllowedTypes='1';
myExportComponent.componentAttributes.width = '350';
myExportComponent.componentAttributes.height = '140';
myExportComponent.componentAttributes.showMessage = '1';
myExportComponent.componentAttributes.message = 'Click on button above to begin export of charts. Then save from here.';
myExportComponent.componentAttributes.defaultExportFileName = 'MyCharts';
myExportComponent.componentAttributes.defaultExportFormat='JPG';// JPG, PNG or PDF


myExportComponent.Render("fcexpDiv");

myExportComponent.BeginExport();


}

具体参数什么意思,查文档吧,里面说的很全很详细。

过程截图:

这样图片就完成了导出。在服务器路径下,你可以找到图片然后进行其他操作。

还有个小问题,就是批量导出时,图片的名字不可设置,是随机生成的,而且多张图片到处时,

没有先后顺序,这样最后生成的图片没法和页面对应,我们拿到这几张图片是无序的,处理起来

没法辨认顺序。我想到一个办法就是每张报表chart都有一个独立的文件夹在服务器下,生成报表图片后,

即使是无序的文件名,我也会让程序按照页面上对应的顺序去服务器下找图片,这样貌似有些麻烦,不失为一个解决途径。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本压缩包收集了以下内容: 1、FusionCharts 3.1版的所有破解SWF文件,一共49个,并非其他类似破解版的36个,是最全的; 2、FusionCharts 3.1版的破解器:fusionChartsCracker.rar,有了这个破解器,可以自己下载官方的评估版自己破解自己使用; 3、收集了3.1版的FusionCharts Free中文开发指南.pdf,PDF格式,对E文不好的朋友有很大的帮助哦。 4、收集网上一些FusionCHarts的使用问题,如中文乱码的解决办法; 5、包括了官方的FusionCharts.js脚本文件,拿去即可使用了; 6、最新独家修改的官方的DEMO例子,直接可以在本地打开哦。 不了解FusionCharts的人可以看看这个介绍: FusionCharts是一种制图组件,可以帮您为您的Web应用创建交互式的、数据驱动的图表、仪表盘和地图。它具有智能化、用户友好和创新等特点,可以将单调的数据转化为栩栩如生的图像,从而使您的Web应用更加的生动。它可以完美的应用于web应用软件、管理仪表板、分析学、展示和决策支持系统,可以与诸如ASP、ASP.NET、PHP、JSP、ColdFusion和Ruby on Rails等多种web技术进行集成。 FusionCharts提供75种以上的2D/3D flash图表和450种以上的flash地图供用户选择。其图表类型各式各样,包括从诸如饼型图表、条型图表和折线图表等的基本图表到诸如真实三维图表、滚动图表和自动更新图表等的高级图表。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值