我有兩個排行榜我想顯示一個圖表,但由於某些原因,它只能顯示第一個谷歌圖表只顯示每
它只顯示sarahChart如果我交換的功能的順序是隻有將顯示anthonyChart
這裏是我的腳本:
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawSarahChart);
google.setOnLoadCallback(drawAnthonyChart);
function drawSarahChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Emplacement');
data.addColumn('number', 'Quantité');
data.addRows(<?php echo "[\n";
echo $prefix . " [\n";
echo ' "Stock",' . "\n";
echo $count_stock . '' . "\n";
echo " ]";
$prefix = ",\n";
echo $prefix . " [\n";
echo ' "Maintenance",' . "\n";
echo $count_maint . '' . "\n";
echo " ]";
$prefix = ",\n";
foreach ($combined_depart as $key => $value) {
echo $prefix . " [\n";
echo ' "' . $key . '",' . "\n";
echo $value . '' . "\n";
echo " ]";
$prefix = ",\n";
}
echo "\n]";?>);
var options = {title:'Nombre de materiel par emplacement',
width:600,
height:500};
var chart = new google.visualization.PieChart(document.getElementById('Sarah_chart_div'));
chart.draw(data, options);
}
function drawAnthonyChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'type');
data.addColumn('number', 'quantité');
data.addRows(<?php echo "[\n";
foreach ($combined as $key => $value) {
echo $prefix . " [\n";
echo ' "' . $key . '",' . "\n";
echo $value . '' . "\n";
echo " ]";
$prefix = ",\n";
}
echo "\n]"; ?>);
var options = {
title: "Nombre de materiel par type",
width: 400,
height: 300
};
var chart = new google.visualization.BarChart(document.getElementById('Anthony_chart_div'));
chart.draw(data, options);
}
</script>
這裏是HTML:
<table class="columns">
<tr>
<td><div id="Sarah_chart_div"></div></td>
<td><div id="Anthony_chart_div"></div></td>
</tr>
</table>
通過,如果我把
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawSarahChart);
google.charts.setOnLoadCallback(drawAnthonyChart);
在開始,而不是那道,也不圖表的顯示控制檯顯示以下錯誤:
無法讀取的不確定
財產「負荷」如果我只更換2行
google.charts.setOnLoadCallback(drawSarahChart);
google.charts.setOnLoadCallback(drawAnthonyChart);
既不再次顯示,控制檯顯示以下錯誤:
無法讀取屬性「setOnLoadCallback」的未定義
請幫忙,謝謝!
它不顯示任何內容或者不幸。 – Meryem
在控制檯中的任何錯誤? – WhiteHat
對不起,我錯了,它只顯示其中一個圖表,並且錯誤顯示爲 給出的每一行都必須爲null或數組。 – Meryem