首页 > 代码库 > chart.js操作实例(前后台互通)
chart.js操作实例(前后台互通)
前提:需要导入chart.js
我的项目环境是:SpringMVC+mongodb
SpringMVC的controller层:
/** * 查询得到财务信息报表 * @author liupeng * @param request * @return * @throws UnknownHostException * @throws ParseException */ @RequestMapping(value=http://www.mamicode.com/"/innerChartOutForFinal")>
SpringMVC的DAO层:/** * 根据时间范围获取全部信息 * @author liupeng * @param timeStart * @param timeEnd */ public List<KeyRequest> findByTimeForFinalCommon(String timeStart, String timeEnd) { List<KeyRequest> kRList = new ArrayList<KeyRequest>(); BasicDBObject obj = new BasicDBObject(); obj.put("kq_timer_start",new BasicDBObject("$gte",timeStart).append("$lt", timeEnd)); try{ DBCursor dbCursor = keyRequest.find(obj).sort(new BasicDBObject("kq_timer_start",1));//以时间倒序排序,不排序的话数据会有问题,X坐标会显示相同的时间 List<DBObject> list = dbCursor.toArray(); for (DBObject dbObject:list) { KeyRequest tmp = setKeyRequest(dbObject); kRList.add(tmp); } }catch (Exception e) { e.printStackTrace(); } return kRList; }
SpringMVC的显示层:<% String strx = (String)request.getAttribute("strx"); String strY1 = (String)request.getAttribute("strY1"); String strY2 = (String)request.getAttribute("strY2"); //"January","February","March","April","May","June","July" %> <script> var data = http://www.mamicode.com/{>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。