Highcharts动态更新饼图mysql

Highcharts动态更新饼图mysql,mysql,dynamic,charts,highcharts,Mysql,Dynamic,Charts,Highcharts,我有一个饼图,我想从mysql data.php每隔3秒添加一次动态更新。我需要在.ready(function())中添加事件? 任何帮助都将不胜感激 $(document).ready(function() { var options = { chart: { renderTo: 'container', plotBackgroundColor: null,

我有一个饼图,我想从mysql data.php每隔3秒添加一次动态更新。我需要在.ready(function())中添加事件? 任何帮助都将不胜感激

            $(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);
        });
    });
$(文档).ready(函数(){
变量选项={
图表:{
renderTo:'容器',
plotBackgroundColor:null,
plotBorderWidth:null,
影子:错,
背景颜色:'rgba(255,255,255,0.0)'
},
标题:{
文字:“Grafic”
},
工具提示:{
格式化程序:函数(){
返回“+this.point.name+”:“+this.percentage+”%”;
},},
学分:{
已启用:false
},
打印选项:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
启用:对,
颜色:'#000000',
连接器颜色:'#000000',
格式化程序:函数(){
返回'+this.point.name+':'+this.percentage.toFixed(4)+'%';},
系列:[{
键入“pie”,
数据:[]}]}
$.getJSON(“data.php”,函数(json){
options.series[0].data=json;
图表=新的高点图表。图表(选项);
});
});

您可能需要使用“setinterval”

您可能还需要设置一个递归回调,以便它每次都更新highcharts

如果你有任何问题,请告诉我

更新日期:2016年9月29日

这里是另一种方法,在jQuery中使用递归settimeout,以防有所帮助

(function($){

    $(function(){  //document.ready

    });

    (function recurseEvent(element){

            element.doStuff();

            setTimeout(function(){
                recurseEvent(element);
            }, 2000);

    })($('#myElement'));

})(jQuery);`

几年前的一篇帖子可能会有所帮助。[从动态数据系列到高端图表][1][1]:您需要捕捉加载事件,比如调用ajax并使用它来操纵值。