JS:
//评分趋势
progressLoadNew({
body: '#lineScore'
});
$.post(basePath + 'pfmReport/getExportReportKpiChartScoreData', {
dbid: dbid,
owner: owner,
table_name: tableName,
checkrecorderId: flcheckrecordid,
startTime: $('#beginTime').datetimebox('getValue'),
endTime: $('#endTime').datetimebox('getValue')
}, function(data) {
data = typeof data == 'string' ? JSON.parse(data) : data;
var obj, series = [];
series.push({
name: '评分趋势',
type: 'line',
data:data.data
});
obj = initBrokenLine('lineScoreView', data.dateList, [''], series, data.X_axis, data.Y_axis);
setTimeout(function() {
report.score = obj.getDataURL();
}, 1000);
progressCloseNew({
body: '#lineScore'
});
});
}
// 初始化折线图
function initBrokenLine(id, dateList, name, series, X_axis, Y_axis) {
var options = {
tooltip: {
trigger: 'axis'
},
legend: {
data: name,
},
xAxis: [{
type: 'category',
boundaryGap: false,
data: dateList,
name:X_axis,
}],
yAxis: [{
type: 'value',
name:Y_axis,
}],
grid: {
x: 100,
x2: 100,
},
series: series
};
var eChartColumn = echarts.init(document.getElementById(id));
eChartColumn.setOption(options, true);
return eChartColumn;
}
controller:
/**
*
* @param tableId
* @param dbid
* @return
*/
@ResponseBody
@RequestMapping("/getExportReportKpiChartScoreData")
public Map
if(dbid==null||owner==null||table_name==null){
logger.error("关键参数为空");
return null;
}
Map
if(data.size()>0){
return data;
}
return null;
}
service:
PropertyHelper propertyHelper = new PropertyHelper(
PathHelper.getClassesPath(this.getClass()) + "com/snc/hottablemanage/config/export.properties");
int days = Integer.parseInt(propertyHelper.getProperty("exportDays"));
String temp=" SELECT DISTINCT"+
" a.score,"+
" a.timeid,"+
" b.flchecktime"+
" FROM"+
" htm_pfm_table_score a,"+
" htm_basejob_checkrecords b"+
" WHERE 1=1"+
" AND a.flcheckrecordid=b.flid"+
" AND a.dbid =?"+
" AND a.owner = ?"+
" AND a.table_name =? ";
//起始时间不为空
if(startTime!=null&&!startTime.equals("")){
temp+=" AND b.flchecktime>='"+startTime+"'";
}
//结束时间不为空
if(endTime!=null&&!endTime.equals("")){
temp+=" AND b.flchecktime<='"+endTime+"'";
}
//如果日期没有传进来,取距离flchecktime最大值前N天的记录
if(StringUtil.isEmpty(startTime)&&StringUtil.isEmpty(endTime)){
HtmBasejobCheckrecords hbc = htmBasejobCheckrecordsDaoImpl.get(HtmBasejobCheckrecords.class,Long.parseLong(checkrecorderId));
if(hbc==null||hbc.getFlchecktime()==null){
return null;
}
Date endDate = hbc.getFlchecktime();
Calendar cal = Calendar.getInstance();
cal.setTime(endDate);
endDate = cal.getTime();
cal.set(Calendar.DATE, cal.get(Calendar.DATE)-days);
Date startDate = cal.getTime();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String endDate_=sdf.format(endDate);
String startDate_=sdf.format(startDate);
temp+=" AND b.flchecktime>='"+startDate_+"' AND b.flchecktime<='"+endDate_+"'";
}
Map
result.put("X_axis","时间");
result.put("Y_axis","得分");
List
效果:本图仅仅做参考,具体形状根据数据变化而变化