在这里,我写了2个Echarts图表,都是定时异步刷新的。
每隔20秒向服务器请求一次数据,每8秒渲染一次Echarts图表。
效果(gif录制的效果不是很好):
图书每日销售数据的JSON数据(从后台拿到):
{"code":100,"msg":"处理成功!","extend":{"dateArr":["04.15","04.16","04.17","04.18","04.19","04.20","04.21","04.22","04.23","04.24","04.25","04.26","04.27","04.28","04.29"],"orderCount":[19,40,7,10,17,17,21,15,10,10,13,11,50,50,50],"salesData":[10982,20104,6003,3579,9354,7405,11603,5141,5451,2559,7882,3220,20453,16833,66103]}}
图书每日销售数据的JSP源代码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
pageContext.setAttribute("DashGoods_PATH", request.getContextPath());
%>
ECharts
2019销售趋势(每月销售数据)的JSON数组:
{"code":100,"msg":"处理成功!","extend":{"dateArr":["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"orderCount":[0,0,0,440,50,0,0,0,0,0,0,0],"salesData":[0,0,0,232832,9296,0,0,0,0,0,0,0]}}
2019销售趋势(每月销售数据)的JSP源码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
pageContext.setAttribute("DashGoods_PATH", request.getContextPath());
%>
ECharts
我是写着玩的,仅作参考,祝顺利~