日期:2014-05-17  浏览次数:20763 次

highcharts数据问题
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="WEB-INF/c.tld" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0026)http://www.softeem.com/index.htm -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<%=basePath %>js/jquery-1.4.min.js"></script>
<script type="text/javascript" src="<%=basePath %>js/highcharts.js"></script>
<script type="text/javascript">
var enginConn_chart;
var datas;
function getData(data){
alert(data);
datas = eval(${data}); 
alert(datas);
//$(data).each(function(i,dept){
// enginConn_chart.series[{
// name:'红色',
// data:[dept.dept_name,dept.dept_id]
// }];

// })
}
$(document).ready(function() {
enginConn_chart = new Highcharts.Chart({
//data=datas;
chart: {
renderTo: 'container',
margin: [50, 200, 60, 170],
defaultSeriesType: 'pie',
events: {  
load: requestData()

},
title: {
text: '图书类型饼图'
},
plotArea: {
shadow: null,
borderWidth: null,
backgroundColor: null
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
}
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
formatter: function() {
if (this.y > 5) return this.point.name;
},
color: 'white',
style: {
font: '13px Trebuchet MS, Verdana, sans-serif'
}
}
}
},
legend: {
layout: 'vertical',
style: {
left: 'auto',
bottom: 'auto',
right: '50px',
top: '100px'
}
},
series: [{
//${depts}
type: 'pie',
name:'',
data:datas
//data: [3.40, 1.05, 2.90, 1.65, 1.35, 2.59, 1.39, 3.07, 2.82]
}]
});
});
function requestData() {
alert("ok")
$.ajax({
url:'AutoCompleAction!autoCompleAction',
dataType:'json',
type:'post',
cache:false,
success:function(data){
getData(data);
},
});
};
</script>
</head>
  <div id="container" style="width: 800px; height: 400px">
  </div>
 这个是我jsp页面我想做一个饼图出来可是我不在数据如何传递到 series: [{
//${depts}
type: 'pie',
name:'',
data:datas
//data: [3.40, 1.05, 2.90, 1.65, 1.35, 2.59, 1.39, 3.07, 2.82]
}]

显示出动态数据
上面是我的代码 很急啊纠结很多天  
希望大哥们帮忙一下呀~~!!

------解决方案--------------------
帮你顶下 jquery语法不熟~