1
我想繪製一個電子表格中提供的數據圖表,我的第一個問題是與JSON訂閱源。與Google電子表格的高圖表JSON
如果我把關鍵字放在谷歌Json示例中,它什麼也不給我。 但是,如果我在瀏覽器中粘貼地址,我可以清楚地看到JSON供稿。
然後我將它插入到Highcharts頁面的其中一個示例中,它不會加載。
$(function() {
$.getJSON('https://spreadsheets.google.com/feeds/list/1zgfoS-vYXU_SKDyYEa2fUh6zIaluynibs75a2zZIclI/od6/public/values?alt=json-in-script&callback=?', function(data)
{
// Add a null value for the end date
data = [].concat(data, [[Date.UTC(2015, 9, 14, 19, 59), null, null, null, null]]);
// create the chart
$('#container').highcharts('StockChart', {
chart : {
type: 'spline',
zoomType: 'x'
},
navigator : {
adaptToUpdatedData: false,
series : {
data : data
}
},
scrollbar: {
liveRedraw: false
},
title: {
text: 'AAPL history by the minute from 1998 to 2011'
},
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
}
}]
});
});
});
/** * 裝入新的數據取決於所選擇的最小和最大 */
function afterSetExtremes(e) {
var currentExtremes = this.getExtremes(),
range = e.max - e.min,
chart = $('#container').highcharts();
chart.showLoading('Loading data from server...');
$.getJSON('https://spreadsheets.google.com/feeds/list/1zgfoS-vYXU_SKDyYEa2fUh6zIaluynibs75a2zZIclI/od6/public/values?alt=json-in-script&callback=?', function(data)
{
chart.series[0].setData(data);
chart.hideLoading();
});
}
有人點我什麼問題或提供其他選擇嗎?