我有以下代码来制作谷歌饼图。
目前,此代码显示图例,但显示的是任务的百分比,而不是实际饼图上显示的数字。
有没有办法让图例显示任务数量,饼图不显示任何数字?
function init() {
google.load("visualization", "1.1", { packages:["corechart"],
callback: 'drawChart' });
}
// Draw the chart and set the chart values
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Tasks', 'Completed'],
['Morning', 28],
['Afternoon', 0],
['Evening', 0],
['Night', 161]
]);
// Optional; add a title and set the width and height of the chart
var options = {
width: 900,
height: 400,
title: 'Total = 189',
pieHole: 0.5,
colors: ['#008000', '#ffbf00', '#FF0000','#4E6282'],
pieSliceText: 'value',
sliceVisibilityThreshold :0,
fontSize: 17,
legend: {
position: 'labeled'
},
};
// Display the chart inside the <div> element with id="piechart"
var chart = new
google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}