简体   繁体   English

Google图表+ Google表格:指定范围无法正确识别数据

[英]Google Charts + Google Sheets: Specified range does not identify data correctly

I settled on using Google Charts to draw the data from an auto-updating Google Sheet that draws from my Analytics account (the analytic API wasn't working out). 我决定使用Google图表从从我的Google Analytics(分析)帐户中提取的自动更新的Google表格中提取数据(解析API无效)。

I've done quite a lot of reading, but I'm finding the query language reference to be a pain. 我已经读了很多书,但是我发现查询语言参考很麻烦。

I've chosen to use the ChartWrapper. 我选择使用ChartWrapper。

https://jsfiddle.net/7xzv59kj/2/ https://jsfiddle.net/7xzv59kj/2/

     // Visits
      var wrap = new google.visualization.ChartWrapper();
      wrap.setChartType('ColumnChart');
           wrap.setDataSourceUrl('https://docs.google.com/spreadsheets/d/1jICOBDvZzRxEThcWqnpFmNLUqjVP81Zd9RTwpbG29cE/gviz/tq?sheet=Sheet2&range=Keywords-All_Time!B11:C12&headers=1&tq=');
      wrap.setContainerId('visits-all-time');
      wrap.draw();
  }

I want the chart to display the labels for Users and Sessions on the H-Axis, and then the values on the V-Axis. 我希望图表在H轴上显示“用户”和“会话”的标签,然后在V轴上显示值。 Instead, the data gets all jumbled and confused. 相反,数据变得混乱不清。 I don't know what parameters to specify and how to label them properly. 我不知道要指定哪些参数以及如何正确标记它们。

Spreadsheet located here. 电子表格位于此处。

https://docs.google.com/spreadsheets/d/1jICOBDvZzRxEThcWqnpFmNLUqjVP81Zd9RTwpbG29cE https://docs.google.com/spreadsheets/d/1jICOBDvZzRxEThcWqnpFmNLUqjVP81Zd9RTwpbG29cE

I would like to draw the data from the sheet titled Keywords-All_Time from range B11:C12 我想从标题为range B11:C12的工作表的Keywords-All_Time提取数据

The issue here was just my foggy brain - I took a break and came back to it yesterday to discover a couple issues: 这里的问题只是我的大脑模糊-我休息了一会儿,昨天又回到了那里,发现了几个问题:

  wrap.setDataSourceUrl('https://docs.google.com/spreadsheets/d/1jICOBDvZzRxEThcWqnpFmNLUqjVP81Zd9RTwpbG29cE/gviz/tq?sheet=Sheet2&range=Keywords-All_Time!B11:C12&headers=1&tq=');
  1. My URL specifies the sheet twice. 我的网址两次指定了工作表。 I recall someone telling me to format the range with the sheet, but I suppose I never erased the other parameter. 我记得有人告诉我用工作表格式化范围,但是我想我从未擦除其他参数。

  2. My table had the axes the wrong way around. 我的桌子的轴绕错了方向。 I reversed them and found everything worked well from there. 我扭转了它们,发现从那里一切正常。

I abandoned the chart wrapper and decided to move on to that when I actually have a need for it. 我放弃了图表包装程序,并决定在我确实需要它时继续进行下去。 Here's the current jsfiddle with the code I'm working on now: https://jsfiddle.net/c11c9a0w/19/ 这是当前我正在使用的代码的当前jsfiddle: https ://jsfiddle.net/c11c9a0w/19/

This will be extremely helpful for anyone having trouble building a dynamic dashboard from a Google Sheet that has multiple graphs on a single page, so feel free to work off of this. 这对于任何人都无法从在单个页面上具有多个图形的Google表格构建动态仪表板的工作中,非常有用,因此请随时进行处理。

-Joel -Joel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM