javascript - 谷歌饼图更改文本对齐方式
解决方案
为了让图例上有多行,
你必须使用图例位置-->'top'
然后你可以增加数量-->maxLines
legend: {
position: 'top',
maxLines: 3
},
从文档...
legend.maxLines
- 图例中的最大行数。将此设置为大于一的数字以向图例添加线条。此选项仅在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>
推荐阅读
- function - 无效的二元操作数,缺少理论
- powershell - 以字母命名的目录路径的正则表达式
- python-3.x - Keras 模型的准确度和精确度
- javascript - 当定义的任何变量在内存中有 0 或 1 个转储值时,null 如何表示“无值”?
- python - 如何在 Python 中部分转置 CSV 表
- swift - ios 12 (Swift 4.2) 之后按钮渐变不起作用
- java - findViewById-int 上的 android studio 空指针异常
- mysql - 如何在 select 语句中选择 count()
- python-3.x - 更新嵌套字典中的值正在更新同一级别中的其他值
- microsoft-graph-api - Microsoft Graph API Beta Outlook 任务重复