【发布时间】:2021-07-14 14:22:44
【问题描述】:
我正在尝试通过 Google Sheets API 从 Python 在 Google Sheets 中创建折线图。但我无法激活聚合选项。
{
"addChart": {
"chart": {
"spec": {
"title": type,
"basicChart": {
"chartType": "LINE",
"legendPosition": "TOP_LEGEND",
"axis": [
# X-AXIS
{
"position": "BOTTOM_AXIS",
"title": "Date"
},
# Y-AXIS
{
"position": "LEFT_AXIS",
"title": "Number of "+type
}
],
"domains": [
{
"domain": {
"sourceRange": {
"sources": [
{
"sheetId": gid,
"startRowIndex": 0,
"endRowIndex": 1000000,
"startColumnIndex": 1,
"endColumnIndex": 2
}
]
}
}
}
],
"series": [
{
"series": {
"sourceRange": {
"sources": [
{
"sheetId": gid,
"startRowIndex": 0,
"endRowIndex": 1000000,
"startColumnIndex": 9,
"endColumnIndex": 10
}
]
},
"aggregateType": "SUM"
},
"targetAxis": "LEFT_AXIS"
}...
正如您在上面看到的,我正在创建一个折线图,其中包含来自另一张工作表的 adimpression 数据。除了聚合之外,一切都很好。我添加了 'aggregateType' = 'SUM' 但它仍然不起作用。 你们有解决这个问题的办法吗?
我一直在寻找解决方案,但找不到任何有用的东西。有人谈到了 .setOption('applyAggregateData', 0) 但该解决方案对我不起作用,我想我需要在请求正文中提供一些额外的信息。
谢谢。
【问题讨论】:
标签: python google-api python-requests google-sheets-api