我正在嘗試循環(huán)繪制餅圖。在我的數(shù)組中有 3 個值,我想繪制 3 個餅圖。我已經(jīng)嘗試過如下。<?php foreach($pie as $m) { ?> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], <?php foreach($piearray[$m] as $kf=>$v){ ?> ['<?php echo $kf;?>', <?php echo $v;?>], <?php } ?> ]); var options = { title: 'Brand Placement' }; var chart = new google.visualization.PieChart(document.getElementById('piechart<?php echo $m;?>')); chart.draw(data, options); } <?php }?><script src="https://gstatic.com/charts/loader.js"></script> <?php foreach($pie as $mi) { <div id="piechart<?php echo $mi;?>" style="width: 900px; height: 500px;"></div> }}但它只運行最后一個。請幫助我。
- 1 回答
- 0 關(guān)注
- 119 瀏覽
添加回答
舉報
0/150
提交
取消