问题:我成功查询了 Yahoo Finance API,我想将一个多维数组输出到 Highstock 图表。但是,数据仅在导航器中呈现,而不是某些缩放级别的主图表。
问题:谁能告诉我哪里出错了,或者这是一个错误?
注意:Highstocks 在 series.data 中需要这样的数据:http ://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback= ?
这是一个现场演示:http ://stevebrown.co/highstock/
var quoteData = [];
$(function() {
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22YHOO%22%20and%20startDate%20%3D%20%222009-09-11%22%20and%20endDate%20%3D%20%222010-03-10%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=";
$.getJSON(url, function(
$.each(data.query.results.quote, function(index, value) {
var theTime = value.Date;
var milliTime = new Date(theTime);
milliTime = milliTime.getTime();
var results = [milliTime, parseFloat(value.Low), parseFloat(value.High)];
quoteData.push(results);
})
});
setTimeout("createChart()", 1000);
});
function createChart() {
console.log('quoteData', quoteData);
// Create the chart
window.chart = new Highcharts.StockChart({
chart : {
renderTo : 'container'
},
rangeSelector : {
selected : 1
},
title : {
text : 'AAPL Stock Price'
},
series : [{
name : 'AAPL',
data : quoteData,
tooltip: {
valueDecimals: 2
}
}]
});
}