我正在尝试加载用于使用 Google Chart API 创建饼图的会话数据。但是我似乎无法使其工作。有人可以给我一些指导吗?下面是源代码:
在 AnalyzeUserClient.jsp 中:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
var sessionId = '<%= (HashMap<String, String>)request.getSession().getAttribute("hashMap") %>';
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
[sessionId],
]);
// Create and draw the visualization.
new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, {title:"Percentage of Category for User:"});
}
google.setOnLoadCallback(drawVisualization);
</script>
//HTML Code
<div id="visualization" style="width: 600px; height: 400px;"></div>
我在会话中的数据如下所示:
{Environment=1, Education=1, Hospitality_Recreation=2, Disaster_Accident=1, Human Interest=3, Labor=1}