gpt4 book ai didi

javascript - 谷歌绘制没有数据的饼图

转载 作者:行者123 更新时间:2023-12-03 11:18:26 26 4
gpt4 key购买 nike

我正在尝试在我的民意调查网站中使用 Google 图表。一切正常,直到我没有投票可显示(例如,没有人回答问题)。该图表甚至没有出现,正如您在此示例中所看到的:http://jsfiddle.net/au9prxsg/3/

google.setOnLoadCallback(drawChart);
function drawChart() {

var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 0],
['Eat', 0],
['Commute', 0],
['Watch TV', 0],
['Sleep', 0]
]);

var options = {
title: 'My Daily Activities',
sliceVisibilityThreshold: 0
};

var chart = new google.visualization.PieChart(document.getElementById('piechart'));

chart.draw(data, options);
}

enter image description here

我什至设置了属性 sliceVisibilityThreshold: 0。是否可以制作包含任何数据的饼图?

最佳答案

改变视角

var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 0],
['Eat', 0],
['Commute', 0],
['Watch TV', 0],
['Sleep', 0],
['No activities or no response', 24]
]);

var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work no response', 4.8],
['Eat no response', 4.8],
['Commute no response', 4.8],
['Watch TV no response', 4.8],
['Sleep no response', 4.8]
]);

关于javascript - 谷歌绘制没有数据的饼图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27228750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com