1
我有一個餅,我想每3秒添加動態更新從MySQL data.php.I需要添加事件.ready(function()? 任何幫助將不勝感激。Highcharts動態更新餅圖mysql
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
backgroundColor:'rgba(255, 255, 255, 0.0)'
},
title: {
text: 'Grafic'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
},},
credits: {
enabled: false
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage.toFixed(4) +' %';}}}},
series: [{
type: 'pie',
data: []}]}
$.getJSON("data.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
});
幾年前的帖子可能會有幫助。 [動態數據系列爲高圖表] [1] [1]:http://stackoverflow.com/questions/10682484/adding-dynamic-data-series-to-high-charts/10693975#10693975 –
您需要像[這裏](http://www.highcharts.com/demo/dynamic-update)那樣捕獲加載事件,調用ajax並使用[point.update](http://api.highcharts .com/highcharts#Point.update)來操縱價值。 –