简体   繁体   English

使用Google Spreadshhet和highstocks图表生成图表

[英]generate chart using google spreadshhet and highstocks chart

I am looking to draw chart using highstocks. 我正在使用高库存绘制图表。 I am using google spreadshhet as a data source. 我正在使用google spreadshhet作为数据源。 Spreadsheet contains around 15000 rows. 电子表格包含约15000行。 Getting error 400 bad request. 收到错误400错误的请求。 How can I get proper response from google spreadsheet to generate highstock chart? 如何从Google电子表格中获得适当的响应以生成高库存图表? see the fiddle and code is: 看到小提琴和代码是:

** **

JS JS

**
    $(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 HTML

** **

<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>

A couple of things: 有两件事:

  • use https instead of http 使用https而不是http
  • getJSON() , requires JSON, your URL returns script, which need to be executed, ad parameters: alt=json-in-script&callback=? getJSON() ,需要JSON,您的URL返回脚本,该脚本需要执行,广告参数: alt=json-in-script&callback=? to make it work. 使它工作。
  • your URL is just broken, I don't know where did you get that, but should be like this: https://spreadsheets.google.com/feeds/cells/o13394135408524254648.240766968415752635/od6/public/values?alt=json-in-script&callback=? 您的网址刚刚坏了,我不知道您从哪里得到的,但应该像这样: https://spreadsheets.google.com/feeds/cells/o13394135408524254648.240766968415752635/od6/public/values?alt=json-in-script&callback=? : https://spreadsheets.google.com/feeds/cells/o13394135408524254648.240766968415752635/od6/public/values?alt=json-in-script&callback=?

See: http://jsfiddle.net/vHM6m/1/ (chart is not rendered properly, since demo is using some random spreadsheet). 请参阅: http : //jsfiddle.net/vHM6m/1/ (由于演示使用了一些随机电子表格,因此图表无法正确呈现)。

Anyway, see some demos and google API first: https://developers.google.com/gdata/samples/spreadsheet_sample 无论如何,请先查看一些演示和Google API: https//developers.google.com/gdata/samples/spreadsheet_sample

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

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