var list = [];
$.each(dataObj.model_Response[0].array, function(key, item) {
var row = [];
var value = item.account.amount;
colors.push(_toColor(item.account.number.toString()));
row.push(item.account.name);
row.push(value);
list.push(row);
});
//.. list add to google DataTable.
_toColor函数:
var _toColor = function(n) {
n = crc32(n);
n &= 0xffffffff;
return("#" + ("000000" + dechex(n)).substr(-6));
}
1 回答
我想我们遇到了同样的问题 . 在我的情况下,我必须在我的谷歌饼图中将分类帐帐号与某些颜色组合在一起 . 因此,在为饼图构建我的数组数据时,我还会创建一个数组颜色 . 在那个循环中我用这个:
_toColor函数:
在我的选项var中我可以简单地分配数组:
结果是两个带有链接分类帐帐户和颜色的饼图!希望我已经足够清楚了,如果你对此仍有疑问,请告诉我 .
这是我的两个饼图的结果: