Google 饼图更改文本对齐方式
Google Pie Chart Change Text Alignment
这是我的报告,
如何一个一个地改变我的底值而不是滚动。
var options = {
legend:'bottom',
is3D: true
}
为了在图例上允许多行,
您必须使用图例位置 --> 'top'
那么你可以增加数量 --> maxLines
legend: {
position: 'top',
maxLines: 3
},
来自 documentation...
legend.maxLines
- Maximum number of lines in the legend. Set this to a number greater than one to add lines to your legend. This option works only when legend.position
is '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>
这是我的报告,
如何一个一个地改变我的底值而不是滚动。
var options = {
legend:'bottom',
is3D: true
}
为了在图例上允许多行,
您必须使用图例位置 --> 'top'
那么你可以增加数量 --> maxLines
legend: {
position: 'top',
maxLines: 3
},
来自 documentation...
legend.maxLines
- Maximum number of lines in the legend. Set this to a number greater than one to add lines to your legend. This option works only whenlegend.position
is'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>