How to properly integrate google spreadsheets with highcharts?

只谈情不闲聊 提交于 2019-12-12 01:36:23

问题


I am having zero luck creating a data viz with highcharts using google spreadsheets. I've spent most of the day goggling for help and reading through google API / highcharts documentation / stack overflow / etc, and I'm still at the same spot I started this morning.

It seems to be an issue relating to new vs. old google spreadsheets. For example, I found this example to work, but as you'll see, the google spreadsheet has the older URL construction that includes "key=". When I update with a key from a new spreadsheet (one that does not have the URL construction with "key="), the chart isn't created.

Any ideas? My sheets are all public and published to the web, so I know that's not it.

Here's the spreadsheet I've been testing with: https://docs.google.com/spreadsheets/d/18jFq7JiZI4wfj0SOMZh3fii1lquGF7NWJnmoFsXNJbM/edit?usp=sharing, using the key 18jFq7JiZI4wfj0SOMZh3fii1lquGF7NWJnmoFsXNJbM

Any ideas much appreciated.


回答1:


If you point Highcharts at your key, you get an error 14. Looking at your sheet, it chokes on the second row "Total" since those numbers are formatted as strings. Fixing that in the sheet, and tweaking some of the parameters you can pass to Highcharts and your chart will start to take shape:

data: {
    googleSpreadsheetKey: '18jFq7JiZI4wfj0SOMZh3fii1lquGF7NWJnmoFsXNJbM',
    startColumn: 0,
    endColumn: 5,
    startRow: 0
},

Hopefully, that'll get you going, your chart still needs a bit more work (too many xAxis labels, the total column overwhelms the rest of the data, etc...)



来源:https://stackoverflow.com/questions/23436425/how-to-properly-integrate-google-spreadsheets-with-highcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!