我已经实现了谷歌饼图。一切正常,但是当我尝试添加小于 10 的数据时,它不会在图表上绘制,而是在图例下添加一个名为“其他”的新条目
我的脚本是
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Age Difference'],
['>10', 15],
['10-15', <?php echo $agecnt2;?>],
['16-20', <?php echo $agecnt3;?>],
['21-25', <?php echo $agecnt4;?>],
['26-30', <?php echo $agecnt5;?>],
['31-35', <?php echo $agecnt6;?>],
['36-40', <?php echo $agecnt7;?>],
['41-45', <?php echo $agecnt8;?>],
['46-50', <?php echo $agecnt9;?>],
['51-55', <?php echo $agecnt10;?>],
['56-60', <?php echo $agecnt11;?>],
['61-65', <?php echo $agecnt12;?>],
['66-70', <?php echo $agecnt13;?>],
['71-75', <?php echo $agecnt14;?>],
['76-80', <?php echo $agecnt15;?>],
['>80', <?php echo $agecnt16;?>]
]);
var options = {
title: 'Age Difference'
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div4'));
chart.draw(data, options);
}
</script>