0

私のハイストックはローカルホストのチャートでデータを開きません。誰かがその理由を知っていますか?

グラフには日付が表示されません。localhost、ipaddressを試しましたが、まだうまくいきません。

//jsonp.php file
<?php
$host="localhost";
$username="root"; 
$password=""; 
$db_name="northwind"; 
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "select unix_timestamp(OrderDate) as datetime, Freight from TEST1 ORDER BY OrderDate ASC LIMIT 100";
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_array($result)) {
extract ($row);
$datetime *= 10000; // convert from Unix timestamp to JavaScript time
$data[] = array((float)$datetime,(float) $Freight);

}
$array2[] = json_encode($data);
///data2[] = json_decode($array2);
echo json_encode($data);
?>




////output from jsonp.php file
[[8364528000000,32.38],[8365392000000,11.61],[8367984000000,65.83],[8368848000000,51.3],[8369712000000,58.17],[8370576000000,22.98],[8371440000000,148.33],[8374032000000,13.97],[8374896000000,81.91],[8375760000000,140.51],[8376624000000,3.25],[8377488000000,3.05],[8380080000000,48.29],[8380944000000,146.06],[8381808000000,3.67],[8382672000000,55.28],[8383536000000,25.73],[8386128000000,208.58],[8386992000000,66.29],[8387856000000,4.56],[8388720000000,136.54],[8389584000000,98.03],[8392176000000,76.07],[8393040000000,6.01],[8393904000000,26.93],[8394768000000,13.84],[8395632000000,125.77],[8398224000000,92.69],[8399088000000,25.83],[8399952000000,8.98],[8399952000000,2.94],[8400816000000,12.69],[8401680000000,84.81],[8404272000000,76.56]]


////html file
html file-----below
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>

<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>

<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">

<style type='text/css'>

</style>



<script type='text/javascript'>//<![CDATA[ 

$(function() {

$.getJSON('127.0.0.1/HIGH_STOCK/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
// Create the chart
window.chart = new Highcharts.StockChart({
chart : {
renderTo : 'container'
},

rangeSelector : {
selected : 1
},

title : {
text : 'TEST DATA'
},

series : [{
name : 'TEST',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});

});

//]]> 

</script>


</head>
<body>
<script src="JS/highstock.js"></script>
<script src="JS/modules/exporting.js"></script>

<div id="container" style="height: 500px; min-width: 500px"></div>

</body>


</html>
4

2 に答える 2

0

すべてがコードで正常に機能しているようです。
デモ

あなたの中であなたは同一生成元ポリシー$.getJSON(...)の世話をする必要があります

発生するエラーや直面している問題を特定していないため、このような場合に支援することは非常に困難です。エラーのjsFiddle複製を投稿することを検討してください

于 2012-12-25T06:57:01.593 に答える