gpt4 book ai didi

javascript - 如何在饼图标题中应用背景颜色

转载 作者:行者123 更新时间:2023-11-28 08:32:14 24 4
gpt4 key购买 nike

如何在饼图标题中应用背景颜色。此外,背景颜色应应用于标题的整个区域。以下是我使用过的代码..

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<div id="donut-1" style="width: 450px; height: 300px; float:left;">
</div>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['', 111],
['4081.00', 252],
['724.00', 122],
['', 122],
['', 111],
['436.00', 111],
['1343.00', 111],
['', 111],
['', 111],
['270.00', 111]
]);
var options = {
backgroundColor: '#FFF',
pieHole: 0.5,
legend: 'none',
chartArea: { backgroundColor: { 'fill': '#F0F8FC', 'opacity': 100 }, left: 20, top: 30, width:"90%",height:"85%" },
pieSliceText: 'label',
title: "Total Chargeable Weight", titleTextStyle: { color: '#007DB0', fontSize: '16'}
};
var chart = new google.visualization.PieChart(document.getElementById('donut-1'));
chart.draw(data, options);
}
</script>

最佳答案

您可以指定要为图表显示的文本标题的颜色,但不能指定文本的背景填充颜色(如果这是您想要的颜色)寻找)

titleTextStyle 配置选项(它是一个对象)允许您指定以下属性

{ 
color: <string>,
fontName: <string>,
fontSize: <number>,
bold: <boolean>,
italic: <boolean>
}

关于javascript - 如何在饼图标题中应用背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21701543/

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