我正在尝试将json数据调用到高图表。我对此只有一个series..Newbie ..有没有人能帮我看看我调用的json文件是否正确。请帮助我:(
我在highcharts中调用json的代码
<script>
var chart;
$(document).ready(function ()
{
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'
}
}
},
series: [{
name: 'Total Views',
data: []
}, ]
});
chart.series[0].setData(
});
</script>
<script>
$.getJSON('data.php', function(data)
{
chart.series[0].append(data);
}
</script>
<div id="container1" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html> 发布于 2013-09-07 00:30:15
您希望在getJSON成功函数中创建图表。
$.getJSON('data.php', function (data) {
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'
}
}
},
series: [{
name: 'Total Views',
data: data
}, ]
});
});这里有一个非常简单的教程,介绍如何在Highcharts http://blueflame-software.com/blog/how-to-load-mysql-results-to-highcharts-using-json/中使用JSON
https://stackoverflow.com/questions/18661657
复制相似问题