首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用google spreadshhet和highstocks图表生成图表

使用google spreadshhet和highstocks图表生成图表
EN

Stack Overflow用户
提问于 2014-03-05 16:05:27
回答 1查看 523关注 0票数 0

我希望绘制图表使用高股票。我使用google spreadshhet作为数据源。电子表格包含大约15000行。获取错误400错误请求。如何从谷歌电子表格中获得适当的响应,以生成高库存图表?see the fiddle和代码是:

**

JS

代码语言:javascript
复制
**
    $(function() {


    $.getJSON('http://spreadsheets.google.com/feeds/feed/0AhWK8Tqp6GNkdENFYjRrOFJxWE1BNFhiZFdIejNxaFE/worksheet/public/basic?alt=json-in-script&gid=4', function(data) {

        // Add a null value for the end date 
        data = [].concat(data, [[Date.UTC(2011, 9, 14, 19, 59), null, null, null, null]]);
            console.log(data);  
        // create the chart
        $('#container').highcharts('StockChart', {
            chart : {
                type: 'candlestick',
                zoomType: 'x'
            },

            navigator : {
                adaptToUpdatedData: false,
                series : {
                    data : data
                }
            },

            scrollbar: {
                liveRedraw: false
            },

            title: {
                text: 'graph visualization'
            },

            subtitle: {
                text: 'Displaying 1.7 million data points in Highcharts Stock by async server loading'
            },

            rangeSelector : {
                buttons: [{
                    type: 'hour',
                    count: 1,
                    text: '1h'
                }, {
                    type: 'day',
                    count: 1,
                    text: '1d'
                }, {
                    type: 'month',
                    count: 1,
                    text: '1m'
                }, {
                    type: 'year',
                    count: 1,
                    text: '1y'
                }, {
                    type: 'all',
                    text: 'All'
                }],
                inputEnabled: false, // it supports only days
                selected : 4 // all
            },

            xAxis : {
                events : {
                    afterSetExtremes : afterSetExtremes
                },
                minRange: 3600 * 1000 // one hour
            },

            series : [{
                data : data,
                dataGrouping: {
                    enabled: false
                }
            }]
        });
    });
});

**

HTML

**

代码语言:javascript
复制
<div id="container"></div>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
EN

回答 1

Stack Overflow用户

发布于 2014-03-05 21:06:03

有几件事:

  • 使用https而不是JSON需要JSON,你的URL返回需要执行的脚本,广告参数:alt=json-in-script&callback=?才能使它工作。
  • 你的URL刚刚坏了,我不知道你是从哪里得到的,但应该是这样的:https://spreadsheets.google.com/feeds/cells/o13394135408524254648.240766968415752635/od6/public/values?alt=json-in-script&callback=?

参见:http://jsfiddle.net/vHM6m/1/ (图表不能正确呈现,因为演示使用了一些随机的电子表格)。

无论如何,先看一些演示和google API:https://developers.google.com/gdata/samples/spreadsheet_sample

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22191932

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档