gpt4 book ai didi

api - Google Charts Api - 单系列多色

转载 作者:行者123 更新时间:2023-12-04 16:08:44 26 4
gpt4 key购买 nike

有没有办法使用 Google Charts Api (google.visualization.ColumnChart) 为系列中的每个项目创建一个具有不同颜色的系列?

基本上我想要一个柱状图,其中的每一列都是不同的颜色,每一列都有标签。

谢谢

最佳答案

不幸的是,Google Charts API 不支持每个系列超过一种颜色。

您可以通过多个系列来伪造它,每个系列一个值:

function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Sequence', '1', '2', '3', '4', '5', '6'],
['', 1,1,2,3,5,8],
]);

// Create and draw the visualization.
new google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data,
{title:"Fibonacci",
width:600, height:400}
);
}

Fibonacci sequence with distinct colors

关于api - Google Charts Api - 单系列多色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9774367/

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