【发布时间】:2016-04-21 09:27:25
【问题描述】:
我正在使用 ng-google-charts 模块为我的 Angular 应用程序构建谷歌图表,我想要做的是绘制一个柱形图。
代码有效,图表似乎绘制正确,但我不知道如何在我生成的行中添加颜色,以便每列的颜色不同。
这是我的代码,查看谷歌图表文档似乎我应该能够为每一列分配一个十六进制代码,但我见过的示例都没有使用角度,并且没有一个将它们的行构建为文字对象我需要做。
var collsArray = [];
var rowsArray = [];
for (var i = 0; i < vm.projects.length ; i++) {
//this is where I build each data row and where I think I need to add the color
rowsArray.push({
"c": [
{
"v": vm.projects[i].name
},
{
"v": vm.projects[i].developers,
"f": vm.projects[i].developers + ' developers working on ' + vm.projects[i].name
}]
});
}
collsArray = [{id: 'project', label: 'Project', type: 'string'},
{id: 'developers', label: 'Developers working', type: 'number'}];
vm.chartProjects = {
"type": "ColumnChart",
"displayed": false,
"data": {
"cols": collsArray,
"rows": rowsArray
},
"options": {
"isStacked": "true",
"fill": 0,
"width": '100%',
"height": '100%',
"displayExactValues": true,
"chartArea": {
"left": "1%",
"top": "1%",
"height": "98%",
"width": "98%"
}
},
"formatters": {},
"view": {}
};
【问题讨论】:
标签: javascript angularjs charts google-visualization