1 回答

TA貢獻1898條經驗 獲得超8個贊
為了讓圖例上有多行,
你必須使用圖例位置 -->'top'
然后你可以增加數量 -->maxLines
legend: {
position: 'top',
maxLines: 3
},
從文檔...
legend.maxLines- 圖例中的最大行數。將此設置為大于一的數字以向圖例添加線條。此選項僅在legend.positionis 時有效'top'。
請參閱以下工作片段...
google.charts.load('current', {
packages: ['corechart', 'table']
}).then(function () {
var data = google.visualization.arrayToDataTable([
['category', 'value'],
['Category 1', 34],
['Category 2', 18.7],
['Category 3', 18.6],
['Category 4', 18.6],
['Category 5', 10]
]);
var pie = new google.visualization.PieChart(document.getElementById('chart-pie'));
pie.draw(data, {
legend: {
position: 'top',
maxLines: 3
},
height: 400,
is3D: true,
width: 400
});
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart-pie"></div>
添加回答
舉報