我正在尝试循环绘制饼图。在我的数组中有 3 个值,我想绘制 3 个饼图。我已经尝试过如下。<?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> }}但它只运行最后一个。请帮助我。
添加回答
举报
0/150
提交
取消