gpt4 book ai didi

google-visualization - Google 差异条形图 - 更改条形颜色

转载 作者:行者123 更新时间:2023-12-01 09:25:52 25 4
gpt4 key购买 nike

我有一个 Google 差异条形图。我正在尝试更改外部栏的颜色。默认情况下,它是褪色的颜色。我可以使用选项下的颜色参数更改内栏颜色。有人可以指导我吗?下面是我的代码。

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", '1.1', {packages:['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var oldData = google.visualization.arrayToDataTable([
['Name', 'Popularity'],
['Cesar', 250],
['Rachel', 4200],
['Patrick', 2900],
['Eric', 8200]
]);

var newData = google.visualization.arrayToDataTable([
['Name', 'Popularity'],
['Cesar', 370],
['Rachel', 600],
['Patrick', 700],
['Eric', 3500]
]);
var colChartDiff = new google.visualization.ColumnChart(document.getElementById('colchart_diff'));
var options = {
diff: { newData: { widthFactor: 0.6 } },
legend: { position: 'top' } ,
colors: ['#f38eff', '#C0C0C0'],
backgroundColor: '#fffff5',
hAxis: {title: 'People'},
vAxis: {title: 'Numbers'}};
var diffData = colChartDiff.computeDiff(oldData, newData);
colChartDiff.draw(diffData, options);
}
</script>

最佳答案

您可以在 diff 对象中设置它,例如,

var options = { ...
diff: {
oldData: { opacity: 1, color: '#e6693e' },
newData: { opacity: 1}
}...
}

关于google-visualization - Google 差异条形图 - 更改条形颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24344251/

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