在线生成报表

时间:2021-03-30 09:39:39

引入三个fusioncharts.js,fusioncharts.charts.js,themes(主题)三个js文件

<script type="text/javascript" src="${basePath }js/fusioncharts/fusioncharts.js"></script>
<script type="text/javascript" src="${basePath }js/fusioncharts/fusioncharts.charts.js"></script>
<script type="text/javascript" src="${basePath }js/fusioncharts/themes/fusioncharts.theme.fint.js"></script>


//页面元素加载完毕之后才执行此方法
$(document).ready(function(){
getAnnualStatisticData();
});

//-------------------


//根据年份统计投诉数
function getAnnualStatisticData() {
var $year=$("#year").val();

$.ajax({
url:"${bashPath}nsfw/complain_getAnnualStatisticData.action",
data:{"year":$year},
type:"post",
success:function(data){
if(data.msg=="success"){
var revenueChart = new FusionCharts({
"type": "line",
"renderAt": "chartContainer",
"width": "600",
"height": "400",
"dataFormat": "json",
"dataSource": {
"chart":{
"caption": $year+"年度投诉数统计图",
"subCaption": "",
"xAxisName": "月 份",
"yAxisName": "投 诉 数",
"theme": "fint"
},
"data": data.asData
}
});
revenueChart.render();
}
},

error:function(){
alert("统计数据获取失败!");
}

});

}