您的位置:首页 > 运维架构

Ubuntu-10.04下配置OpenIMSCore

2013-05-31 21:25 281 查看
// 路径配置
require.config({
paths : {
echarts : 'js/build/dist'//注意路径问题
}
});
// 使用
require([ 'echarts', 'echarts/chart/bar' // 使用柱状图就加载bar模块,按需加载
], draw);
function draw(ec) {
// 基于准备好的dom,初始化echarts图表
$("#main").css({"width":"780px","height":"400px"});
var myChart = ec.init(document.getElementById('main'));
var option = {
tooltip : {
show : true
},
legend : {
data : [ '降水' ]
},
toolbox : {
show : true,
feature : {
saveAsImage : {
show : true
}
}
},
xAxis : [ {
type : 'category',

} ],
yAxis : [ {
type : 'value'
} ],
series : [ {
"name" : "降水",
"type" : "bar",

} ]
};

// 为echarts对象加载数据
loadDATA(option);
myChart.setOption(option);
}
function loadDATA(option) {
$.ajax( {
url : 'yearOnePicRain.action',
type : 'get',
dataType : 'json',
async : false,
data : {
'beginyear' : beginyear,
'endyear' : endyear,
'station' : station
},
success : function(result) {
if (result) {
$('#main').show();
option.xAxis[0].data = [];
for (var i = 0; i < result.length; i++) {
option.xAxis[0].data
.push(result[i].YEAR);
}
option.series[0].data = [];
for (var i = 0; i < result.length; i++) {
option.series[0].data
.push(result[i].AVG);
}
}
}
});
}
后台代码:

HttpServletRequest req = ServletActionContext.getRequest();
req.setCharacterEncoding("UTF-8");
int rows = Integer.parseInt(req.getParameter("rows"));
int	 page = Integer.parseInt(req.getParameter("page"));
String begindate = req.getParameter("begindate");
String enddate = req.getParameter("enddate");
String station = req.getParameter("station");
station = new String(station.getBytes("ISO-8859-1"), "UTF-8");
Map map = new HashMap();
map.put("begindate", begindate);
map.put("enddate", enddate);
map.put("station", station);
map.put("rows", rows);
map.put("page", page);
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
PageInfo pageInfo = this.hRainService.historyquery(map);
PrintWriter writer = response.getWriter();
JSONObject jsondata = JSONObject.fromObject(pageInfo);
writer.print(jsondata.toString());
所需echarts.js请到http://down.51cto.com/data/2128071下载
本文出自 “没有水勒鱼” 博客,请务必保留此出处http://javaqun.blog.51cto.com/10687700/1727802
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: