使用之前要导入FusionCharts插件
//展现页面
});
Ext.define('GroupOnlineApp.view.PrinterView', {
extend : 'Ext.window.Window',
alias : 'widget.printerView',
title : '报表展示',
width : 700,
minHeight:450,
autoHeight:true,
layout: 'fit',
itemId :'printerWindow',
modal : true,
border : false,
closeAction : 'destroy',
html : "<div id='myChartDiv'></div>"
//控制页面
lookInfo : function(button){
var
view = Ext.widget('printerView');
view.show();
var chart = new FusionCharts(window.BIZCTX_PATH +"/common/FusionCharts/Charts/MSColumn3DLineDY.swf"
, "ChartId", "700", "400");
chart.setDataURL(window.BIZCTX_PATH +"/grouporg/lookGroupOrg.action?stime="+stime);
chart.render("myChartDiv");
}
/**
* 柱状图分组上线率统计
* @return
*/
public String lookGroupOrg(){
if(onLine==null){
onLine=new OnLine();
}
try {
Thread.sleep(300);
if(!SessionUtils.getUser().getLoginname().equals("admin")){
onLine.setUserid(SessionUtils.getUserId());
}
onLine.setStime(URLDecoder.decode(stime,"UTF-8"));
list = onlineService.selectCheckOrg(onLine);
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/xml;charset=gbk");
Document document = DocumentHelper.createDocument();
Element apdoc=document.addElement("chart");
apdoc.addAttribute("caption","分组上线率统计");
apdoc.addAttribute("xAxisName", "分组");
apdoc.addAttribute("PYAxisName", "总车辆数");//Y主轴的名称
apdoc.addAttribute("SYAxisName", "上线率");//Y次轴的名称
apdoc.addAttribute("numberSuffix", "辆");//数据后缀单位
apdoc.addAttribute("rotateNames", "true");//是否旋转显示标签,默认为0(False):横向显示
apdoc.addAttribute("labelDisplay", "Rotate");//横坐标旋转显示
apdoc.addAttribute("slantLabels", "2");//横坐标旋转显示角度45 或 90
Element categories = apdoc.addElement("categories");
for (OnLine onLine2 : list) {
Element totalAmount = categories.addElement("category");
totalAmount.addAttribute("label", onLine2.getDeptname());//name label
}
Element dataset1 = apdoc.addElement("dataset");
dataset1.addAttribute("seriesName", "总车辆");
dataset1.addAttribute("parentYAxis", "P");
dataset1.addAttribute("ShowValues", "1");
for (OnLine onLine2 : list) {
Element totalAmount1 = dataset1.addElement("set");
totalAmount1.addAttribute("value", onLine2.getSumcount().toString());
}
Element dataset2 = apdoc.addElement("dataset");
dataset2.addAttribute("seriesName", "上线率");
dataset2.addAttribute("parentYAxis", "S");
for (OnLine onLine2 : list) {
Element totalAmount2 = dataset2.addElement("set");
totalAmount2.addAttribute("value", onLine2.getCentage().toString());
}
Element trendlines = apdoc.addElement("trendlines");
Element line = trendlines.addElement("line");
line.addAttribute("startValue", "300");
line.addAttribute("color", "91C728");
line.addAttribute("displayValue", "Target");
line.addAttribute("showOnTop", "1");
String outString = document.asXML();
response.getWriter().print(outString);
} catch (Exception e) {
logger.error("onLineAction的方法 lookGroupOrg执行出错,原因:" + e, e);
return ERROR;
}
return null;
}