easyui和highcharts 动态加载数据和X轴数据

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery-1.8.2.min.js"></script>   
<script src="${pageContext.request.contextPath}/resource/jquery-easyui-1.4.5/jquery.easyui.min.js"type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/resource/jquery-easyui-1.4.5/themes/default/easyui.css"rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/resource/jquery-easyui-1.4.5/themes/icon.css"rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
</head>
<script type="text/javascript">
//定义一个Highcharts的变量,初始值为null
var oChart = null;
//定义oChart的布局环境
//布局环境组成:X轴、Y轴、数据显示、图标标题
var oOptions = { 
//设置图表关联显示块和图形样式
chart: { 
 renderTo: 'container', //设置显示的页面块
 type:'line'  ,  //设置显示的方式
 type: 'column'
},
//图标标题
title: { 
 text: '学生信息查询', //设置标题
 //text: null, //设置null则不显示标题
},
credits: {//去除水印
           enabled: false
        },
//x轴
xAxis: {
 title: {
  text: '时间'
 },
 categories:[]
},
//y轴
yAxis: {
 title: { text: '分数' }, //设置Y轴标题关闭
},
//数据列
series: [{
 data:[]
 }] 
}; 
$(document).ready(function(){
oChart = new Highcharts.Chart(oOptions);
//异步添加第2条数据列
LoadSerie_Ajax();
}); 
//异步读取数据并加载到图表
function LoadSerie_Ajax() { 
 oChart.showLoading(); 
 $.ajax({ 
  url: "../statistic/statisticOneInfo",
  type : 'POST',
  dataType : 'json',
  async : false, //同步处理后面才能处理新添加的series
  contentType: "application/x-www-form-urlencoded; charset=utf-8", 
  success : function(resp){
     scoreValue = resp['score'];//分数
lineLabel=resp['date'] ;//时间
    var oSeries = {
    name: "语文",
    data: scoreValue
   };
    for(var i=0;i<lineLabel.length;i++){
    oOptions.xAxis.categories.push(lineLabel[i]);//动态加载x轴数据
    }
   oChart.addSeries(oSeries);
  }
 });
 oChart.hideLoading(); 
}


</script>
<body>
    <div id="container" style="min-width:400px;width:1200px;height:400px;"></div>
</body>
</html>
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值