Json 数据未显示在 highcharts 图表上。:(请帮助..使用了根本不解析的getJSON。.post作品显示味精..不知道如何解决..我的图形代码..
$(function () {
var chart;
$.post("data.php", function(json)
{
//alert("Data Loaded: " + json);
chart = new Highcharts.Chart({
chart: {
renderTo: 'container1',
type: 'area'
},
yAxis: {
type: 'double',
min: 0
},
xAxis: {
type: 'datetime',
labels: {
formatter: function () {
return Highcharts.dateFormat('%b %y', this.value);
},
dateTimeLabelFormats: {
month: '%b \'%y',
year: '%Y'
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: json
});
});
});
这是我的 php 代码.. 获取 json 数据
$mysql_connect = mysql_connect($db_host, $db_user, $db_pword, $db_name);
$query = "Select DATE_FORMAT(`timestamp`,'%Y,%m,%d') as date, Count(*) as frequency from table group by date order by date,frequency asc";
if (!$mysql_connect) die("unable to connect to database: " . mysql_error());
@mysql_select_db($db_name) or die( "Unable to select database");
$result = mysql_query($query);
$response = array();
if($result === FALSE)
{
die(mysql_error());
}
echo "[";
$results = array();
while($row=mysql_fetch_array($result))
{
$results[] = "[Date.UTC(".$row ['date']."),".$row['frequency']."]";
}
echo implode(',',$results);
echo "]";
mysql_close($mysql_connect);