Highcharts 脚本有一些问题。这是我的代码:
<?php
$query = mysql_query("SELECT UNIX_TIMESTAMP(time)*1000, COUNT(*) FROM visits GROUP BY DAY(time)");
DAY(date)");
$dataset[] = array();
while(list($month, $count) = mysql_fetch_array($query)) {
$dataset1[] = array($month, $count);
}
?>
其结果将是类似 [time, visitor_count] 的数组。例如 [1370271538, 10], [1370271233, 3]
这是JS:
<script type="text/javascript">
$(function () {
var graphData = <?php echo json_encode($dataset); ?>;
$('#container').highcharts({
chart: {
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Активность проекта',
x: -20 //center
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
text: 'Count'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: ''
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'Visitors',
data: graphData !!!!!!!!!!!!!!!!!!
}]
});
</script>
如何将查询结果正确加载到 Highcharts 数据?
谢谢!