1
我有一個關於谷歌API流程圖的問題。我想在一個jsp頁面上添加幾個流程圖。在我的流程圖控制器中,我運行從數據庫中獲得的列表,並且想要爲流程圖製作一個foreach。使用谷歌API在jsp頁面上顯示流程圖的最佳方式
將此添加到模型並在jsp頁面上顯示的最佳方式是什麼?
流程代碼是這樣的:
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
該代碼,但我值填充,在for循環,但我不知道如何給它的模式呢? (As String does not work我只是試過:D)
做了所有地圖中使用同一div 「chart_div」? –
是的,如果可能的話。 – user1480139
你不能這樣做,地圖將被覆蓋。您必須使用不同的div併爲setOnLoadCallback註冊每個div。 –