0

嗨,我正在尝试在对象本身的高图中动态地设置类别,如下所示:

$('#container').highcharts({
            chart: {
                type: 'bar',
                events : {
                load : function() {

                    // set up the updating of the chart each second
                    var series = this.series[0];
                    setInterval(function() {


                        /*var x = (new Date()).getTime(), // current time
                        y = 0;//Math.round(Math.random() * 100)*/;
                        jQuery.ajax({
                        url:    'ajaxgames?game_id=<?php echo $_GET['game_id']; ?>&game_type_id=<?php echo $_GET['game_type_id']; ?>', 
                        success: function(result) {
                            var res = JSON.parse(result);
                            var cat = new Array();
                            for(x in res) {
                                cat.push(x['username']);
                            }
                           this.xAxis[0].setCategories(cat);                            
                            alert(res[0]['id']);
                        },
                        async:   false
                        });     

                    }, 5000);
                }
            }

但是 this.xAxis[0] 似乎是未定义的......你能帮忙吗?

4

0 回答 0