我希望使用highstocks绘制图表。我使用谷歌spreadshhet作为数据源。电子表格包含大约15000行。获取错误400错误请求。如何从谷歌电子表格中获得适当的响应以生成高价图表? see the fiddle代码为:
**
**
$(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
}
}]
});
});
});
**
**
<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>
答案 0 :(得分:1)
有几件事:
getJSON()
,需要JSON,您的网址返回需要执行的脚本,广告参数:alt=json-in-script&callback=?
才能生效。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