2016-06-30 70 views
0

我正在使用Google Charts API作爲項目,而且我遇到了顯示多個圖表的問題。根據我發現的內容,我修改了一些代碼,但仍無法顯示第二個圖表。你可以看看我正在工作的this jsfiddle,看到只有第一個圖表出現。任何人有任何想法,爲什麼這是發生或我失蹤?使用Google Charts API顯示兩個圖表

<script type="text/javascript" src="https://www.google.com/jsapi"></script> 
<script> 
google.load('visualization', '1', {packages: ['corechart']}); 
google.setOnLoadCallback(drawVisualizations); 
function drawVisualizations() { 
    var turbidityData = google.visualization.arrayToDataTable([['Date/Time', 'Turbidity'],['Jun 29, 2016 10:15 AM', 12],['Jun 29, 2016 10:30 AM', 11],['Jun 29, 2016 10:45 AM', 11]]); 
    var hgData = google.visualization.arrayToDataTable([['Date/Time', 'HG'],['Jun 29, 2016 10:15 AM', 0.46],['Jun 29, 2016 10:30 AM', 0.46],['Jun 29, 2016 10:45 AM', 0.461]]); 
    var turbidityOptions = { 
     title: 'SMC Turbidity (past 24 hours)', 
     height: 800, 
     width: 1000, 
     vAxis: {title: 'Turbidity'}, 
     hAxis: {title: 'Date/Time'}, 
     seriesType: 'bars', 
     series: {3: {type: 'area'}} }; 
    var hgOptions = { 
     title: 'HG Turbidity (past 24 hours)', 
     height: 800, 
     width: 1000, 
     vAxis: {title: 'HG'}, 
     hAxis: {title: 'Date/Time'}, 
     seriesType: 'bars', 
     series: {3: {type: 'area'}} }; 
    var turbidityChart = new google.visualization.ComboChart(document.getElementById('turbidity_chart_div')); 
    var hgChart = new google.visualization.ComboChart(document.getElementById('hg_chart_div')); 
    turbidityChart.draw(turbidityData, turbidityOptions); 
    hgChart.draw(hgData, hgOptions); 
} 
</script> 
<div id="turbidity_chart_div"> 
<div id="hg_chart_div"> 

謝謝!

回答

1

閉上你的div

<div id="turbidity_chart_div"> </div> 
<div id="hg_chart_div"> </div> 
+0

天哪我今天啞的情況。感謝那! – Chiggins

+0

哈哈,沒問題!我們都有他們。 –

+0

如果您可以將此標記爲答案,我將非常感謝代表! –