(急)使用highcharts制作饼图的时候,想从服务器获取数据显示在饼图上
下图是服务器响应给jsp的内容(这个内容会随着数据库的变化而变化,比如下次传的可能是{"pt":8,"qw":4})(附上jsp的代码),jsp的饼图要怎样处理这个数据使之显示在饼图里呀
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<% //jQuery 安装:使用 Staticfile CDN 静态资源库来加载jQuery库%>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<% //Highcharts 安装:使用使用官方提供的 CDN 地址%>
<script src="https://code.highcharts.com/highcharts.js"></script>
</head>
<body>
<div id="container1" style="min-width:400px;height:400px"></div>
<script>
Highcharts.chart('container1', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: '权威用户与非权威用户占有比例'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: '非权威用户',
y: 5,
sliced: true,
selected: true
}, {
name: '权威用户',
y: 3
}]
}]
});
</script>
</body>
</html>