FusionChart3.1的基本应用
FusionChart3.1的基本应用
FusionChart在3.07版本已经支持导出功能了,最近做项目正好需要。用3.1版本实现
介绍一种导出图片比较简单的方法:
<chart palette="4" exportEnabled='1' exportHandler='/FC/FCExporter.jsp' decimals="0" enableSmartLabels="1" enableRotation="0" bgColor="99CCFF,FFFFFF" bgAlpha="40,100" bgRatio="0,100" bgAngle="360" showBorder="1" startingAngle="70">只需要在chart里面加入: exportEnabled='1' exportHandler='/FC/FCExporter.jsp' --/FC/FCExporter.jsp是这个jsp文件所在的的位置。
<script language="JavaScript" src="/charts31/JSClass/FusionCharts.js"></script> <script language="JavaScript" src="/charts31/JSClass/FusionChartsExportComponent.js"></script>
<div id="chartdiv1" align="center"></div> <script type="text/javascript"> var myChart = new FusionCharts("/charts31/Column2D.swf", "myChartId1","90%","90%",0,1); //参数含意 需要图表的swf文件,图表ID,宽度,高度,debug模式,是否允许JS与图表通信 myChart.setDataURL("data.xml"); //承载数据的xml文件,也可以是程序文件生成xml myChart.setTransparent(false); //设置flash与其他层的层次,false是flash在最下 myChart.render("chartdiv1"); </script> </td>
<chart ...exportEnabled='1' exportAtClient='1' exportHandler='fcExporter_all' exportDialogMessage='正在导出,请稍候...' exportFileName='图表' exportFormats='PDF=导出PDF文件|PNG=导出PNG文件|JPG=导出JPG文件' ...>
<div id="fcexpDiv" ></div> <script type="text/javascript"> var myExportComponent = new FusionChartsExportObject("fcExporter_all", "/charts31/FCExporter.swf"); //这里的第一个参数必须和数据文件中exportHandler的值相同 myExportComponent.componentAttributes.btnFontSize = '12'; myExportComponent.componentAttributes.btndisabledtitle = '等待导出'; myExportComponent.componentAttributes.btnsavetitle = '下载'; myExportComponent.Render("fcexpDiv"); </script>
<div id="fcexpDiv" ></div> <script type="text/javascript"> var myExportComponent = new FusionChartsExportObject("fcExporter_all", "/swf/charts31/FCExporter.swf"); myExportComponent.componentAttributes.fullMode = '1'; myExportComponent.componentAttributes.saveMode = 'both'; myExportComponent.componentAttributes.showAllowedTypes = '1'; myExportComponent.componentAttributes.width = '400'; myExportComponent.componentAttributes.height = '150'; myExportComponent.componentAttributes.showMessage = '1'; myExportComponent.componentAttributes.message = '成功导出文件列表'; myExportComponent.componentAttributes.defaultExportFilename = '综合分析'; myExportComponent.componentAttributes.saveAllTitle = '合并类型'; myExportComponent.componentAttributes.btnSaveAllTitle = '合并下载'; myExportComponent.componentAttributes.btnFontSize = '12'; myExportComponent.componentAttributes.btnsavetitle = '下载'; myExportComponent.Render("fcexpDiv"); </script>
<embed type="application/x-shockwave-flash" src="/charts31/StackedArea2D.swf" width="90%25" height="90%25" id="myChartId1" name="myChartId1" quality="high" allowScriptAccess="always" WMode="Opaque" flashvars="debugMode=0&chartWidth=90%25&chartHeight=90%25&DOMId=myChartId1?isterWithJS=1&scaleMode=noScale&lang=EN&dataURL=data.xml"/>