可以实时达到类似任务管理器查看cpu使用率一样,慢慢的线性加载,而不是刷新整个页面
1: 后台代码
public void realTj(){
if(null != equipmentKey && equipmentKey > 0){//只有选择设备才会出来数据
Calendar c = Calendar.getInstance();
c.add(Calendar.MINUTE, -30);
startDate = c.getTime();
dataCollectList = dataCollectService.getXxtjList(equipmentKey,startDate,null);
String dataParameters = "";
StringBuffer label = new StringBuffer();
label.append("&label=");
StringBuffer value = new StringBuffer();
value.append("&value=");
for(DataCollect dc : dataCollectList){
label.append(formatter.format(dc.getCollectTime()));
label.append(",");
value.append(dc.getDataValue());
value.append(",");
}
dataParameters += label.substring(0,label.length()-1);
dataParameters += value.substring(0,value.length()-1);
HttpServletResponse response = ServletActionContext.getResponse ();
response.setCharacterEncoding ("UTF-8");
PrintWriter out = null;
try {
out = response.getWriter ();
out.print(dataParameters);
} catch (IOException e) {
e.printStackTrace ();
}
out.flush ();
out.close ();
}
}
二:Data.xml 文件
<chart caption='' subCaption='' dataStreamURL='dataCollectAction!realTj.action?equipmentKey=2'
refreshInterval='60' numberPrefix='' setAdaptiveYMin='1' xAxisName=''
showRealTimeValue='1' realTimeValuePadding='50' labelDisplay='Rotate' slantLabels='1' >
<categories>
</categories>
<dataset seriesName='' showValues='0'>
</dataset>
<styles>
<definition>
<style type='font' name='captionFont' size='14' />
</definition>
<application>
<apply toObject='Caption' styles='captionFont' />
<apply toObject='Realtimevalue' styles='captionFont' />
</application>
</styles>
</chart>
三:jsp页面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src='javascript/FusionCharts.js'></script>
</head>
<body>
<div id="chartdiv" align="center" class="table_list_div marginTop10">
</div>
<script type="text/javascript">
var chart1 = new FusionCharts("swf/RealTimeLine.swf", "ChId1", "1050", "360", "0", "0");
chart1.setDataURL("Data.xml");
chart1.render("chartdiv");
</script>
</body>
</html>
四:附上整个例子使用的js和swf破解文件