Javascript 无法让getjson在highstock上工作
我在导入csv以获取highstock图表时遇到一些问题。 我使用了与ohlc示例相同的代码(在本地运行良好),但是使用了另一个由php在本地主机上创建的CSV PHP获取CSVJavascript 无法让getjson在highstock上工作,javascript,csv,getjson,highstock,Javascript,Csv,Getjson,Highstock,我在导入csv以获取highstock图表时遇到一些问题。 我使用了与ohlc示例相同的代码(在本地运行良好),但是使用了另一个由php在本地主机上创建的CSV PHP获取CSV <?PHP // Declare the new variable as an array $arrCSV = array(); // Open the CSV file if (($handle = fopen("http://ichart.finance.yahoo.com/table.csv?s=AAP
<?PHP
// Declare the new variable as an array
$arrCSV = array();
// Open the CSV file
if (($handle = fopen("http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=7&e=7&f=2012&g=d&a=8&b=7&c=1984&ignore=.csv", "r")) !==FALSE)
{
// Set the parent array key to 0
$key = 0;
// While there is data available loop through unlimited times (0) using separator (,)
while (($data = fgetcsv($handle, 0, ",")) !==FALSE) {
// Count the total keys in each row
$c = count($data);
//print $c . "<BR>"; // <------ 7 o numero de colunas
//Populate the array
If ($key != 0) {
$arrCSV[$key-1][0] = strtotime($data[0])*1000; //Time
$arrCSV[$key-1][1] = $data[1]; //Open
$arrCSV[$key-1][2] = $data[2]; //High
$arrCSV[$key-1][3] = $data[3]; //Low
$arrCSV[$key-1][4] = $data[6]; //Adj Close
$arrCSV[$key-1][5] = $data[5]; //Volume
}
$key++;
} // end while
$keymax = $key;
// Close the CSV file
fclose($handle);
} // end if
print "?(/* AAPL historical OHLC data from the Google Finance API */<BR>";
echo json_encode($arrCSV,JSON_NUMERIC_CHECK);
print ");";
?>
帮忙
谢谢现在已经解决了,问题是在json_编码前后添加的CHO中,没有必要添加它们
print "?(/* AAPL historical OHLC data from the Google Finance API */<BR>";
echo json_encode($arrCSV,JSON_NUMERIC_CHECK);
print ");";
print”?(/*AAPL历史OHLC数据来自谷歌金融API*/
”;
echo json_编码($arrcvs,json_数字检查);
印刷品“;”;
所以,去掉它们就解决了问题
[23:39:29.980] GET http://localhost/TraderMananger/Highstock/ohlc4.htm [HTTP/1.1 304 Not Modified 1ms]
[23:39:30.036] GET http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js [HTTP/1.1 304 Not Modified 87ms]
[23:39:30.055] GET http://localhost/TraderMananger/Highstock/js/highstock.js [HTTP/1.1 304 Not Modified 1ms]
[23:39:30.073] GET http://localhost/TraderMananger/Highstock/js/modules/exporting.js [HTTP/1.1 304 Not Modified 1ms]
[23:39:30.219] GET http://localhost/TraderMananger/Highstock/teste04.php [HTTP/1.1 200 OK 2056ms]
print "?(/* AAPL historical OHLC data from the Google Finance API */<BR>";
echo json_encode($arrCSV,JSON_NUMERIC_CHECK);
print ");";