我想使用使用jgoogle图表的甜甜圈图:
https://developers.google.com/chart/interactive/docs/gallery/piechart#making-a-donut-chart
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="donutchart" style="width: 900px; height: 500px;"></div>
</body>
</html>
我面临的问题是如何使甜甜圈的一部分比其他甜甜圈更厚;即,如所附图片所示-(“必填图”)。有人可以帮忙吗?
最佳答案
看着documentation,我认为那是不可能的。
您可以为甜甜圈图中的每个“切片”设置偏移量,但这不会影响厚度:
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
slices: {0: {offset: 0.5}}, // positions the first slice out from the center
};
关于javascript - Google Charts JS提供的自定义甜甜圈图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39475416/