您好我想放置类似于this的高线图,但我无法做到这一点。 我想我无法从jsonp文件中获取数据,因为数据来自示例。 Plz帮助。
这是我的代码 的图表-demo.php
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function () {
$.getJSON('http://localhost/admin/jsonp.php', function (data) {
// Create the chart
$('#container').highcharts('StockChart', {
rangeSelector: {
selected: 1
},
title: {
text: 'Highstock Scalable Y-Axis Demo'
},
series: [{
name: 'AAPL',
data: data,
tooltip: {
valueDecimals: 2
}
}],
yAxis: {
endOnTick: false,
startOnTick: false
}
});
});
});
</script>
</head>
<body>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="https://rawgithub.com/RolandBanguiran/highcharts-scalable-yaxis/master/scalable-yaxis.js"></script>
<div id="container" style="min-width: 310px; height: 500px; margin: 0 auto"></div>
</body>
</html>
jsonp.php
$sql_viewer = "select count(id) as num,created_at from users group by year(created_at) desc, month(created_at) desc";
$result_viewer = mysqli_query($conn,$sql_viewer);
while($rec_viewer=mysqli_fetch_array($result_viewer)){
$_viewerDate=$rec_viewer['created_at'];
$_viewerNum= intval ( $rec_viewer['num'] );
// Create an array with just integer indexes
$main_arr[]=array(strtotime($_viewerDate) * 1000, $_viewerNum);
}
print_r('callback(' . json_encode($main_arr) . ');') ;
提前完成。